我创建了一个生成此错误的脚本,但它仍然可以完美执行。我该怎么做才能解决此错误?我尝试了一些常见的修补程序,比如SET SQLBLANKLINES ON,但它没有用。
错误:SP2-0734:未知命令开始“CONCAT('IN ...” - 忽略其余行。
这是生成错误的脚本的一部分:
PROMPT 'ENTER THE PERCENTAGE YOU WISH TO INCREASE THE PRICE BY: '
ACCEPT V_PCT_INCREASE NUMBER
PROMPT
PROMPT 'ENTER THE PRODUCT SEARCH CRITERIA: '
ACCEPT V_PRODUCT_DESC
PROMPT
PROMPT 'YOU HAVE CHOSEN TO UPDATE PRODUCTS WHOSE DESCRIPTION BEGINS WITH &V_PRODUCT_DESC WITH A PERCENTAGE INCREASE OF &V_PCT_INCREASE PERCENT.'
PROMPT
SET TERMOUT OFF;
SET VERIFY OFF;
SET SQLBLANKLINES ON;
SPOOL c:\runscripts\insert_prices.sql;
SELECT CONCAT('INSERT INTO TAR_TEMP_PRICE (PRODUCT_ID, START_DATE, LIST_PRICE, MIN_PRICE, END_DATE)
VALUES (', P.PRODUCT_ID||', '''||PR.START_DATE||''', '||PR.LIST_PRICE * (1+(&V_PCT_INCREASE/100))||', '||PR.MIN_PRICE * (1+(&V_PCT_INCREASE/100))||', CURRENT_DATE'||');')
FROM TAR_PROD P
JOIN TAR_PRICE PR
ON P.PRODUCT_ID = PR.PRODUCT_ID
WHERE UPPER(P.DESCRIPTION) LIKE UPPER('&V_PRODUCT_DESC%');
SPOOL OFF;
SET FEEDBACK ON;
SET TERMOUT ON;
PROMPT 'A SCRIPT insert_prices.sql HAS BEEN CREATED AT c:\runscripts\insert_prices.sql'
PROMPT
PROMPT 'THE FOLLOWING PRODUCTS WERE ADDED TO THE INSERT SCRIPT WITH THE ADJUSTED PRICES: '
SELECT P.PRODUCT_ID, P.DESCRIPTION, PR.LIST_PRICE, PR.MIN_PRICE,
PR.LIST_PRICE * (1+(&V_PCT_INCREASE/100)) AS "ADJ_LIST_PRICE",
PR.MIN_PRICE * (1+(&V_PCT_INCREASE/100)) AS "ADJ_MIN_PRICE"
FROM TAR_PROD P
JOIN TAR_PRICE PR
ON P.PRODUCT_ID = PR.PRODUCT_ID
WHERE UPPER(P.DESCRIPTION) LIKE UPPER('&V_PRODUCT_DESC%');
@C:\runscripts\insert_prices.sql
PROMPT 'INSERT SCRIPT IS COMPLETE.'
PROMPT 'SEE BELOW FOR RESULT VALIDATION.'
SELECT *
FROM TAR_TEMP_PRICE;
ROLLBACK;
它仍然有效,但我希望能够抑制错误。
上面代码生成的insert语句:
CONCAT('INSERTINTOTAR_TEMP_PRICE(PRODUCT_ID,START_DATE,LIST_PRICE,MIN_PRICE,END_DATE)VALUES(',P.PRODUCT_ID||','''||PR.START_DATE||''','||PR.LIST_PRICE
------------------------------------------------------------------------------------------------------------------------------------------------------
INSERT INTO TAR_TEMP_PRICE (PRODUCT_ID, START_DATE, LIST_PRICE, MIN_PRICE, END_DATE)
VALUES (100860, '01-JUN-90', 39.2, 31.36, CURRENT_DATE);
INSERT INTO TAR_TEMP_PRICE (PRODUCT_ID, START_DATE, LIST_PRICE, MIN_PRICE, END_DATE)
VALUES (100860, '01-JAN-90', 35.84, 28.672, CURRENT_DATE);
INSERT INTO TAR_TEMP_PRICE (PRODUCT_ID, START_DATE, LIST_PRICE, MIN_PRICE, END_DATE)
VALUES (100860, '01-JAN-89', 33.6, 26.88, CURRENT_DATE);
INSERT INTO TAR_TEMP_PRICE (PRODUCT_ID, START_DATE, LIST_PRICE, MIN_PRICE, END_DATE)
VALUES (100861, '01-JUN-90', 50.4, 40.32, CURRENT_DATE);
INSERT INTO TAR_TEMP_PRICE (PRODUCT_ID, START_DATE, LIST_PRICE, MIN_PRICE, END_DATE)
VALUES (100861, '01-JAN-90', 47.04, 37.632, CURRENT_DATE);
INSERT INTO TAR_TEMP_PRICE (PRODUCT_ID, START_DATE, LIST_PRICE, MIN_PRICE, END_DATE)
VALUES (100861, '01-JAN-89', 43.68, 34.944, CURRENT_DATE);
INSERT INTO TAR_TEMP_PRICE (PRODUCT_ID, START_DATE, LIST_PRICE, MIN_PRICE, END_DATE)
VALUES (100870, '01-JAN-90', 3.136, 2.688, CURRENT_DATE);
INSERT INTO TAR_TEMP_PRICE (PRODUCT_ID, START_DATE, LIST_PRICE, MIN_PRICE, END_DATE)
VALUES (100870, '01-JAN-89', 2.688, 2.128, CURRENT_DATE);
由于某种原因,它正在从上面的代码中添加部分select语句。
这是输出:
'ENTER THE PERCENTAGE YOU WISH TO INCREASE THE PRICE BY: '
12
'ENTER THE PRODUCT SEARCH CRITERIA: '
DYN
'YOU HAVE CHOSEN TO UPDATE PRODUCTS WHOSE DESCRIPTION BEGINS WITH DYN WITH A PERCENTAGE INCREASE OF 12 PERCENT.'
'A SCRIPT insert_prices.sql HAS BEEN CREATED AT c:\runscripts\insert_prices.sql'
'THE FOLLOWING PRODUCTS WERE ADDED TO THE INSERT SCRIPT WITH THE ADJUSTED PRICES: '
PRODUCT_ID DESCRIPTION LIST_PRICE MIN_PRICE ADJ_LIST_PRICE ADJ_MIN_PRICE
---------- ------------------------------ -------------- -------------- -------------- --------------
100860 DynaBlaster 400 $35.00 $28.00 $39.20 $31.36
100860 DynaBlaster 400 $32.00 $25.60 $35.84 $28.67
100860 DynaBlaster 400 $30.00 $24.00 $33.60 $26.88
100861 Dynablaster 600 $45.00 $36.00 $50.40 $40.32
100861 Dynablaster 600 $42.00 $33.60 $47.04 $37.63
100861 Dynablaster 600 $39.00 $31.20 $43.68 $34.94
100870 Dynablaster xl60 $2.80 $2.40 $3.14 $2.69
100870 Dynablaster xl60 $2.40 $1.90 $2.69 $2.13
8 rows selected.
SP2-0734: unknown command beginning "CONCAT('IN..." - rest of line ignored.
答案 0 :(得分:3)
将此添加到SQL * Plus提示中。 (SET HEAD OFF
)
SET TERMOUT OFF;
SET VERIFY OFF;
SET SQLBLANKLINES ON;
SET HEAD OFF /* This turns of the headers in result */
SET FEEDBACK OFF /* Turns off the result feedback */
问题是SELECT
的结果列的默认名称以CONCAT(..
作为别名开头。
所以就像..
CONCAT('INSERTINTOTAR_TEMP_PRICE(PRODUCT_ID,START_DATE,LIST_PRICE,MIN_PRICE,END_DATE)VALUES(',P.PRODUCT_ID||','''||PR.START_DATE||''','||PR.LIST_PRICE
------------------------------------------------------------------------------------------------------------------------------------------------------
当您执行INSERT
脚本时,甚至会与其他插件一起执行。所以,我们必须关闭标题。