View previous topic :: View next topic
|
Author |
Message |
Sheshadri
New User
Joined: 09 Oct 2006 Posts: 12 Location: Chennai, India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Sheshadri
New User
Joined: 09 Oct 2006 Posts: 12 Location: Chennai, India
|
|
|
|
Its working now!!!
Thanks a ton Dick!!!
Cheers!!!
Sheshadri |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome - good to hear it is working.
Thanks for letting us know
d |
|
Back to top |
|
|
|