Alex Rivera | Logout

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

Asked 2011-10-14T15:57:20.130
17

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.

Edit
Report

1 Answer

20

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?

answered 2011-10-14T16:06:37.130

Your Answer