|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Help to create Stored Procedures
i try to create a Stored Procedure for a Pager
but i can nut create the sucessful, because i get the error Message ...Specify SET OPTION OUTPUT=*PRINT If i delete the last 4 Lines "--- AND finally select and return desired -Paged- Rows ..." the SP ist created, so i guess there is the reason (in the last 4 lines) i am not so trusted with DB2 Stored Procedures and need any help to make this source right ------------------------------------------------------ CREATE PROCEDURE KPSLIB.USP_KMS_GetPagedDistributor ( IN PageSize DECIMAL(8,0), IN CurrentPage DECIMAL(8,0), OUT ItemCount DECIMAL(8,0) ) LANGUAGE SQL MODIFIES SQL DATA BEGIN DECLARE UpperBand DECIMAL(8,0); DECLARE LowerBand DECIMAL(8,0); -- Get The Count Of The Rows That They Meet the Criteria SET ItemCount = (SELECT COUNT(*) FROM TABLE); -- Calculate the LowerCount and UpperCount SET LowerBand = (CurrentPage - 1) * PageSize ; SET UpperBand = (CurrentPage * PageSize) + 1; -- create a temporary table CREATE TABLE #AllRows( RowID int PRIMARY KEY, DistributorCode VARCHAR(5) ) ; -- INSERT ALL the Rows that meets the Criteria INSERT INTO #AllRows SELECT DISTINCT A1.PRDIST as DistributorCode, A2.GDNAME, ROW_NUMBER() AS RowNumber FROM KPSLIB.PSPRDP AS A1 LEFT OUTER JOIN NCPLIB_IWS.GADSTP AS A2 ON A2.GDDSTR = A1.PRDIST WHERE A1.PRDATE >= '20080313' AND A1.PRDATE <= '20080326' and A1.PRYEAR = '6' ORDER BY A1.PRDIST; --- AND finally select and return desired -Paged- Rows SELECT RowID, DistributorCode FROM #AllRows WHERE RowID > LowerBand AND RowID < UpperBand ; RETURN 0; END; ---------->>> I get this error Message: SQL State: 42904 Vendor Code: -7032 Message: [SQL7032] SQL procedure, function, or trigger USP_KMS_GETPAGEDDISTRIBUTOR in KPSLIB not created. Cause . . . . . : SQL procedure, function, or trigger USP_KMS_GETPAGEDDISTRIBUTOR in KPSLIB was not created. The compile was not successful. SQL creates an SQL procedure, function, or trigger as a C program that contains embedded SQL. Errors not found during the initial parsing of the CREATE PROCEDURE, CREATE FUNCTION, or CREATE TRIGGER statement can be found during the precompile. Recovery . . . : If a compile error occurred, see the appropriate listing in QSYSPRT. If the SQL precompile failed, there is always a listing with the error. If the C compile failed, the listing is only created if requested. Specify SET OPTION OUTPUT=*PRINT prior to the routine body in the CREATE statement if listings are required. i don't know how write this StoredPorcedures right. Any help ist welcome!!! Thanks! |
![]() |
| Viewing: Dev Shed Forums > Databases > DB2 Development > Help to create Stored Procedures |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|