oracle ORA-00906错误与我的INSERT SQL语句;这在DB2数据库中有效

qyuhtwio  于 2023-05-06  发布在  Oracle
关注(0)|答案(2)|浏览(158)

你好,我在oracle数据库中的sql查询出错。上面写着“ORA-00906:缺少左括号”
下面是我的SQL语句:

insert into UBTB_ACCOUNTTRANSLIMIT(
  UBACCTTRANSLIMITID,
  UBACCOUNTID,
  UBTRANSACTIONGROUPID,
  UBISACTIVE,
  UBEXPOSUREAMOUNT,
  UBEXPOSURECOUNT,
  UBEXPOSUREREVIEWFREQ,
  UBTRANSACTIONLIMITCOUNT,
  UBTRANSACTIONLIMITAMT,
  UBLIMITEXCESSACTION,
  UBLASTREVIEWDATE,
  UBTRANSACTIONLIMITYPE,
  UBTRANSACTIONLIMITID,
  UBREVIEWMONTH,
  UBREVIEWDAY,
  VERSIONNUM
) 
SELECT UBACCTTRANSLIMITID,
       ACCOUNTID,
       UBTRANSACTIONGROUPID,
       UBISACTIVE,
       UBEXPOSUREAMOUNT,
       UBEXPOSURECOUNT,
       UBEXPOSUREREVIEWFREQ,
       UBTRANSACTIONLIMITCOUNT,
       UBTRANSACTIONLIMITAMT,
       UBLIMITEXCESSACTION,
       UBLASTREVIEWDATE,
       UBTRANSACTIONLIMITYPE,
       UBTRANSACTIONLIMITID,
       UBREVIEWMONTH,
       UBREVIEWDAY,
       VERSIONNUM
FROM   (
  SELECT UB_CONCAT(
           '20230503184525443',
           cast(ROW_NUMBER() OVER (ORDER BY ACCOUNTID) as varchar)
         ) as UBACCTTRANSLIMITID,
         ACCOUNTID,
         'Y' AS UBEXPOSUREREVIEWFREQ,
         0 AS UBLIMITEXCESSACTION,
         '0' AS UBTRANSACTIONLIMITYPE,
         'TRANSGROUP1' AS UBTRANSACTIONGROUPID,
         1000.000000 AS UBTRANSACTIONLIMITAMT,
         0 AS UBTRANSACTIONLIMITCOUNT,
         'LIMITJPY1' AS UBTRANSACTIONLIMITID,
         'Y' AS UBISACTIVE,
         {d '2023-05-03'} AS UBLASTREVIEWDATE,
         0 AS UBEXPOSUREAMOUNT,
         0 AS UBEXPOSURECOUNT,
         '01' AS UBREVIEWMONTH,
         '3' AS UBREVIEWDAY,
         0 AS VERSIONNUM
  FROM   ACCOUNT
  WHERE PRODUCTCONTEXTCODE = ?
) VALUELIST

我期待什么可能是错误的原因我的sql语句似乎罚款

46qrfjad

46qrfjad1#

这是错误的:

{d '2023-05-03'} AS UBLASTREVIEWDATE

在Oracle中,使用日期文字:

DATE '2023-05-03' AS UBLASTREVIEWDATE

其他值看起来不可疑,所以-尝试使用它,并说如果它仍然不工作,但然后提供一些更多的信息(和测试用例)。

wko9yo5t

wko9yo5t2#

可以使用||运算符代替UB_CONCAT(除非UB_CONCAT是用户定义的函数),使用CAST和日期文字代替{d '2023-05-03'}。您也不需要使用子查询(可以在SELECT查询中删除AS column_alias,因为它们是不必要的,但可以保留它们以帮助记录代码):

insert into UBTB_ACCOUNTTRANSLIMIT(
  UBACCTTRANSLIMITID,
  UBACCOUNTID,
  UBTRANSACTIONGROUPID,
  UBISACTIVE,
  UBEXPOSUREAMOUNT,
  UBEXPOSURECOUNT,
  UBEXPOSUREREVIEWFREQ,
  UBTRANSACTIONLIMITCOUNT,
  UBTRANSACTIONLIMITAMT,
  UBLIMITEXCESSACTION,
  UBLASTREVIEWDATE,
  UBTRANSACTIONLIMITYPE,
  UBTRANSACTIONLIMITID,
  UBREVIEWMONTH,
  UBREVIEWDAY,
  VERSIONNUM
) 
SELECT '20230503184525443' || ROW_NUMBER() OVER (ORDER BY ACCOUNTID) as UBACCTTRANSLIMITID,
       ACCOUNTID,
       'Y' AS UBEXPOSUREREVIEWFREQ,
       0 AS UBLIMITEXCESSACTION,
       '0' AS UBTRANSACTIONLIMITYPE,
       'TRANSGROUP1' AS UBTRANSACTIONGROUPID,
       1000.000000 AS UBTRANSACTIONLIMITAMT,
       0 AS UBTRANSACTIONLIMITCOUNT,
       'LIMITJPY1' AS UBTRANSACTIONLIMITID,
       'Y' AS UBISACTIVE,
       DATE '2023-05-03' AS UBLASTREVIEWDATE,
       0 AS UBEXPOSUREAMOUNT,
       0 AS UBEXPOSURECOUNT,
       '01' AS UBREVIEWMONTH,
       '3' AS UBREVIEWDAY,
       0 AS VERSIONNUM
FROM   ACCOUNT
WHERE PRODUCTCONTEXTCODE = ?

相关问题