Search Postgresql Archives

Re: Capturing return value of a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jul 16, 2007, at 15:55 , Jasbinder Singh Bali wrote:

I was wondering what would the function return if insert fails.
I want it to return 'success' upon a successful insert and 'failure' if
insert fails.

Depends on what you mean by "failed". Do you mean an error was raised? Then you'll just get a normal error message. To catch this, check the error trapping section of the PL/pgSQL documentation.

Do you mean nothing was inserted? If so, you won't catch this in your above code. You can check the FOUND special variable after the INSERT to see if anything was inserted and set your result message based on that.

Would the following implementation work for that?

No. BEGIN/END blocks in PL/pgSQL are not equivalent to SQL BEGIN/ COMMIT transactions.


Michael Glaesemann
grzm seespotcode net




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux