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: Help! OCI's for an arbitrary stored procedure?

Re: Help! OCI's for an arbitrary stored procedure?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/12/04
Message-ID: <3487cf7a.2345011@inet16>#1/1

On Wed, 03 Dec 1997 16:52:15 -0600, royl_at_trinitech.com wrote:

>Anybody could tell me how to use OCI functions to handle an arbitrary
>stored procedure? For instance, obndra() doesn't appear to be able to
>handle an unknown set of parameters. How can I bind an arbitrary set of
>program variables with a set of placeholders? Thanks in advance!
>
>-------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet

A block of C code like the following will do it for you (the answer is, you have to look for the bind vars yourself). You send this routine the PL/SQL statement with bind variables and it binds them (using Null terminated strings)

static void do_binds( 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 ) )
            {
				printf( "You have a bind variable '%s'\n", ph );
				-- DO YOUR BINDING HERE
            }
            *cp = tmpch;
        }

    }
}      

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  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Thu Dec 04 1997 - 00:00:00 CST

Original text of this message

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