View previous topic :: View next topic
|
Author |
Message |
dsarlie Currently Banned New User
Joined: 22 Apr 2008 Posts: 5 Location: Chennai
|
|
|
|
Hi,
I am using the following piece of code in my program.I am getting undefined or unusable host variable.Can someone tell me what is the error in the code.
03 W070-RANDOM-NUMBER1 PIC 9(1)V VALUE ZEROES
EXEC SQL
SELECT DECIMAL(RAND() * 10)
INTO :W070-RANDOM-NUMBER1
FROM SYSIBM.SYSDUMMY1
END-EXEC
DSNH312I E DSNHSMUD LINE 1314 COL 20 UNDEFINED OR UNUSABLE HOST VARIABLE
"W070-RANDOM-NUMBER1"
Thanks
Jeba David |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
The result of the RAND function is a double precision floating-point number... ... try changing the PIC clause to accomodate floating point |
|
Back to top |
|
|
dsarlie Currently Banned New User
Joined: 22 Apr 2008 Posts: 5 Location: Chennai
|
|
|
|
I checked with the picture clause matching.It is not getting matched.I hope this error may be because of attribute mistach.I dont know the exact length of the output for this query. |
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
Quote: |
03 W070-RANDOM-NUMBER1 PIC 9(1)V VALUE ZEROES |
...not sure if it will work..Try defining the variable as USAGE COMP-2.
WTF |
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
Sorry ..missed out on the DECIMAL part of the query ...
PIC S9(9)V9(2) USAGE COMP-3. should work.
Hope this helps.
WTF |
|
Back to top |
|
|
dsarlie Currently Banned New User
Joined: 22 Apr 2008 Posts: 5 Location: Chennai
|
|
|
|
Hi,
Thanks.Comp-2 works now.Comp-3 gives the same error.While I am getting the data from the table it is Floating point precision.
For eg:
(blank.20000000000000000E 01 ) this is the output I get from the table.I need only the number 2.
03 ws-num1 usage comp-2
03 ws-num2 redefines ws-num1
05 filler pic x(02)
05 ws-num3 pic 9(1)
05 filler pic 9(17).
This is how I have declared the variables.
in my ouput ws-num3 has blank space and it is not displaying anything.Is there any error over here.How should I get the value 2. |
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
Jeba,
Lets work on your original request.
I tried the following code ...and it worked for me.
Code: |
WORKING STORAGE.
01 RAN PIC S9(1) USAGE COMP-3.
01 RAN-DISP PIC S9(1) VALUE ZEROES.
PROCEDURE DIVISION.
EXEC SQL
SELECT DECIMAL(RAND() * 10)
INTO :RAN
FROM SYSIBM.SYSDUMMY1
END-EXEC
MOVE RAN TO RAN-DISP
DISPLAY 'OUTPUT:'RAN
DISPLAY 'OUTPUT DISPLAY :'RAN-DISP
|
Spool Output
OUTPUT:7
OUTPUT DISPLAY :G
I believe this should work for you as well, do let us know otherwise.
WTF |
|
Back to top |
|
|
|