How to pass string array parameter to a postgresql storedprocedure?

hello guys,

i have to pass an array of strings to a storedprocedure
but, every time i received this msg

"code": 0,
"file": "/var/www/html/dmxConnectLib/lib/db/Connection.php",
"line": 141,
"message": "Array to string conversion",

my array is a simple amail list like this

[ "blablabla@dominio","blablabla2@dominio2" ]

and sp have this header

FUNCTION bb.emailcanal_import(p_cli_id integer, p_canal_id integer, p_email character varying, p_flush integer)

where p_email is a character varying prepared to receive my array

I tried several ways

the last one was like this
api_filename.data.contatos.flatten('email') as :P1

inline it was like this
select * from bb.emailcanal_import(10,35935,array[:P1],1)

these other values ​​are just for testing
I tried with and without the array

any idea on how to do this data transfer?

but doesnot work

To convert an array to a string you can use the join formatter, generally it's joined by a comma ,

But I don't know anything about stored procedures, is the stored procedure expecting a comma-separated string?

1 Like

hi guys
i think i found something

using this call with double quotes, as a reading of a json is generated within wappler, this error occurs


column does not exists

and the same error happens if I point to a function that doesn't even exist inside my postgre

It seems that wappler doesn't even really reach the function

but if I change it to single quotes

now he actually got to the function, or at least tried to get there, he understood the parameters

putting the correct name of the function back in everything works

Any idea how to solve this?
thanks

@George @Teodor @patrick

hi guys
any news about this ?

@George @Teodor @patrick

I don't believe that is a valid way to pass the array value in postgres.

Convert the array first to a string by joining the values like:

api_filename.data.contatos.join(",")

Change the SQL to:

select * from bb.emailcanal_import(10, 35935, string_to_array(:P1, ','), 1)

hi patrick,
i'll try it next week and return, thanks