Problem with comparion of clobs in stored procedure

Hi ,
i have a stored procedure which involves a clob variable and a string comparison.
Below is my procedure
CREATE OR REPLACE PROCEDURE TEMP_SP (
empId IN VARCHAR2)
IS
tempStr CLOB :='Hello';
finalStr CLOB :='world';
BEGIN
IF finalStr = 'xxx' THEN
tempStr := ' ';
finalStr := finalStr || empId;
END IF;
IF trim(finalSqltoCur) IS NOT NULL AND tempStr <> ' ' THEN
finalStr := finalStr || ' and ' || tempStr;
ELSE
finalStr := finalStr || tempStr;
END IF;
dbms_output.put_line('=========final string value======' || finalStr);
END TEMP_SP;
I would like to know why it goes to the else block as tempStr <> ' ' will be true
and trim(finalSqltoCur) IS NOT NULL also results as true.
It would be great if some one could help me with this.
Regards
Shyam

> trim(finalStr) IS NOT NULL AND tempStr <> ' '
And this is (TRUE AND TRUE) and evaluates to TRUE - which means the ELSE block will not be executed,
SQL> declare
2 empId number := 123;
3 tempStr CLOB :='Hello';
4 finalStr CLOB :='world';
5 begin
6 IF finalStr = 'xxx' THEN
7 tempStr := ' ';
8 finalStr := finalStr || empId;
9 END IF;
10
11
12 IF trim(finalStr) IS NOT NULL AND tempStr <> ' ' THEN
13 finalStr := finalStr || ' and ' || tempStr;
14 ELSE
15 finalStr := finalStr || tempStr;
16 END IF;
17
18 DBMS_OUTPUT.put_line('=========final string value======' || finalStr);
19 end;
20 /
=========final string value======world and Hello
PL/SQL procedure successfully completed.
SQL>
Tested on Oracle 10.2.0.1.

Similar Messages

  • Problem with JDBC results calling simple stored procedure in VC 7.0

    Hi all,
    I am building a simple VC model which calls a stored procedure on a JDBC database. I have created the system in the portal, defined the alias and user mapping, the connection test is fine and the VC "find data" lists my bespoke stored procedure.
    The stored procedure is :
    CREATE PROCEDURE dbo.dt_getBieUsers
    AS
    select * from dbo.emailuserlink
    GO
    When I test it using query analyser, it returns 3 records each with the two fields I expect - user and email address.
    I drag the model onto the workspace in VC and create an input form ( with just a submit button ). i drag the result port out to create a table. This has no fields in it.
    I build and deploy as flex and the app runs, I click the submit button and SUCCESS! I get 3 records in my table each with 2 fields. The data is all correct. The problem with this is the fields are determined at runtime it seems.
    I go back to the table and add 2 columns "email" and "address".
    i build and deploy and run the app. Again I get 3 records, but this time the contents of all of the rows is not data, but "email" and "address". The data has been replaced by the header texts in all of the rows.
    Can anyone help? Why isn't the data being put in my columns as I would expect?
    I tried to build and deploy the app as Web Dynpro rather than Flex to see if it was a bug in Flex. The application starts but when I click the submit button to run the JDBC stored procedure I get a 500 Internal Server Error
    com.sap.tc.wd4vc.intapi.info.exception.WD4VCRuntimeException: No configuration is defined for the entry JDBCFunction
        at com.sap.tc.wd4vc.xglengine.XGLEngine.createComponentInternal(XGLEngine.java:559)
        at com.sap.tc.wd4vc.xglengine.XGLEngine.getCompInstanceFromUsage(XGLEngine.java:362)
        at com.sap.tc.wd4vc.xglengine.XGLEngine.getCompInstance(XGLEngine.java:329)
        at com.sap.tc.wd4vc.xglengine.wdp.InternalXGLEngine.getCompInstance(InternalXGLEngine.java:167)
        at com.sap.tc.wd4vc.xglengine.XGLEngineInterface.getCompInstance(XGLEngineInterface.java:165)
    The JDBC connection I am using has a connection URL of jdbc:sap:sqlserver://localhost;DatabaseName=BIEUSERS
    and a driver class of com.sap.portals.jdbc.sqlserver.SQLServerDriver
    Can anyone solve my wierd problems?
    Cheers
    Richard

    Hi Richard,
    After you drag and drop the data service, right click on it and choose "Test data service". Then click on "Execute" and after you see the result on the right, click on "Add fields" button (inside the same window). Now you'll see that the fields are on the tabel. This is required only for JDBC data services, since this data (how the resultset is built) is not know in DT and it needs to be run firest - then analysed and only then you have to add the fields to the table).
    Regards,
    Natty

  • Problem with execute SSIS package from stored procedure

    Hi,
    I would like to execute SSIS package from stored procedure. Therefore, I implemented sp which exec SSISDB.CATALOG.CREATE_EXECUTION method. When I try to test it from SSMS on remote server, I got error that
    I was able to solve by adding “WITH EXECUTE AS …”. Then I got another error: The server principal "Domain\user" is not able to access the database "SSISDB" under the current security context. On Internet, I found a couple post that describe
    how to access SSIS catalog (one of them by Ke Yang -
    http://blogs.msdn.com/b/mattm/archive/2012/03/20/ssis-catalog-access-control-tips.aspx). It didn’t help. I’m still getting the error message.
    How to debug this issue?
    Any suggestion?
    Thanks
    SQL Server 2014 BI

    SSMS does not propagate user credentials thus the error
    Arthur
    MyBlog
    Twitter

  • Issue with Executing OS commands from Stored Procedure

    I am trying to execute the scripts provided at :
    http://github.com/xtender/XT_SHELL
    provided by xtender user.
    As required, I have asked my DBAs to grant privileges by executing the following scripts:
    Begin
      --change to needed permissions and execute
      dbms_java.grant_permission( 'ODS', 'SYS:java.io.FilePermission', '/var/factiva/ODS/bin/CVIM_Rpt_ExportCSVFile’, 'read,write,execute' );
    end;
    /where CVIM_Rpt_ExportCSVFile is my script residing in the Unix server where my Oracle is installed.
    The error I am facing when I try to execute the following command is:
    select * from table(xt_shell.shell_exec('/var/scripts/CVIM_Rpt_ExportCSVFile',100))
    Exception:the Permission (java.io.FilePermission /var/scripts/CVIM_Rpt_ExportCSVFile execute) has not been granted to ODS. The PL/SQL to grant this is dbms_java.grant_permission( 'ODS', 'SYS:java.io.FilePermission', '/var/scripts/CVIM_Rpt_ExportCSVFile', 'execute' )I have asked my DBA to also execute the following scripts: - But I still see the same error as above. I am not able to figure out whats going on. Can anyone pls help me out??
    EXEC Dbms_Java.Grant_Permission('ODS', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    EXEC Dbms_Java.Grant_Permission(ODS', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    dbms_java.grant_permission( 'ODS', 'SYS:java.io.FilePermission', '/var/scripts/CVIM_Rpt_ExportCSVFile', 'execute' )

    DUPLICATE
    ===============================================================
    Issue with Executing OS commands from Stored Procedure
    ==============================================================

  • $200 reward to solve problem with JDBC and CLOB.getCharacterOutputStream

    I'm trying to update CLOB with the getCharacterOutputStream as suggested in the example code. It works with US7ASCII DB instance but not instances in UTF8.
    I've been browsing through all the Oracle doc's and found some rather confusing statements:
    In the page at http://oradoc.photo.net/ora816/java.816/a81354/oralob2.htm#1043220
    it says: [When writing to or reading from a CLOB, the JDBC drivers perform all character set conversions for you.]
    also: [The oracle.sql.CLOB class supports all the character sets that the Oracle data server supports for CLOB types.]
    So far so good.
    In the page at http://oradoc.photo.net/ora816/java.816/a81354/oraint3.htm#1012518
    it says [The oracle.sql package supports these datatypes in several ways: CLOBs point to large fixed-width character data items (that is, characters that require a fixed number of bytes per character) and are supported by the oracle.sql.CLOB class.]
    Ooh no! Is this for real? UTF8 is variable width and does this mean it is not supported?
    Any way to get around this?
    In the page at http://oradoc.photo.net/ora816/java.816/a81358/03_pub2.htm#36009
    says [6.The mappings to oracle.sql classes are optimal because they preserve data formats and require no character-set conversions (apart from the usual network conversions). Those classes are especially useful in applications that "shovel" data between SQL and Java.]
    "No character set conversion"? Very confusing!
    I've been hammering on this CLOB/JDBC/UTF8 problem for more than a week now and I really appreciate some solutions, workarounds, or whatever help I can get. I'm running java stored procedure in 8.1.6 on Linux RH6.2.
    For your trouble, I'd pay $200 for the first guy who come up with a verifiable solution.

    This is just findings based upon your comments:
    Please refer to document Oracle8i National Language Support Guide
    Release 2 (8.1.6) from Oracle Documentation Library, Release 8.1.7
    Chapter 6 Java,
    There its clearly mention that:
    "Oracle JDBC drivers provide globalization support by allowing users to retrieve data from or insert data into a database in any character set that Oracle supports. Because Java strings are UCS2 encoded (16-bit Unicode) for JDBC programs, the target character set on the client is always UCS2. Character set conversion is required to convert data from the database character set (Db Charset) to UCS2. This applies to CHAR, LONG, CLOB, and VARCHAR2 data types; RAW data is not converted. "
    Also..please refer this...
    "oracle.sql.CLOB's method getCharacterStream() returns the contents of a CLOB as a Unicode stream."
    "The techniques that Oracle's drivers use to perform character set conversion for Java applications depend on the character set the database uses. The simplest case is where the database uses a US7ASCII or WE8ISO8859P1 character set. In this case, the driver converts the data directly from the database character set to UCS2,which is used in Java applications. "
    "If you are working with databases that employ a non-US7ASCII or non-WE8ISO8859P1 character set (for example, Japanese or Korean), then the driver converts the data, first to UTF8, then to UCS2. "
    In my case the characte-set of the database is WE8ISO8859P1 and for security reason i can't change the character set but my feeling is that if you are updating the CLob from the java client you are forming a reference of a clob in the client which is UCS2 at the Java side. Now when you are populating the clob through java.io.Writer and call the procedure to pass the reference of the clob to the procedure then I believe the JDBC will convert the UCS2 datatype of Clob to UTF8 in the database.
    You can try out the code snippet:
    package ServletGDC;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import oracle.sql.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import ClassesGDC.*;
    public class testUpload extends HttpServlet {
    private String m_strMessage="";//It stores the message to be uploaded along with the Document
    Connection conn=null;
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    String strContent="";
    //res.setContentType("application/msword");
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    try {
    CallableStatement cmt=null;
    OutputStream output=null;
    ByteArrayOutputStream byteoutput=null;
    String strDocString="";
    oracle.sql.CLOB tempClob = null;
    String strPassedFileName="";     // the file name passed in the request object
    String strStdFilename="";//the file name to be given to the best practice
    String strSaveDirectory="";     //the directory in which the bp is to be saved
    String strParamName="";//name of parameters
    String strParamValue="";//value of parameters
    int intTempVariable=0; // temporaty variable
    long lngSizeOfFileUploaded=0;//stores the size of the file which had been uploaded in the file system
    File filePathOfFileUploaded=null;//stores the path of the file uploaded to the file system
    String strQuery="";
    //ST------------checks if the user has logged in or not-----------------------
    HttpSession session=req.getSession(true);
    if(req.getContentLength()>20*1024*1024)
    throw new skip("The size of the posted content is more than 10 MB . If you have a best practice whose size is more than 1 MB please mail it to Us.");
    byteoutput = new ByteArrayOutputStream();
    MultipartParser mp = new MultipartParser(req, 20*1024*1024); // 10MB is the limit of the file to be uploaded
    Part part;//Its an abstact part which helps in retrieving information about the file and the parameters
    while ((part = mp.readNextPart()) != null) {//Reads the next part
    strParamName = part.getName();
    // the following if is executed if the part is for a parameter rather than a file
    if (part.isParam()) {
    }else if (part.isFile()) {
    // it's a file part
    m_strMessage="inside file part";
    FilePart filePart = (FilePart) part;
    strPassedFileName = filePart.getFileName();
    strContent= filePart.getContentType();
    out.println("<BR><font color=red>strPassedFileName is "+strPassedFileName+"</font>");
    if(strPassedFileName != null || !(strPassedFileName.trim().equals("")) ) {
    // the part actually contained a file
    out.println("<BR><font color=red> before forming long</font>");
    //lngSizeOfFileUploaded = filePart.writeTo(filePathOfFileUploaded);      //the statement upload the bestpractice in the
    lngSizeOfFileUploaded = filePart.writeTo(byteoutput);     //specified file path filePathOfFileUploaded.
    out.println("<BR><font color=red> after file is written into the outputstream</font>");
    else {
    throw new skip("The file name is null or it is empty space. Files in such Format are not accepted");
    }//end of else if
    }//end of while loop
    if(     lngSizeOfFileUploaded==0)     {// the size of the file uploaded is zero then the file supplied was not proper and hence exception is to be thrown
    //if(filePathOfFileUploaded.exists())
    //     filePathOfFileUploaded.delete();
    throw new skip("The File could not be uploaded,Possible reasons may be that the file is sent null or the file is corrupted");
    //END---------------the file is uploaded in the proper directory--------------------
    //res.setContentType(strContent);
    out.println("<BR><font color=red>long value is : "+lngSizeOfFileUploaded+" and content is "+strContent+"</font>");
    String strbyte= byteoutput.toString();
    byteoutput.flush();
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // Establish network connection to database
    conn = DriverManager.getConnection("jdbc:oracle:thin:@pc-p32670:1521:GDCDBI","gdc_user","myuser");
    //if(conn!=null)
    out.println("<BR><font color=red>Connection formed"+conn);
    //els
    //out.println("<BR><font color=red>long value is : "+strbyte+"</font>");
    try{
    tempClob = oracle.sql.CLOB.createTemporary(conn,true, oracle.sql.CLOB.DURATION_SESSION);
    out.println("<BR><font color=red>tempClob : "+tempClob);
    tempClob.open( oracle.sql.CLOB.MODE_READWRITE);
    java.io.Writer tempClobWriter = tempClob.getCharacterOutputStream();
    // writing the string formed from the multipart file to the clob
    tempClobWriter.write(strbyte);
    if(tempClob!=null){}
    out.println("<BR><font color=red>CLOB value is : "+tempClob+"</font>");
    strQuery="{call INSERT_CLOB(?,?)}";
    cmt=conn.prepareCall(strQuery);
    cmt.setString(1,strPassedFileName);
    cmt.setClob(2,tempClob);
    cmt.registerOutParameter(2,java.sql.Types.CLOB);
    cmt.execute();
    tempClobWriter.flush();
    tempClobWriter.close();
    tempClob.freeTemporary();
    //res.setContentType(strContent);
    //strDocString.toString();
    out.println("<BR><font color=red>bob is "+strbyte+"</font>");
    tempClob.close();
    }catch(Exception e){
    tempClob.close();
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    //e.printStackTrace(out);
    cmt.close();
    //out.println("<BR><font color=red><h2><b>SUCCESS</h2></font>");
    //res.sendRedirect("../test/showfile.jsp?contentype="+strContent.trim()+"");
    }catch(Exception e){
    java.util.Date d = new java.util.Date();
    String s =d.toString();
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    //e.printStackTrace(out);
    }finally{
    try{
    if(conn!=null)
    conn.close();
    }catch(Exception e){
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    }// end of finally
    } //end of doPost
    } //end of class
    in the Procedure you will be inserting/updating the clob in a table with the reference clob in the out parameter of the procedure
    Thanks.

  • Write CLOB in stored procedure from a passed Long over 4k

    Hi,
    I have a requirement to write a CLOB into a table as part of a stored procedure. The data to be written is passed in as a long to avoid any maximum size issues. Previously I was able to simple insert the LONG into the column which was a CLOB with no problem however we had a patch applied to out 8.1.6 database which now does not let the procedure and complains of a bad type.
    To work around this I have attempted to instead convert the LONG into a temporary CLOB and write the CLOB (below is basically what it does):
    CREATE PROCEDURE WRITE CLOB (data IN long)
    IS
    v_lob_add CLOB;
    v_size integer;
    BEGIN
    dbms_lob.CREATETEMPORARY(v_lob_add,true,dbms_lob.call);
    select vsize(data) into v_size from dual;
    dbms_lob.WRITE(v_lob_add,v_size,1,pi_add);
    insert into tab1 values (v_lob_add);
    END ADD_LONG2LOB;
    This works fine unless the LONG is over 4001 as this causes the 'select vsize(..' to fail with an 'unreasonable conversion' error.
    My question is:
    1, How can you get the length of a long if its over 4000
    2, Can dbms_lob.WRITE be passed a length over 4000
    3, If none of the above how can a LONG be converted to a CLOB for insertion
    4, Is it a bug that I can't just insert the LONG into the CLOB column (which I could do before this patch was installed 2 days ago!).
    Many thanks for your time.
    John

    Worked out how to get LONG length so just for anyones interest the following works fine:
    PROCEDURE INSERT_INCOMING2(
    chr_MMS_REF IN CHAR,
    chr_NATIVE_MSG IN LONG,
    ) IS
    v_lob2 CLOB;
    v_size integer;
    y varchar2(100);
    BEGIN
    dbms_lob.CREATETEMPORARY(v_lob2,true,dbms_lob.call);
    v_size :=0;
    loop
    y := substr(chr_NATIVE_MSG,v_size,100);
    exit when y is null;
    v_size := v_size + length(y);
    end loop;
    v_size:=v_size-1;
    dbms_lob.WRITE(v_lob2, v_size,1, chr_NATIVE_MSG);
    INSERT INTO INCOMING (MMS_REF, NATIVE_MSG) VALUES(
    chr_MMS_REF,
    v_lob2,);
    END INSERT_INCOMING2;

  • Problem with java.sql.Clob and oracle.sql.CLOB

    Hi,
    I am using oracle9i and SAP web application server. I am getClob method and storing that in java.sql.Clob and using the getClass().getName() I am getting the class name as oracle.sql.CLOB. But when I am trying to cast this to oracle.sql.CLOB i am getting ClassCastException. The code is given below
    java.sql.Clob lOracleClob = lResultSet.getClob(lColIndex + 1);
    lPrintWriter = new PrintWriter(new BufferedWriter (((oracle.sql.CLOB) lOracleClob).getCharacterOutputStream()));
    lResourceStatus = true;
    can anybody please tell me the what is the problem with this and solution.
    thanks,
    Ashok.

    Hi Ashok
    You can get a "ClassCastException" when the JVM doesn't have access to the specific class (in your case, "oracle.sql.CLOB").
    Just check your classpath and see if you are referring to the correct jar files.
    cheers
    Sameer
    PS: Please award points if you find the answer useful

  • Master-Detail with 2 blocks based in stored procedure doesn't work.

    Hi. I'm Oscar and I'm new for here.
    I have a problem that i can't find the correct answer to solve it.
    Well. I've created a form with 2 blocks. Both of them have the Query Data Source Type Property to "Procedure", and both procedures on database returns one ref cursor of a record type each one.
    BLOCK BL_COMPETICIONES --> query data source: p_get_competiciones (p_Cursor is cursor of record (CODIGO NUMBER,
    NOMBRE VARCHAR2(50),
    SETCRICKETSN VARCHAR2(1),
    SET01SN VARCHAR2(1),
    FECHAINICIO DATE,
    FECHAFIN DATE).
    On triggers (on-lock, on-insert, on-delete and on-update) I have the call to the corresponding stored procedure to lock, insert, delete or update.
    Well, when i've only this block in form, the form works correctly.
    But when I added a second block (which is suppossed to be a detailed data from the first one), and after I've assigned the query procedure and created the relation between both blocks, then run the form and try to execute query on first block, returning records correctly, but then, when execution goes to the program unit "query_master_details", the sentence "execute query" doesn't do anything (and the cursor is in the detailed block), so detailed block continues to be without records.
    I don't know how to solve this. Someone can help me, please?. Thanks.
    Edited by: user5067020 on 09-abr-2009 16:38

    It could be that there is something screwy with LV, but given that it uses standard interfaces for comm with the DBMS, I would not expect that. A much more realistic possibility is that the toolkit is mucking things up. (A fairly common occurrence.)
    Try bypassing the toolbox -- which you don't really need anyway -- an talk directly to the ActiveX or .net interface.
    Also, what DBMS? What drivers are you using?
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Problem passing REF CURSOR to JAVA STORED PROCEDURE

    Hi,
    I've written a small Java class with a static method and
    imported that into Oracle 8i. The method expects a
    java.sql.ResultSet object as parameter. According to the
    documentation of Oracle, a REF CURSOR (cursor variable) maps to
    java.sql.ResultSet in JDBC.
    The definition of the Java Stored Procedure was accepted without
    problems:
    CREATE OR REPLACE PROCEDURE RESULTSETPASSINGTESTPROC (row
    WASTypes.GenericCurType)
    as language java
    name 'sqlj.ResultSetPassingTest.testResultSetPassing
    (java.sql.ResultSet)';
    WASTypes is a package containing the definition of the generic
    cursor:
    CREATE OR REPLACE PACKAGE WASTYPES
    is
    TYPE GenericCurType IS REF CURSOR;
    END WASTypes;
    In a function I'm opening the cursor via
    'Open cursorVariable for sqlStatement';
    Then this cursor variable is passed to the java method and the
    error ORA-03113 is shown.
    I tried to solve the problem by changing the type of the
    parameter to oracle.sql.REF without success.
    Does anybody know what wents wrong?
    Thanks in advance.
    Jan

    Hi,
    I've written a small Java class with a static method and
    imported that into Oracle 8i. The method expects a
    java.sql.ResultSet object as parameter. According to the
    documentation of Oracle, a REF CURSOR (cursor variable) maps to
    java.sql.ResultSet in JDBC.
    The definition of the Java Stored Procedure was accepted without
    problems:
    CREATE OR REPLACE PROCEDURE RESULTSETPASSINGTESTPROC (row
    WASTypes.GenericCurType)
    as language java
    name 'sqlj.ResultSetPassingTest.testResultSetPassing
    (java.sql.ResultSet)';
    WASTypes is a package containing the definition of the generic
    cursor:
    CREATE OR REPLACE PACKAGE WASTYPES
    is
    TYPE GenericCurType IS REF CURSOR;
    END WASTypes;
    In a function I'm opening the cursor via
    'Open cursorVariable for sqlStatement';
    Then this cursor variable is passed to the java method and the
    error ORA-03113 is shown.
    I tried to solve the problem by changing the type of the
    parameter to oracle.sql.REF without success.
    Does anybody know what wents wrong?
    Thanks in advance.
    Jan

  • How to retrieve 'long' column with 32K length in Java stored procedure

    For some reasons, we are not using CLOB, BLOB, or BFILE to store large objects and I have to live with LONG. So I wrote a Java stored procedure to insert, select and manipulate a LONG column by retrieving the LONG into a java.lang.String class (which happens to be the Java class mapped to the LONG SQL datatype). It all works fine as long as the length of the value being retrieved is less than the magic figure of 32767 bytes (which is the restriction on LONG and VARCHAR2 datatype in PL/SQL as well). So looks like Oracle's implementation of the JVM limits String values to a max of 32767 bytes. Suggestions on how to overcome this limitation (other classes that you suggest or do I have to move to files)?
    Thanks,
    Jeet
    null

    the jvm has nothing to do with it ...
    this is a pol/sql limitation on parameters in stored procedures.
    and java stored procedures require a clal spec that makes the j-s-p look like a pl/qsl stored proc.

  • Clobs in stored procedures

    I have a stored procedure which has a field that includes a CLOB.
    These are the fields for this stored procedure:
    PKEY NUMBER IN
    ID VARCHAR2 IN
    DESCRIPTION VARCHAR2 IN
    COMMENTS CLOB IN
    LAST_MODIFIED DATE IN
    Now when i try to execute this stored procedure in SQL Plus or my VB program I am getting the following problem if the CLOB field isn't null.
    PLS-00306: wrong number or types of arguments in call to 'IMSP_STATE_EDIT'
    How would i insert the CLOB field if say I want it to be equal to 'I want to insert info here'. Is there a certain format for this?? I am using Oracle 8.1.7
    null

    Hi,
    sorry for my english I'm french.
    I have the same problem of you. I can put file into my long raw. I use SQL odbc function like sqlputdata and sqlgetdata. I know that you use an other method, but I think if we help us, perhaps there is easiear.
    So if you want you can mailto
    [email protected]
    thanks
    xav

  • Problems binding array in C# to stored procedure.

    I'm having trouble trying to pass an array of ID's to a stored procedure that is expecting an array (listed the procedure definition below). My current interface doesn't return an error, but it also doesn't insert the proper id's.
    STORED PROCEDURE DEFINITION:
    TYPE source_ids IS TABLE OF wweb.DM_ASSOCIATIONS.source_id%TYPE INDEX BY PLS_INTEGER;
    PROCEDURE add_message_associations
    (p_dm_message_id IN wweb.dm_messages.dm_message_id%TYPE
    ,p_association_type IN wweb.dm_associations.association_type%TYPE
    ,p_sources IN source_ids
    ,p_create_user IN wweb.dm_associations.create_user%TYPE)
    .......variable definitions here...
    v_source_id := p_sources.First;
    WHILE v_source_id IS NOT NULL
    LOOP
    -- Check if this association already exists.
    -- If not add them.
    v_assoc_exists := 0;
    FOR r_chk IN
    (SELECT 1 AS assoc_exists_flag
    FROM dm_associations a
    WHERE a.dm_message_id = p_dm_message_id
    AND a.association_type = p_association_type
    AND a.source_id = v_source_id)
    LOOP
    v_assoc_exists := r_chk.assoc_exists_flag;
    END LOOP;
    IF v_assoc_exists = 0 THEN
    -- Add the association
    INSERT INTO wweb.dm_associations
    (dm_association_id
    ,dm_message_id
    ,association_type
    ,source_id
    ,source_column_name
    ,active_flag
    ,create_date
    ,create_user
    ,last_update_date
    ,last_update_user)
    VALUES
    (wweb.dm_associations_s.NEXTVAL
    ,p_dm_message_id
    ,p_association_type
    ,v_source_id
    ,v_source_column_name
    ,1
    ,SYSDATE
    ,p_create_user
    ,SYSDATE
    ,p_create_user);
    END IF;
    .......error handling here...
    C# CODE:
    OracleParameter[] param = new OracleParameter[4];
    param[0] = new OracleParameter("p_dm_message_id", OracleDbType.Long);
    param[1] = new OracleParameter("p_association_type", OracleDbType.Varchar2, 5);
    param[2] = new OracleParameter("p_sources", OracleDbType.Int32);
    param[3] = new OracleParameter("p_create_user", OracleDbType.Varchar2, 25);
    param[0].Value = 1;
    param[1].Value = "ER";
    param[2].Value = new Int32 [] {1, 172, 412, 7953};
    param[3].Value = "SVC-GDESAI";
    param[2].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    param[2].Size = 4;
    param[2].ArrayBindStatus = new OracleParameterStatus[4]{OracleParameterStatus.Success, OracleParameterStatus.Success, OracleParameterStatus.Success, OracleParameterStatus.Success};
    cn = new OracleConnection(ConnectionString);
    cn.Open();
    OracleCommand cmd = new OracleCommand();
    cmd.Connection = cn;
    cmd.CommandText= "dynamic_messages_api.add_message_associations";
    cmd.CommandType= CommandType.StoredProcedure;
    foreach (OracleParameter p in param)
    if ((p.Direction == ParameterDirection.InputOutput || p.Direction == ParameterDirection.Input) && (p.Value == null || p.Value.ToString() == ""))
    p.Value = DBNull.Value;
    cmd.Parameters.Add(p);
    cmd.ExecuteNonQuery();
    This ran fine, and created four rows in the table, but the source id's were (1, 2, 3, 4) instead of (1, 172, 412, 7953) which were the ones I passed in.
    Does anyone know what I'm doing wrong here?
    Thanks,
    Gauranga

    Hi,
    I think you have a problem in you PL/SQL procedure. When you receive an array in the procedure, it is your responsibility to parse it explicitely with a loop or to bulk insert with a "forall" (implicit).
    For instance, here is an example of a procedure of mine. I don't catch exceptions as I want the C# calling code to know about them:
    The type t_* are defined like yours.
    procedure UpdateDistribDates(p_bannerid in t_bannerid,
    p_promonumber in t_promonumber,
    p_datenumber in t_datenumber,
    p_actualdate in t_actualdate ) is
    BEGIN
    -- First delete the existing dates in bulk
    FORALL I IN P_BANNERID.FIRST..P_BANNERID.LAST
    DELETE FROM PROMODISTRIBDATE
    WHERE BANNERID = P_BANNERID(I)
    AND PROMONUMBER = P_PROMONUMBER(I);
    -- Then, insert the values passed in arrays.
    FORALL I IN P_BANNERID.FIRST..P_BANNERID.LAST
    INSERT INTO PROMODISTRIBDATE
    (BANNERID,
    PROMONUMBER,
    DATENUMBER,
    ACTUALDATE)
    VALUES (P_BANNERID(I),
    P_PROMONUMBER(I),
    P_DATENUMBER(I),
    P_ACTUALDATE(I));
    END;
    As you can see, the FORALL keyword will process the arrays passed as any other PL/SQL array in one chunk.
    When you do the insert like:
    INSERT INTO wweb.dm_associations
    (dm_association_id
    ,dm_message_id
    ,association_type
    ,source_id
    ,source_column_name
    ,active_flag
    ,create_date
    ,create_user
    ,last_update_date
    ,last_update_user)
    VALUES
    (wweb.dm_associations_s.NEXTVAL
    ,p_dm_message_id
    ,p_association_type
    ,v_source_id
    ,v_source_column_name
    ,1
    ,SYSDATE
    ,p_create_user
    ,SYSDATE
    ,p_create_user);
    In source_id, you insert the index of the table, not the value of the field.
    I would suggest you completely rewrite this procedure by using the explicit loop like this:
    1/ Explicit loop
    FOR i IN 1 .. p_sources.COUNT LOOP
    -- Check the existence
    EXIST_FLAG := 0;
    BEGIN
    SELECT 1
    INTO EXIST_FLAG
    FROM ...
    WHERE ...
    AND a.source_id = p_source(i) <-- You are parsing here
    AND ...
    EXCEPTION
    WHEN OTHERS THEN -- Nothing was found
    EXIST_FLAG := 0;
    END;
    IF (EXIST_FLAG = 1)
    INSERT INTO wweb.dm_associations
    (dm_association_id
    ,dm_message_id
    ,association_type
    ,source_id
    ,source_column_name
    ,active_flag
    ,create_date
    ,create_user
    ,last_update_date
    ,last_update_user)
    VALUES
    (wweb.dm_associations_s.NEXTVAL
    ,p_dm_message_id
    ,p_association_type
    ,p_source(i) <-- You parse here
    END IF;
    END LOOP;
    2/ Implicit loop and bulk insert
    You would need to completely review the logic and build an array that maps exactly the row of the table you are trying to insert into. Parse the array and check for the existence of your entry, delete the row in memory when not found, then, after the loop do a bulk insert with a "forall".
    Hope it helps,
    Patrice

  • Invoking BPEL with large request payload from stored procedure

    Hi all,
    I have a stored procedure which invoke BPEL process. It is working fine with small payload (around 3000 characters). But some of the payload are as large as 75 to 100 thousand characters. I used the clob datatype for my soap envelop variable so that it can take more characters. But I am getting error if the payload size is large. Can someone help me figure how I am able to do this. Thanks.

    Hi James,
    Thanks for your response. What I need to do is, if any of the instance is failed in the first invokation, user can manual re-invoke the same process from the dashboard. I tried invoking bpel from ADF 11g and finally found out that it is not supported with SOA 10.1.3.4. (I can't use Data control as the payload is already in the database).
    I am invoking an Asynchronous process. So, it is not the timeout error. The same procedure went fine with the same process if the payload is small. I include one output parameter to send the message from the procedure back to ADF, and what Ifound out was if the payload is big, I got the exception right after "utl_http.write_text(l_http_request, l_soap_envelope);". Any hope that I can still use this without going to ODI?
    Thanks.
    SHY

  • Issue with XSL transformation in Java Stored Procedure

    Hi,
    Am having issue applying XSL transformation in Java Stored procedure. I have loaded the java class as well as .XSL files through loadjava uility and their status in DB is VALID.
    Below is the code in the java stored procedure:
    public static String tranform(String strInputXML ){
    URL url = ClassLoader.getSystemClassLoader().getResource(first.xsl);
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(new ByteArrayInputStream (strInputXML.getBytes("UTF-8")));
    TransformerFactory tFactory = TransformerFactory.newInstance();
    StreamSource stylesource = new StreamSource(url.openStream());
    Transformer transformer = tFactory.newTransformer(stylesource);
    When I run this procedure, am getting following errors:
    {color:#ff0000}*ERROR: 'No such file or directory'*
    FATAL ERROR: 'Could not compile stylesheet'{color}
    My first.xsl file has reference to other excel file (Ex: &lt;xsl:include href="second.xsl"/&gt;) which seems to be causing this error. When I remove the reference, procedure is working fine.
    Pls let me know how to resolve this and read the .XSL file with references.
    Thanks,

    Hello,
    Thanks for the reply. Actually I have seen that post before creating this thread. I thought that I could make use of java mail to work around this problem. I created a java class that succesfully sends mail to SSL host. I tried to call this java class from pl-sql through java stored procedure. That did not work
    So, is this not supported in Oracle ? Please note that I have tested this in both 9i and 11g , in both the versions I got the error. You can refer to the code in the above post.
    Thanks
    Srikanth
    Edited by: user12050615 on Jan 16, 2012 12:17 AM

  • Parsing XML passed as CLOBs to stored procedures

    I am a newbie using XML with PL/SQL. I would like to pass XML as a CLOB to a stored procedure, parse the nodes in a loop and insert or update records. Something like this:
    The xml:
    <emps>
    <emp>
    <empno>7369</empno>
    <ename>SMITH</ename>
    </emp>
    <emp>
    <empno>7499</empno>
    <ename>ALLEN</ename>
    </emp>
    </emps>
    In the stored procedure:
    CREATE update_emps( xmlCLob in CLOB )
    begin
    load xmlClob into parser p
    nodelist = p.someMethod( '/emps/emp' )
    for each node in nodelist
    insert into emp( empno, ename) values ( node.empno, node.ename
    end loop
    cleanup
    end
    Any assistance you could provide would be greatly appreciated.
    TIA

    If the file size is not large, it seems easier to use XSLT to transform the doc and using XSU to do the updates.

Maybe you are looking for

  • Adding symbol sign in messageStyledText  in UIX?

    Hi, Following scenario: <messageStyledText styleClass="OraDataText" rendered="true" prompt="Price:" text="EUR 12.35"/> I want to replace "EUR" for but when i do that the output looks like this: Prijs: ? 12.75 How can i insert a symbol within messageS

  • Air App Storage

    I'm new to Air and am trying to open an xml file via a FileStream object. The xml file (site.xml) is in the same directory where the .swf gets published and I've also included it in Settings>Include Files, but this produces a file not found when I te

  • Costing variant with a valuation strategy

    Hello all, I have the following issue: In PM I have defined a costing variant with a valuation strategy first u201Cstandard priceu201D and second u201CMoving Average priceu201D, and assigned this costing variant to the plant and order type. When I cr

  • Problems with mpeg2 codec for quicktime

    I just downloaded the mpeg2 codec for quicktime and installed it. My computer doesn't recongnize it and I still can't play mpeg2 clips. When I check the video codecs installed on my computer, the mpeg2 codec doesn't appear in the list even if I did i

  • Flash Website Advice Needed.

    Hi, Im going to give my own site a go in flash and was wondering if someone could give me a few pointers or direction as i have not used flash for a few years now. I want my site to work like this but obviously i wanna customize it to suite. http://w