By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,514 Members | 1,693 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,514 IT Pros & Developers. It's quick & easy.

What is wrong with this Script? Problem with DECLARE etc, etc

P: 25
Hi all,
My environment is DB2 UDBv8.2 on Windows and Linux.
I am getting a lot of errors on the script you see below. Some of the error I am geting are:


-----------------------------------Start of Script-----------------------------------
---------------------original creation by Norm Wong------------------------

CREATE PROCEDURE DB2ADMIN.REORGTS( )
DYNAMIC RESULT SETS 1
LANGUAGE SQL
MODIFIES SQL DATA

P1: BEGIN

DECLARE procresult RESULT_SET_LOCATOR VARYING ;

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 "END-OF-STATEMENT" was found following "_SET_LOCATOR VARYING". Expected tokens may include: "<psm_semicolon>". LINE NUMBER=23. SQLSTATE=42601

DECLARE TABLE_SCHEMA VARCHAR(128) ;

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 TABLE_SCHEMA VARCHAR" was found following "BEGIN-OF-STATEMENT". Expected tokens may include: "<values>". SQLSTATE=42601.
Same thig with all DECLARE shown below.

DECLARE TABLE_NAME VARCHAR(128) ;
DECLARE CARD INTEGER ;
DECLARE OVERFLOW INTEGER ;
DECLARE NPAGES INTEGER ;
DECLARE FPAGES INTEGER ;
DECLARE ACTIVE_BLOCKS INTEGER ;
DECLARE TSIZE INTEGER ;
DECLARE F1 FLOAT ;
DECLARE F2 FLOAT ;
DECLARE F3 FLOAT ;
DECLARE REORG CHAR(3) ;
DECLARE has_lob INTEGER DEFAULT 0 ;
DECLARE retval INTEGER DEFAULT 0 ;
DECLARE reorgcmd VARCHAR(512) ;
DECLARE at_end SMALLINT DEFAULT 0 ;
DECLARE not_found CONDITION FOR SQLSTATE '02000' ;
DECLARE CONTINUE HANDLER FOR not_found
SET at_end = 1 ;

Can someone show me what I am doing wrong? I need this help as soon as I can get it...
Thank you all
Okonita
Sep 12 '07 #1
Share this Question
Share on Google+
1 Reply


P: 9
Hello, send you an example


CREATE PROCEDURE RACE.SP_LISTARPAISES6(
IN OPCION VARCHAR(2) ,
IN CODPAIS VARCHAR(3) ,
IN DENPAIS VARCHAR(30),
IN TIP VARCHAR(1)
)
LANGUAGE SQL
RESULT SETS 1
BEGIN
DECLARE SQLSELE1 CHAR(512);
DECLARE C1 CURSOR WITH RETURN FOR S1;
-- DEBERAN PASAR EL VALOR DE CODPAIS INCLUYENDO EL PORCENTUAL '02%'--
IF TIP = '1' THEN
SET SQLSELE1 = 'SELECT A .CODPAI , A . DENPAI , A . PFTPAI FROM RACE . YYYPAI A WHERE
A.CODPAI LIKE ? FETCH FIRST 5000 ROWS ONLY ';
ELSE
SET SQLSELE1 = 'SELECT A .CODPAI , A . DENPAI , A . PFTPAI FROM RACE . YYYPAI A WHERE
A.CODPAI LIKE ?
FETCH FIRST 5000 ROWS ONLY';
END IF;
PREPARE S1 FROM SQLSELE1;
OPEN C1 USING CODPAIS;
END;
Sep 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.