Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Declaring in DCLGEN an array for variable
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Cecil

New User


Joined: 23 Oct 2007
Posts: 9
Location: chennai

PostPosted: Tue Jun 03, 2008 7:06 pm    Post subject: Declaring in DCLGEN an array for variable
Reply with quote

Hello all,

I need to declare a variable CDCONF char(3) which occurs 3 times, in DCLGEN and also create an SQL code for reading the value of this variable from the DB2 table. The table is a new one and will be created during prod move by client.
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jun 03, 2008 7:12 pm    Post subject:
Reply with quote

I would very much like to see the SQL for defining this column.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Jun 03, 2008 7:13 pm    Post subject:
Reply with quote

in DCLGEN ????

create an SQL code for reading the value of this variable ????

pls explain ...
Back to top
View user's profile Send private message
Cecil

New User


Joined: 23 Oct 2007
Posts: 9
Location: chennai

PostPosted: Tue Jun 03, 2008 7:33 pm    Post subject:
Reply with quote

To explain more.
My client is making a new table. He has asked me to create a pgm where this table is to be read using SELECT stmt.
In the data defn of the different columns of the new table, I have the variable or column name CDCONF which occurs 3 times.

Wat shud I do? Im kinda really stuck on this..
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Tue Jun 03, 2008 7:34 pm    Post subject:
Reply with quote

"WITH ROWSET POSITIONING" feature of DB2 V8.1 and above can help you.
Please see the below link and let us know if you wanted anything different than this.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Tue Jun 03, 2008 7:37 pm    Post subject:
Reply with quote

I just wanted to know if your database is DB2 for sure? The way you explained the field reminds me of ADABAS.
Back to top
View user's profile Send private message
Cecil

New User


Joined: 23 Oct 2007
Posts: 9
Location: chennai

PostPosted: Tue Jun 03, 2008 7:39 pm    Post subject:
Reply with quote

Yes. Its DB2 for sure.
Back to top
View user's profile Send private message
Cecil

New User


Joined: 23 Oct 2007
Posts: 9
Location: chennai

PostPosted: Tue Jun 03, 2008 7:43 pm    Post subject:
Reply with quote

I'm not sure that its the ROWSET stmt... coz in the pgm Im reading all columns of the table into a copybook..
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Tue Jun 03, 2008 7:44 pm    Post subject:
Reply with quote

Back to sqare one. Answer the Craq's question.
Back to top
View user's profile Send private message
Cecil

New User


Joined: 23 Oct 2007
Posts: 9
Location: chennai

PostPosted: Tue Jun 03, 2008 7:52 pm    Post subject:
Reply with quote

I dont have the SQL..if that's wat u meant by Craq'q question.
I need to create it!
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Tue Jun 03, 2008 7:53 pm    Post subject: Reply to: Declaring in DCLGEN an array for variable
Reply with quote

can You please show the relevant create table statements
( at least for the three column involved )
I guess it has been defined as column char(9)

in this case the host variable were the column will be fetched
might be redefined as an array
( a supposition, I do not speak cobol, can be certainly be done in PL/1 )

the select could use the substring operand
the COBOL the reference modifier
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Tue Jun 03, 2008 8:01 pm    Post subject:
Reply with quote

As enrico suggested we need TABLE creation SQL (At least).
As we understand you need to create SQL query to fetch data from that table.
Back to top
View user's profile Send private message
Cecil

New User


Joined: 23 Oct 2007
Posts: 9
Location: chennai

PostPosted: Tue Jun 03, 2008 8:11 pm    Post subject:
Reply with quote

The table is not yet created.. It'll be done by the client later. So, I dont have the create table stmt.
But even if it is the case as u said (char 9), how will the sql stmt b like?
EXEC SQL SELECT
CDCONF(1:3),
CDCONF(3:6),
CDCONF(6:9)
INTO
icon_mad.gif,
:y,
:z
FROM ..etc

Is this a correct query?
Back to top
View user's profile Send private message
Cecil

New User


Joined: 23 Oct 2007
Posts: 9
Location: chennai

PostPosted: Tue Jun 03, 2008 8:23 pm    Post subject:
Reply with quote

oops.. sorry for the emoticons.. tht was a typo
Back to top
View user's profile Send private message
Cecil

New User


Joined: 23 Oct 2007
Posts: 9
Location: chennai

PostPosted: Tue Jun 03, 2008 9:00 pm    Post subject:
Reply with quote

I think Ive found a probable somn on internet- host variable array.
Do u think it is the soln? Does anyone have any info regarding using host variable arrays?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Tue Jun 03, 2008 9:18 pm    Post subject: Reply to: Declaring in DCLGEN an array for variable
Reply with quote

Code:
EXEC SQL SELECT
CDCONF(1:3),
CDCONF(3:6),
CDCONF(6:9).... 

right from a syntax pint of view but...

why waste resources? having db2 make three moves,
when a
Code:
... SELECT CDCONF INTO ....

and redefining Your variable as three variables or as an array
or using reference modification
is better
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Tue Jun 03, 2008 9:38 pm    Post subject:
Reply with quote

EXEC SQL SELECT
CDCONF(1:3),
CDCONF(3:6),
CDCONF(6:9)
INTO
icon_mad.gif,
:y,
:z


Are you referrring to splitting the column CDCONF (using substring function) into three different host variables? The above sql looks like it.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jun 04, 2008 1:10 am    Post subject:
Reply with quote

Hello,

I've joined the party somewhat late, but i suspect it will be futile to try to write the SELECT code before the table definition is known. . .

Code:
SELECT WhatIWant FROM WhereverItIs WHERE SomeConditon
will not resolve to something useful. . .

Maybe i misunderstand, but if i do understand, coding needs to wait until the table definition is resolved.
Back to top
View user's profile Send private message
Cecil

New User


Joined: 23 Oct 2007
Posts: 9
Location: chennai

PostPosted: Wed Jun 04, 2008 6:40 pm    Post subject:
Reply with quote

enrico-sorichetti,
Could u explain a bit more ur soln?I mean how shud the query code look like?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 04, 2008 6:51 pm    Post subject:
Reply with quote

CECIL,

you should defne your table, and each of these 3 variables should be a separate column.


rowsets is used for multiple rows, not multiple columns.


if your user is a complete idiot and tries to jam 3 numeric fields into one column, you should tell him that is not the way to go. he should have a column per field. because of he does not, there is no way to update the '2nd' field in the column without selecting, parsing, modifiying, re-bundling and then updating the column. (or the 1st or 2nd).

everytime somebody uses a char field to hold numerics or combines fields into an char or refuses to use date/time db2 datatypes, just makes the system harder to deal with. db2 is not vsam.
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am
No new posts Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm
No new posts JOINKEYs and Variable files migusd SYNCSORT 8 Fri Jun 17, 2016 3:16 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us