Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: how to construct an SQL query ?
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 ANDto=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