need an answer from experts [message #35657] |
Thu, 04 October 2001 06:15 |
Venky
Messages: 52 Registered: October 2001
|
Member |
|
|
I got this function from oracle manual
to read a CLOB from a table
My question once the data is read, how to copy that data to local (char *) vairable.Iam able to print the data to standard out, the big question is how to capture that data into a variable.
Appreciate any ones help
int main()
{
EXEC SQL ALLOCATE :a_clob;
EXEC SQL SELECT CLOB INTO :a_clob
FROM emp
WHERE empId = 12345
to_char(emp_clddate, 'DD-MM-YY')
= '23-SEP-01';
EXEC SQL LOB DESCRIBE :a_clob GET LENGTH INTO :lenp;
if(lenp == 0)
printf("n No record found. n");
else
{
EXEC SQL BEGIN DECLARE SECTION;
int amt = lenp;
varchar *the_string;
EXEC SQL END DECLARE SECTION;
the_string = (varchar *)malloc(2 + lenp);
the_string->len = (int)lenp;
EXEC SQL WHENEVER NOT FOUND CONTINUE;
EXEC SQL LOB READ :amt
FROM :a_clob INTO :the_string WITH LENGTH :lenp;
printf("n------------------------------------------------------------------------------------nn");
printf("%.*sn", the_string->len,string->arr);
printf("n------------------------------------------------------------------------------------nn");
free(the_string);
}
EXEC SQL FREE :a_clob;
}
----------------------------------------------------------------------
|
|
|
|