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

SQLCODE = -303 or UNDEFINED OR UNUSABLE HOST VARIABLE.


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

New User


Joined: 09 Oct 2006
Posts: 12
Location: Chennai, India

PostPosted: Sun May 17, 2009 9:47 am
Reply with quote

Hi!

I'm not able to get the number of rows from a table using the following command.

Code:
EXEC SQL                 
     SELECT COUNT(*)     
     INTO               
      :TOT-TABLE-RCD-CNT
      FROM ABCD.TABLE1
END-EXEC                 


ABCD.TABLE1 -
This table has 8 columns. All are of the datatype - CHAR or DATE.

TOT-TABLE-RCD-CNT -

I have declared this variable in the working storage section.
When I created this variable type ALPHANUMERIC, the pgm compiles and runs successfully. But the above SQL statement returns SQLCODE = -303. This is because the datatypes are NOT comparable.

But, when I try to declare this variable as NUMERIC, I get the following message.

UNDEFINED OR UNUSABLE HOST VARIABLE "TOT-TABLE-RCD-CNT"
SELECT COUNT(*)INTO : TOT-TABLE-RCD-CNT FROM ABCD.TABLE1

Also, in the message I see a SPACE between ":" and the variable name(as seen above).

Pls help me solve this.

Thanks!
Sheshadri
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: Sun May 17, 2009 10:14 am
Reply with quote

Hello,

This TOT-TABLE-RCD-CNT is your problem. The definition you've used is not compatable with the count function. How have you defined this variable?

PIC S9(9) COMP should work.

Complete info is available in the DB2 documentation available via the "IBM Manuals" link at the top of the page.
Back to top
View user's profile Send private message
Sheshadri

New User


Joined: 09 Oct 2006
Posts: 12
Location: Chennai, India

PostPosted: Sun May 17, 2009 3:21 pm
Reply with quote

Its working now!!!
Thanks a ton Dick!!! icon_biggrin.gif

Cheers!!!
Sheshadri
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: Sun May 17, 2009 9:38 pm
Reply with quote

You're welcome - good to hear it is working.

Thanks for letting us know icon_smile.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 -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts access the last host command CLIST & REXX 2
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top