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 -> 2 newbie OCI questions

2 newbie OCI questions

From: <dgallardo_at_my-dejanews.com>
Date: Wed, 21 Apr 1999 21:27:50 GMT
Message-ID: <7flfsh$s6a$1@nnrp1.dejanews.com>


Hi everyone -

I'll start with my general question: where can I get doc for the Oracle call interface? I have the doc from Oracle, but I'm finding it hard starting out. I've used code from the examples, but am still having problems understanding exactly what's going on. None of the Oracle books I've seen, including the otherwise fine "ORACLE8, The Complete Reference", have anything about OCI. Also, the pointer to the OCI wrapper that someone provided seems to be dead. Arggghhh....

So on to my second question: Am I on the right track? I'm having various problems trying to process dynamically generated SQL. My code allocates the handles it needs (per code I borrowed from cdemo81.c). I don't do a bind, because I'm not using any bind variables. I prepare the statement & get the statement handle, call OCIStmtExec(), then use a sequence of OCIParamGet() and OCIAttrGet() calls to get the number of columns, the column names, and the datatypes. So far, so good. Then I call OCIDefineByPos() for each column, using the datatypes I got from before. Finally, I call OCIStmtExec() again
(with iterations set to 1, next few params set to 0, and mode set to
OCI_DEFAULT). This is supposed to fill in all the addresses I specified with the define, right?

This all seems to go OK except for the following problems:

  1. I don't get all the column names. The last few are null. (The db looks ok when I use the same SQL statement in SQL*PLUS.)
  2. Char buffers look OK but when I get an int back, it's not what I expect
    (or at least, in the encoding I expect. E.g. instead of 1 I get 0x2c1, 2 is
    0x3c1, 100 is 0x2c2, 255 is 0x3803c2. What's up with that? Do I need to somehow specify the encoding type I want for ints?)
  3. I don't get all the column values for the row. I get an access violation trying to access past the third or fourth column.

And finally--how do I get the next row? If I call OCIStmtExec() again, I get the same row back.

Thanks in advance for any help & apologies if this is all in a FAQ someplace
(I looked but didn't find...)

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Wed Apr 21 1999 - 16:27:50 CDT

Original text of this message

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