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: Does PL/SQL has a THIS for procedures?

Re: Does PL/SQL has a THIS for procedures?

From: Roger Stapley <rstapley_at_uk.oracle.com>
Date: Thu, 13 Jan 2000 09:12:08 +0000
Message-ID: <387D96E8.D8DC58F2@uk.oracle.com>


define a variable inside your proc (v_ina) and assign the value in ina to it then set t.a to v_ina

Jeffrey Mark Braun wrote:
>
> Is there a concept such as THIS in PL/SQL stored procedures or
> functions?
>
> If I have a parameter to a procedure which is named the same as a column
> name in a table, is there a way explicitly refer to the parameter and not
> the column?
>
> Here's an example which might make it more clear what I'm asking.
>
> Let's say I have a table of the following definition:
>
> CREATE TABLE t (
> a VARCHAR2(20),
> ina VARCHAR2(20)
> );
>
> Next let's say we have a naming convention in which parameter names must
> start with the mode type of the parameter (in, out, inout).
>
> Thus the following procedure has a problem:
>
> CREATE OR REPLACE PROCEDURE x (
> ina IN VARCHAR2
> inina IN VARCHAR2
> )
> AS
> BEGIN
>
> UPDATE
> t
> SET
> t.a = ina, -- <-- this is a the problem
> t.ina = inina;
>
> END x;
>
> As you can see we now have a situation in which unintentionally one of the
> procedures parameters is named exactly the same as a column in the
> table. Oracle at this point thinks it should update the column T.A to the
> value of T.INA not the value of the procedure parameter INA. If this were
> C++ or Java I could use THIS to refer to the procedure itself.
>
> In other words, I would like to be able to do something like this:
>
> UPDATE
> t
> SET
> t.a = THIS.ina,
> t.ina = inina;
>
> Is there a similar concept in PL/SQL?
>
> Thanks.
>
> Jeff BraunA
Received on Thu Jan 13 2000 - 03:12:08 CST

Original text of this message

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