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: describe parameter in OCI ?

Re: describe parameter in OCI ?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/05/06
Message-ID: <33714e26.1954139@newshost>#1/1

On Mon, 05 May 1997 16:16:16 -0700, James Chen <james_at_iweave.com> wrote:

>
>Hi All,
>
>Does anyone know how to get the information about
>input parameters in a dynamic SQL statement ?
>
>odescr() only gives you information about the resultset.
>
>Thanks in advance,
>--
>James Chen, at Interweave Software, Inc.
>james_at_iweave.com

You can't describe bind variables. Consider

"select * from emp where ename= :x"

What is the datatype of :x? It could be a number, string, date, whatever it wants to be. It is up to you the developer to determine what type you want to use and bind it. Oracle will tell you the outputs and their types, you must tell it about the inputs.

I use a small routine like:

static void do_binds( myctx * ctx, char * stmt_buf ) {

int     i;
int     in_literal;
int     n;

char *cp;
char *ph;
char tmpch;
char * value;
int     maxl;
int     occurrs;
 

    for( i = 0, in_literal = FALSE, cp = stmt_buf; *cp; cp++)     {

        if (*cp == '\'') in_literal = ~in_literal;  

        if (*cp == ':' && !in_literal)
        {
            for(ph = ++cp, n = 0;
                *cp && (isalnum(*cp) || *cp == '_') && n < 31;
                cp++, n++);
 
            tmpch = *cp;
            *cp = '\0';
            if ( strlen( ph ) )
            {
                /* 
                   DO YOUR BINDING FOR THE VARIABLE
                   WHOSE NAME IS CONTAINED IN ph HERE
                   Use obndrv to bind by name
                */
            }
            *cp = tmpch;
        }

    }
}  

To do my binding. It finds :bind_variable name in pl/sql blocks and select statements.

This is a slightly modified version of do_binds that you will find in cdemo2.c in the $ORACLE_HOME/rdbms/demo directory. The one in cdemo2 doesn't deal with := (pl/sql assignment) correctly.

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD

http://govt.us.oracle.com/ -- downloadable utilities



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Tue May 06 1997 - 00:00:00 CDT

Original text of this message

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