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

Home -> Community -> Usenet -> c.d.o.tools -> Re: SQL parameter with join?

Re: SQL parameter with join?

From: <xmark.powell_at_eds.com.x>
Date: 12 Apr 2001 13:31:34 GMT
Message-ID: <9b4anm$rv9$1@news.netmar.com>

In article <3AD477EC.B240F21E_at_ratp.fr>, gg200492 <gg200492_at_ratp.fr> writes:
>
>Can I have a parameter in the where clause when i have already a join on
>this field?
>how to do else?it doesn't work quickly
>
>ex:
>
>select a.f1,b.f2
>from a,b
>where a.f1=b.f1
>and a.f1 like &parameter1;
>

The short answer to your first question is yes. In SQL*Plus you would code something like:
select *
from tableA A, tableB B
where a.col = upper('&variable')
and a.col1 = b.col1;

In embedded code change the '&' to a ':' while in pl/sql you would just use the plsql variable name in the SQL statement.

To use a like clause you would need to use correct syntax as in:  like upper('&variable'||'%') where '%' is the Oracle wildcard indicator for any value of any length and '_' (underscore) is the any character of 1 byte wild card. You could also code it like upper('&tbl_name')||'% .

I hope this answers your questions.

Received on Thu Apr 12 2001 - 08:31:34 CDT

Original text of this message

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