How can I call a function from another schema in Postgresql?

Viewed 499

Tell me, how can I call a function from another schema in the trigger of an SQL function? We have Postgresql, the main public schema and the amqp schema, which was formed when pg_amqp was connected. The public schema has a trigger function for tracking INSERT/UPDATE/DELETE in the table:

   if (TG_OP = 'INSERT') then
       INSERT INTO table_1_audit_log (
           table_1_id,
           old_row_data,
           new_row_data,
           dml_type,
           dml_timestamp
       )
       VALUES(
           NEW.id,
           null,
           to_jsonb(NEW),
           'INSERT',
           CURRENT_TIMESTAMP
       );
      
          
       RETURN NEW;
       
   elsif (TG_OP = 'UPDATE') then
       INSERT INTO table_1_audit_log (
           table_1_id,
           old_row_data,
           new_row_data,
           dml_type,
           dml_timestamp
       )
       VALUES(
           NEW.id,
           to_jsonb(OLD),
           to_jsonb(NEW),
           'UPDATE',
           CURRENT_TIMESTAMP
       );
            
       RETURN NEW;
   elsif (TG_OP = 'DELETE') then
       INSERT INTO table_1_audit_log (
           table_1_id,
           old_row_data,
           new_row_data,
           dml_type,
           dml_timestamp
       )
       VALUES(
           OLD.id,
           to_jsonb(OLD),
           null,
           'DELETE',
           CURRENT_TIMESTAMP
       );
       
       RETURN OLD;
   end if;
    
END;

I want to call the amqp.publish function from the amqp schema in this function:

SELECT amqp.publish(1, '', 'queu', 'messange')

But it gives me an error:

ERROR: function amqp.publish(integer, unknown, unknown, unknown) does not exist
1 Answers

It was necessary to set the types forcibly:

SELECT amqp.publish(1, ''::varchar, 'queu'::varchar, 'messange'::varchar)
Related