Обсуждение: Trigger using function written in PL/PGSQL returns "Unrecognized language specified"
I am writing my first trigger & function.
First question:
---------------
I can't get psql to take the function declaration.
ds=# > CREATE FUNCTION trigger_insert_update_copay()
ds-# RETURNS opaque
ds-# RETURNS opaque AS 'BEGIN
ds'# new.copay = (new.allowable * new.percent);
ds'# RETURN new;
ds'# END;'
ds-# LANGUAGE 'plpgsql'
ds-# Error: ERROR: Unrecognized language specified in a CREATE FUNCTION:
'plpgsql'. Recognized languages are sql, C, internal and the created
procedural languages.
Here is my function:
CREATE FUNCTION trigger_insert_update_copay()
RETURNS opaque -- should this be NUMERIC(??) or FLOAT4?
AS 'BEGIN
new.copay = (new.allowable * new.percent);
RETURN new;
END;'
LANGUAGE 'plpgsql';
Here is my Trigger:
CREATE TRIGGER trigger_copay
BEFORE INSERT
ON coverage
FOR EACH ROW
EXECUTE PROCEDURE trigger_insert_update_copay();
Second question:
----------------
It is supposed to multiply the 'allowable' and 'percent' field and leave
the result in 'copay'. Is
new.copay = (new.allowable * new.percent);
RETURN new;
The correct code to do that?
FYI:
[root@ds /root]# rpm -q -a | grep post
postgresql-devel-7.0.3-2
postgresql-jdbc-7.0.3-2
postgresql-tcl-7.0.3-2
postgresql-tk-7.0.3-2
postgresql-7.0.3-2
postgresql-odbc-7.0.3-2
postgresql-perl-7.0.3-2
postgresql-python-7.0.3-2
postgresql-server-7.0.3-2
postgresql-test-7.0.3-2
[root@ds /root]#
Dan Browning, Cyclone Computer Systems, danb@cyclonecomputers.com
Hi folks My installation of phpPgAdmin has suddenly stopped working. I am not very experienced in this area and have run out of ideas. Any pointers would be much appreciated. THE SYMPTOMS: - To summarise, I get all the forms primed with the initial data from the default DB, but it won't run any queries via links or fields. - Either nothing happens, I get a duplicate LH pane, or I get an error. For example if I click on "select" I get the message: Warning: PostgreSQL query failed: ERROR: Relation '' does not exist in /www/htdocs/phpPgAdmin/tbl_select.php on line 12 PostgreSQL said: ERROR: Relation '' does not exist Your query: SELECT * FROM "" LIMIT 1 WHAT I HAVE CHECKED - I am logging on as the SU who owns all the databases - PHP/Postgres is working fine - I can access the databases via psql and PHP scripts without problems. - I re-intalled phpPgAdmin from scratch. So, advice would be very welcome - it's a great app and I am missing it! Geoff Caplan Caplan Associates PS I did post this to the phpPgAdmin specialist list but without reply. Sorry for the cross posting, but I am very keen to get this fixed.