aspose file tools*
The moose likes JDBC and the fly likes Any sample working code or tutorial for dynamic sql in db2 procedures Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Any sample working code or tutorial for dynamic sql in db2 procedures " Watch "Any sample working code or tutorial for dynamic sql in db2 procedures " New topic
Author

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

Biju moozhikkara
Greenhorn

Joined: Oct 21, 2005
Posts: 20
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Biju,
A quick google search found this example. Are you looking for something more specific?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Biju moozhikkara
Greenhorn

Joined: Oct 21, 2005
Posts: 20
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

Joined: Nov 06, 2012
Posts: 18
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Any sample working code or tutorial for dynamic sql in db2 procedures