Home » Developer & Programmer » Precompilers, OCI & OCCI » PRO*c + OCI
icon9.gif  PRO*c + OCI [message #128134] Fri, 15 July 2005 05:53 Go to next message
palanivel_pk
Messages: 4
Registered: July 2005
Location: chennai
Junior Member
hi,

Iam new to OCI and using it in my PRO*C application.

my program is like

#include <oci.h>
#include <sqlcpr.h>
#define SQLCA_NONE
#include <sqlca.h>
......
........

EXEC SQL BEGIN DECLARE SECTION;
...................
....................
OCIClobLocator *a_clb;
char tmpst[500];
unsigned int Cloblen,WriteAmt,Offset;
int Charlen,NewCharbuflen;
Varchar *NewCharbuf;
int Charlen,NewCharbuflen;
Varchar *NewCharbuf;
Varchar *tvarchr;
EXEC SQL END DECLARE SECTION;

//** 1
EXEC SQL AT DB_NAME ALLOCATE :a_clb;
//** 2
EXEC SQL AT DB_NAME LOB WRITE ONE :WriteAmt FROM :NewCharbuf INTO :a_clb AT :Offset;
//**3
EXEC SQL AT DB_NAME LOB DESCRIBE :a_clb GET LENGTH INTO :Cloblen;

For all the above EXEC SQL ( except //**1 )statement, the error log is like "ORA-22275: invalid LOB locator specified"

after the above EXEC sql, iam trying to insert date to the table like
EXEC SQL AT DB_NAME INSERT INTO MESSAGE_DATA(MESSAGEDATAID,MESSAGEID,MSGDATANAME,MSGDATAVALU
E) values (3191,1189,'Insert1',:a_clb);

The database is getting stored empty value for the CLOB field and rest of the field values are getting stored correctly.

Any idea to solve the problem..

Thanks in advance..

Vel
Re: PRO*c + OCI [message #128396 is a reply to message #128134] Mon, 18 July 2005 06:16 Go to previous message
palanivel_pk
Messages: 4
Registered: July 2005
Location: chennai
Junior Member
problem got solved.


Need to insert a record in the table with empty_clob as value and then fetch that particular record and point it to the CLOB Locator and then do WRITE LOB.

OCIClobLocator *a_clb;

//Clob Allocation
EXEC SQL AT DB_NAME ALLOCATE :a_clb;

//Creating a new record with empty_clob()
EXEC SQL AT DB_NAME INSERT INTO emp(empname,empage,empdescription) values ('john',25,empty_clob())

//initialising the clob pointer variable ( i.e a_clb)
EXEC SQL AT DB_NAME SELECT empdescription INTO :a_clb from emp where empname='john' and empage=25;

//LOB WRITE
EXEC SQL AT DB_NAME LOB WRITE ONE :WriteAmt FROM :NewCharbuf INTO :a_clb;


***CLOB Data updated successfully in the database..

Thanks to all who analysed the problem

vel

Previous Topic: problem in preprocessor directive
Next Topic: PROBLEM WITH SQLCXT
Goto Forum:
  


Current Time: Thu Mar 28 11:12:11 CDT 2024