问题
I have a linux command that i want to run in following function:
CREATE FUNCTION tarifador_func2() RETURNS TRIGGER
LANGUAGE plsh
AS $$
#!/bin/sh
SET userid[] = // here i want to run linux command and use that return value to insert into below table
for loop with i index
INSERT INTO public.act_id_priv_mapping(id_, priv_id_, user_id_, group_id_) VALUES (auuid,new.priv_id_,userid[i],new.group_id_);
$$;
I have following values return by command with new line:
ankit
ankit1
Can anyone help me to complete my function. Thanks
回答1:
You should solve this problem differently.
Use COPY ... FROM PROGRAM
to execute the shell command and populate a (temporary?) table with the result.
来源:https://stackoverflow.com/questions/61071706/running-system-command-in-postgres-and-use-return-value-in-insert