[ic] Calling Functions with Row Data as Arguments
kevin at cursor.biz
Sat Jul 5 17:54:21 EDT 2003
Bryan Zera [Bryanz at pollstar.com] wrote:
> I have a Trigger/Function combination for one of my tables, but I want
> to pass a column of data from each row to the function as an argument.
> Is this possible?
> CREATE FUNCTION move_to_users_deleted(int) RETURNS void AS 'insert into
> users_deleted select * from users where key = $1 and premium = \'t\''
> LANGUAGE SQL;
> CREATE TRIGGER move_to_users_deleted before delete on users for each
> row execute procedure move_to_users_deleted([What do I put here?");
Correct me if I'm wrong, but this is not an Interchange-related issue;
You may do whatever you usually do to create a DELETE trigger. For
instance, PL/pgSQL has a DELETE trigger function variable, called 'OLD',
that you would be able to make use of.
You didn't specify PostgreSQL, nor any other SQL server, so I can't
offer a lot of specific help here. You will need to consult your SQL
server's manual and its users' mail list archive, if one exists. A
Google search may also scare up some useful information.
Wouldn't it be better to simply have a 'deleted' column in your 'users'
table? You could set that to true or false, instead of performing
actual DELETEs and INSERTs and relying on triggers to do things for
you behind the scenes.
_/ _/ _/_/_/_/ _/ _/ _/_/_/ _/ _/
_/_/_/ _/_/ _/ _/ _/ _/_/ _/ K e v i n W a l s h
_/ _/ _/ _/ _/ _/ _/ _/_/ kevin at cursor.biz
_/ _/ _/_/_/_/ _/ _/_/_/ _/ _/
More information about the interchange-users