Обсуждение: Stored Functions

Поиск
Список
Период
Сортировка

Stored Functions

От
"Yolanda Phillips"
Дата:
Good day,

Thanks to Barry Lind's response, I am now able to successfully use stored
functions with JDBC.

However, I've searched the archives and the doc's, but unable to find a
solution to the following:

I'm wanting to do an insert, then if it was successfull the function should
return the id. This id is using a sequence.nextval(). How do I return the
new id?

Help in the right direction will be appreciated.


Sincerely,


Yolanda Phillips
Web Applications Developer


Re: Stored Functions

От
Anders Hermansen
Дата:
* Yolanda Phillips (yphillips@dlkconsulting.co.za) wrote:
> I'm wanting to do an insert, then if it was successfull the function should
> return the id. This id is using a sequence.nextval(). How do I return the
> new id?

After the insert statement, run a new statement:
SELECT curval('sequencename')

This statement will return the id.


Hope this helps,
Anders

--
Anders Hermansen
YoYo Mobile as

Re: Stored Functions

От
Dave Cramer
Дата:
You need to call curval('sequencename') to get the last id

Dave
On Fri, 2003-08-29 at 04:29, Yolanda Phillips wrote:
> Good day,
>
> Thanks to Barry Lind's response, I am now able to successfully use stored
> functions with JDBC.
>
> However, I've searched the archives and the doc's, but unable to find a
> solution to the following:
>
> I'm wanting to do an insert, then if it was successfull the function should
> return the id. This id is using a sequence.nextval(). How do I return the
> new id?
>
> Help in the right direction will be appreciated.
>
>
> Sincerely,
>
>
> Yolanda Phillips
> Web Applications Developer
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
--
Dave Cramer <Dave@micro-automation.net>