我需要使用类似条件的列,例如关注'UPDATE'
UPDATE CUSTOMER_TRANSACTIONS ct
SET PROCESSID = vQUARTER
where ct.CUSTOMERID = l_arrc1(i).CUSTOMERID
and ct.APPOINTOFCAID = l_arrc1(i).APPOINTOFCAID
and ct.INVOICEID like "'"||l_arrc1(i).INVOICEID||%||"'";
代替
UPDATE CUSTOMER_TRANSACTIONS ct
SET PROCESSID = '2015Q4'
where ct.CUSTOMERID = l_arrc1(i).CUSTOMERID
and ct.APPOINTOFCAID = l_arrc1(i).APPOINTOFCAID
and ct.INVOICEID like '0158741%';
INVOICEID
和l_arrc1(i).INVOICEID
是VARCHAR
怎么做?
答案 0 :(得分:1)
您缺少适当的字符串分隔符,单引号:
UPDATE CUSTOMER_TRANSACTIONS ct
SET PROCESSID = vQUARTER
WHERE ct.CUSTOMERID = l_arrc1(i).CUSTOMERID and
ct.APPOINTOFCAID = l_arrc1(i).APPOINTOFCAID and
ct.INVOICEID LIKE l_arrc1(i).INVOICEID || '%' ;
SQL中字符串的相应分隔符是单引号而不是双引号。
答案 1 :(得分:0)
假设INVOICEID
为number
列:
UPDATE customer_transactions ct
SET processid = vQUARTER
WHERE ct.customerid = l_arrc1(i).customerid
AND ct.appointofcaid = l_arrc1(i).appointofcaid
AND to_char(ct.invoiceid) LIKE to_char(l_arrc1(i).INVOICEID) || '%';
如果invoiceid不是number
数据类型,则可以删除to_char