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
 

 

want to get all columns of a db2 table using easytriev

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

New User


Joined: 22 Jul 2005
Posts: 12
Location: Philippines

PostPosted: Fri Jul 21, 2006 4:16 pm    Post subject: want to get all columns of a db2 table using easytriev
Reply with quote

i need to get all columns in a table by using easytrieve I have part of the ezytriev code below, but sadly, it only writes back my id_number into the output file. icon_sad.gif

What am i missing? any samples?

Thanks in advance!
Code:

   SQL DECLARE CSR1 CURSOR FOR +                           
   SELECT * +               
   FROM DB2SYS.SOMETABLE +                       
   WHERE ID_NUMBER = :WS-ID-NUMBER  +                   
   WITH UR                                             
                                                       
                                                       
 JOB INPUT NULL                                         
 GET INF1                                               
    DO WHILE NOT EOF INF1                               
       WS-ID-NUMBER = ID-NUM                           
                                                       
       SQL OPEN CSR1                                   
       SQL FETCH CSR1 +                                 
          INTO :WS-ID-QUERY                             
                                                       
       IF SQLCODE NE 0 AND SQLCODE NE 100               
          DISPLAY 'FETCH FAILED: ' SQLCODE             
       ELSE                                             
          IF SQLCODE = 0                               
             OUTREC1 = WS-ID-QUERY                     
             PUT OUTRJCT                               
          ELSE                                         
             DISPLAY 'ID NUMBER NOT FOUND:' WS-ID-NUMBER
          END-IF                                       
       END-IF                                           
       SQL CLOSE CSR1                                   
       GET INF1                                         
    END-DO                                             
 STOP                                                   
Back to top
View user's profile Send private message

barobaybay

New User


Joined: 22 Jul 2005
Posts: 12
Location: Philippines

PostPosted: Fri Jul 21, 2006 4:19 pm    Post subject:
Reply with quote

mods, sorry, can we move my topic to the CA Products forum? thanks
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Fri Jul 21, 2006 4:29 pm    Post subject:
Reply with quote

You have to write your sql in
EXEC sql

ENd EXEC'
Back to top
View user's profile Send private message
barobaybay

New User


Joined: 22 Jul 2005
Posts: 12
Location: Philippines

PostPosted: Mon Jul 24, 2006 9:06 am    Post subject:
Reply with quote

sorry, I can exec the SQL statement, but what i want to happen is to put the results of my query onto the output file...
Back to top
View user's profile Send private message
barobaybay

New User


Joined: 22 Jul 2005
Posts: 12
Location: Philippines

PostPosted: Mon Jul 24, 2006 12:24 pm    Post subject:
Reply with quote

good news guys! thanks for this post: http://ibmmainframes.com/viewtopic.php?t=12436&sid=bb869b04d72055436fcdd8cbd331d269

last post(or one of the last) ont the above topic basically reminds us to include each of the fields and put it into the host variable. just remember which data type of the field is the equivalent data type in the ezytriev program... great! problem solved! now it's possible to have several (100+) records as input and look them up directly from the table...
you guys rock! i love this forum!
Back to top
View user's profile Send private message
chiranjeevi_mca

New User


Joined: 19 Feb 2006
Posts: 27

PostPosted: Mon Jul 31, 2006 11:14 am    Post subject:
Reply with quote

i don't know the easytrive

but for that the query is

select name from sysibm.syscolumns where table='tablename'
Back to top
View user's profile Send private message
chiranjeevi_mca

New User


Joined: 19 Feb 2006
Posts: 27

PostPosted: Mon Jul 31, 2006 11:25 am    Post subject:
Reply with quote

Hi,

i understand what you written.

but i want to know you need the column names of the table
or
you need to retrieve all the data from that table.

if you need columns, the above posted topic is the write query
if you need the data, you are not getting even a single row from your table.

that's why it's displaying your id.
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 unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am


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