ora 00907在更新语句期间缺少右括号

时间:2014-04-09 09:18:24

标签: sql oracle

错误:ora 00907 missing right parenthesis during an update statement

cust_rds表中的custid有字符串中的数据,如p0037,p106等.gcdb_source_key和客户表中的gcdb_source_key_org是数字,所以尝试gcdb_source_key,gcdb_source_key_org为字符串并尝试插入,但这里我得错过右括号在to_c

UPDATE Customer c
SET
   (
      c.city
    , c.description
    , c.state
    , c.postal_code_1
    , c.address_1
    , to_char(c.gcdb_source_key)
    , to_char(c.gcdb_source_key_org)
    , c.true_gcdb_source_key
   )  =
(SELECT 
      cr.city
    , cr.name
    , cr.sub_cntry
    , cr.postl_code
    , cr.stret_addr_line_1
    , cr.cust_id
    , cr.cust_id
    , cr.cust_id
FROM cust_rds cr
WHERE cr.cust_id = c.true_gcdb_source_key)
WHERE c.true_gcdb_source_key IS NOT NULL
AND c.true_gcdb_source_key IN (SELECT cust_id FROM cust_rds);

CREATE TABLE CUSTOMER
(
  CLASS                 VARCHAR2(40 BYTE)       DEFAULT 'TEMPORARY',
  CREATED               DATE                    DEFAULT sysdate               NOT NULL,
  CITY                  VARCHAR2(40 BYTE),
  COUNTRY               VARCHAR2(40 BYTE),
  CUST_CUST_ID          NUMBER(10),
  DESCRIPTION           VARCHAR2(40 BYTE),
  STATE                 VARCHAR2(40 BYTE),
  DS_DS_ID              NUMBER(10)              NOT NULL,
  EXPIRES               DATE,
  POSTAL_CODE_1         VARCHAR2(20 BYTE),
  POSTAL_CODE_2         VARCHAR2(20 BYTE),
  ADDRESS_1             VARCHAR2(40 BYTE),
  ADDRESS_2             VARCHAR2(40 BYTE),
  SOURCE_KEY            VARCHAR2(15 BYTE),
  CUST_ID               NUMBER(10)              NOT NULL,
  SECONDARY_SOURCE_KEY  VARCHAR2(15 BYTE),
  GCDB_SOURCE_KEY       NUMBER(10),
  GCDB_SOURCE_KEY_ORG   NUMBER(10),
  TRUE_GCDB_SOURCE_KEY  VARCHAR2(20 BYTE)

 )


CREATE TABLE CUST_RDS
(
  CUST_ID             VARCHAR2(15 BYTE)         NOT NULL,
  TRADE_CHANL_ID      VARCHAR2(15 BYTE),
  NAME                VARCHAR2(30 BYTE)         NOT NULL,
  LONG_NAME           VARCHAR2(60 BYTE),
  LONG_DESC           VARCHAR2(2000 BYTE),
  STRET_ADDR_LINE_1   VARCHAR2(30 BYTE),
  STRET_ADDR_LINE_2   VARCHAR2(30 BYTE),
  CITY                VARCHAR2(30 BYTE),
  SUB_CNTRY           VARCHAR2(30 BYTE),
  POSTL_CODE          VARCHAR2(10 BYTE),
  ISO_CNTRY_NUM       VARCHAR2(3 BYTE),
  STTUS_CODE          VARCHAR2(1 BYTE),
  DELET_DATE          DATE,
  CUST_ACCT_GRP_CODE  VARCHAR2(4 BYTE)          NOT NULL,
  TRNSP_ZONE          VARCHAR2(30 BYTE)
  )

1 个答案:

答案 0 :(得分:2)

您不能在to_char()子句的中间使用set。如果要将函数应用于您正在设置的某个值,则它属于select子句,而不是set