| View previous topic :: View next topic |
| Author |
Message |
Hershcu Sorin Guest
|
Posted: Sun Apr 10, 2005 12:55 pm Post subject: Using parameters question |
|
|
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
|
Posted: Sun Apr 10, 2005 2:08 pm Post subject: Re: Using parameters question |
|
|
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
|
Posted: Sun Apr 10, 2005 3:42 pm Post subject: Re: Using parameters question |
|
|
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
|
Posted: Mon Apr 11, 2005 1:20 am Post subject: Re: Using parameters question |
|
|
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
|
Posted: Mon Apr 11, 2005 2:48 pm Post subject: Re: Using parameters question |
|
|
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
|
Posted: Tue Apr 12, 2005 3:44 pm Post subject: Re: Using parameters question |
|
|
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
|
Posted: Tue Apr 12, 2005 4:28 pm Post subject: Re: Using parameters question |
|
|
Long day?
"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
|
Posted: Wed Apr 13, 2005 4:47 pm Post subject: Re: Using parameters question |
|
|
Ron wrote:
| Quote: | Long day?
|
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 |
|
 |
|