Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Varying List Select SQL Query In DB2 Cobol Program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
NikhilGuptaGaya

New User


Joined: 28 May 2018
Posts: 5
Location: India

PostPosted: Wed Jun 27, 2018 11:01 pm    Post subject: Varying List Select SQL Query In DB2 Cobol Program
Reply with quote

How SQLDA fields are mapped with the retrieved columns from varying list select sql query? and how parameter marker to be used in this case?

Support with example please....
Back to top
View user's profile Send private message

Tushar Sood

New User


Joined: 26 Oct 2008
Posts: 11
Location: New Jersey

PostPosted: Thu Jun 28, 2018 1:17 am    Post subject: Reply to: Varying List Select SQL Query In DB2 Cobol Program
Reply with quote

Hi Nikhil,

Check if the link helps:

https://www.ibm.com/support/knowledgecenter/en/SSEPEK_12.0.0/apsg/src/tpc/db2z_samplecoboldynamicsql.html
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2300
Location: NY,USA

PostPosted: Thu Jun 28, 2018 8:45 pm    Post subject:
Reply with quote

In your last post , it is already said that you need to learn How to code Dynamic SQLs in Cobol but looks like you are making no efforts.
Code:
 See if you get it, I will try to narrate important steps..
1. Set you # of columns to SQLN OF SQLDAVAR
2. At this point,  it is assumed that, your query is already ready in host variable say SQLSTMT.
3. PREPARE STMT( e.g.) INTO :SQLDAVAR FROM :SQLSTMT
4. SQLD OF SQLDAVAR is populated with actual number of columns after step3 is executed ( different than step1) and move it to SQLN OF SQLDAVAR
5. Next step is to establish address for storing column value till end of all columns found in step4.  So use SQLDATA OF SQLDAVAR, SQLIND  OF SQLDAVAR, SQLTYPE OF SQLDAVAR and SQLLEN OF SQLDAVAR to SET ADDRESS to local defined Descriptor table and to also calculate the actual length of various data type columns.
6. Now you do set up the Parameter markers here, clue is to use SQLDATA OF SQLDAPRM pointer and play around with offsets based on your Host variable(should sync up with table structure and data types) to set markers
7. Now time to get all selected rows(FETCH cursor USING DESCRIPTOR :SQLDAVAR)
Back to top
View user's profile Send private message
NikhilGuptaGaya

New User


Joined: 28 May 2018
Posts: 5
Location: India

PostPosted: Thu Jun 28, 2018 10:04 pm    Post subject:
Reply with quote

Thank you Tushar and Rohit.

I am studying it and going through the link which Tushar had provided. I will come back if I get any doubts in that. However, the URL is very useful. I am studying it. Thank you once again.

Regards,
Nikhil Gupta
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2300
Location: NY,USA

PostPosted: Thu Jun 28, 2018 10:07 pm    Post subject:
Reply with quote

I would suggest you to find any existing program which uses this and see the logical flow and then get into specific area if not understood which is the easiest way to learn.
Back to top
View user's profile Send private message
Tushar Sood

New User


Joined: 26 Oct 2008
Posts: 11
Location: New Jersey

PostPosted: Sat Jun 30, 2018 7:59 pm    Post subject:
Reply with quote

NikhilGuptaGaya wrote:
Thank you Tushar and Rohit.

I am studying it and going through the link which Tushar had provided. I will come back if I get any doubts in that. However, the URL is very useful. I am studying it. Thank you once again.

Regards,
Nikhil Gupta



Nice to know that it helped...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Is multiple program names allowed in ... Sakthidevi PL/I & Assembler 1 Tue Nov 19, 2019 11:12 pm
No new posts COBOL -DB2 SQL code to have GROUP BY ... vinu78 DB2 21 Wed Oct 23, 2019 7:00 pm
No new posts Query on JCL abdulrafi DFSORT/ICETOOL 5 Wed Oct 16, 2019 7:02 pm
No new posts Running a REXX exec program using ZOSMF Sakthi344 CLIST & REXX 3 Tue Oct 15, 2019 3:13 pm
No new posts How to handle NULL in COBOL program bhaskar_kanteti COBOL Programming 8 Mon Oct 07, 2019 3:54 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us