Re: EXECUTE ... SELECT COUNT(*) ... INTO ?
Posted in 1996
In <32A55433.2D6F@west.co.za> "Mark D. Stock" <marks@west.co.za> writes: >Bryan Tonnet wrote: >> It's good isn't it. I've had the same problem and ended up just declaring >> a cursor and being done with it. >> >> LET p_sql_stmt = "SELECT COUNT(*) FROM v3 WHERE ", p_where_clause >> PREPARE pre_count FROM p_sql_stmt >> DECLARE a_curs CURSOR FOR pre_count >> OPEN a_curs >> FETCH a_curs INTO p_row_cnt >> CLOSE a_curs >> >> Ugly, but functional. >What do you mean ugly? That is exactly what DECLAREing a CURSOR was >designed to do; return values from either a hard-coded SELECT or a PREPAREd >one. The EXECUTE command has never returned values. Sorry, didn't mean to offend any sensibilities. My point is that the EXECUTE syntax is a lot cleaner looking compared to the cursor variety, and where there is no need for a cursor (i.e. single row or values), it would make for a more logical construct. Of course, the difference to the engine is about zero. The reason I had any problem at all, was that I got overexcited when I got the V6.0 tools and EXECUTE was listed in the SQL syntax as having an INTO clause. Good stuff, I thinks. Bzzzztt. Back to the old way. :) Bryan Tonnet batonnet@zeta.org.au