Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: SQL parameter with join?
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 ¶meter1;
>
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.