【问题标题】:SQL Statement Failed in ATGATG 中的 SQL 语句失败
【发布时间】:2014-11-19 13:38:05
【问题描述】:

我正在使用 ATG 应用程序。今天,我在 /atg/userprofiling/ProfileAdapterRepository 中得到了以下 SQL 异常,这是因为违反了唯一约束。

atg.repository.RepositoryException; SOURCE:java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (DCS_USR_ACTVPROM_P) violated

对ATG的用户提升表dcs_usr_actvpromo执行插入查询时出现异常。我搜索了执行此查询的时间和地点,传递了哪些值,但直到现在我才找到。

已从自定义 FormHandler 调用 atg.scenario.userprofiling.ScenarioProfileFormHandler 的

handleLogin 方法。调用此方法后我找不到流程。此方法调用后,发生异常。

谁能告诉我这个方法内部发生了什么,以及上表在 ATG 中从哪里执行 SQL 查询?

【问题讨论】:

    标签: atg atg-droplet


    【解决方案1】:

    您没有添加您尝试运行的实际 sql,但错误消息几乎说明了一切。您违反了unique 约束。

    假设您有一个名为Foo 的表,并且您有一个名为barunique 列。如果您打算在Foo 中插入一条记录,并且bar 的值为'loremipsum',那么如果您的Foo 表已经有一条记录,其中bar 的值为@987654330,那么该语句将不会成功@。

    因此,insert 的:

    insert into Foo(bar)
    values('loremipsum');
    

    有失败的风险。为了防止发生这种风险,您必须检查该值是否已经存在,如下所示:

    insert into Foo(bar)
    select 'loremipsum'
    from Foo
    where 'loremipsum' not in (select distinct bar from Foo)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-27
      • 2012-07-02
      • 2017-06-14
      • 2021-02-17
      • 1970-01-01
      • 2016-11-16
      • 1970-01-01
      • 2012-09-18
      相关资源
      最近更新 更多