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

Problem with MAX() query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kranthikumarb

Active User


Joined: 02 Jan 2009
Posts: 115
Location: Hyderabad

PostPosted: Tue Jan 27, 2009 7:31 pm
Reply with quote

Hi,

I have a table in which a field "accno" is defined as numeric(5). Wen i genereated the DCLGEN for the table, the same field is decimal(5,0) and the corresponding hoset variable is "ws-accno" with data type s9(5)v usage comp-3.

Now when i try to use a query in tha program, it is throwing an error.
The query is

Select MAX(accno) into :ws-accno from account

The error is undefined or unusable host variable ws-accno.

1) I tried using a local variable
2) i tried using a comp variable instead of comp-3
3) i changed the query to write max function in a sub query.

Nothing worked out.

Please help me
Back to top
View user's profile Send private message
Suresh Ponnusamy

Active User


Joined: 22 Feb 2008
Posts: 107
Location: New York

PostPosted: Tue Jan 27, 2009 9:51 pm
Reply with quote

Hi

1) What is the definition of ws-accno in your program.

2) Are you directly using this variable in the query or doing some operation (initialize or move) before that.
Back to top
View user's profile Send private message
muthukannan

New User


Joined: 03 Aug 2006
Posts: 42
Location: Chennai

PostPosted: Wed Jan 28, 2009 1:48 am
Reply with quote

Hi,

Have you included the DCLGEN in your COBOL program.
Back to top
View user's profile Send private message
CHANDAN KAPOOR

New User


Joined: 12 Apr 2008
Posts: 36
Location: NOIDA

PostPosted: Wed Jan 28, 2009 12:47 pm
Reply with quote

I think you shull use null indicator variable also if the column is nullable in the database.
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Wed Jan 28, 2009 12:55 pm
Reply with quote

There are a lot of functions which are nullable even though the columns are not nullable. This is one of them. But I do not think it would say unusable host variable. We'll get this if the variable is not declared or : is missing from the query. Check this in your program. If it is not the problem, paste the code from your program(both declaration and the SQL).
Back to top
View user's profile Send private message
sumit agarwalla

New User


Joined: 13 Nov 2008
Posts: 17
Location: hyderabad

PostPosted: Wed Jan 28, 2009 2:02 pm
Reply with quote

Quote:
The error is undefined or unusable host variable ws-accno


Check if u have included the DCLGEN member in Area B.This error is sometimes thrown when the DCLGEN member is not in Area B and thus the variable is not recognised by the application program
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
Search our Forums:

Back to Top