• Post Reply Bookmark Topic Watch Topic
  • New Topic

Any sample working code or tutorial for dynamic sql in db2 procedures

 
Biju moozhikkara
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Can any body provide me with Any sample working code or tutorial for dynamic sql in db2 procedures.

i need to change certain part of sql statment, like order by field dynamcally.

Regards
Biju M
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36031
432
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Biju,
A quick google search found this example. Are you looking for something more specific?
 
Biju moozhikkara
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Jeanne ,
Thanks for the link.But i was looking for dynamic sql embedded in db2 stored procedure. hope that is very much possible.

Regards
Biju M
 
Sagar Dafle
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the SIMPLEST SP that i executed ..

CREATE PROCEDURE SP_SAMPLE()
DYNAMIC RESULT SETS 1
BEGIN
DECLARE c CURSOR WITH RETURN FOR
SELECT * FROM sagar123.emp;
OPEN c;
END
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!