I have a Table that looks something like this:
CREATE TABLE My_Table(
Entry integer PRIMARY KEY DEFAULT nextval('Number'),
TimeInsert timestamp DEFAULT current_timestamp,
Severity ENUM_Severity NOT NULL,
where Number is a SEQUENCE and ENUM_Severity is an ENUM
There are 2 things I want to do.
After an INSERT statement I want to be able to know what was the
'Entry' number I just added. I was thinking on creating an AFTER
trigger returning the new ROW or just the 'Entry'-number but the
documentation on triggers state that the return is ignored on a AFTER
trigger. How can I get this information. (I want to use this in a C
function, using SPI I assume).
I also want to use the ENUM 'ENUM_Severity' in my C functions (using
v1 calling). I want to create a function looking like this:
CREATE FUNCTION add_to_my_table(ENUM_Severity, text) RETURNS integer
AS 'myLibFile', 'add_to_my_table'
and then in the function insert the passed arguments into the table.
How do I handle the ENUM in my function (c function, dynamic library).
What function should I use to get the correct value (PG_GETARG_XXX(0);)?
Then this comes together. I want to call the function to insert the
new row and then return the new number if the user want to look at the
new entry after the function call.
Please help, and if it helps this is my 2nd week using postgreSQL (any
DB for that matter)
This message and attachments are subject to a disclaimer. Please refer
to www.it.up.ac.za/documentation/governance/disclaimer/ for full
details. / Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule
onderhewig. Volledige besonderhede is by
pgsql-novice by date
|Next:||From: A. Kretschmer||Date: 2010-03-29 07:44:14|
|Subject: Re: Return row after a Insert|
|Previous:||From: L. Loewe||Date: 2010-03-29 00:19:04|
|Subject: slow plan on join when adding where clause|