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

COBOL: 'USER' problem


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Tue Jan 11, 2011 9:58 am
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
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

Moderator Emeritus


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

PostPosted: Tue Jan 11, 2011 11:21 am
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
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: 2358
Location: Israel

PostPosted: Tue Jan 11, 2011 11:48 am
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

Moderator Emeritus


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

PostPosted: Tue Jan 11, 2011 11:49 am
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
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
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
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
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
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

Moderator Emeritus


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

PostPosted: Wed Jan 12, 2011 8:38 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top