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 

Using parameters question

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop)
View previous topic :: View next topic  
Author Message
Hershcu Sorin
Guest





PostPosted: Sun Apr 10, 2005 12:55 pm    Post subject: Using parameters question Reply with quote



Hi
I'm using D7 with Paradox and I have a Query that use parameters
on the WHERE clauses.
During the runtime the parameter value change and that change the query
result.
Sometimes the parameter can be empty without any value and on this case
I'll like the query to ignore the parameter.
Can that be done and how?
Thanks Sorin


Back to top
Ron
Guest





PostPosted: Sun Apr 10, 2005 2:08 pm    Post subject: Re: Using parameters question Reply with quote



Can you change the sql text for the query in your run time code? So, you
would have a different SQL text for each possible condition, and then set
the query to have that selected version of SQL text.
HTH
Ron.

"Hershcu Sorin" <sorinh (AT) zahav (DOT) net.il> wrote

Quote:
Hi
I'm using D7 with Paradox and I have a Query that use parameters
on the WHERE clauses.
During the runtime the parameter value change and that change the query
result.
Sometimes the parameter can be empty without any value and on this case
I'll like the query to ignore the parameter.
Can that be done and how?
Thanks Sorin





Back to top
Bill Todd
Guest





PostPosted: Sun Apr 10, 2005 3:42 pm    Post subject: Re: Using parameters question Reply with quote



No. You will have to remove the WHERE clause.

--
Bill Todd (TeamB)
TeamB cannot answer questions received via email

Hershcu Sorin wrote:

Quote:
Can that be done and how?

Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Mon Apr 11, 2005 1:20 am    Post subject: Re: Using parameters question Reply with quote

Hershcu Sorin wrote:
Quote:
I'm using D7 with Paradox and I have a Query that use parameters
on the WHERE clauses.
During the runtime the parameter value change and that change the
query result.
Sometimes the parameter can be empty without any value and on this
case I'll like the query to ignore the parameter.
Can that be done and how?

If you create a stored proc to execute the query, then you can check the
parameters in the proc and act accordingly. For example you can do this (not
checked for syntax):

create procedure Foo
(param integer)
return
(id integer)
as begin
for select id from table
where :param is null or field = :param
into id
do
suspend;
end
end;

Alternatively you can specify different SQL in the proc:

if (:param is null) then
for select id from table where <conditions> ...
else
for select id from table where <different conditions> ...

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"The moment the idea is admitted into society that property is not as
sacred as the laws of God and there is not a force of law and public
justice to protect it, anarchy and tyranny commence." - John Adams



Back to top
Ron
Guest





PostPosted: Mon Apr 11, 2005 2:48 pm    Post subject: Re: Using parameters question Reply with quote

Stored procedures with Paradox?
I didn't know that could be done!

Ron.

"Wayne Niddery [TeamB]" <wniddery (AT) chaffaci (DOT) on.ca> wrote

Quote:
If you create a stored proc to execute the query, then you can check the
parameters in the proc and act accordingly. For example you can do this
(not
checked for syntax):


<snip>



Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Tue Apr 12, 2005 3:44 pm    Post subject: Re: Using parameters question Reply with quote

Ron wrote:
Quote:
Stored procedures with Paradox?
I didn't know that could be done!

Good point, I managed to forget that he was using Paradox even though he did
say so.

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"The two most abundant elements in the universe are hydrogen and
stupidity." - Harlan Ellison



Back to top
Ron
Guest





PostPosted: Tue Apr 12, 2005 4:28 pm    Post subject: Re: Using parameters question Reply with quote

Long day? Smile
"Wayne Niddery [TeamB]" <wniddery (AT) chaffaci (DOT) on.ca> wrote

Quote:
Ron wrote:
Stored procedures with Paradox?
I didn't know that could be done!

Good point, I managed to forget that he was using Paradox even though he
did
say so.

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"The two most abundant elements in the universe are hydrogen and
stupidity." - Harlan Ellison





Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Wed Apr 13, 2005 4:47 pm    Post subject: Re: Using parameters question Reply with quote

Ron wrote:
Quote:
Long day? Smile

See sig...

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
Working for yourself is great because you get to work half days, and you can
choose any twelve hours you want.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop) 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.