Hi all,
Quick question - I'm writing a program that uses the ODBC API to bulk load
data into SQL Server. I have nailed the Bulk Insert, no problems. Now I
need to use Update By Bookmark, but am having trouble. Does anyone know
where I can find ODBC Update By Bookmark samples? The SQL BulkOperations
sample application on MSDN is inadequate, incomplete and buggy.
ThanksNever mind, figured it out, works great.
"Michael C" wrote:
> Hi all,
> Quick question - I'm writing a program that uses the ODBC API to bulk load
> data into SQL Server. I have nailed the Bulk Insert, no problems. Now I
> need to use Update By Bookmark, but am having trouble. Does anyone know
> where I can find ODBC Update By Bookmark samples? The SQL BulkOperations
> sample application on MSDN is inadequate, incomplete and buggy.
> Thanks
Showing posts with label insert. Show all posts
Showing posts with label insert. Show all posts
Monday, March 19, 2012
Monday, March 12, 2012
odbc - start transaction - open query - new process
I try to do:
- open transaction
- open cursor nr 1
- open cursor nr 2
- insert
- commit
for cursor nr 2 and for insert new connection establishes
When next time I try to do the same I gen dead lock
What for is this new connection (what should I do - it makes probles)
Any suggestions?I'm not sure, just guessing (not too great with cursors)
are you closing your cursors?|||I close them but after insert
When I close cursor befour open next curosr or insert there is no problem. It happens only during transaction
Thx for replay
- open transaction
- open cursor nr 1
- open cursor nr 2
- insert
- commit
for cursor nr 2 and for insert new connection establishes
When next time I try to do the same I gen dead lock
What for is this new connection (what should I do - it makes probles)
Any suggestions?I'm not sure, just guessing (not too great with cursors)
are you closing your cursors?|||I close them but after insert
When I close cursor befour open next curosr or insert there is no problem. It happens only during transaction
Thx for replay
Labels:
commitfor,
connection,
cursor,
database,
do-,
establishes,
insert,
insert-,
microsoft,
mysql,
odbc,
oracle,
process,
query,
server,
sql,
transaction,
transaction-
Friday, February 24, 2012
Obtain a list of all rows insert via a select statement
With Table A being the parent table and having an identity column as the
primary key.
With Table B being a child of table A
I need to do an insert based on a select statement (multiple row returned)
in Table A. Then I need to insert multiple child rows in Table B for every
row inserted in Table A.
What is the best strategy? Is there a way to have a list of all the rows
inserted?
I'm open to any suggestion.
Thank you in advance
MartinYou can access those within a trigger, and have it populate a temp table
that the calling batch created, if such a temp table exists, e.g.,
create table t(k int not null identity primary key, d varchar(10));
go
create trigger trg_i_t on t for insert
as
if object_id('tempdb..#t') is not null
insert into #t select k from inserted;
go
-- test
create table #t(k int);
insert into t(d)
select 'a'
union all select 'b'
union all select 'c';
select * from #t;
drop table #t;
-- Output:
k
--
4
5
6
In SQL Server 2005 it will be much easier with the DML with results
enhancements.
Cheers,
--
BG, SQL Server MVP
www.SolidQualityLearning.com
"Martin Rajotte" <MartinRajotte@.discussions.microsoft.com> wrote in message
news:35F4A835-AC48-4896-B535-B550A768CF74@.microsoft.com...
> With Table A being the parent table and having an identity column as the
> primary key.
> With Table B being a child of table A
> I need to do an insert based on a select statement (multiple row returned)
> in Table A. Then I need to insert multiple child rows in Table B for every
> row inserted in Table A.
> What is the best strategy? Is there a way to have a list of all the rows
> inserted?
> I'm open to any suggestion.
> Thank you in advance
> Martin|||On Tue, 22 Mar 2005 15:51:02 -0800, Martin Rajotte wrote:
>With Table A being the parent table and having an identity column as the
>primary key.
>With Table B being a child of table A
>I need to do an insert based on a select statement (multiple row returned)
>in Table A. Then I need to insert multiple child rows in Table B for every
>row inserted in Table A.
>What is the best strategy? Is there a way to have a list of all the rows
>inserted?
>I'm open to any suggestion.
>Thank you in advance
>Martin
Hi Martin,
I'm not entirely sure if I understand you. Do you mean that you have
some data in one or more tables that needs to be inserted in two new
tables, where the second table links to the identity column of the
first?
The proper way to find the identity value of inserted rows after a
multirow insert is to query the table with the natural key as search
argument. That should return you the identity values.
If you need more specific advise, then please code DDL, sample data and
desired results. Check out www.aspfaq.com/5006.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
primary key.
With Table B being a child of table A
I need to do an insert based on a select statement (multiple row returned)
in Table A. Then I need to insert multiple child rows in Table B for every
row inserted in Table A.
What is the best strategy? Is there a way to have a list of all the rows
inserted?
I'm open to any suggestion.
Thank you in advance
MartinYou can access those within a trigger, and have it populate a temp table
that the calling batch created, if such a temp table exists, e.g.,
create table t(k int not null identity primary key, d varchar(10));
go
create trigger trg_i_t on t for insert
as
if object_id('tempdb..#t') is not null
insert into #t select k from inserted;
go
-- test
create table #t(k int);
insert into t(d)
select 'a'
union all select 'b'
union all select 'c';
select * from #t;
drop table #t;
-- Output:
k
--
4
5
6
In SQL Server 2005 it will be much easier with the DML with results
enhancements.
Cheers,
--
BG, SQL Server MVP
www.SolidQualityLearning.com
"Martin Rajotte" <MartinRajotte@.discussions.microsoft.com> wrote in message
news:35F4A835-AC48-4896-B535-B550A768CF74@.microsoft.com...
> With Table A being the parent table and having an identity column as the
> primary key.
> With Table B being a child of table A
> I need to do an insert based on a select statement (multiple row returned)
> in Table A. Then I need to insert multiple child rows in Table B for every
> row inserted in Table A.
> What is the best strategy? Is there a way to have a list of all the rows
> inserted?
> I'm open to any suggestion.
> Thank you in advance
> Martin|||On Tue, 22 Mar 2005 15:51:02 -0800, Martin Rajotte wrote:
>With Table A being the parent table and having an identity column as the
>primary key.
>With Table B being a child of table A
>I need to do an insert based on a select statement (multiple row returned)
>in Table A. Then I need to insert multiple child rows in Table B for every
>row inserted in Table A.
>What is the best strategy? Is there a way to have a list of all the rows
>inserted?
>I'm open to any suggestion.
>Thank you in advance
>Martin
Hi Martin,
I'm not entirely sure if I understand you. Do you mean that you have
some data in one or more tables that needs to be inserted in two new
tables, where the second table links to the identity column of the
first?
The proper way to find the identity value of inserted rows after a
multirow insert is to query the table with the natural key as search
argument. That should return you the identity values.
If you need more specific advise, then please code DDL, sample data and
desired results. Check out www.aspfaq.com/5006.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
Subscribe to:
Posts (Atom)