Passing array of timestamps into oracle stored proc

Hey there,
I have an interesting problem. I need to pass an array of java.sql.Timestamp into a stored proc.
I see that the PreparedStatement provides a setArray() method which takes as arguments an int, java.sql.Array
Anybody know how I can use the java.sql.Array to my advantage here ? Basically, I don't see how I can create a java.sql.Array of Timestamps
thanks in advance for all your help.
Manish Mandelia

The java.sql.Array implementation is provided by your jdbc driver.
For exemple using Oracle you can obtain an sql.Array with something like this :
Connection con=getConnection() // get a connection to the DB
//first declare what type of array you will use in the DB
// you probably want to replace CHAR(7) by Timestamp here
PreparedStatement createArray=
con.prepareStatement("CREATE OR REPLACE TYPE MYARRAY AS VARRAY(100) OF CHAR(7)");
createArray.execute();          
//then get an java instance of this Array
oracle.sql.ArrayDescriptor arrayDescriptor = oracle.sql.ArrayDescriptor.createDescriptor("MYARRAY",con);
// content is used to fill the Array
String[] content= {"string0", "string1"};
java.sql.Array sqlArray=new oracle.sql.ARRAY(arrayDescriptor, con, content);               
// then call your stored procedure
java.sql.CallableStatement callStmt=con.prepareCall("call MyStoredProcedure(?)");
// passing the array as an argument
callStmt.setArray(1,sqlArray);
callStmt.execute();
As you can see the code is quite database specific.
hope that helps.

Similar Messages

  • How to passing array as parameter to oracle stored procedure from JPA

    Hi All,
    I need to call a stored proc in Oracle that accepts an array as input parameter.
    Pls let me know how should i call it from my JPA. Is this even possible without using JDBC directly?
    i keep getting the ff error:
    wrong number or types of arguments in call to ....
    my code is something like this:
    String[] myArr...
    Query query = em.createNativeQuery("BEGIN myStoredProc(:arr); END;");
    query.setParameter("arr", myArr);
    Thanks in advance.

    I also fail to get this done my code till now is:
    PLSQL Function:
    function getHtml(pWhere VARCHAR2 DEFAULT NULL,
    pColSort HTP.STRINGARRAY) return clob is
    begin
    errorhndl.Log(pMessage => 'called');
    htp.prn('das ist der test
    for i in 1 .. pColSort.count loop
    htp.p('
    pColSort['||i||']: '||pColSort(i));
    end loop;
    htp.prn('
    <table> <tr> <td> max1.0 </td> <td> max2.0 </td> </tr>');
    htp.prn('<tr> <td> max1.1 </td> <td> max2.1 </td> </tr> </table>');
    htp.prn('test ende');
    return htp.gHtpPClob;
    exception
    when others then
    null;
    end getHtml;
    PLSQL TYPE: (in HTP package - self created - but could be anywhere else too)
    type STRINGARRAY is table of varchar2(256) index by binary_integer;
    JAVA DOA:
    public class ShowReportDOAImpl implements ShowReportDOA {
         private JdbcTemplate jdbcTemplate;
         private SimpleJdbcCall procShowReport;
         public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
              this.jdbcTemplate = jdbcTemplate;
              procShowReport = new SimpleJdbcCall(this.jdbcTemplate)
              .withCatalogName("Show_Report")
              .withFunctionName("getHtml")
              .withoutProcedureColumnMetaDataAccess()
              .declareParameters(
                   new SqlParameter("pWhere", Types.VARCHAR),
                   new SqlParameter("pColSort", Types.ARRAY, "HTP.STRINGARRAY"),
                   new SqlOutParameter("RETURN", Types.CLOB)
         public String readReport(Long id, ParameterHelper ph) {
              String[] sortCol = {"max", "michi", "stefan"};
              String pWhere = "fritz";
              MapSqlParameterSource parms = new MapSqlParameterSource();
              parms.addValue("pWhere", pWhere);
              parms.addValue("pColSort", sortCol, Types.ARRAY, "HTP.STRINGARRAY");
    parms.addValue("pColSort", Arrays.asList(sortCol), Types.ARRAY, "HTP.STRINGARRAY");
    Clob clob = procShowReport.executeFunction(Clob.class, parms);
    String clobString = "";
    try {
         System.out.println("length: "+new Long(clob.length()).intValue());
                   clobString = clob.getSubString(1, new Long(clob.length()).intValue());
              } catch (SQLException e) {
                   e.printStackTrace();
    return clobString;
    EXCEPTION IS:
    org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{? = call SHOW_REPORT.GETHTML(?, ?)}]; SQL state [null]; error code [17059]; Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]; nested exception is java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
         org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
         org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
         org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
         org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:969)
         org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
         org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
         org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
         org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
         at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
         at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
         org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    root cause
    java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
         oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
         oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
         oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:860)
         oracle.sql.ARRAY.toARRAY(ARRAY.java:209)
         oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7767)
         oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7448)
         oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7836)
         oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4586)
         org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
         org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
         org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:356)
         org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:216)
         org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:127)
         org.springframework.jdbc.core.CallableStatementCreatorFactory$CallableStatementCreatorImpl.createCallableStatement(CallableStatementCreatorFactory.java:212)
         org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:947)
         org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
         org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
         org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
         org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
         at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
         at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
         org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    Please help!!
    Please help!!

  • How to pass a refcursor to a java stored proc

    Hi all,
    Please forgive me as I am new to Java and JDeveloper....
    I want to pass a refcursor to a java stored proc. Does anyone know how to accomplish this?
    Thanks,
    dayneo

    Hi,
    As Avi has indicated, you can map ref cursor to java.sql.ResultSet
    here are Call Specs and a code snippet from chapter 3 in my book.
    procedure rcproc(rc OUT EmpCurTyp)
    as language java
    name 'refcur.refcurproc(java.sql.ResultSet[])';
    function rcfunc return EmpCurTyp
    as language java
    name 'refcur.refcurfunc() returns java.sql.ResultSet';
    * Function returning a REF CURSOR
    public static ResultSet refcurfunc () throws SQLException
    Connection conn = null;
    conn = DriverManager.getConnection("jdbc:oracle:kprb:");
    ((OracleConnection)conn).setCreateStatementAsRefCursor(true);
    Statement stmt = conn.createStatement();
    ((OracleStatement)stmt).setRowPrefetch(1);
    ResultSet rset = stmt.executeQuery("select * from EMP order by empno");
    // fetch one row
    if (rset.next())
    System.out.println("Ename = " + rset.getString(2));
    return rset;
    Kuassi

  • How to pass XMLType as parameters to Java stored procs ?

    How to pass XMLType as parameters to Java stored procs ?
    ORA-00932: inconsistent datatypes: expected an IN argument at position 1 that is an instance of an Oracle type convertible to an instance of a user defined Java class got an Oracle type that could not be converted to a java class
    Java stored proc -->
    CREATE or replace FUNCTION testJavaStoredProcMerge( entity xmltype,event xmltype ) RETURN VARCHAR2 AS LANGUAGE JAVA
    NAME 'XDBMergeOp.merge(org.w3c.dom.Document,org.w3c.dom.Document) return java.lang.String';
    PL/SQL -->
    declare
    theQuote VARCHAR2(50);
    entity xmltype;
    event xmltype;
    begin
    entity := xmltype('<Quote><Fields><Field1>f1</Field1></Fields></Quote>');
    event := xmltype('<Quote><Fields><Field2>f2</Field2></Fields></Quote>');
    theQuote := testJavaStoredProcMerge(entity,event);
    dbms_output.put_line(theQuote);
    end;
    Java class -->
    public class XDBMergeOp {
    public static String merge(Document entity, Document event) throws Exception {
    return ...
    Thanks in advance.

    I think you'll need to use XMLType and then extract the DOM inside java..
    create or replace package SAXLOADER
    as
      procedure LOAD(P_PARAMETERS XMLTYPE, P_DATASOURCE BFILE);
    end;
    create or replace package body SAXLOADER
    as
    procedure LOAD(P_PARAMETERS XMLTYPE, P_DATASOURCE BFILE)
    AS
    LANGUAGE JAVA
    NAME 'com.oracle.st.xmldb.pm.saxLoader.SaxProcessor.saxLoader ( oracle.xdb.XMLType, oracle.sql.BFILE)';
    end;
      public static void saxLoader(XMLType parameterSettings, BFILE dataSource)
      throws Exception {
        Document parameters = parameterSettings.getDocument();
        SaxProcessor app = new SaxProcessor(parameters);
        app.processXMLFile(dataSource);
      Edited by: mdrake on Apr 6, 2009 11:28 AM

  • Error while debugging the Oracle Stored Proc Body

    I am trying to debug a standalone Oracle Stored Proc. I keep a break point on the Package body, and JDeveloper doesn't seem to pick it up at all. I have made sure that are the prerequisites are met and all the instructions have been followed diligently, but still i keep getting this error message:
    Unable to set breakpoint (C:\Program Files\JDeveloper\jdev\mywork\ADReports\ADReportsProject\packagebody staging.staging_reports.sql 57), unable to resolve Java package.
    The Debugger doesn't seem to stop at the specified break point in the package body. Though it does connect to the DB, and shows all the data values inside the procs, and other stuff as mentioned in the debug tutorial/manual.
    Some replied to my previous post saying that it was a bug with the JDeveloper itself and it has been fixed, so if this is the case, can someone point me to the right place where we can download the bug free version.
    Thanks in advance

    Hi,
    Please see:
    PL/SQL Debugging does not stop on breakpoint
    - Mark

  • Here's how to pass XML as a parameter to an Oracle stored proc

    This, or something like it, should be all over the web and I intend to do so.
    The first sample has exactly what you need in order to pass "XML" as a parm to a stored proc.
    http://www.oracle-base.com/forums/viewtopic.php?f=2&t=8468

    > Really, what is the difference between the 2?
    "What is a...?" questions are easily answered by Google. Generally speaking, however, "JavaScript" is Netscape's implementation of ECMAScript, a scripting language primarily for client-side development for a web browser. "Java" is an entire platform, but typically refers to an object-oriented programming language that is typically compiled to bytecode and run in a virtual machine.
    They're not the same thing at all.
    ~

  • Passing XMLType Data into oracle stored procedure using JDBC

    Hi Friends,
    I have requirement where my oracle stored procedure accepts XML file as an input. This XML File is generated in runtime using java, I need to pass that xml file using JDBC to oracle stored procedure. Please let me know the fesibile solution for this problem.
    Following are the environment details
    JDK Version: 1.6
    Oracle: 10g
    Server: Tomcat 6.x
    Thanks in Advance

    user4898687 wrote:
    I have requirement where my oracle stored procedure accepts XML file as an input. This XML File is generated in runtime using java, I need to pass that xml file using JDBC to oracle stored procedure. Please let me know the fesibile solution for this problem.As stated - no.
    A 'file' is a file system entity. There is no way to pass a 'file' anywhere. Not PL/SQL. Not java.
    Now you can pass a file path (a string) in java and to PL/SQL.
    Or you can pass xml data (a string) in java and to PL/SQL. For PL/SQL you could use eithe a varchar2, if the xml is rather small, or a blob/clob.

  • Passing series of value to a stored proc

    I call a stored proc from an ASP page (VBScript or Jscript) via ADO and I need to give to this proc a series of value.
    The proc as to execute a query that look like
    select a_Column from a_Table
    where a_TableId in (My_Series)
    I would like to pass My_Series as a single parameter.
    Could I declare My_Series as something like an array ?
    or a string like ( 'A', 'B' , , 'C') ?

    See:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:110612348061
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:210612357425
    or just do a search for "in list" on http://asktom.oracle.com/

  • Call EJB From Oracle Stored proc or Database loaded Java?

    Are there any examples of calling an EJB, residing in the OC4J on a machine separate from the DB server,
    from an Oracle PL/SQL stored proc.
    The Stored proc can call java loaded into the DB. That java makes the intial bean context. Or another way if suggested.
    The reason is that I need to use some drivers that I have so far been unable to load directly into the DB using
    loadjava util. I plan on using the driver in the EJB, located on a different machine. But I'd like so know if its possible to
    make the IntialContext call to the EJB container from PL/SQL. Are the OC4J drivers loadable to be
    able to be called from a database loaded java class? ( I might be a little off on my terminology)
    Bob
    [email protected]

    Hi Bob,
    Your question has been previously asked on this forum many times already.
    You can probably find the relevant postings by doing a search of the
    forum archives.
    To summarize those posts, as I understand it, the latest version of OC4J
    (version 9.0.3) contains a "oc4jclient.jar" file (I think that's the name
    of the file), that can be loaded into the Oracle database (using the
    "loadjava" utility), and which allows a java stored procedure to invoke
    methods on an EJB residing in OC4J.
    Please note that I have not tried any of the above -- I am only summarizing
    for you what has already been posted. And like I said before, a search
    of the forum archives will probably give you more details.
    Good Luck,
    Avi.

  • Problem with output data when calling into Oracle stored procedure

    I have a problem that I think I've seen posted by others, but I can't find it anywhere on the forum. Here's what it looks like:
    I have a application that sends a query parameter called custID in a URL to a JSP page.
    http://domain.com/decrypt.jsp?custID=ewsw
    The JSP subsequently calls into the method below to run a decryption stored procedure on an Oracle db. The custId parameter works fine from most clients. However, I have seen the decryption stored procedure return invalid information on some clients in the following case:
    http://domain.com/decrypt.jsp?custID='eirwx
    Here is how I define my call to the DCUSTID (decryption stored procedure):
    public long dCustID(String sCustID)throws SQLException {
    CallableStatement cs = null;
    try {
    long nCustID = 0;
    if(conn == null || conn.isClosed()) {getLocalConnection();}
    String sp = "BEGIN DCUSTID(?,?);END;";
    cs = conn.prepareCall(sp);
    cs.setString(1, sCustID);
    cs.registerOutParameter(2,java.sql.Types.NUMERIC);
    cs.execute();
    nCustID = cs.getLong(2);
    return nCustID;
    }finally { release(cs); }
    I have not been able to find a problem with the stored procedure (although Im not counting that out). Is there any way that the jsp or the code above is corrupting the data before it gets to the stored procedure? I'm very suspicious of the single quote at the begining of the custID query string parameter.
    Thanks

    >
    The JSP subsequently calls into the method below to
    run a decryption stored procedure on an Oracle db.
    The custId parameter works fine from most clients.
    However, I have seen the decryption stored procedure
    e return invalid information on some clients in the
    following case:
    The back tick doesn't matter.
    How do you know that the routine that you posted returns invalid information? Are you printing the value retreived before you return in the code that you posted? That is the only way to tell if that code is the problem vs some translation problem in something else.
    And what do you mean by 'invalid'? It does return a numeric value right? Is it negative? Or so large that it couldn't be a key? Or what?
    The input parameter to the stored proc is a varchar and not a char correct?

  • Business Objects XI R2 - Oracle Stored Proc - Deski report failing

    Business Objects XI R2
    Hi All,
    I have a stored proc created in Oracle 10 - see bottom for code
    I run a deski report on iit - using it as a datasource. This works fine in Desktop Intelligence until I schedule the report from infoview - then I get the following error...
    "Object failed to run due to an error while processing on the Job Server"
    My other deski reports based on Universes are ok.
    create or replace procedure test_PROC1
    (Test_Rpt_Cur OUT SYS_REFCURSOR)
    is
    begin
    open Test_Rpt_Cur FOR
    SELECT ID, FIRSTNAME, LASTNAME
    FROM test_table;
    end test_proc1;

    Hi,
    Cause of this issue :
    Once the Job Server recieves the scheduled job and spawns a new child process, the child process is unable to complete the job. The child process constantly is waiting to load the job. Looking further into the log and specifically the startup script, the -port option was incorrectly used (-restart-port) and didn't allow the child process to bind to the correct port using the correct DNS name. 
    In Order to resolve this issue follow the steps given below..
    1.Open CCM
    2. Stop Server
    3. Right Click Server and go to Properties
    4. insert -port option in to command line, example below
    ex. "
    win2k3\C$\ProgramFiles\Business Objects\BusinessObjects Enterprise 11.5\win32_x86\JobServerFullClient.exe" -service -name win2k3.Desktop_IntelligenceJobServer  -ns win2k3 -objectType CrystalEnterprise.FullClient -lib pp_procFC  -jsTypeDescription "Desktop Intelligence Job Server" -maxDesktops 0 -restart -port win2k3.it.bo.example
    5. Save setting and restart server.
    Hope it helps.
    Regards,
    Sandeep Singh

  • To pass new session variable value to stored proc before running a report.

    Hi,
    Below is summary of the report requirement -
    Database level design
    1. Created a view and a global temporary table (GTT)
    2. Created an Oracle package procedure to accept from and to business dates on basis of which it will fetch, process and populate the GTT.
    Repository level design
    1. Created a business model containing the view and the GTT (mentioned above)
    2. Created two SESSION variables "from_dt" and "to_dt" to be initialized by their respective init blocks. Each of the variable is initialized with a DATE column value (of type DATETIME) from a database lookup table. I have also set the option "Enable that variable to be set by any user" for both variables.
    Query for these variables :
    from_dt = select from_date from <table>
    to_dt = select add_months(from_date,12) from <table>
    Presentation level design
    1. Using a text box, i display the default/initialized values of these variables like this -
    Current business date:@{biServer.variables['NQ_SESSION.from_dt']} Future business dt:@{biServer.variables['NQ_SESSION.to_dt']}
    Dates get displayed in YYYY-MM-DD 00:00:00 format
    The text msg displays these default dates and allows the user to specift different date range for which i create prompts as shown below.
    2. Using any random two columns of date type from the business model, i create two date dashboard prompts with labels "From Dt" and "To Dt".
    i select Calender Controls for both; setting Default To = Report Defaults.
    The Set Variable is set to Presentation variables - such that pv_from_dt maps to "From Dt" and pv_to_dt maps to "To Dt".
    3. i create the report using the business model created above. In the report "Advanced Tab" => "Prefix" field i specify the following -
    SET VARIABLE from_dt='@{pv_from_dt}',to_dt='@{pv_to_dt}';
    Note : The logic here is to display the default dates and allow user to specify different date values which will be stored in presentation variables.
    If the user does specify different "from dt" and "to dt" values, then using the presentation variables, i want to "write" back these new values to the corresponding session variables mentioned above.
    If the user does not specify different date range, then the default/initialized dates must be considered.
    I also display the default and new date values in the report title.
    Back to Repository level design
    To execute the stored procedure that will load the GTT before running the report I need to pass two date parameters to the stored procedure on basis of which it will fetch data, process and populate the GTT.
    In the Connection Pool --> Connection Script Tab --> Execute before query, I wrote the below query using the repository variables FROM_DT and TO_DT to execute the procedure -
    DECLARE
    v_from_dt date;
    v_to_dt date;
    BEGIN
    v_from_dt := VALUEOF(From_Dt);
    v_to_dt := VALUEOF(To_Dt);
    package_name1.package_body(v_from_dt,v_to_dt);
    END;
    Now when i try to run the report i get the following error :
    [nQSError: 10058] A general error has occurred. [nQSError: 23006] The session variable, NQ_SESSION.to_dt, has no value definition. (HY000)..
    Need help on this.
    Is it possible to "write back" a new value to a session variable ?
    Any other alternatives.
    Thanks
    Nusrat
    Edited by: user10309945 on Jan 24, 2011 10:08 PM

    Sandeep, I found a several topics where users describe saving values in DB through stored procedure or function. For example, [How to store OBIEE presentation level variable values in DB |http://forums.oracle.com/forums/thread.jspa?threadID=892006] I tried it and get an error
    *10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 14551, message: ORA-14551: cannot perform a DML operation inside a query ORA-06512*
    It's not a BI error. This error are generated by Oracle DB. If I write next:
    SELECT MyPLSQLFunction(p1,p2) FROM DUAL
    I get the same error.
    Oracle doesn't allow DML operations in SELECT.
    Did you relalize this feature yourself? Where did I mistake?

  • S'one tell me how to call Oracle Stored Proc from Java

    Hi,
    I have a problem in calling the Stored proc using callable statement.It looks like we are doing the same thing or no..
    Pl..let me know if you can correct me..Am enclosing the stored proc and java Code...
    CREATE OR REPLACE PROCEDURE StoreFTPAddress (FTP in FTPTYPE) is
    BEGIN
    INSERT INTO DES.FTPSERVICE(
    FTPID,
    COMPANYID,
    SERVERNAME,
    DIRECTORY,
    USERNAME,
    PASSWORD,
    INSTRUCTIONS)
    VALUES( FTPID.NEXTVAL,
    FTP.COMPANYID,
    FTP.SERVERNAME,
    FTP.DIRECTORY,
    FTP.USERNAME,
    FTP.PASSWORD,
    FTP.INSTRUCTIONS);
    END;
    JAVA CODE :;
    public String retrieveFormatExtension(String formatName)
    OracleResultSet rs_form = null;
    try
    conn = ConnectionDataObjectImpl.getConnection();
    Statement stmt = conn.createStatement();
    String sql_retrieve = "{call retrieveFormatExtension} " ;
    CallableStatement cst = conn.prepareCall(
    "{call retrieveFormatExtension(?,?)}");
    cst.setString(1," FName ");
    cst.registerOutParameter(1, OracleTypes.VARCHAR); // OUT Parameter
    cst.executeQuery();
    rs_form = (OracleResultSet) cst.getObject(1);
    cst.close();
    catch (SQLException ex)
    System.out.println("SQLException : " + ex.getMessage());
    return null;
    Regards
    Deepauk
    [email protected]
    null

    Syntactically it looks fine. Only thing is u r calling the proc with wrong name. Your procedure takes only one parameter and i.e
    IN type. I think u need to correct ur preparecall statement.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Ayappa:
    Hi,
    I have a problem in calling the Stored proc using callable statement.It looks like we are doing the same thing or no..
    Pl..let me know if you can correct me..Am enclosing the stored proc and java Code...
    CREATE OR REPLACE PROCEDURE StoreFTPAddress (FTP in FTPTYPE) is
    BEGIN
    INSERT INTO DES.FTPSERVICE(
    FTPID,
    COMPANYID,
    SERVERNAME,
    DIRECTORY,
    USERNAME,
    PASSWORD,
    INSTRUCTIONS)
    VALUES( FTPID.NEXTVAL,
    FTP.COMPANYID,
    FTP.SERVERNAME,
    FTP.DIRECTORY,
    FTP.USERNAME,
    FTP.PASSWORD,
    FTP.INSTRUCTIONS);
    END;
    JAVA CODE :;
    public String retrieveFormatExtension(String formatName)
    OracleResultSet rs_form = null;
    try
    conn = ConnectionDataObjectImpl.getConnection();
    Statement stmt = conn.createStatement();
    String sql_retrieve = "{call retrieveFormatExtension} " ;
    CallableStatement cst = conn.prepareCall(
    "{call retrieveFormatExtension(?,?)}");
    cst.setString(1," FName ");
    cst.registerOutParameter(1, OracleTypes.VARCHAR); // OUT Parameter
    cst.executeQuery();
    rs_form = (OracleResultSet) cst.getObject(1);
    cst.close();
    catch (SQLException ex)
    System.out.println("SQLException : " + ex.getMessage());
    return null;
    Regards
    Deepauk
    [email protected]
    <HR></BLOCKQUOTE>
    null

  • URGENT: Passing Array from JSP to a Stored Procedure

    Hi,
    Can some one please help me understanding how can I pass array from JSP page to a stored procedure in database.
    Thanks in advance.
    Jatinder

    Thanks.
    I tried ArrayExampla.java and was successful in passing array values to the stored database procedure.
    How can I use this class in JSP? Like I have first JSP where in I will collect input from the user and then submit it to the second JSP - that needs to call the ArrayExample.java to pass the values as array to the database.
    How should I call this java code in my second JSP?
    Thanks in advance.

  • Oracle stored proc problem

    HI, I have created a stored proc in oracle similar below:
    CREATE OR REPLACE PACKAGE PACK_REFCURSOR_NHM_TRANSACTION AS
    TYPE TRANS_TableRows IS REF CURSOR
    RETURN NHM_TRANSACTION%ROWTYPE;
    PROCEDURE REFCUR_NHM_TRANSACTION (
    IN_sTMPACC IN string,
    IN_sITEM_TYPES IN string,
    OUT_TRANS OUT TRANS_TableRows);
    END PACK_REFCURSOR_NHM_TRANSACTION ;
    -- the above works fine
    --but this one below has the error when
    CREATE OR REPLACE PACKAGE BODY PACK_REFCURSOR_NHM_TRANSACTION
    AS
    PROCEDURE REFCUR_NHM_TRANSACTION (
    IN_sTMPACC IN string,
    IN_sITEM_TYPES IN string,
    OUT_TRANS OUT TRANS_TableRows) IS
    BEGIN
    OPEN OUT_TRANS FOR
    SELECT T.TRANSACTION_ID, T.TRANSACTION_TYPE,
    T.TRANSACTION_DATE, T.TRANSACTION_TIME,
    T.ITEM_CODE, 0 OE_DETAIL_ID,
    T.QUANTITY, T.LIST_PRICE, T.DISCOUNT, T.SALE_PRICE,
    T.GST_AMOUNT, 'I'INSURER_TYPE
    FROM NHM_TRANSACTION T
    WHERE DISPENSED_FLG = 'Y'
    AND T.ACCOUNT_ID = IN_sTMPACC
    AND T.TRANSACTION_TYPE IN ('01','02', '09')
    AND NVL(T.STATUS,'F') != 'C'
    AND T.BILLED_FLG = 'N'
    AND T.ITEM_TYPE IN (IN_sITEM_TYPES)
    AND T.BILL_ITEM_FLG = 'Y'
    UNION ALL
    SELECT T.OE_TRANSACTION_ID TRANSACTION_ID, TRANSACTION_TYPE,
    T.TRANSACTION_DATE,
    T.TRANSACTION_TIME, NVL(T.ITEM_CODE,T.PACKAGE_CODE)
    ITEM_CODE, T.OE_DETAIL_ID,
    T.QUANTITY, T.LIST_PRICE, T.DISCOUNT, T.SALE_PRICE,
    T.GST_AMOUNT, 'S' INSURER_TYPE
    FROM NHC_OE_TRANSACTION T, NHC_MASTER_ITEM M, NHM_PACKAGE P
    WHERE T.ACCOUNT_ID = IN_sTMPACC
    AND T.ITEM_CODE = M.ITEM_CODE(+)
    AND T.PACKAGE_CODE = P.PACKAGE_CODE(+)
    AND (DECODE(T.ITEM_CODE,NULL,P.BILL_OPTION,M.BILL_OPTION) in
    ('P','O','F'))
    AND NVL(T.STATUS,'F') != 'C'
    AND T.BILLED_FLG = 'N'
    AND ((T.TRANSACTION_TYPE = '09' AND STATUS IN ('P','R'))
    OR T.TRANSACTION_TYPE IN ('01','02','11','12', '10'))
    AND T.BILL_ITEM_FLG = 'Y'
    AND T.ITEM_TYPE IN (IN_sITEM_TYPES) ;
    END REFCUR_NHM_TRANSACTION ;
    END PACK_REFCURSOR_NHM_TRANSACTION ;
    --this gives error: PLS-00382: expression is of wrong type
    but when i tried to change the query similar to this:
    OPEN OUT_TRANS FOR
    SELECT T.*
    FROM NHM_TRANSACTION T
    WHERE DISPENSED_FLG = 'Y'
    AND T.ACCOUNT_ID = IN_sTMPACC
    AND T.TRANSACTION_TYPE IN ('01','02', '09')
    AND NVL(T.STATUS,'F') != 'C'
    AND T.BILLED_FLG = 'N'
    AND T.ITEM_TYPE IN (IN_sITEM_TYPES)
    AND T.BILL_ITEM_FLG = 'Y' ;
    --that worked fine. what i found out is the proc doesn't seem
    to work with complicated queries. instead it works only in
    something similar to SELECT T.*? and not when individual fields are
    extracted? I can't understand why? can anyone help me with this>
    thanks.

    I think what is hapenning is that you are declaring the
    reference cursor in your package spec as a "strong" type as a
    rowtype of table NHM_TRANSACTION. However, in your OPEN FOR SELECT
    statement, you are selecting columns that do not exist in the the
    NHM_TRANSACTION table, such as 0 OE_DETAIL_ID, 'I'INSURER_TYPE,
    etc.
    You would be much better off to declare your reference cursor
    as a "weak" type so that your OPEN FOR SELECT statement actually
    defines the return structure:
    TYPE TRANS_TableRows
    IS REF CURSOR;
    In other words, leave off the RETURN NHM_TRANSACTION%ROWTYPE
    in your ref cursor declaration, and you would probably be OK
    (assuming, of course, that all of the columns selected in your
    UNION statements are like data types).
    Phil

Maybe you are looking for

  • I click on a website, it loads, and then immediately goes to a blank page

    This problem just started about 2 weeks ago. I will click on a site, and for a second i am there, then the page goes blank. sometimes I get the word "Done" in the lower left-hand corner of the page. This appears to be random w/pages. Some, never have

  • Changing SPRM 0 with a script ?

    Hi list, In have searched the archives but I did not found an answer or solution: Is there any way you can change SPRM 0 (menue language) with a script ??? Any help would be great, Michael

  • How to add movies on iTunes?

    How to add movies on iTunes? So I could put it on my iPad. Thanks in advance!

  • Contract and defensive programming

    I'm exploring the differences between Contract and Defensive programming. I'm seeking any comments from the community on the subject of these two apparently opposing paradigms. (Or am I wrong? Do they oppose?) Contract Programming, or Design by contr

  • Need to Clone A Database From Solaris to Linux Oracle 11g

    Hi Team, I am using Oracle Database Version 11.2.0.1. We have 6 production servers and all of them are in solaris box. We have a new requirement from application to use Linux boxes and for that we need to perform a database refresh from Solaris to Li