Re: ProC and dynamic selects using SQLDA?

From: Scott Urman <surman_at_dlsun338.us.oracle.com>
Date: 1997/03/11
Message-ID: <5g47je$guf_at_inet-nntp-gw-1.us.oracle.com>#1/1


In article <3324f231.0_at_news.usinternet.com>, kenf_at_usinternet.com (Ken Frank) writes:
|> Does anyone out there have any references on doing dynamic select
|> statements (with completely unknown result-sets) under ProC? I need
|> to duplicate some stuff I wrote for Ingres to work under Oracle, but
|> can't find any documentation on how to do this. Even Oracle's own
|> manual (the one claiming to be for C programmers) states that it's an
|> advanced topic, and not covered.

Perhaps you are looking at the wrong manual. The Pro*C manual (Oracle part number A21021) has an entire chapter on dynamic method 4. The online sample program sample10.pc (or possibly sample9.pc, depending on your platform) does exactly this as well - it presents an SQL> prompt and allows you to execute arbritray SQL statements, including selects.

|>
|> Under Ingres, the basics look like:
|>
|> exec sql declare stmt statement;
|> exec sql declare :cursorname cursor for stmt;
|> exec sql prepare stmt from :qrystr;
|> sqlda = sqlda_new(MAX_ELEMS);
|> exec sql describe stmt into :sqlda;
|>
|> /* allocate result-vars */
|> for (i = 0; i < sqlda->sqld; i++) {
|> sqv = &sqlda->sqlvar[i];
|> [
|> big switch on sqv->sqltype, with calls to allocate space for
|> appropriate result-types and null-indicators omitted ...
|> ]
|> }
|>
|> exec sql open :cursorname;
|> ...
|>
|> That's the basics under Ingres, anyways. Can anyone give me some
|> tips for Oracle? I'd like to stay away from OCI if possible.

It's basicly the same for Oracle as well. The sqlda is likely similar also.

|>
|> Thanks in advance!
|> Ken Frank
|> kenf_at_usinternet.com
|>
|> PS - Is it just me, or is a post to this newsgroup pretty much
|> guaranteed to get you on every spammers mailing list?
|>
|>



Scott Urman Oracle Corporation surman_at_us.oracle.com

Author of _Oracle PL/SQL Programming_ ISBN 0-07-882176-2 Published by Oracle Press - http://www.osborne.com/oracle/index.htm

"The opinions expressed here are my own, and are not necessarily that of  Oracle Corporation"
Received on Tue Mar 11 1997 - 00:00:00 CET

Original text of this message