Re: Getting ROWID from Cda_Def (OCI stuff)

From: Scott Urman <surman_at_wwsun10.us.oracle.com>
Date: 21 Nov 1994 18:09:00 GMT
Message-ID: <3aqnns$4cu_at_dcsun4.us.oracle.com>


In article <CzJLH4.LMu_at_netnews.whoi.edu>, dhiltz_at_whsun1.whoi.edu (David Hiltz) writes:
|> Hello all you OCI programmers out there.
|>
|> I'm writing a C, OCI program which inserts a row into a table. The
|> Cda_Def structure used in the "oopen", "oparse" and "oexec" calls gets
|> updated with the ROWID of the newly inserted row (its stored in a
|> sub-structure off of Cda_Def called "rid". It looks like this:
|>
|> struct {
|> struct {
|> ub4 rcs4;
|> ub2 rcs5;
|> ub1 rcs6;
|> } rd;
|> ub4 rcs7;
|> ub2 rcs8;
|> } rid;
|>
|> Now, when I retrieve a ROWID from SQL*Plus it looks something like this:
|>
|> 00004FBD.0000.0006
|>
|> My question is: How do I put the "rid" structure info together to form
|> a ROWID that is in the same format as the one I can get from SQL*Plus?
|>
|> I didn't see a function in the "Programmer's Guide to Oracle Call
|> Interfaces" which would do this for me nor did it explain how this
|> "rid" structure forms a valid ROWID.
|>
|> I'm working on a Sun Workstation using Oracle 7.0.16 if that helps.
|>
|> Thanks in advance for any ideas.
|>
|> -----------
|> David Hiltz
|> dhiltz_at_whsun1.wh.whoi.edu
|> Network System Administrator
|> Northeast Fisheries Science Center
|> ######&_at_&######

Rowids can be in either internal or external format. The internal format is binary, and is sizeof(rid) bytes long. The external format is always 18 characters long, and looks like the SQL*Plus output. SQL*Plus is selecting a rowid into a character variable, so ROWIDTOCHAR() is implicitly called by the database. You can call this yourself, and pass the bind variable with type 11 (rowid), size sizeof(rid), and the address of rid. You would have to do this with a parsed statement of 'select rowidtochar(:1) from dual'. Bind :1 with rid, define an 18 character output variable, and do the fetch. Then you have the rowid just inserted in the external format. Received on Mon Nov 21 1994 - 19:09:00 CET

Original text of this message