#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    3
    Rep Power
    0

    Segmentation Fault(core dump) - BLOB Locator use in Oracle DB using Pro*C/C++


    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.
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    854
    Rep Power
    387

    Cool


    Originally Posted by saumitra8361
    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
    . . . E t c . . .
    Can you guys suggest any thing. Thanks for your help.
    Did you insert the row(s) using EMPTY_BLOB()?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by LKBrwn_DBA
    Did you insert the row(s) using EMPTY_BLOB()?
    Hi LKBrwn_DBA,

    Yes I tried to insert row using EMPTY_BLOB(), but that also didn't worked.

    According to my knowledge EMPTY_BLOB() only initializes LOB Locator particular to that column.
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    854
    Rep Power
    387

    Cool


    Originally Posted by saumitra8361
    Yes I tried to insert row using EMPTY_BLOB(), but that also didn't worked.

    According to my knowledge EMPTY_BLOB() only initializes LOB Locator particular to that column.
    That is exactly how it works:

    1) Insert EMPTY_BLOB()
    2) Update the blob.

  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    3
    Rep Power
    0

    Thumbs up


    Hi LKBrwn_DBA,

    Now i get the solution . It involves following Steps:-

    1) First Allocate Memory and Initialize LOB Locator

    EXEC SQL ALLOCATE :<LOB_Locator>;

    2) Then use INSERT/UPDATE to initialize LOB Column,
    here we are using example of UPDATE query....

    EXEC SQL UPDATE <Table_Name>
    SET <LOB_Column> = EMPTY_BLOB(),(column = : <Value>,......)
    (WHERE <condition_check>)
    RETURNING <LOB_Column> INTO :<LOB_Locator> ;

    Here, 'RETURNING' Clause will map LOB_Locator with LOB Column in the DB Table.

    3) OPEN LOB Locator according to use.

    EXEC SQL LOB OPEN :<LOB_Locator> READ WRITE;

    4) Now WRITE data into LOB Locator.

    EXEC SQL
    LOB WRITE ONE :<amt> FROM :<Data_Buffer> INTO : <LOB_Locator>;

    here, 'amt' is the no. of bytes need to be written.

    5) CLOSE the LOB Locator after read/write Operation.

    EXEC SQL LOB CLOSE :<LOB_Locator>;

    6) FREE Allocated Memory of LOB Locator.

    EXEC SQL FREE :<LOB_Locator>;

IMN logo majestic logo threadwatch logo seochat tools logo