Why must the function that a trigger calls return "opaque" ???

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

Why must the function that a trigger calls return "opaque" ???

От:
"Greg Patnude" <GPatnude@adelphia.net>
Дата:
This seem rather limiting...  Suppose I want a trigger that after insert,
returns the currval(sequence) of the newly inserted row automatically
without having to run another query ???

GP




Re: Why must the function that a trigger calls return "opaque" ???

От:
Josh Berkus <josh@agliodbs.com>
Дата:
Greg,

> This seem rather limiting...  Suppose I want a trigger that after insert,
> returns the currval(sequence) of the newly inserted row automatically
> without having to run another query ???

Because you can't capture the return value of a trigger.  The trigger is 
returning the new/altered/deleted row.

If you want a function to return a value, don't use a trigger.

-- 
-Josh Berkus
 Aglio Database Solutions
 San Francisco

Re: [GENERAL] Why must the function that a trigger calls return

От:
Darren Ferguson <darren@crystalballinc.com>
Дата:
What would the trigger return the value too. You did not call the trigger 
the system called the trigger. Also triggers are not meant for use in this 
way they are meant for data manipulation before or after a table is 
inserted,updated or deleted.

You would have to run select currval('seq_name') as the next query.

On Thu, 29 Aug 2002, Greg Patnude wrote:

> This seem rather limiting...  Suppose I want a trigger that after insert,
> returns the currval(sequence) of the newly inserted row automatically
> without having to run another query ???
> 
> GP
> 
> 
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> 

-- 
Darren Ferguson

FAQ