[OCL]Is there any sample code for query/update BLOB data in OCL C++?

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
euca
Posts: 3
Joined: Tue 07 Aug 2007 06:10

[OCL]Is there any sample code for query/update BLOB data in OCL C++?

Post by euca » Tue 07 Aug 2007 06:16

As title, is there any sample code for querying/updating BLOB or LONG RAW data in Oracle database through OCL (Oracle Class Library for C++).

Thanks a lot.

ps. stored procedure samples would be better :)

Paul
Posts: 725
Joined: Thu 28 Oct 2004 14:06

Post by Paul » Tue 07 Aug 2007 07:41

Please see the following projects in OCL installation package
ocl\demos\clob\clob.cpp
ocl\demos\long\long.cpp

Work with CLOB and BLOB using OraLob type, work with LONG and LONG RAW using OraLong type.

euca
Posts: 3
Joined: Tue 07 Aug 2007 06:10

Post by euca » Tue 07 Aug 2007 08:07

But as I looked into clob.cpp, I found the sample code is for file i/o using "loadFromFile(fileName)".

Is there any other sample code using something like "setBlob()" for stored procedure input parameter?

Thanks a lot!

Paul
Posts: 725
Joined: Thu 28 Oct 2004 14:06

Post by Paul » Thu 09 Aug 2007 11:25

We do not have such example. You can use the one of the following cases to update CLOB, BLOB field. You can find information how to use other methods of OraLob, CRLob classes in OCL documentation.

void loadFromFile(OraQuery& query)
{
int id;
string fileName, title;

cout > id;

cout > title;

cout > fileName;

if (query.isActive())
query.close();

query.setCommandText(insertSQL);

query.param("ID").setInt(id);
query.param("TITLE").setString(title);

query.param("VALUE").setDirection(pdInput);
//query.param("VALUE").getClob().loadFromFile(fileName);

OraLob *lob = &query.param("VALUE").getClob();
char *s1 = "string data";
lob->write(0, strlen(s1), s1);

char *s2 = "string data1";
lob->setChars(s2);

CRString s3 = "string data3";
lob->setString(s3);

//lob.set

query.execute();
}

euca
Posts: 3
Joined: Tue 07 Aug 2007 06:10

Post by euca » Fri 10 Aug 2007 03:06

It works!!!

The sample codes you provided help me very much!
Thank you very very much!
:D

ps. but if the stored procedure has an input parameter type "BLOB", it'll said "unsupported datatype". After I turned to use "Long Raw" instead, it worked.

Post Reply