I'm having a hard time creating a function in Postgres
running a shell
Linux command, with one detail: function
Trigger after insert
and I need to use some columns of NEW
.
In Mysql
, using plugin
"MySQL UDF" was very simple, trigger
looked like this:
BEGIN
DECLARE result int(10);
SET result = sys_exec
(
'/usr/bin/php /var/www/html/.../regras.php
NEW.uniqueid NEW.linkedid NEW.eventtype'
);
END
Now in PostgreSQL
, I installed language PL/sh
, which makes it possible to execute any script sh
, so I tried the following function
:
CREATE FUNCTION tarifador_func2() RETURNS TRIGGER
LANGUAGE plsh
AS $$
#!/bin/sh
/usr/bin/php /var/www/html/...regras.php
NEW.uniqueid NEW.linkedid NEW.eventtype
$$;
It even runs the php
file, the problem is that this language does not recognize the NEW
nomenclature, so the values in the args
that I get are exactly the ones I pass in the parameter. >
Does anyone know how to use NEW
in PL/sh
?
Another solution would be to manually pass the three values I need per argument in the creation of Trigger
and in function
I would use $1
, $2
and $3
.
Is this possible in any way?