Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: how to construct an SQL query ?

Re: how to construct an SQL query ?

From: karsten reincke <kreincke_at_cl-ki.uni-osnabrueck.de>
Date: Mon, 14 Jun 1999 08:23:21 +0200
Message-ID: <37649FD9.A4069BCD@cl-ki.uni-osnabrueck.de>


Wassim wrote:
>
> Hi,
> suppose that i have a form like this :
> name :
> date : from [ ] to [ ]
>
> [send] [cancel]
>
> i want to know how to construct the SQL query while i can't be done only
> dynamically because criteria of search are only known after submission
> of the form, search can be on 'name' only, or 'name'+'from_date' or the
> 3 criteria..
>
> Have i to do it using UNION between 2 or 3 SELECT query?
> Thanks for help !!

(1) you have to create a cgi-script where you build the final form the SQL-query by evaluating your parameters.

(2) you have three possibilties:

(a) SELECT * FROM table WHERE name=FORMNAME
(b) SELECT * FROM table WHERE name=FORMNAME AND from=FORMFROM
(c) SELECT * FROM table WHERE name=FORMNAME AND from=FORMFROM AND
to=FORMTO

the other possibilities seem to be more or less syntactical sugar:

(3) instead of creating 3 autnonom queries you could create one query using different variables (we are talking about your cgi-language, not directly about oracle)

(4) you could also create two views.

BUT in all cases you have to organize the decision about the form of the query logically outside of oracle in a computing language (PL/SQL, C, PERL ...) --

       salut d'Allemagne kr



les chats cont les vrais hédonistes
et devraient être donc notre idéal.

 karsten reincke [ 0541/9696223 ]
 kreincke_at_cl-ki.uni-osnabrueck.de Received on Mon Jun 14 1999 - 01:23:21 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US