Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums 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: 1942
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: 1942
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 Utility to list Data Set Information Auryn JCL & VSAM 4 Tue Jul 17, 2018 5:03 pm
No new posts Error while initiation CICS program f... Ashishpanpaliya CICS 3 Mon Jul 16, 2018 5:12 pm
No new posts Query for fetching matching data in t... Poha Eater DB2 10 Mon Jul 09, 2018 6:06 pm
No new posts LIST NODE DIRECTORY - db2 clp - tryin... elixir1986 IBM Tools 1 Sat Jul 07, 2018 6:15 pm
No new posts SQL IN predicate using COBOL table jerryte DB2 16 Fri Jun 29, 2018 10:30 pm

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