dros
dros

Reputation: 1567

How to pass TEXT Array [ ] to a postgres function?

I have this function which has been translated from oracle to postgres:

CREATE OR REPLACE FUNCTION myblah ( values TEXT[], evalues TEXT[], p_pid bigint, c_id bigint, pr_id bigint, p_name TEXT, p_use text default 'N') 
RETURNS VOID
AS $body$

and I am trying to call this function in order to test. But I am having issue inserting the array parameter, unsure of the syntax and cannot find anything to show me.

for example I am trying this but it is not acceptable syntax:

select myblah (TEXT['hello','whynot','jasmine'], 43423, 434234,534534,'fggffgfg','N');

the error is

ERROR:  syntax error at or near ","
LINE 1: select myblah(TEXT['hello','whynot','jasmin...

however removing the ',' does not work

Upvotes: 1

Views: 364

Answers (2)

Laurenz Albe
Laurenz Albe

Reputation: 248215

As the documentation will tell you, there are two options:

'{string 1,string 2}'

or

ARRAY['string1', 'string 2']

Upvotes: 1

user330315
user330315

Reputation:

You need the array keyword:

select myblah (array['hello','whynot','jasmine'], 43423, 434234,534534,'fggffgfg','N');

Upvotes: 2

Related Questions