Segmentation Fault(core dump) - BLOB Locator use in Oracle D

All posts relating to Oracle database administration.

Moderator: Tim...

Segmentation Fault(core dump) - BLOB Locator use in Oracle D

Postby saumitra8361 » Thu Mar 07, 2013 7:04 am

Hi,
I am trying to implement BLOB Locators concept in oracle db using pro*c/c++.
My DB table columns are of BLOB datatype and i want to insert/update data using BLOB Locators and that data is passed as parameter in the function.

As i have understood till this point the Locators concept, please comment if i am wrong:-
    Declare the Locator variable - OCIBlobLocator *<locator_variable>;
    Allocate the memory for Locator variable - EXEC SQL ALLOCATE :<locator_variable>;
    Map the Locator variable with the DB Column - EXEC SQL SELECT <column_name> INTO :<locator_variable> FROM <table_name>;
    Perform the operation(in this case UPDATE operation) - EXEC SQL UPDATE <table_name> SET <cloumn_name>=:<locator_variable>;
    Free the memory of Locator variable - EXEC SQL FREE :<locator_variable>;

In my case i am having data passed as parameter in the function, so how to map the locator variable to particular column.

While updating the BLOB column i am getting the Segmentation Fault(core dump). So during UPDATE operation what <locator_variable> contains memory address or the data value.

I my opinion i am having address mapping problem, while updating the BLOB column.

Can you guys suggest any thing. Thanks for your help. :)
saumitra8361
Member
 
Posts: 1
Joined: Thu Mar 07, 2013 6:57 am

Re: Segmentation Fault(core dump) - BLOB Locator use in Orac

Postby Tim... » Thu Mar 07, 2013 7:51 am

Hi.

Not sure I can help with Pro*C. It's amny years since I've been down that road. :)

What I can see is you are doing a SELECT for the locator, but I think you should be doing a SELECT ... FOR UPDATE.

So looking at this from a PL/SQL perspective, to insert a new blob you will probably end up doing something like this.

Code: Select all
DECLARE
  l_bfile  BFILE;
  l_blob   BLOB;
BEGIN
  INSERT INTO tab1 (id, clob_data)
  VALUES (1, empty_blob())
  RETURN clob_data INTO l_blob;

  l_bfile := BFILENAME('IMAGES', 'MyImage.gif');
  DBMS_LOB.fileopen(l_bfile, Dbms_Lob.File_Readonly);
  DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
  DBMS_LOB.fileclose(l_bfile);

  COMMIT;
END;
/


To update an existing blob, you will probably do something like this.

Code: Select all
DECLARE
  l_bfile  BFILE;
  l_blob   BLOB;
BEGIN
  SELECT clob_data
  INTO   l_clob
  FROM   tab1
  WHERE  id = 1
  FOR UPDATE;

  l_bfile := BFILENAME('IMAGES', 'MyImage.gif');
  DBMS_LOB.fileopen(l_bfile, Dbms_Lob.File_Readonly);
  DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
  DBMS_LOB.fileclose(l_bfile);
END;
/


So you need to replicate that type of process in Pro*C.

Note sure this will help your specific problem, but might make you think a little differently. :)

You may get a better perspective by asking the question in the Pro*C forum on the OTN forums.

Sorry I can't be of more help.

Cheers

Tim...
Tim...
Oracle ACE Director
Oracle ACE of the Year 2006 - Oracle Magazine Editors Choice Awards
OakTable Member
OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
OCP Advanced PL/SQL Developer
Oracle Database: SQL Certified Expert
My website: http://www.oracle-base.com
My blog: http://www.oracle-base.com/blog
Tim...
Site Admin
 
Posts: 17936
Joined: Mon Nov 01, 2004 5:56 pm
Location: England, UK


Return to Oracle Database Administration

Who is online

Users browsing this forum: No registered users and 8 guests