 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Matthew Pascoe Guest
|
Posted: Wed Mar 16, 2005 9:29 am Post subject: Passing a dataset to a stored procedure |
|
|
I would like to be able to pass all the records in a delphi memory table
into a sql server 2000 stored procedure so that be added to the database in
a batch.
Is there anyway to do this without calling the stored procedure once for
every record in the dataset?
Thanks for any advice.
Matthew Pascoe
|
|
| Back to top |
|
 |
Martijn Tonies Guest
|
Posted: Wed Mar 16, 2005 1:31 pm Post subject: Re: Passing a dataset to a stored procedure |
|
|
| Quote: | I would like to be able to pass all the records in a delphi memory table
into a sql server 2000 stored procedure so that be added to the database
in
a batch.
Is there anyway to do this without calling the stored procedure once for
every record in the dataset?
|
As a "Delphi memory table" has nothing to do with a
"Microsoft SQL Server stored procedure", how do you
expect to do this?
--
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server
Upscene Productions
http://www.upscene.com
|
|
| Back to top |
|
 |
Patrick Guest
|
Posted: Wed Mar 16, 2005 1:51 pm Post subject: Re: Passing a dataset to a stored procedure |
|
|
| Quote: | Is there anyway to do this without calling the stored procedure once for
every record in the dataset?
Not really. There are only a couple of ways to get large blocks of data into |
MS-SQL via stored procedures:
BCP (bulk copy) or BULK INSERT
OPENROWSET or OPENDATASOURCE
|
|
| Back to top |
|
 |
Bill Todd Guest
|
Posted: Wed Mar 16, 2005 3:07 pm Post subject: Re: Passing a dataset to a stored procedure |
|
|
Insert the records into a temporary table.
--
Bill Todd (TeamB)
TeamB cannot answer questions received via email
|
|
| Back to top |
|
 |
Matthew Pascoe Guest
|
Posted: Wed Mar 16, 2005 8:05 pm Post subject: Re: Passing a dataset to a stored procedure |
|
|
If I knew the answer, I wouldn't hve posted the question
Thanks & Regards,
Matthew
"Martijn Tonies" <m.tonies (AT) upscene (DOT) removethis.nospam.com> wrote
| Quote: |
I would like to be able to pass all the records in a delphi memory table
into a sql server 2000 stored procedure so that be added to the database
in
a batch.
Is there anyway to do this without calling the stored procedure once for
every record in the dataset?
As a "Delphi memory table" has nothing to do with a
"Microsoft SQL Server stored procedure", how do you
expect to do this?
--
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS
SQL
Server
Upscene Productions
http://www.upscene.com
|
|
|
| Back to top |
|
 |
Martijn Tonies Guest
|
Posted: Thu Mar 17, 2005 7:02 am Post subject: Re: Passing a dataset to a stored procedure |
|
|
| Quote: | If I knew the answer, I wouldn't hve posted the question
|
Well, a Delphi memory dataset is a typical delphi structure.
Either call the procedure once for each record or copy the
structure in some SQL Server structure that can be reached
from the procedure.
Either way, you cannot do it directly.
--
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server
Upscene Productions
http://www.upscene.com
| Quote: | Thanks & Regards,
Matthew
"Martijn Tonies" <m.tonies (AT) upscene (DOT) removethis.nospam.com> wrote in message
news:423834fd$1 (AT) newsgroups (DOT) borland.com...
I would like to be able to pass all the records in a delphi memory
table
into a sql server 2000 stored procedure so that be added to the
database
in
a batch.
Is there anyway to do this without calling the stored procedure once
for
every record in the dataset?
As a "Delphi memory table" has nothing to do with a
"Microsoft SQL Server stored procedure", how do you
expect to do this?
--
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS
SQL
Server
Upscene Productions
http://www.upscene.com
|
|
|
| Back to top |
|
 |
Tomislav Kardaš Guest
|
Posted: Sun Mar 20, 2005 6:40 pm Post subject: Re: Passing a dataset to a stored procedure |
|
|
Hi Matthew!
On Wed, 16 Mar 2005 20:29:31 +1100, "Matthew Pascoe"
<mpascoe (AT) stocklogix (DOT) com.au> wrote:
| Quote: | I would like to be able to pass all the records in a delphi memory table
into a sql server 2000 stored procedure so that be added to the database in
a batch.
Is there anyway to do this without calling the stored procedure once for
every record in the dataset?
|
You may put your records into XML string and pass it into stored
procedure as text parameter. SQL server can open cursor on data from
XML source.
search for OPENXML in "books on line".
here is the first example that shows the idea:
DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc ='
<ROOT>
<Customer CustomerID="VINET" ContactName="Paul Henriot">
<Order CustomerID="VINET" EmployeeID="5"
OrderDate="1996-07-04T00:00:00">
<OrderDetail OrderID="10248" ProductID="11" Quantity="12"/>
<OrderDetail OrderID="10248" ProductID="42" Quantity="10"/>
</Order>
</Customer>
<Customer CustomerID="LILAS" ContactName="Carlos Gonzlez">
<Order CustomerID="LILAS" EmployeeID="3"
OrderDate="1996-08-16T00:00:00">
<OrderDetail OrderID="10283" ProductID="72" Quantity="3"/>
</Order>
</Customer>
</ROOT>'
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
-- Execute a SELECT statement that uses the OPENXML rowset provider.
SELECT *
FROM OPENXML (@idoc, '/ROOT/Customer',1)
WITH (CustomerID varchar(10),
ContactName varchar(20))
Here is the result set:
CustomerID ContactName
---------- --------------------
VINET Paul Henriot
LILAS Carlos Gonzlez
tomi.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|