-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[EMAIL PROTECTED] wrote:

| Gaetano Mendola <[EMAIL PROTECTED]> wrote ..
|
|>Hi all,
|>do you know any clean workaround at ill-planned queries inside a stored
|>procedure?
| I use "EXECUTE" inside a stored procedure for just this purpose. This is
| not the same as PREPARE/EXECUTE, it lets you send an arbitrary string as
| SQL within the procedure. You have to write the query text on the fly in
| the procedure, which can be a little messy with quoting and escaping.
|

Yes I knew, I wrote "clean workaround" :-)

I hate write in function piece of code like this:

~   [...]

~   my_stm := ''SELECT '' || my_operation || ''( '' || a_id_transaction;
~   my_stm := my_stm || '', '' || a_id_contract;
~   my_stm := my_stm || '', '' || quote_literal(a_date) || '') AS res'';

~   FOR my_record IN EXECUTE my_stm LOOP
~      IF my_record.res < 0 THEN
~         RETURN my_record.res;
~      END IF;

~      EXIT;
~   END LOOP;

~   [...]

note also that useless loop that is needed to retrieve the value!



Regards
Gaetano Mendola












-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBMLRE7UpzwH2SGd4RAv0TAJ9+IokZjaXIhgV5dOH86FCvzSnewQCgwqxD
nuW9joHmPxOnlRWrvhsKaag=
=Axb7
-----END PGP SIGNATURE-----


---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Reply via email to