Michiel,
> And this function:
> CREATE FUNCTION add_cust() RETURNS INT4 AS ' -- SERIAL data type is really
> an INT4 (and some more).
> BEGIN
> RETURN NEW.my_key;
> END;
> ' LANGUAGE 'plpgsql';
>
> CREATE TRIGGER add_cust BEFORE INSERT ON mytable
> FOR EACH ROW EXECUTE PROCEDURE ad
To those who pointed at the SELECT currval , thanks!, I think
this is what I need instead of a trigger. So the real problem is solved I
think. However I am quite curious about the plpgsql thing, I think I may
need to use it, or may WANT to use it (performance wise... better to be as
close as po
Michiel,
> Maybe this should be sent to novice... I was not certain, but if it
> should, please tell me so.
No need to apologise. Novice would have been appropriate, but SQL is
OK too.
> When I do an 'INSERT INTO VALUES '
> and on the table is a serial primary key named p_key.
> As I want thi
On Wednesday 20 November 2002 10:48, Henshall, Stuart - Design & Print wrote:
> Michiel Lange wrote:
> Trigger functions can only return type OPAQUE which isn't seen by the
> client program.
I just saw that in 7.3 the return type for triggers has changed to TRIGGER.
HTH
Johannes Lochmann
--
Title: RE: [SQL] trying to learn plpqsql... so please forgive..
Michiel Lange wrote:
> Maybe this should be sent to novice... I was not certain, but if it
> should, please tell me so.
>
> The matter at hand is this:
>
> When I do an 'INSERT INTO VALUES '
&g
When I do an 'INSERT INTO VALUES '
and on the table is a serial primary key named p_key.
As I want this number to be auto-generated, but use it as a 'customer
number', I want to create this function to return the value of this
insert.
Try this:
SELECT currval();
Luis Sousa
smime.p7s
De