I can't figure out how to populate an array into my statement, I have googled and searched this forum with no results.
example: "insert into mytable(someArray) values (:myArray);" //myArray is integer[10]
qry->ParamByName("myArray")->Value = ?????
I've tried various ways of setting this and get different errors each time. Help! Thanks!
How to set array parameter in sql statement?
-
- Posts: 4
- Joined: Wed 24 Jul 2013 16:17
-
- Devart Team
- Posts: 271
- Joined: Wed 23 Jan 2013 11:21
Re: How to set array parameter in sql statement?
Hello.
Devart dbExpress Driver for PostgreSQL doesn't support arrays. As a workaround, you can use the following approaches:
1) If you save data to fields with array types (e.g., integer[]), you can list all the elements directly in the SQL query text, for example:You can read more about using PostgreSQL server array types at http://www.postgresql.org/docs/9.1/static/arrays.html
2) If you save data to bytea fields, you can copy data from the array to TMemoryStream, and then load the data to a parameter using the TParam.LoadFromStream method.
Devart dbExpress Driver for PostgreSQL doesn't support arrays. As a workaround, you can use the following approaches:
1) If you save data to fields with array types (e.g., integer[]), you can list all the elements directly in the SQL query text, for example:
Code: Select all
insert into mytable(someArray) values (ARRAY[42, 2, 3, 5, 7, 42]);
2) If you save data to bytea fields, you can copy data from the array to TMemoryStream, and then load the data to a parameter using the TParam.LoadFromStream method.