Search code examples
c++arraysoracleembedded-sql

Storing Oracle DB table's ROWID as a character array


I would like to retrieve ROWID of a table from Oracle DB and store in memory as a character array for later use. For example, I run the following query:

SELECT ROWID, MARKS FROM MTB WHERE EID='123';

Then using Pro*C, I would like to store this ROWID as a character array rrr to use later as:

UPDATE MTB SET MARKS = 80 WHERE ROWID='<rrr>'

Please help and point to appropriate documentation of Pro*C usage to convert a ROWID to an array of character strings.


Solution

  • You can use the ROWIDTOCHAR and CHARTOROWID functions:

    SELECT ROWIDTOCHAR(ROWID), MARKS INTO :rrr, :marks FROM MTB WHERE EID='123';
    

    And then

    UPDATE MTB SET MARKS = 80 WHERE ROWID=CHARTOROWID(:rrr);