Re: EXECUTE ... SELECT COUNT(*) ... INTO ?
Posted in 1996
Bryan Tonnet wrote: ... > You are correct because that's the way it works. But when I saw the > following in the SQL syntax guide V7.1 (Pg 1-251)... > > "The INTO clause [of the EXECUTE statement] provides a concise and > efficient alternative to using more complicated and lengthy syntax... > ...if you use the INTO clause, you do not have to use the PREPARE, > DECLARE, OPEN and FETCH sequence of statements to retrieve values > from a table" > > Fairly cut and dried, and to my mind, making a lot of sense for singleton > SELECTs. But it doesn't work (at least in 4gl). Yikes!! Bryan, that piece of documentation is talking about the EXECUTE <stored procedure> command. You were talking about the EXECUTE <prepared statement> ommand. Strangely enough, even version 6.x of 4GL cannot comprehend the EXECUTE PROCEDURE statement. In 4GL, even to get the single row returned from a stored procedure required you to PREPARE the "EXECUTE PROCEDURE" statement, declare a cursor for it, open cursor and fetch cursor. For ESQL/C, you can still EXEC SQL EXECUTE PROCEDURE yadayada INTO :var1, :var2; but only for a procedure that returns a single row. If the proc returns multiple rows you must still use the cursor. But this is a digression. The main point is still that prepared statement that returns ANY value can be used ONLY with a cursor. > >However, I have hated the -4373 message since the first day I saw it! > >YUCHH! SO exquisitely meaninless!! ;-)) > > No argument there. Personally, I'm in favour of just one error number > that covers all possibilities. Something like "Error -1. You stuffed it." Why do I talk to these extremists? ;-) I hope I've ogtten the message across. I'm essentially tossing a day's worth of class while sitting on one bun. (I didn't have the balance to type it standing on 1 foot. ;-)) -- Jake Salomon