Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: describe parameter in OCI ?
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;
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
![]() |
![]() |