Fstdt if e disk
Dnam s 10a
Ddept s 3a
C/exec sql
C+ SELECT NAME, BRANCH INTO :nam, :dept FROM stdt WHERE STDID < 10
C+
C/end-exec
C seton lr
Hai all ..!
I have this code ..
But i'm not getting the output..
how can i get the result..? orelse what is the error here ..?
Software/Hardware used:
ASKED:
November 18, 2011 1:35 PM
UPDATED:
March 6, 2012 6:26 PM
A Small Correction to the Code,
Select ; When SqlCod = 100 ; Leave ; When SqlCod = 0 ; //Perform the Required Operation Other ; EndSl ; If you still not getting the Result, You can check for the SqlCod, That will help you in Resolving this problem. Pradeep.Output ..Your program doesn’t have any output commands.
Sorry but I can’t resist:this paraphrase: “we don ned no stinkin output”
Fstdt if e disk
Dnam s 10a
Ddept s 3a
C/exec sql
C+ SELECT NAME, BRANCH INTO :nam, :dept FROM stdt WHERE STDID < 10
C+
C/end-exec
C NAM DSPLY
C DEPT DSPLY
C seton lr
Of course as discussed in another response.this will fail if more than one record qualify. If you call this program it will now show you the results.
Phil
Also, since there is no program I/O for the STDT file, the F-spec for it can be deleted.
But Phil is right — the program doesn’t have any output defined. If you don’t code output, don’t expect output. So far, all that happens is some set of rows is selected — as coded, it needs to be a single-row set. Now the program needs to do something with those rows.
Tom
Thanks Pradeep .
I’m having more than one record that STDID < 10.
But the Output Shows only one record….
Isn’t possible read all those records which is STDID < 10.
Surey.
The fetch will get the next row from the cursor
So putting the fetch in a loop will allow you to get and process each step
Pradeep’s code with his admendments should read and process all rows except if there is an error.
NOTE: This SQL requires a cursor but it doesn’t need to be Dynamic. Dynamic is needed when the actuall SQL command is created as a string and loaded programmatically.
Phil
Can you post your SQL statements (I’m assuming you’ve modified what you previously posted)?
But the Output Shows only one record….
If you need to retrieve more than a single row at a time, use a multiple-row FETCH to fetch a block at a time into an array. Otherwise, you will need to loop through individual rows. If you loop and you also want to hold the values from each row, then you’ll have to store the values in an array (or some kind of repeating structure) after you fetch each row.
Tom
Hi Splat..
Fstdt if e disk
Dnam s 10a
Ddept s 3a
C/exec sql
C+ SELECT NAME, BRANCH INTO :nam, :dept FROM stdt WHERE STDID < 10
C+
C/end-exec
C nam dsply
C dept dsply
C seton lr
this is my code. …
See Tom’s answer just above – he’s got the right of it (as is usual).
@Sureyz:
Why do you have the F-spec for STDT in the program? Your program doesn’t do anything with it, so the line should be removed. All it does is add overhead.
Tom
And note that the SQL might be changed to { WHERE STDID = :i } and put inside a { for i = 1 to 9 } loop. With i defined as a basic integer, the dsply statements could display values as the loop progressed.
(But the F-spec still should be deleted.)
Tom
Yes Tom..
I got it .. thanks
and thanks to all..
Surey.