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

Home -> Community -> Usenet -> c.d.o.server -> Re: Variables in select statement?

Re: Variables in select statement?

From: Nicky <nickyterwel_at_hotmail.com>
Date: Thu, 2 Sep 1999 09:08:23 +0200
Message-ID: <7ql7gv$3806m$1@reader3.wxs.nl>

Thomas Kyte <tkyte_at_us.oracle.com> wrote in message news:37d145a3.103942241_at_newshost.us.oracle.com...
> A copy of this was sent to "Nicky" <nickyterwel_at_hotmail.com>
> (if that email address didn't require changing)
> On Wed, 1 Sep 1999 17:06:28 +0200, you wrote:
>
> >This is what we are trying to do, but it doesn't work.
> >
> >select strColumnName1 from strTableName where strColumnName2 =
strValue;
> >
> >When we don't use the variables but the real values instead it works just
> >fine.
> >What am I doing wrong?
> >
> >Nicky Terwel
> >
> >
>
>
> You need to use dynamic sql to do that (replace column and tablenames) in
a
> query. The query needs to be parsed before each and every execution.
>
> what language are you using?

We are using PL\SQL in Oracle procedure builder. The function looks like this:

function NameOfFunction (strColumnName1 varchar2, strTableName varchar2, strColumnName2 varchar2, strValue integer) return number is

Declares
....
...

Begin

....
....
....

    select  strColumnName1
        into numResult
        from strTableName
        where strColumnName2 =  strValue;

return numResult;

End

> what environment are you in?
>
> then, we might be able to help you out.
>
> --
> See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to
Oracle8i'...
> Current article is "Part I of V, Autonomous Transactions" updated June
21'st
>
> Thomas Kyte tkyte_at_us.oracle.com
> Oracle Service Industries Reston, VA USA
>
> Opinions are mine and do not necessarily reflect those of Oracle
Corporation Received on Thu Sep 02 1999 - 02:08:23 CDT

Original text of this message

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