BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Stored Procedure passing Array / comma seperated values

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Jeremy Collins
Guest





PostPosted: Thu May 20, 2004 12:30 pm    Post subject: Re: Stored Procedure passing Array / comma seperated values Reply with quote



Aji wrote:


Quote:
I have one question. I am using SQLServer 2000 and Delphi 7 - dbexpress.
My requirement is to pass an array of IDs to a stored procedure. Since we
cant use array as parameter, I used comma seperated values. This works
ok, if the input to stored procedure is within a particular limit. But
when the list of values increases, it seems the input value gets
truncated when it reaches the stored proc.

How do you build the list of IDs in the first place? Is
it possible to construct a query to build the list?


--
jc

Remove the -not from email

Back to top
Dennis Passmore
Guest





PostPosted: Thu May 20, 2004 12:36 pm    Post subject: Re: Stored Procedure passing Array / comma seperated values Reply with quote



Use a secondary work table and pre-populate it before calling the stored procedure and
then in the stored procedure JOIN to it just like any other table. It will be more
maintainable and run faster since SQL server does not like IN lists in select statements.


Dennis Passmore
Ultimate Software, Inc.
Back to top
alex
Guest





PostPosted: Thu May 20, 2004 1:58 pm    Post subject: Re: Stored Procedure passing Array / comma seperated values Reply with quote



Maybe it will be more efficient to populate temp table ?


<Dennis Passmore> wrote

Quote:
Use a secondary work table and pre-populate it before calling the stored
procedure and
then in the stored procedure JOIN to it just like any other table. It will
be more
maintainable and run faster since SQL server does not like IN lists in
select statements.


Dennis Passmore
Ultimate Software, Inc.



Back to top
Aji
Guest





PostPosted: Thu May 20, 2004 2:00 pm    Post subject: Stored Procedure passing Array / comma seperated values Reply with quote

Hi all,

I have one question. I am using SQLServer 2000 and Delphi 7 - dbexpress.
My requirement is to pass an array of IDs to a stored procedure. Since we
cant use array as parameter, I used comma seperated values. This works
ok, if the input to stored procedure is within a particular limit. But
when the list of values increases, it seems the input value gets
truncated when it reaches the stored proc. The list of comma seperated
values is defined as varchar and has size of 8000. Any suggestions on how
we can solve this prob ?

Another related ques, Can I use XML to pass the values to stored proc ?
If so, how can I use this from Delphi ?

Thanks & Best Regards
Ajith

Ajith

--- posted by geoForum on http://delphi.newswhat.com
Back to top
Del Murray
Guest





PostPosted: Thu May 20, 2004 2:38 pm    Post subject: Re: Stored Procedure passing Array / comma seperated values Reply with quote

Yes , much more efficient. Once you use that "in" list, then sql server
hasn't much chance of optimizing the query


Back to top
Aji
Guest





PostPosted: Thu May 20, 2004 2:39 pm    Post subject: Re: Stored Procedure passing Array / comma seperated values Reply with quote

Quote:
How do you build the list of IDs in the first place? Is
it possible to construct a query to build the list?


I have some objects in a list, which have property ID. From this, I make
comma seperated IDs(just string concatenation).

Nop, it is not possible to use a query to build the list.

Ajith

--- posted by geoForum on http://delphi.newswhat.com

Back to top
Aji
Guest





PostPosted: Fri May 21, 2004 7:58 am    Post subject: Re: Stored Procedure passing Array / comma seperated values Reply with quote

Quote:
Yes , much more efficient. Once you use that "in" list, then sql server
hasn't much chance of optimizing the query



Thanks for ur suggestions.

In the method suggested, I have to populate the IDs one by one to the
temp table and then use the same in stored proc. Once my usage is
finished, I can delete the temp table. Did I get it right ?

In oracle we had something like Array DML, were we could send many
records in a go, which speeds up the process. Does SQL server has
something similar ?

Another question is regarding the usage of XML. Can we write the data in
an xml format, pass the same to SQL Server. Use OpenXML to access the
data from XML doc. Here also do I have to pass the xml value as string ?

Ajith

--- posted by geoForum on http://delphi.newswhat.com

Back to top
Ray Carpenter
Guest





PostPosted: Thu Jul 29, 2004 5:44 pm    Post subject: Re: Stored Procedure passing Array / comma separated values Reply with quote

When using a temporary work table in MS SQL Server you will need to give it
a connection-specific name if there is any possibility that other
connections are doing the same thing at the same time. You could, for
example, append @@SPID to the fixed name of the table to obtain a
connection-specific name.

Regards

Ray Carpenter


<Dennis Passmore> wrote

Quote:
Use a secondary work table and pre-populate it before calling the stored
procedure and
then in the stored procedure JOIN to it just like any other table. It will
be more
maintainable and run faster since SQL server does not like IN lists in
select statements.


Dennis Passmore
Ultimate Software, Inc.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.