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

Home -> Community -> Usenet -> c.d.o.misc -> Re: sql query problem HELP

Re: sql query problem HELP

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Tue, 4 Sep 2001 00:32:38 +0200
Message-ID: <tp8igjh04b5ocd@news.demon.nl>

"Vucko" <mvucic_at_barok.foi.hr> wrote in message news:newscache$qpt3jg$tv$1_at_tower.foi.hr...
> Sybrand Bakker <postbus_at_sybrandb.demon.nl> wrote:
>
> >One statement is, IMO, not possible, as there is no relationship between
the
> >2 resultsets.
> >One sql script is definitely possible.
> >Most people here don't like to do other peoples homework, and your
question
> >definitely is of the homework type.
> >
> >
> >
> >Regards,
> >Sybrand Bakker, Senior Oracle DBA
>
> There is something in your signature that makes me think you'll know
> the answer ;-)
> There is a procedure X with an argument yyy which is a condition in
> a where clause. Also, there is a table Z with a column named yyy. What
will
> happen in the case below? (I was not sure about that, so I renamed
argument
> yyy to yyy1). Would it have the same effect as if there is no "where"
clause,
> or what? Tnx.
>
> Procedure x (var yyy varchar2)
> begin
> select * from database
> where yyy=yyy;
> end;
>
> --
> Vucko
>
> p.s. Sorry about bad English.
> p.p.s. This was not my homework. ;-)

Due to the scoping rules of pl/sql the parser doesn't discriminate between the 2 yyy's in the where clause. So yes, it would run as if written without a where clause.
In short, your bind variable names should never ever equal a column name in the same select.
One easy solution is to prefix parameters always with p_

Hth,

Sybrand Bakker, Senior Oracle DBA Received on Mon Sep 03 2001 - 17:32:38 CDT

Original text of this message

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