Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Dynamic order by clause in a cursor? Is it possible?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
Author Message
Treefarn

New User


Joined: 16 Jun 2005
Posts: 1

PostPosted: Thu Jun 16, 2005 7:32 pm    Post subject: Dynamic order by clause in a cursor? Is it possible?
Reply with quote

I have an application with a web front end with a cobol/db2 back end. The results from DB2 get sent back to the web page 10 at a time. There is an Order by clause which sorts these results by an account #.

If I ask the user on the webpage what column to sort by, is there a way on the mainframe end to alter the cursor, so instead of sorting account #, it could sort by account #7 or name or dollar amount.

What I was picturing was an 'order by x' clause, where x is an integer. Based on what the user indicated on the web page, x would be assigned the column number, and the cursor would sort accordingly.

But that doesn't seem to be possible, as I am getting bind problems, that the order clause is invalid because x is not a column of the results table. (SQL=-208).

Is it possible to do this in the declare cursor statement, other than by writing separate cursors for each possibility?
Back to top
View user's profile Send private message
References
sangiah

Active User


Joined: 10 Jun 2005
Posts: 64

PostPosted: Tue Jun 21, 2005 12:22 pm    Post subject:
Reply with quote

Can u use dynamic sql
Back to top
View user's profile Send private message
kulkarni_alok

New User


Joined: 07 Jul 2005
Posts: 4

PostPosted: Fri Jul 08, 2005 12:06 am    Post subject:
Reply with quote

go to the link www.mainframeweek.com/code/showcode.php/0075/mw75db21.txt
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1