Poco Data Odbc insert into table with identity column

A general discussion forum.
unknown
Posts: 3
Joined: 12 Sep 2012, 12:23

Poco Data Odbc insert into table with identity column

Postby unknown » 12 Sep 2012, 13:22

Hi, I use SQL Server 2008 R2, poco-1.4.3 and try to insert into table with identity filed.
definitioan of the table:
create table name_list
(
id int identity(1,1),
name varchar(200)
)
code:
Poco::Tuple<int, string> t = Poco::Tuple<int, string>(1, "Mike");
vector<Poco::Tuple<int, string>> data= vector<Poco::Tuple<int, string>>();
data.push_back(t);
statement << insert into name_list values (?, ?), use(data), now
I recieve StatementException:
SQLParamData()
Requested SQL statement: insert into name_list values (?, ?)
Native SQL statement: insert into name_list values (?, ?)

If table does not have identity column, it is work fine.
I have to do something like that(T-Sql):
insert into name_list(name) values("Mike");
But all my attempts were failed with column not found exception.
Last edited by unknown on 12 Sep 2012, 16:59, edited 1 time in total.

alex
Posts: 1278
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Poco Data Odbc insert into table with identity column

Postby alex » 12 Sep 2012, 16:34

See Understanding Identity Columns. Also, keep in mind that Poco::Data is a generic interface and as such implements a common denominator of various DBMS systems. Particular database specifics often make more sense to be dealt with on the DBMS side.

unknown
Posts: 3
Joined: 12 Sep 2012, 12:23

Re: Poco Data Odbc insert into table with identity column

Postby unknown » 12 Sep 2012, 17:58

Alex, Thanks for your reply. :)
I have an idea how to work around the problem using "IDENTITY_INSERT" settings and so on.
But as i know in various DBMS systems we have an opportunity to define default values
for table column. And in my case when i want to insert into such table i have to do extra and duplicate work
for defining this values on app side. Also I would have problems if the table definition is changed.
Of course we can create DDL trigger, but it extra work again. It is sure thing to determine only values
which i know. And my question is: Can i use POCO library for such insert?
t-sql:
insert into name_list(name) values("Alex");
See name_list definition in my first post.

unknown
Posts: 3
Joined: 12 Sep 2012, 12:23

Re: Poco Data Odbc insert into table with identity column

Postby unknown » 13 Sep 2012, 06:59

I accepted this solution in separate thread:
1. Insert data into files on the disk.
2. Run stored procedure that performs bulk insert into database.
3. Delete files if bulk insert successful.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest

cron