DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old April 21st, 2008, 01:38 AM
Rayman33 Rayman33 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 1 Rayman33 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m
Reputation Power: 0
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!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > Help to create Stored Procedures


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway