SQL Help, I am trying to store an array in postgre...
# sql
s
SQL Help, I am trying to store an array in postgresql. The accepted insert query looks like this
Copy code
insert into example(arrColumn) values('{1, 2, 3}');
Notice the Curly braces instead of
[1,2,3]
Currently the only way i can do an insert with
cfqueryparam
is to serialize the array and replace the
[]
with
{}
There is a
CF_SQL_ARRAY
cfsqltype, however it does not work complaining that even when passing an actual CF array in or a string, CF complains that it is not an array Is there any better way of doing this?
m
I'm not familiar with postgressql, but it looks like there another way to do arrays:
Copy code
ARRAY [ '(408)-589-5846','(408)-589-5555' ]
Does that work?
s
I did try that way as well, And oddly enough it will work as raw sql. But in a cfqueryparam it actually returns an error asking for it to be formatted with the
{1,2,3}
notation
t
haven't ever dealt with this, so really just spit balling. But what about
{<cfqueryparam cfsqltype="integer" list="true" value=ArrayToList(array)>}
?
s
ill give it a shot
t
That works for
IN ( a list )
. And the syntax looks similar, so it might work for
{ a list }
as well.