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
 

 

COBOL: 'USER' problem

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
pbc3199

New User


Joined: 28 Sep 2007
Posts: 7
Location: Malaysia

PostPosted: Tue Jan 11, 2011 9:49 am    Post subject: COBOL: 'USER' problem
Reply with quote

My scenario problem is regarding to 'USER' are
1) I'm login to mainframe as 'EDS01'
2) My USER_PROFILE table structured are USER, NAME, BRANCH.
3) My data in USER_PROFILE are (ABC123, MYNAME, 01)
4) My cobol programming
Code:
 EXEC SQL DECLARE KURSOR CURSOR FOR
               SELECT USER,
                           NAME,
                           USER_ID
                FROM   USER_PROFILE
                END-EXEC.
               
               EXEC SQL
               FETCH KURSOR INTO
                         :USR-USER,
                         :USR-NAME,
                         :USR-BRANCH
               END-EXEC.
               DISPLAY 'USR-USER = ' USR-USER.


The problem is, when I display the USR-USER, the system display 'EDS01', not ABC123. Please help me how to display the correct data.
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: Tue Jan 11, 2011 9:58 am    Post subject:
Reply with quote

Hello,

Your code is showing the data that is in the table.

Why might the sql show something that is not part of the table?

You could log on as "FRED" and the result should still be the same is it is now.

Possibly, there is something i misunderstand.
Back to top
View user's profile Send private message
pbc3199

New User


Joined: 28 Sep 2007
Posts: 7
Location: Malaysia

PostPosted: Tue Jan 11, 2011 10:05 am    Post subject:
Reply with quote

supposedly, the system should display 'ABC123'.
But, the system display my mainframe login userid ('EDS01').
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: Tue Jan 11, 2011 11:21 am    Post subject:
Reply with quote

Hello,

Looks like i read your results backwards. . . icon_redface.gif

Regardless, the sql is returning the value in the table.

Suggest you run a query in spufi without using a cursor and see what is really in the table.

Suggest also you make sure the column names are correct as well as the host variable names and definitions.
Back to top
View user's profile Send private message
pbc3199

New User


Joined: 28 Sep 2007
Posts: 7
Location: Malaysia

PostPosted: Tue Jan 11, 2011 11:38 am    Post subject:
Reply with quote

the data is exactly correct when i do the SPUFI.......
'ABC123', 'MYNAME', '01'

and i have define the variable correctly

I'm still stuck.......why the system display my mainframe login id?
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Tue Jan 11, 2011 11:48 am    Post subject:
Reply with quote

What do you see in the other host variables?

O.
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: Tue Jan 11, 2011 11:49 am    Post subject:
Reply with quote

Hello,

Quote:
why the system display my mainframe login id?

Not the answer you want, but the answer is in your code.

If the spufi query returned the problem value we might look elsewhere, but i suspect the code is the culprit.

Or there may be the possibility that the program is not using the exact same table as the spufi. How many different tables have the name USER_PROFILE?
Back to top
View user's profile Send private message
pbc3199

New User


Joined: 28 Sep 2007
Posts: 7
Location: Malaysia

PostPosted: Tue Jan 11, 2011 12:14 pm    Post subject:
Reply with quote

can i say that USER column is reserved word in COBOL?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Jan 11, 2011 1:30 pm    Post subject:
Reply with quote

pbc3199 wrote:
can i say that USER column is reserved word in COBOL?


at first, i wrote a quick an dirty criticizing you lack of db2 skills.

then I tested something and received some interesting results.

next post, out of time.
Back to top
View user's profile Send private message
pbc3199

New User


Joined: 28 Sep 2007
Posts: 7
Location: Malaysia

PostPosted: Tue Jan 11, 2011 1:34 pm    Post subject:
Reply with quote

i'm new in mainframe.....could you please tell me more about bind parms?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Jan 11, 2011 1:49 pm    Post subject:
Reply with quote

pbc3199,

I changed my post after you read it.

ok,

i have a table at work that has a column name: USER WHICH IS A RESERVED WORD.

in spufi,

if i
Code:

select company
      ,product
      ,user
from my_company_table

results are:
Code:

company
product
my user id

if my sql is
Code:

select company
      ,product
      ,user  as my_userid
      ,a.user  as tab_user1
      ,"user"  as tab_user2
from my_company_table a

results are:
Code:

company,
product,
my user id,
user id from table
user id from table


so, I am not going to say that I don't believe you when you say SPUFI works ok,
just going to say,
qualify the column name or use double quotes
as the manual tells you to do.
Back to top
View user's profile Send private message
pbc3199

New User


Joined: 28 Sep 2007
Posts: 7
Location: Malaysia

PostPosted: Wed Jan 12, 2011 8:29 am    Post subject:
Reply with quote

at last.....i have settled my problem....thank you very much dbzTHEdinosauer........
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 Jan 12, 2011 8:38 am    Post subject: Reply to: COBOL: 'USER' problem
Reply with quote

Good to hear it is working - thank you for letting us know icon_smile.gif

And another excellent catch by our resident "Dino". . . icon_cool.gif

d
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 am
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts IMS region inactive - User abend code... gthmrj IMS DB/DC 5 Tue Mar 07, 2017 12:29 pm
No new posts User Cancels the job PANDU1 DB2 1 Sat Mar 04, 2017 8:21 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm


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