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

want to get all columns of a db2 table using easytriev


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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: 1208
Location: Bangalore,India

PostPosted: Fri Jul 21, 2006 4:29 pm
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
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
Reply with quote

good news guys! thanks for this post: 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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Remote Unload of CLOB Columns DB2 6
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top