From: "M(dot)L(dot)Bowman" <M(dot)L(dot)Bowman(at)ukc(dot)ac(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject:
Date: 2002-01-17 18:59:18
Message-ID: E16RHks-00062v-00@myrtle.ukc.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I am new to postgresql and new to this list so please excuse any
obvious blunders.

I am currently trying to convert an ingres database into a postgres database.
While trying to implement a procedure I have come across the two
following problems.

1.
In Ingres I can check if the ingres superuser is the current userby using

WHERE dbmsinfo('username') = dbmsinfo('dba')

I can't find out how to do the equivalent in postgres. Can anyone help?

The special function
current_user
will give me the current user but I can't find a function to give me
the postgresql superuser (typically 'postgres'). I tried getpgusername()
but it returns the current user.

2.
I want to run 2 procedures from a single trigger. However, I believe
that only one is permitted. Therefore the trigger needs to execute a
procedure which in turn executes the 2 procedures.

When I implement this and then attempt to insert a line into the table
I get the following
psql:ex.junk:91: NOTICE: FUNCTION BOTH - start
psql:ex.junk:91: ERROR: parser: parse error at or near "f_one"

How can I get this to work?


eg.

CREATE FUNCTION f_one()
RETURNS OPAQUE AS
'
DECLARE

BEGIN
RAISE NOTICE ''FUNCTION 1'';

IF TG_OP = ''DELETE'' THEN
RETURN OLD;
ELSE
RETURN NEW; -- for UPDATE and INSERT operations
END IF;
END;
'
LANGUAGE 'plpgsql';


CREATE FUNCTION f_both()
RETURNS OPAQUE AS
'
DECLARE
BEGIN
RAISE NOTICE ''FUNCTION BOTH - start '';

EXECUTE PROCEDURE f_one();
RAISE NOTICE ''FUNCTION BOTH -done'';
IF TG_OP = ''DELETE'' THEN
RETURN OLD;
ELSE
RETURN NEW; -- for UPDATE and INSERT operations
END IF;
END;
'
LANGUAGE 'plpgsql';


CREATE TRIGGER t_personnel_udi
BEFORE INSERT OR UPDATE OR DELETE
ON personnel
FOR EACH ROW
EXECUTE PROCEDURE f_both();

Many Thanks
Maggie

Responses

  • Re: at 2002-01-17 19:36:36 from Frank Bax
  • Re: at 2002-01-17 19:37:47 from Holger Krug

Browse pgsql-general by date

  From Date Subject
Next Message Emmanuel SARACCO 2002-01-17 19:06:02 Re: installing pl/pgsql
Previous Message Johnson, Shaunn 2002-01-17 17:22:01 installing pl/pgsql