Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax to call a PostgreSQL function that contains an array among its arguments

I am testing some PostgreSQL functions that I did not write, one of which is defined like:

email_maker_for_new_work_order(integer, character varying, integer[]);

I'm trying to call it like:

select email_maker_for_new_work_order(13987,"TEST_CeeLoGreen",['231822','267657','268399','270125','270127','270470','271320'])

But I get the error:

ERROR:  syntax error at or near "["
LINE 1: ..._maker_for_new_work_order(13987,"TEST_CeeLoGreen",['231822',...
                                                             ^


********** Error **********

ERROR: syntax error at or near "["
SQL state: 42601
Character: 63

I've tried without the single-quotes around the integer array. However, I get essentially the same error at the same location.

Any help would be appreciated. Thanks.

like image 871
Jon Mitten Avatar asked Oct 14 '11 15:10

Jon Mitten


1 Answers

The syntax is

array[1,2,3]

and note, that the arguments are not strings as in '42' but plain integers like 42.

By the way: The part "TEST_CeeLoGreen" is interpreted as a column name, not as a plain string. Is that intended?

like image 130
A.H. Avatar answered Sep 27 '22 20:09

A.H.