Blob datatype as arguement to PL/SQL procedure

Hi,
Iam trying to pass Blob data from application program to PL/SQL as one of its arguement. The PL/SQL procedure will inturn insert the given Blob data into appropriate table in its corresponding Blob column.
Ex:-
PL/SQL Procedure:
CREATE OR REPLACE PACKAGE TestPkg as
PROCEDURE logData
data IN Blob
END TestPkg;
Application Program:
1. string sqlStmt="BEGIN TestPkg.logData(:1); END;";
2. Connection * pConnection = getConnection();
3. Statement * pStatement = pConnection->createStatement(sqlStmt);
4. Blob blob(pConnection);
5. blob.setEmpty();
6. blob.write(100, pBuffer, 100, 1); <=== This results in (ORA-22275: invalid LOB locator specified)
7. pStatement->setBlob(blob);
8. pStatement->executeUpdate();
9. pConnection->terminateStatement(pStatement);
10. releaseConnection(pConnection);
I used to get similar error while directly inserting from application program to a table with Blob column.
We fixed it by using the "FOR UPDATE" clause in a select statement and obtaining the locator
for LOB. Iam looking for a similar syntax for PL/SQL procedure inputs.

Gaurav,
Just a guess, but try the following:
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor( "SCOTT.HEADER_UPLOAD_TAB", oracleconnection );In other words, prefix the data-type name, HEADER_UPLOAD_TAB, with its schema owner name.
Good Luck,
Avi.

Similar Messages

  • How to insert BLOB datatype image using PL/SQL Procedure and SQL Loader

    Hi,
    How to insert an image into database using PL/SQL Procedure and also how to insert using SQL Loader. Please help by giving sample code and process description.
    Thanks,
    Vijay V

    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:232814159006

  • Assigning server file to Blob variable in pl/sql procedure

    I have a file on the Unix box say 'test.txt' at '/temp/..'(path) which might be of a any size(which is not known), Now I wanted to read & open that file into a Blob variable in my pl/sql procedure. How can I do that ?
    Can any one please help me....
    Thanks
    Ravi

    This is not an appropriete forum to ask this pl/sql question.
    Check "DBMS_LOB Demos / Blob Load Demo" part of the below reference for an example -
    http://psoug.org/reference/dbms_lob.html

  • How can i make a pl/sql function for BLOB datatype

    hi..anyone here who is very familiar about BLOB datatype. i have a COLUMN_ID, COLUMN_A in a certain TABLE_1. COLUMN_A is blob datatype that contains almost 250,000rows
    SQL>select column_A from table_1 where column_id=1234567
    column_A
    00000001000000010000000606D4E833074B69EC06D4E91F074CO18406D50C58074C031E
    how can i make a user-defined function to compute and convert this blob datatype into decimal length value. this hex value are points in the map.. the function must contain
    1.get the length of a blob then
    2.convert blob to variable hexadecimal characters by parsing it into 8
    3.to_number function or other function used to convert haxadecimal characters to decimal numbers
    4.phythagorean formula to compute length between two points. this is the formula i think LENGTH =
    SQRT(power((coordinate_x-prev_coordinate_x),2)+power((coordinate_y-prev_y),2));
    after this when i type this
    SQL>select user_function(column_A) from table_1 where column_id=1234567
    user_functions(column_A)
    --output length will be in decimal value already
    the function will goes like this
    step1 is to get the blob length
    00000001000000010000000606D4E833074B69EC06D4E91F074CO18406D50C58074C031E
    step2 is parsing of data by eights
    00000001 =>1
    00000001 =>1
    00000006 =>6 (number of coordinates)
    06D4E833 => X1
    074B69EC => Y1
    06D4E91F => X2
    074CO184 => Y2
    06D50C58 => X3
    074C031E => Y3
    step3 to_number function used to convert hex char to decimal
    step4 compute by phytagorean (NOTE ! when computing length the third parsed eight will tell how many coordinates are there..the number of coordinates is ranging from 2 up to E..above example shows 6 coordinates so it means
    LENGTH1 =
    SQRT(power((X2-X1),2)+power((Y2-Y1),2));
    LENGTH2=
    SQRT(power((X3-X2),2)+power((Y3-Y2),2));
    TOTAL LENGTH=LENGTH1 + LENGTH2
    thanks

    its my first time to use that.There's got to be a first tiem for anything. Be brave.
    btw if theres more easy suggestion pls feel free..Well of course the easiest solution would be if the calling program passed in the parameters as separate arguments instead of glomming them together in a string that has to be parsed. This sort of kluj really ought not to have survived into C21.
    Cheers, APC

  • Passing variable of size greater than 32767 from Pro*C to PL/SQL procedure

    Hi,
    I am trying to pass a variable os size greater than 32767 from Pro*C to an SQL procedure.I tried assigning the host variable directly to a CLOB in the SQL section but nothing happens.In the below code the size of l_var1 is 33000.PROC_DATA is a procedure that takes CLOB as input and gives the other three(Data,Err_Code,Err_Msg) as output.These variables are declared globally.
    Process_Data(char* l_var1)
    EXEC SQL EXECUTE
    DECLARE
    l_clob clob;
    BEGIN
    l_clob := :l_var1
    PROC_DATA(l_clob,:Data,:Err_Code,:Err_Msg) ;
    COMMIT;
    END;
    END-EXEC;
    I also tried using DBMS_LOB.This was the code that i used.
    Process_Data(char* l_var1)
    EXEC SQL EXECUTE
    DECLARE
    l_clob clob;
    BEGIN
    DBMS_LOB.CREATETEMPORARY(l_clob,TRUE);
    DBMS_LOB.OPEN(l_clob,dbms_lob.lob_readwrite);
    DBMS_LOB.WRITE (l_clob, LENGTH (:l_var1), 1,:l_var1);
    PROC_DATA(l_clob,:Data,:Err_Code,:Err_Msg) ;
    COMMIT;
    END;
    END-EXEC;
    Here since DBMS_LOB packages allow a maximum of 32767,the value of l_var1 is not being assigned to l_clob.
    I am able to do the above process provided i split l_var1 into two variables and then append to l_clob using WRITEAPPEND.i.e l_var1 is 32000 in length and l_var2 contains the rest.
    Process_Data(char* l_var1,char* l_var2)
    EXEC SQL EXECUTE
    DECLARE
    l_clob clob;
    BEGIN
    dbms_lob.createtemporary(l_clob,TRUE);
    dbms_lob.OPEN(l_clob,dbms_lob.lob_readwrite);
    DBMS_LOB.WRITE (l_clob, LENGTH (:l_var1), 1,:l_var1);
    DBMS_LOB.WRITEAPPEND (l_clob, LENGTH(:l_var2), :l_var2);
    PROC_DATA(l_clob,:Data,:Err_Code,:Err_Msg) ;
    COMMIT;
    END;
    END-EXEC;
    But the above code requires dynamic memory allocation in Pro*C which i would like to avoid.Could you let me know if there is any other way to perform the above?

    Hi,
    The Long Datatype has been deprecated use Clob or Blob. This will solve lot of problems inherent with the datatype.
    Regards,
    Ganesh R

  • Insert record in table having BLOB datatype

    Hi All,
    I have a table with BLOB datatype, Pls assist me how to insert a record in this table?
    CREATE TABLE document_BLOB_tab (
    doc_id_no NUMBER
    , doc_name VARCHAR2(200)
    , doc_value BLOB);
    What are the process to execute DBMS_LOB.fileOpen ?
    Rgds
    Sarfaraz

    1- Create a table that has a list of all directory, filenames combination
    SQL> create table listpic (directory varchar2(10), filename varchar2(10));
    Table created.
    2- Insert into that table all your directories and the filenames of the images within each
    directory (directory, filename) combination
    on my file system, I have
    d:\tars\samples1\lilies.jpg
    d:\tars\samples1\Sunset.jpg
    d:\tars\samples2\Blue.jpg
    d:\tars\samples1\Winter.jpg
    Here is my insert statment
    SQL> insert into listpic values('Samples1', 'lilies.jpg');
    1 row created.
    SQL> insert into listpic values('Samples1', 'Sunset.jpg');
    1 row created.
    SQL> insert into listpic values('Samples2', 'Blue.jpg');
    1 row created.
    SQL> insert into listpic values('Samples2', 'Winter.jpg');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from listpic;
    DIRECTORY FILENAME
    Samples1 lilies.jpg
    Samples1 Sunset.jpg
    Samples2 Blue.jpg
    Samples2 Winter.jpg
    3- Create the table where you are going to store your pictures
    SQL> create table pictures (id number(5), image blob);
    Table created.
    4- Create a directory pointing to the common parent Directory
    SQL> create or replace directory IMAGES as 'd:\tars';
    Directory created.
    5- Create the following procedure to insert the image
    SQL> set serveroutput on
    SQL> create or replace procedure insert_image as
    2 f_lob bfile;
    3 b_lob blob;
    4 i number := 1;
    5 cursor image_cur is select directory, filename from listpic;
    6 pic_rec image_cur%ROWTYPE;
    7 begin
    8
    9 OPEN image_cur;
    10 Loop
    11 fetch image_cur into pic_rec;
    12 EXIT WHEN image_cur%NOTFOUND;
    13 insert into pictures values ( i, empty_blob() )
    14 return image into b_lob;
    15
    16 f_lob := bfilename( 'IMAGES','\'||pic_rec.DIRECTORY||'\'||pic_rec.FILENAME);
    17 dbms_lob.fileopen(f_lob, dbms_lob.file_readonly);
    18 dbms_lob.loadfromfile( b_lob, f_lob, dbms_lob.getlength(f_lob) );
    19 dbms_lob.fileclose(f_lob);
    20 dbms_output.put_line (pic_rec.directory ||'\'||pic_rec.filename);
    21 commit;
    22 i := i+1;
    23 END LOOP;
    24 end;
    25 /
    Procedure created.
    6- execute the procedure
    SQL> exec insert_image;
    Samples1\lilies.jpg
    Samples1\Sunset.jpg
    Samples2\Blue.jpg
    Samples2\Winter.jpg
    PL/SQL procedure successfully completed.
    SQL> select count(*) from pictures;
    COUNT(*)
    4
    SQL> select length(image) from pictures;
    LENGTH(IMAGE)
    83794
    71189
    28521
    105542
    Image has been uploaded to the dataabase.

  • Reading contents of a BLOB datatype having more than 4000 characters.

    Hi,
    I am unable to read contents of a column having BLOB datatype.I tried using ult_raw.cast_varchar2(Col_name) procedure,but since varchar2 has a size limit of 4000 bytes,complete contents are not visible.
    Pl. suggest some way to view the contents.
    Regards,
    Saket Bansal

    In the link that you mentioned a procedure is used that gets the length first then loops through if length is greater than 32760.
    I mean to say can user get the output in a single SQL query e.g.
    select utl_raw.cast_to_varchar2(column_name) from table_name;something like this for bytes greater than 4000 bytes.
    ----- Read your reply a bit late thanks.
    Edited by: Avi on Mar 2, 2009 1:21 AM

  • Generating an xml from a pl/sql procedure

    Hi Friends,
    I have come up with a requirement to generate an xml from a pl/sql procedure.
    I did some R & D and also got some sample procedures but could not understand the datatypes being used.
    The procedure declares variables like this:
    doc                  xmldom.DOMDocument;
    mainNode         xmldom.DOMNode;
    headerElem      xmldom.DOMElement; Pls could anyone tell what do these xmldom.DOMDocument, xmldom.DOMNode and xmldom.DOMElement mean?
    Later in the procedure, these variables are assigned values like
    doc      := xmldom.newDOMDocument;
    mainNode := xmldom.makenode(doc); This went a bouncer on me.
    Pls help.
    Thanks in advance ...!

    You can check this one -- Learned this from michael.
    satyaki>
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    satyaki>
    satyaki>
    satyaki>with person_h
      2  as
      3    (
      4      select 1 id, 'M' gender, 'W' race, '170' weight from dual union all
      5      select 1, 'M', 'W', '170' from dual union all
      6      select 1, 'M', 'W', '180' from dual union all
      7      select 1, 'M', NULL, '175' from dual union all
      8      select 1, NULL, 'W', NULL from dual
      9    )
    10    select xmlelement("Person",(
    11                                 select xmlagg(xmlelement("Sex", gender))
    12                                 from (
    13                                        select distinct gender
    14                                        from person_h
    15                                        where id = 1
    16                                        and gender is not null
    17                                      ) pg
    18                                ),
    19                                (
    20                                  select xmlagg(xmlforest(race as "Race"))
    21                                  from (
    22                                         select distinct race
    23                                         from person_h
    24                                         where id = 1
    25                                       ) pg
    26                                ),
    27                                (
    28                                  select xmlagg(xmlforest(weight as "Weight"))
    29                                  from (
    30                                         select distinct weight
    31                                         from person_h
    32                                         where id = 1
    33                                       ) pg
    34                                 )
    35                     ).getstringval() Res
    36    from dual;
    RES
    <Person><Sex>M</Sex><Race>W</Race><Weight>170</Weight><Weight>175</Weight><Weight>180</Weight></Person>
    satyaki>Regards.
    Satyaki De.

  • Passing Queries to PL/SQL procedures

    Hi,
    Is there any way in PL/SQL procedure that i can pass two Queries Texts as parameters and return the result set by taking MINUS of the rwo Query results.
    Thanx in Advace
    Shafiq

    Here is the principle...
    SQL> conn scott/tiger
    Connected.
    SQL> CREATE OR REPLACE FUNCTION qry_minus
      2     (p1 IN VARCHAR2, p2 IN VARCHAR2)
      3     RETURN sys_refcursor
      4  IS
      5     return_value sys_refcursor;
      6  BEGIN
      7     OPEN return_value FOR p1||' MINUS '||p2;
      8     RETURN return_value;
      9  END;
    10  /
    Function created.
    SQL> VAR q refcursor
    SQL> exec :q := qry_minus('SELECT deptno FROM dept', 'SELECT deptno FROM emp')
    PL/SQL procedure successfully completed.
    SQL> print q
        DEPTNO
            40
    SQL> Obviously because the query is text strings the calling program is responsible for ensuring the validity of the two queries (matching number and datatype of selected columns, etc).
    Cheers, APC

  • Cannot view BLOB datatypes in Oracle10g

    After a successful upgrade from Oracle8i to Oracle10g, I cannot view tables with BLOB datatypes. I'm getting the following error in SQL*PLUS upon quering the table:
    SP2-0678: Column or attribute type can not be displayed by SQL*Plus
    When i try to do the same thing from TOAD, I'm getting this error instead:
    A Query with LOB's requires OC18 mode, but OC17 mode is used.
    I have also tried to create a new table with BLOB datatype (since i thought the culprit was a broken migrated data) but I got the same error. What am I missing here????

    Hy,
    you never could view blobs via sqlplus
    you only could use utl_raw.cast_to_varchar2 if there ist text inside your blobs.
    regard
    Martin

  • ORA-01458 error while using Pro*C to invoke PL/SQL procedure, pls help

    I am using Pro*C (Oracle 10g on Itanium platform) to invoke PL/SQL procedure to read RAW data from database, but always encoutered ORA-01458 error message.
    Here is the snippet of Pro*C code:
    typedef struct dataSegment
         unsigned short     len;
         unsigned char     data[SIZE_DATA_SEG];
    } msg_data_seg;
    EXEC SQL TYPE msg_data_seg IS VARRAW(SIZE_DATA_SEG);
         EXEC SQL BEGIN DECLARE SECTION;
              unsigned short qID;
              int rMode;
              unsigned long rawMsgID;
              unsigned long msgID;
              unsigned short msgType;
              unsigned short msgPriority;
              char recvTime[SIZE_TIME_STRING];
              char schedTime[SIZE_TIME_STRING];
              msg_data_seg dataSeg;
              msg_data_seg dataSeg1;
              msg_data_seg dataSeg2;
              short     indSeg;
              short     indSeg1;
              short     indSeg2;
         EXEC SQL END DECLARE SECTION;
         qID = q_id;
         rMode = (int)mode;
         EXEC SQL EXECUTE
              BEGIN
                   SUMsg.read_msg (:qID, :rMode, :rawMsgID, :msgID, :msgType, :msgPriority, :recvTime,
                        :schedTime, :dataSeg:indSeg, :dataSeg1:indSeg1, :dataSeg2:indSeg2);
              END;
         END-EXEC;
         // Check PL/SQL execute result, different from SQL
         // Only 'sqlcode' and 'sqlerrm' are always set
         if (sqlca.sqlcode != 0)
              if (sqlca.sqlcode == ERR_QUEUE_EMPTY)          // Queue empty
                   throw q_eoq ();
              char msg[513];                                        // Other errors
              size_t msg_len;
              msg_len = sqlca.sqlerrm.sqlerrml;
              strncpy (msg, sqlca.sqlerrm.sqlerrmc, msg_len);
              msg[msg_len] = '\0';
              throw db_error (string(msg), sqlca.sqlcode);
    and here is the PL/SQL which is invoked:
    SUBTYPE VarChar14 IS VARCHAR2(14);
    PROCEDURE read_msg (
         qID          IN     sumsg_queue_def.q_id%TYPE,
         rMode          IN     INTEGER,
         raw_msgID     OUT     sumsg_msg_data.raw_msg_id%TYPE,
         msgID          OUT sumsg_msg_data.msg_id%TYPE,
         msgType          OUT sumsg_msg_data.type%TYPE,
         msgPrior     OUT sumsg_msg_data.priority%TYPE,
         msgRecv          OUT VarChar14,
         msgSched     OUT VarChar14,
         msgData          OUT sumsg_msg_data.msg_data%TYPE,
         msgData1     OUT sumsg_msg_data.msg_data1%TYPE,
         msgData2     OUT sumsg_msg_data.msg_data2%TYPE
    ) IS
    BEGIN
         IF rMode = 0 THEN
              SELECT raw_msg_id, msg_id, type, priority, TO_CHAR(recv_time, 'YYYYMMDDHH24MISS'),
                   TO_CHAR(sched_time, 'YYYYMMDDHH24MISS'), msg_data, msg_data1, msg_data2
                   INTO raw_msgID, msgID, msgType, msgPrior, msgRecv, msgSched, msgData, msgData1, msgData2
                   FROM (SELECT * FROM sumsg_msg_data WHERE q_id = qID AND status = 0 ORDER BY sched_time, raw_msg_id)
                   WHERE ROWNUM = 1;
         ELSIF rMode = 1 THEN
              SELECT raw_msg_id, msg_id, type, priority, TO_CHAR(recv_time, 'YYYYMMDDHH24MISS'),
                   TO_CHAR(sched_time, 'YYYYMMDDHH24MISS'), msg_data, msg_data1, msg_data2
                   INTO raw_msgID, msgID, msgType, msgPrior, msgRecv, msgSched, msgData, msgData1, msgData2
                   FROM (SELECT * FROM sumsg_msg_data WHERE q_id = qID AND status = 0 ORDER BY recv_time, raw_msg_id)
                   WHERE ROWNUM = 1;
         ELSE
              SELECT raw_msg_id, msg_id, type, priority, TO_CHAR(recv_time, 'YYYYMMDDHH24MISS'),
                   TO_CHAR(sched_time, 'YYYYMMDDHH24MISS'), msg_data, msg_data1, msg_data2
                   INTO raw_msgID, msgID, msgType, msgPrior, msgRecv, msgSched, msgData, msgData1, msgData2
                   FROM (SELECT * FROM sumsg_msg_data WHERE q_id = qID AND status = 0 ORDER BY priority, raw_msg_id)
                   WHERE ROWNUM = 1;
         END IF;
         UPDATE sumsg_msg_data SET status = 1 WHERE raw_msg_id = raw_msgID;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
              raise_application_error (-20102, 'Queue empty');
    END read_msg;
    where sumsg_msg_data.msg_data%TYPE, sumsg_msg_data.msg_data1%TYPE and sumsg_msg_data.msg_data2%TYPE are all defined as RAW(2000). When I test the PL/SQL code seperately, everything is ok, but if I use the Pro*C code to read, the ORA-01458 always happen, unless I change the SIZE_DATA_SEG value to 4000, then it passes, and the result read out also seems ok, either the bigger or smaller value will encounter ORA-01458.
    I think the problem should happen between the mapping from internal datatype to external VARRAW type, but cannot understand why 4000 bytes buffer will be ok, is it related to some NLS_LANG settings, anyone can help me to resolve this problme, thanks a lot!

    It seems that I found the way to avoid this error. Now each time before I read RAW(2000) data from database, i initialize the VARRAW.len first, set its value to SIZE_DATA_SEG, i.e., the outside buffer size, then the error disappear.
    Oracle seems to need this information to handle its data mapping, but why output variable also needs this initialization, cannot precompiler get this from the definition of VARRAW structure?
    Anyone have some suggestion?

  • Error while pasing arrays to pl/sql procedure

    Hi,
    I am trying to pass an array from java to pl/sql procedure.
    I tried this code:
    CREATE OR REPLACE TYPE HEADER_UPLOAD IS OBJECT
    (VENDOR_NAME VARCHAR2(240) --hr_all_organization_units.name%TYPE
    ,BILL_TO_CUSTOMER_NAME VARCHAR2(240)-- hz_parties.party_name%TYPE
    ,BILL_TO_CUSTOMER_NUMBER VARCHAR2(240) --hz_cust_accounts.account_number%TYPE
    ,BILL_TO_SITE_USE_ID VARCHAR2(240) --hz_cust_site_uses_all.site_use_id%TYPE
    ,RESELLER_NAME VARCHAR2(240) --hz_parties.party_name%TYPE
    ,RESELLER_ADDRESS_1 VARCHAR2(240)--hz_locations.address1%TYPE
    ,RESELLER_ADDRESS_2 VARCHAR2(240)--hz_locations.address2%TYPE
    ,RESELLER_ADDRESS_3 VARCHAR2(240)--hz_locations.address3%TYPE
    ,RESELLER_ADDRESS_4 VARCHAR2(240)--hz_locations.address4%TYPE
    ,RESELLER_COUNTRY VARCHAR2(240)--hz_locations.country%TYPE
    ,RESELLER_STATE VARCHAR2(240) --hz_locations.state%TYPE
    ,RESELLER_CITY VARCHAR2(240)--hz_locations.city%TYPE
    ,RESELLER_POSTAL_CODE VARCHAR2(240)--hz_locations.postal_code%TYPE
    ,FEDERAL_GOVT_END_USER VARCHAR2(240)
    ,END_USER_NAME VARCHAR2(240)--hz_parties.party_name%TYPE
    ,END_USER_ADDRESS_1 VARCHAR2(240)--hz_locations.address1%TYPE
    ,END_USER_ADDRESS_2 VARCHAR2(240)--hz_locations.address2%TYPE
    ,END_USER_ADDRESS_3 VARCHAR2(240)--hz_locations.address3%TYPE
    ,END_USER_ADDRESS_4 VARCHAR2(240)--hz_locations.address4%TYPE
    ,END_USER_COUNTRY VARCHAR2(240)-- hz_locations.country%TYPE
    ,END_USER_STATE VARCHAR2(240) --hz_locations.state%TYPE
    ,END_USER_CITY VARCHAR2(240) --hz_locations.city%TYPE
    ,END_USER_POSTAL_CODE VARCHAR2(240)--hz_locations.postal_code%TYPE
    ,END_USER_CONTACT_NAME VARCHAR2(240)
    ,END_USER_EMAIL VARCHAR2(2000)
    ,SHIP_TO_CUSTOMER_NAME VARCHAR2(240)--ra_customers.customer_name%TYPE
    ,SHIP_TO_ADDRESS_1 VARCHAR2(240) --hz_locations.address1%TYPE
    ,SHIP_TO_ADDRESS_2 VARCHAR2(240) --hz_locations.address2%TYPE
    ,SHIP_TO_ADDRESS_3 VARCHAR2(240) --hz_locations.address3%TYPE
    ,SHIP_TO_ADDRESS_4 VARCHAR2(240) --hz_locations.address4%TYPE
    ,SHIP_TO_COUNTRY VARCHAR2(240) --hz_locations.country%TYPE
    ,SHIP_TO_STATE VARCHAR2(240) --hz_locations.state%TYPE
    ,SHIP_TO_CITY VARCHAR2(240)--hz_locations.city%TYPE
    ,SHIP_TO_POSTAL_CODE VARCHAR2(240)--hz_locations.postal_code%TYPE
    ,SHIP_TO_CONTACT_NAME VARCHAR2(240)
    ,SHIP_TO_CONTACT_PHONE VARCHAR2(50)
    ,SHIPPING_INSTRUCTIONS VARCHAR2(240)--oe_order_headers_all.shipping_instructions%TYPE
    ,SHIPPING_METHOD VARCHAR2(240) --fnd_lookup_values.meaning%TYPE
    ,ALERT_EMAIL VARCHAR2(2000)
    ,LICENSE_EMAIL VARCHAR2(2000)
    ,ORDER_CONTACT_FIRST_NAME VARCHAR2(150)
    ,ORDER_CONTACT_LAST_NAME VARCHAR2(150)
    ,ORDER_CONTACT_PHONE VARCHAR2(50)
    ,ORDER_CONTACT_FAX_NUMBER VARCHAR2(50)
    ,ORDER_CONTACT_EMAIL VARCHAR2(2000)
    ,NOTES VARCHAR2(4000)
    ,CURRENCY_CODE VARCHAR2(240) --fnd_currencies.currency_code%TYPE
    ,SERVICE_RENEWAL_ORDER varchar2(10)
    ,CUSTOMER_PO_NUMBER VARCHAR2(240) --oe_order_headers_all.cust_po_number%TYPE
    ,RESUBMITTED_ORDER VARCHAR2(10)
    ,PREV_CUSTOMER_PO_NUMBER VARCHAR2(240) --oe_order_headers_all.cust_po_number%TYPE
    ,END_USER_PO_NUMBER VARCHAR2(50)
    ,PO_NET_TOTAL NUMBER
    ,FOB VARCHAR2(240) --fnd_lookup_values.meaning%TYPE
    ,FREIGHT_TERMS VARCHAR2(240) --fnd_lookup_values.meaning%TYPE
    ,FREIGHT_ACCOUNT_NUMBER VARCHAR2(200)
    create or replace type header_upload_tab is table of header_upload;
    java code is: this is a java class which first inserts the csv file data into array headerdata
    public static String[] parseCSV(long l)
    throws SQLException, FrameworkException, IOException
    String s = "parseCSV";
    String lResult[] = new String[3];
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "Start");
    OracleConnection oracleconnection = (OracleConnection)TransactionScope.getConnection();
    OraclePreparedStatement oraclepreparedstatement = null;
    OracleResultSet oracleresultset = null;
    BLOB blob = null;
    long l1 = System.currentTimeMillis();
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "Before fetching the File data from FND_LOBS");
    oraclepreparedstatement = (OraclePreparedStatement)oracleconnection.prepareStatement(" SELECT FILE_DATA FROM FND_LOBS WHERE FILE_ID = :1 ");
    oraclepreparedstatement.defineColumnType(1, 2004);
    oraclepreparedstatement.setLong(1, l);
    try
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "Before Executing the query");
    oracleresultset = (OracleResultSet)oraclepreparedstatement.executeQuery();
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "After Executing the query");
    while(oracleresultset.next())
    blob = (BLOB)oracleresultset.getObject(1);
    finally
    if(oracleresultset != null)
    oracleresultset.close();
    if(oraclepreparedstatement != null)
    oraclepreparedstatement.close();
    if(oracleconnection != null)
    TransactionScope.releaseConnection(oracleconnection);
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "Time taken to get the BLOB object(" + (System.currentTimeMillis() - l1) + " milliseconds)");
    l1 = System.currentTimeMillis();
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "Get the stream from the BLOB");
    InputStreamReader inputstreamreader = new InputStreamReader(blob.getBinaryStream());
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "Before creating the csvreader");
    xxbcIbeOrderUploadCSVReader OrderUploadcsvreader = new xxbcIbeOrderUploadCSVReader(inputstreamreader);
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "After creating the csvreader");
    OrderUploadcsvreader.setFieldSeparator(",");
    OrderUploadcsvreader.setHandleEscapes(true);
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "Before getting the headers");
    // Fetch the Header Record
    ArrayList arraylistH = OrderUploadcsvreader.getHeaders();
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "After getting the headers");
    String s1 = (String)arraylistH.get(0);
    if ("HEADER".equals(s1))
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "Parse and Create the Header Record");
    // Fetch the Header Data. This data will be inserted into Staging table, XXBC_IBE_ORDER_HEADER_IFACE
    ArrayList arraylistHData = OrderUploadcsvreader.readRecord();
    String headerData[] = new String[60];
    for(int i = 1; i < arraylistH.size(); i++) {
    headerData[i] = "";
    for(int i = 1; i < arraylistH.size(); i++)
    String h_element = (String)arraylistH.get(i);
    String h_value = (String)arraylistHData.get(i);
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, h_element);
    if ("VENDOR NAME*".equals(h_element)) headerData[1] = h_value;
    if ("BILL TO CUSTOMER*".equals(h_element)) headerData[2] = h_value;
    if ("BILL TO CUSTOMER NUMBER*".equals(h_element)) headerData[3] = h_value;
    if ("BILL TO SITE NUMBER*".equals(h_element)) headerData[4] = h_value;
    if ("RESELLER*".equals(h_element)) headerData[5] = h_value;
    if ("RESELLER ADDRESS LINE 1*".equals(h_element)) headerData[6] = h_value;
    if ("RESELLER ADDRESS LINE 2".equals(h_element)) headerData[7] = h_value;
    if ("RESELLER ADDRESS LINE 3".equals(h_element)) headerData[8] = h_value;
    if ("RESELLER ADDRESS LINE 4".equals(h_element)) headerData[9] = h_value;
    if ("RESELLER COUNTRY*".equals(h_element)) headerData[10] = h_value;
    if ("RESELLER STATE*".equals(h_element)) headerData[11] = h_value;
    if ("RESELLER CITY*".equals(h_element)) headerData[12] = h_value;
    if ("RESELLER POSTAL CODE*".equals(h_element)) headerData[13] = h_value;
    if ("FEDERAL GOVT END USER".equals(h_element)) headerData[14] = h_value;
    if ("END USER*".equals(h_element)) headerData[15] = h_value;
    if ("END USER ADDRESS LINE 1*".equals(h_element)) headerData[16] = h_value;
    if ("END USER ADDRESS LINE 2".equals(h_element)) headerData[17] = h_value;
    if ("END USER ADDRESS LINE 3".equals(h_element)) headerData[18] = h_value;
    if ("END USER ADDRESS LINE 4".equals(h_element)) headerData[19] = h_value;
    if ("END USER COUNTRY*".equals(h_element)) headerData[20] = h_value;
    if ("END USER STATE*".equals(h_element)) headerData[21] = h_value;
    if ("END USER CITY*".equals(h_element)) headerData[22] = h_value;
    if ("END USER POSTAL CODE*".equals(h_element)) headerData[23] = h_value;
    if ("END USER CONTACT**".equals(h_element)) headerData[24] = h_value;
    if ("END USER CONTACT EMAIL**".equals(h_element)) headerData[25] = h_value;
    if ("SHIP TO CUSTOMER*".equals(h_element)) headerData[26] = h_value;
    if ("SHIP TO ADDRESS LINE 1*".equals(h_element)) headerData[27] = h_value;
    if ("SHIP TO ADDRESS LINE 2".equals(h_element)) headerData[28] = h_value;
    if ("SHIP TO ADDRESS LINE 3".equals(h_element)) headerData[29] = h_value;
    if ("SHIP TO ADDRESS LINE 4".equals(h_element)) headerData[30] = h_value;
    if ("SHIP TO COUNTRY*".equals(h_element)) headerData[31] = h_value;
    if ("SHIP TO STATE*".equals(h_element)) headerData[32] = h_value;
    if ("SHIP TO CITY*".equals(h_element)) headerData[33] = h_value;
    if ("SHIP TO POSTAL CODE*".equals(h_element)) headerData[34] = h_value;
    if ("SHIP TO CONTACT**".equals(h_element)) headerData[35] = h_value;
    if ("SHIP TO CONTACT PHONE NUMBER**".equals(h_element)) headerData[36] = h_value;
    if ("SHIPPING INSTRUCTIONS".equals(h_element)) headerData[37] = h_value;
    if ("SHIPPING METHOD*".equals(h_element)) headerData[38] = h_value;
    if ("ALERT EMAIL*".equals(h_element)) headerData[39] = h_value;
    if ("LICENSE EMAIL**".equals(h_element)) headerData[40] = h_value;
    if ("ORDER CONTACT FIRST NAME*".equals(h_element)) headerData[41] = h_value;
    if ("ORDER CONTACT LAST NAME*".equals(h_element)) headerData[42] = h_value;
    if ("ORDER CONTACT PHONE NUMBER*".equals(h_element)) headerData[43] = h_value;
    if ("ORDER CONTACT FAX NUMBER".equals(h_element)) headerData[44] = h_value;
    if ("ORDER CONTACT EMAIL*".equals(h_element)) headerData[45] = h_value;
    if ("NOTES".equals(h_element)) headerData[46] = h_value;
    if ("CURRENCY*".equals(h_element)) headerData[47] = h_value;
    if ("SERVICE RENEWAL ORDER".equals(h_element)) headerData[48] = h_value;
    if ("CUSTOMER PO NUMBER*".equals(h_element)) headerData[49] = h_value;
    if ("RESUBMISSION*".equals(h_element)) headerData[50] = h_value;
    if ("PREVIOUS CUSTOMER PO NUMBER**".equals(h_element)) headerData[51] = h_value;
    if ("END USER PO NUMBER".equals(h_element)) headerData[52] = h_value;
    if ("PO NET TOTAL*".equals(h_element)) headerData[53] = h_value;
    if ("FOB*".equals(h_element)) headerData[54] = h_value;
    if ("FREIGHT TERMS*".equals(h_element)) headerData[55] = h_value;
    if ("FREIGHT ACCOUNT NUMBER".equals(h_element)) headerData[56] = h_value;
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, (String)headerData);
    } // End of processing Header Data
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "Insert the Header Record into Interface Table");
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, (String)headerData[1]);
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, (String)headerData[2]);
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "checkpoint");
    oracleconnection = (OracleConnection)TransactionScope.getConnection();
    oracleconnection.setAutoCommit(true);
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "After getting connection");
    ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor( "HEADER_UPLOAD_TAB", oracleconnection );
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "before new array");
    ARRAY array_to_pass = new ARRAY( descriptor, oracleconnection, headerData );
    if(IBEUtil.logEnabled())
    IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "calling procedure");
    OraclePreparedStatement ps =
    (OraclePreparedStatement)oracleconnection.prepareStatement ( "BEGIN insert_data(:1); END;" );
    ps.setARRAY( 1, array_to_pass );
    ps.execute();.......continued
    the above code executes till the message :---IBEUtil.log("oracle.apps.ibe.shoppingcart.util.OrderUploadCSVReader", s, "before new array");
    after that it gives error as :---Exception=java.sql.SQLException: Fail to convert to internal representation
    Kindly Help....
    Thanks in advance
    Gaurav

    Gaurav,
    Just a guess, but try the following:
    ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor( "SCOTT.HEADER_UPLOAD_TAB", oracleconnection );In other words, prefix the data-type name, HEADER_UPLOAD_TAB, with its schema owner name.
    Good Luck,
    Avi.

  • Problem with special chars in BLOB datatype using contains keyword

    Facing problem, when part searching with special chars in BLOB datatype. It is considering the non alpha-numeric chars as a separtor in a provided string
    EX:
    SELECT *
    FROM RESUME_TEST P,grst_candidate d
    WHERE d.candidate_id = p.candidate_id
    AND CONTAINS(P.CAND_RESUME,'%VB.NET%',1) > 0
    Strings: , VB.NET , PL/SQL AS/400 , C etc..
    Followed the below approaches
    1) created a table:
    Syntax: create table resume_Test(cand_id number(10),cand_resume blob);
    2) inserted the values into this table upto 60,000
    3) created a context index
    3.1 created preferences
    Syntax:
    BEGIN
    ctx_ddl.create_preference('try_lexer3','BASIC_LEXER');
    ctx_ddl.set_attribute('try_lexer3','printjoins','-_~!@#$%^&*(){}[],=?\;|><.+');
    END;
    3.2 created context index
    Syntax:
    CREATE INDEX CANDRESUME_CTX_IDX ON resume_test (cand_resume)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS ('LEXER try_lexer3 memory 500M');
    4) while executing this index, it is taking much time approx 6 hrs(plz explain why it is taking time)
    5) Problems:
    5.1 when searching with string(VB.NET , PL/SQL AS/400 , C etc..) it is considering the special char as a separator
    5.2 used escape char (\) also, but no effect
    5.3 when searching with single char, it is giving error (ORA-29902,ORA-20000,DRG-51030)
    5.4 getting the above error with wild card chars (& ,_, (),{},[])
    So, please explain the clear scenarios, why am getting this error , and how to get the proper results.

    Have you tried adding the / char to the printjoin characters?
    Indexing can take a lot of time, depending on the amount of data and your machine's power. You could try to parallelize the index creation and / or assign more memory
    CREATE INDEX CANDRESUME_CTX_IDX ON resume_test (cand_resume)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS ('LEXER try_lexer3 memory 2000M') PARALLEL 8;

  • How we handle CLOB and BLOB Datatypes in HANA DB

    Dear HANA Gurus,
    We have would like to build EDW using HANA base on our source system Oracle and it's supports CLOB and BLOB datatypes
    Would you please suggest how do we handle in HANA DB.
    Let not say it's oracle specific.
    Regards,
    Manoj

    Hello,
    check SAP HANA SQL Reference Guide for list of data types:
    (page 14 - Classification of Data Types)
    https://service.sap.com/~sapidb/011000358700000604922011
    For this purpose might be useful following data types:
    Large Object (LOB) Types
    LOB (large objects) data types, CLOB, NCLOB and BLOB, are used to store a large amount of data such as text documents and images. The maximum size of an LOB is 2 GB.
    BLOB
    The BLOB data type is used to store large binary data.
    CLOB
    The CLOB data type is used to store large ASCII character data.
    NCLOB
    The NCLOB data type is used to store a large Unicode character object.
    Tomas

  • Redirect From PL/SQL Procedure

    Hi
    I hope this is a relatively straightforward question, but I am having trouble getting a page redirect to work from a PL/SQL procedure.
    I call the following procedure:-
    CREATE OR REPLACE PROCEDURE DOWNLOAD_FILE(p_id NUMBER) AS
    v_mime VARCHAR2(200);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    lob_loc BLOB;
    v_session VARCHAR2(100);
    BEGIN
    v_session := v('SESSION');
    SELECT MIME_TYPE,
    FILE_CONTENT,
    FILE_NAME,
    DBMS_LOB.GETLENGTH(FILE_CONTENT)
    INTO v_mime,
    lob_loc,
    v_file_name,
    v_length
    FROM SRGSUP_UPLOADED_FILES
    WHERE ID = p_id;
    owa_util.mime_header(nvl(v_mime,'application/octet'),FALSE);
    htp.p('Content-length: ' || v_length);
    htp.p('Content-Disposition: attachment; filename="' || v_file_name || '"');
    owa_util.http_header_close;
    wpg_docload.download_file(lob_loc);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    htp.p('Location: f?p=107:30');
    END DOWNLOAD_FILE;
    From the following HTML Expression in column formatting of a report:-
    #FILE_NAME#: [ <a href="#OWNER#.DOWNLOAD_FILE?p_id=#FILE_ID#">Download</a> ]
    When the table SRGSUP_UPLOADED_FILES contains the relevant document the file download works perfectly. However, if there is no file present I wanted the page to redirect back to itself. Instead it goes to the login page.
    Initially I thought it was losing the session details so I tried "htp.p('Location: f?p=107:30:'||v('SESSION'));" but this made no difference.
    Any help would be appreciated.
    Thanks
    Chris
    Message was edited by:
    chrisjcoe

    Hi
    <p>I hope this is a relatively straightforward question, but I am having trouble getting a page redirect to work from a PL/SQL procedure. </p>
    <p>I call the following procedure:- </p>
    CREATE OR REPLACE PROCEDURE DOWNLOAD_FILE(p_id NUMBER) AS
    v_mime VARCHAR2(200);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    lob_loc BLOB;
    BEGIN
      SELECT MIME_TYPE,
             FILE_CONTENT,
             FILE_NAME,
             DBMS_LOB.GETLENGTH(FILE_CONTENT)
      INTO v_mime,
           lob_loc,
           v_file_name,
           v_length
      FROM SRGSUP_UPLOADED_FILES
      WHERE ID = p_id;
      owa_util.mime_header(nvl(v_mime,'application/octet'),FALSE);
      htp.p('Content-length: ' || v_length);
      htp.p('Content-Disposition: attachment; filename="' || v_file_name || '"');
      owa_util.http_header_close;
      wpg_docload.download_file(lob_loc);
      EXCEPTION WHEN NO_DATA_FOUND THEN
      htp.p('Location: f?p=107:30');
    END DOWNLOAD_FILE;
    <p>From the following HTML Expression in column formatting of a report:- </p>
    [pre]
    "#FILE_NAME#: [ <*a h*ef="#OWNER#.DOWNLOAD_FILE?p_id=#FILE_ID#">Download</*a> ] "I've only put an "*" in <*a and </*a> to stop it changing into a url.
    <p>When the table SRGSUP_UPLOADED_FILES contains the relevant document the file download works perfectly. </p>
    <p>However, if there is no file present I wanted the page to redirect back to itself. Instead it goes to the login page. </p>
    <p>Initially I thought it was losing the session details so I tried "htp.p('Location: f?p=107:30:'||v('SESSION'));" but this made no difference. </p>
    <p>Any help would be appreciated. </p>
    <p>Thanks </p>
    <p>Chris</p>

Maybe you are looking for