Menu

Problem with OCI_LobCreate(cn, OCI_BLOB);

Anonymous
2014-06-19
2014-06-20
  • Anonymous

    Anonymous - 2014-06-19

    Hi Vincent

    OCILIB works great but I am having a problem with the lob stuff.

    Working on visual studio express 2012

    The OCI_LobCreate function always returns null.

    Also after doing a select of an existing record. I tried truncating using OCI_LobTruncate(lob,1);

    Does not seem to do anything.

    Your help will be appreciated.

    Thanks

    Martin

     
  • Vincent Rogier

    Vincent Rogier - 2014-06-19

    did you use the sql clause "for update" ?

    Regards,

    vincent

     
  • Anonymous

    Anonymous - 2014-06-19

    Hi Vincent

    Thanks for your quick reply. I am actually a java programmer and not really an expert in c++.

    Inserting a record.

    lob is always null.

    OCI_Lob * lob = OCI_LobCreate(cn, OCI_BLOB);

    lob is null. Why? ****

    String^ sql = "INSERT INTO AD_Image (ad_image_id, created, updated,createdby,updatedby,ad_client_id,ad_org_id,isactive,name,binarydata)" +
    " VALUES (AD_SEQUENCE_NEXTNO('AD_Image'), sysdate, sysdate, 100,100,1000012,0,'Y','Martin',:data)" +
    " returning ad_image_id into :i";
    IntPtr ptrToNativeString = Marshal::StringToHGlobalAnsi(sql);
    char* sql_ch = static_cast<char*>(ptrToNativeString.ToPointer());</char*>

    OCI_Prepare(st, sql_ch); 
    OCI_BindLob(st, ":data", lob); 
    OCI_RegisterInt(st, ":i");
    
    boolean ret = OCI_Execute(st); 
    printf("%d row inserted", OCI_GetAffectedRows(st));
    
     // wsqImg and len is passed.   uchar * wsqImg, uint len
    
    ret = OCI_LobWrite2(lob, wsqImg, &len,&len);
    
     
  • Vincent Rogier

    Vincent Rogier - 2014-06-19

    Did you have a look at the ocilib demo files (under demo folder)

     
  • Anonymous

    Anonymous - 2014-06-19

    Hi

    Yes I did. I was able to do most things. Ex. Select a blob from a table

    Just having a problem with taking an array of bytes. I get this from a fingerprint reader.

    Then need to insert this array into a record as a blob.

    I used one of the demo programs as a basis. Where you read a file and insert into a table.

    Thanks

    Martin

     
  • Anonymous

    Anonymous - 2014-06-20

    Hi Vincent

    I did get this to work. I suppose I am still learning.

    I did a insert using the value EMPTY_BLOB().

    Then I did a select ... for update and

    rs = OCI_GetResultset(st);

    while (OCI_FetchNext(rs)) {
    OCI_Lob *lob5 = OCI_GetLob(rs, 1);
    boolean ret = OCI_LobAppend(lob5, wsqImg, len); // wsqImg - passed buffer
    int lenold = OCI_LobGetLength(lob5);
    }

    Still not sure why OCI_Lob * lob3 = OCI_LobCreate(cn, OCI_BLOB);
    always returns NULL though.
    Thanks