IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Varying List Select SQL Query In DB2 Cobol Program


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 14
Location: New Jersey

PostPosted: Thu Jun 28, 2018 1:17 am
Reply with quote

Hi Nikhil,

Check if the link helps:

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

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Jun 28, 2018 8:45 pm
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
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Jun 28, 2018 10:07 pm
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: 14
Location: New Jersey

PostPosted: Sat Jun 30, 2018 7:59 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top