Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Oracle Miscellaneous > Re: All rows if...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 10 Topic 6816 of 7279
Post > Topic >>

Re: All rows if null

by banaslee <banaslee@[EMAIL PROTECTED] > Apr 6, 2008 at 04:26 PM

On Apr 6, 12:07=A0pm, Urs Metzger <u...@[EMAIL PROTECTED]
> wrote:
> HansH schrieb:
>
>
>
> > "banaslee" <banas...@[EMAIL PROTECTED]
> schreef in bericht
>
>news:a0eae9d2-cd8c-4acd-bca0-7a5050285a1f@[EMAIL PROTECTED]
> >> Why am I building the query dynamically? I have a search tool based
> >> ona form with some text boxes, one for name, other for the date of
birt=
h
> >> and another for ID number. Then, based on the values entered I want
> >> to search for persons that match those criteria.
> >> Imagine, if I have 'John' on name and all the other boxes empty then
I
> >> only want to see people with his name starting by John no matter his
> >> ID number or his DOB.
> >> This is why I use dynamic SQL:
> >> 'select * from people where status =3D ''A''' || where_clauses
> >> Where where_clauses can be 'AND name LIKE ''John%''' or 'AND
id_number
> >> =3D 12345' or 'AND name LIKE ''John%'' AND id_number =3D 12345' or
even=

> >> more possible arrangements (with DOB too of course).
>
> >> I don't know another way of doing this :/
>
> > SELECT * FROM people WHERE status =3D 'A'
> > AND ( '' =3D :name OR name LIKE :name||'%' )
> > AND ( '' =3D :dob =A0OR name =3D =A0 =A0:dob )
>
> > Should have given this more thought before posting ... just 2 cnt
>
> > HansH
>
> "'' =3D :name" won't work, as '' is NULL;
>
> "AND (:name is null or name like :name || '%')
> =A0 AND (:dob is null or dob =3D :dob )"
> will do the trick.
>
> Hth, Urs Metzger

Thanks for your answer.

I considered that but dropped that idea because of performance issues.
Let me know what you think ;)

Thanks for your answers
 




 10 Posts in Topic:
All rows if null
banaslee <banaslee@[EM  2008-04-04 02:51:25 
Re: All rows if null
DA Morgan <damorgan@[E  2008-04-04 09:31:50 
Re: All rows if null
Ed Prochak <edprochak@  2008-04-04 10:49:23 
Re: All rows if null
banaslee <banaslee@[EM  2008-04-05 06:26:08 
Re: All rows if null
"HansH" <han  2008-04-06 12:54:19 
Re: All rows if null
Urs Metzger <urs@[EMAI  2008-04-06 13:07:34 
Re: All rows if null
banaslee <banaslee@[EM  2008-04-06 16:26:55 
Re: All rows if null
Gints Plivna <gints.pl  2008-04-13 09:08:40 
Re: All rows if null
banaslee <banaslee@[EM  2008-04-14 01:34:50 
Re: All rows if null
Gints Plivna <gints.pl  2008-04-14 11:30:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 8:50:42 CST 2008.