db2:预期的令牌可能包括:“<values>”。 LINE NUMBER = 1。 SQLSTATE = 42601 </值>

时间:2012-01-30 22:00:06

标签: sql db2

我正在执行以下操作:

db2  -tvsf ./sql/update_product.sql

我使用eclipse编辑update_product.sql并将文件移动到unix框。我还在执行前从文件中删除了update_product.sql ^M 字符。

我收到以下错误:

Database Connection Information

 Database server        = DB2/AIX64 9.7.0
 SQL authorization ID   = CGO_USER
 Local database alias   = JPN_DEV


DECLARE BEGIN DECLARE   v_eisidentifier VARCHAR(100)
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "DECLARE BEGIN DECLARE v_eisidentifier VARC" was
found following "BEGIN-OF-STATEMENT".  Expected tokens may include:
"<values>".  LINE NUMBER=1.  SQLSTATE=42601

以下是SQL文件:

   CONNECT TO JPN_DEV USER devuser USING password;

   DECLARE 

   BEGIN

    DECLARE v_eisidentifier VARCHAR(100);
DECLARE v_categoryGuid DECIMAL(19,0); 
DECLARE v_localeGuid DECIMAL(19,0);
DECLARE v_realmGuid DECIMAL(19,0);
DECLARE v_catchingPhrase VARCHAR(120) ;
DECLARE v_genericName VARCHAR(80);
DECLARE v_ingredients VARCHAR(900);
DECLARE v_quantity VARCHAR (60);
DECLARE v_dose VARCHAR(40);
DECLARE v_nutritionFacts VARCHAR (900);
DECLARE v_productDescription VARCHAR (900);
DECLARE v_recommendedFor VARCHAR (200);
DECLARE v_promotionMessage VARCHAR (200);
DECLARE v_message VARCHAR (4500);


DECLARE C1 CURSOR FOR
    SELECT 
            EISIDENTIFIER,
            CATEGORY_GUID,
            LOCALEGUID,
            REALMGUID,
            CATCHING_PHRASE,
            GENERIC_NAME,
            INGREDIENTS,
            QUANTITY,
            DOSE,
            NUTIRITION_FACTS,
            PRODUCT_DESCRIPTION,
            RECOMMENDED_FOR,
            PROMOTION_MESSAGE,
            MESSAGE
        FROM 
            TEMP_UPLOAD_PRODUCT_ATTRIBUTES;

        FETCH C1 into :v_eisidentifier,     
                      :v_categoryGuid, 
                      :v_localeGuid,
                      :v_realmGuid,
                      :v_catchingPhrase,
                      :v_genericName,
                      :v_ingredients,
                      :v_quantity,
                      :v_dose,
                      :v_nutritionFacts,
                      :v_productDescription
                      :v_recommendedFor,
                      :v_promotionMessage,
                      :v_message
        ;
        DECLARE v_proudctGuid;  
        WHILE (SQLCODE=0) 
        DO
            IF EXISTS (SELECT 1 FROM PRD_PRODUCT WHERE EISIDENTIFIER = :v_eisidentifier)
            THEN
                SELECT GUID INTO :v_productGuid where PRD_PRODUCT WHERE EISIDENTIFIER = :v_eisidentifier;                       
                UPDATE PRD_PRODUCT_L10N
                SET CATEGORY_GUID = :v_categoryGuid,
                    REALMGUID = :v_realmGuid,
                    CATCHING_PHRASE =:v_catchingPhrase,
                    GENERIC_NAME =:v_genericName,
                    INGREDIENTS =:v_ingredients,
                    QUANTITY=:v_quantity,
                    DOSE=:v_dose,
                    NUTIRITION_FACTS=:v_nutritionFacts,
                    PRODUCT_DESCRIPTION=:v_productDescription,
                    RECOMMENDED_FOR:=v_recommendedFor,
                    PROMOTION_MESSAGE:=v_promotionMessage,
                    MESSAGE:=v_message
                WHERE PRODUCTGUID =:v_proudctGuid and LOCALGUID =:v_categoryGuid;
                IF SQLCODE <> 0 THEN
                    DBMS_OUTPUT.PUT_LINE ('ERROR:' || SUBSTR(SQLERRM,1,175));
                END IF

            ELSE 
                --  INSERT INTO --- should not be the case....
                DBMS_OUTPUT.PUT_LINE ('WARNING: THE PRODUCT' || :v_eisidentifier || ' NOT FOUND IN THE DATABASE' );
            END IF;

            IF EXISTS (SELECT 1 FROM PRD_PRODUCT_CATEGORY WHERE CATEGORY_GUID=:v_categoryGuid AND PRODUCT_GUID=:v_productGuid)
                DBMS_OUTPUT.PUT_LINE ('WARNING: PRODUCT NOT FOUND IN THE DATABASE' );
            ELSE 
                INSERT INTO PRD_PRODUCT_CATEGORY (CATEGORY_GUID, PRODUCT_GUID) VALUES (:v_categoryGuid,:v_productGuid); 
                IF SQLCODE <> 0 THEN
                    DBMS_OUTPUT.PUT_LINE ('ERROR: COULD NOT INSERT categoryGuid: ' || :v_categoryGuid || ' productGuid: ' || :v_productGuid || 'in PRD_PRODUCT_CATEGORY table'); 
                    DBMS_OUTPUT.PUT_LINE ('ERROR:' || SUBSTR(SQLERRM,1,175));
                END IF
            END IF;

            FETCH C1 into :v_productGuid,   
                      :v_categoryGuid, 
                      :v_localeGuid,
                      :v_realmGuid,
                      :v_catchingPhrase,
                      :v_genericName,
                      :v_ingredients,
                      :v_quantity,
                      :v_dose,
                      :v_nutritionFacts,
                      :v_productDescription
                      :v_recommendedFor,
                      :v_promotionMessage,
                      :v_message
            ;
        END WHILE;

END ;
COMMIT;

请告知。

1 个答案:

答案 0 :(得分:1)

您的连接语句后似乎还有一个DECLARE