Stored Procedure in access with parameter name

Hi, i'm new in JDBC.
I came from Ado.Net.
I want to call a stored procedure in access and set my parameters by name and not by index.
When i try to call the SP with params by index it works as expected,
but with param names it give me this exception:
java.lang.UnsupportedOperationException
Is there a way to call SP with parameter names?
BogN,

Well, it still doesn't work. Here is part of the code, have a look please.
public DisplayQueryResults() {
   String studattUrl = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:/StudAtt/StudAtt.mdb";
   String mustbUrl = "jdbc:odbc:mustb";          
   try {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      studattConn = DriverManager.getConnection(studattUrl);
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      mustbConn = DriverManager.getConnection(mustbUrl, "sa", "");               
private void getTable() {
   try {
      stmtStudAtt = studattConn.createStatement(resultSet.TYPE_SCROLL_SENSITIVE, resultSet.CONCUR_READ_ONLY);
      stmtMustb = mustbConn.createStatement();
      CallableStatement callSP = studattConn.prepareCall("{call mustbFaculty}");
      resultSet = callSP.executeQuery();
      displayResultSet(resultSet);
   }

Similar Messages

  • Execute Stored Procedure SQL Statement with Parameter from Cell

    I would like to know if there is a way to pass the parameters to SQL Statement of Power Query. For example, I have a SQL Statement as follows:
    EXEC [dbo].[spReportBuilder]
    @Report = N'Revenue Summary',
    @Year = N'2014',
    @Period = N'11'
    I would like to know if it is possible to pass the @Report, @Year, @Period values from cells in the workbook, preferably without vba.
    Thanks

    rtisserand, 
    Here is the M code: 
    let
    IDValue = Excel.CurrentWorkbook(){[Name="YearTable"]}[Content],
    Source = Sql.Database("localhost", "AdventureWorks2012", [Query="EXEC [dbo].[spReportBuilder] @Report = N'Revenue Summary', @Year = N'" & Number.ToText(IDValue[ID]{0}) & "', @Period = N'11'"])
    in
    Source
    Some notes:
    You have to reference the excel query from another step in the query or you will get the following error: 
    Formula.Firewall: Query <>something<> references other queries or steps and so may not directly access a data source. Please rebuild this data combination.
    I only did the parameter for one value.
    Hope this helps.
    Reeves
    Denver, CO

  • Can I create a Stored Procedure That access data from tables of another servers?

    I'm developing a procedure and within it I'm trying to access another server and make a select into a table that belongs to this another server. When I compile this procedure I have this error message: " PLS-00904: insufficient privilege to access object BC.CADPAP", where BC.CADPAP is the problematic table.
    How can I use more than one connection into an Oracle Stored Procedure?
    How I can access tables of a server from a Stored Procedure since the moment I'm already connected with another server?
    Can I create a Stored Procedure That access data from tables of another servers?

    You need to have a Database Link between two servers. Then you could do execute that statement without any problem. Try to create a database link with the help of
    CREATE DATABASE LINK command. Refer Document for further details

  • Unused stored procedure parameters marked with a check mark in crystal reports

    Post Author: epowers0213
    CA Forum: General
    Hello,
    I have some Crystal Reports that currently use stored procedures as their datasources (I am in the process of modifying them to use datasets instead).  Some of the original reports have check marks next to stored procedure parameters which I cannot find as being used anywhere in the report.  Is this a legitimate possibility? (Some of them do not have check marks, however, so it is not consistent.)
    More Info:  I am using Crystal Reports within Visual Studio 2005.  I have looked through each report in every way I can think of to find if a parameter field is being used anywhere - I have checked all formula fields, the formatting formulas for sections and individual fields, the record and group selection formulas and the grouping and sorting experts, along with any subreports (although some of them have no subreports).
    (I have read on other forums that exporting a report definition file is another way to look for where fields or parameters are being used, but this does not appear possible within Visual Studio 2005.)
    In some cases, I have gone ahead and replaced the stored procedure datasource location with a dataset (generated based on the same stored procedure).  When I do this, Crystal automatically deletes the stored procedure parameters from the report, and I have still been able to run the modified report successfully - at least it looks ok and nothing is complaining.  So is it possible that these parameters were actually not being used anywhere on the report although they were marked with a check mark?
    Any help would be greatly appreciated!  I want to make sure I am not changing the function of these reports somehow without knowing it...
    Thank you!

    Are you referencing another database that Crystal can't see? Also, you can try and copy the SQL to a command object in Crystal to see if it behaves differently there.

  • How to run a webdynpro multiple times by passing different parameters each time and save webpages with parameter name?

    Hi Experts,
    I am a BW consultant and new to webdynpro. Not sure how to run RSO_METADATA_REPOSITORY multiple times and by passing different parameter values each time(either taken from an a standard BW table or user provided - anything is fine) and build web pages with parameter name. Need help with direction on where to start.
    Let me step back and explain my requirement:
    In BW we have an object called transformation.
    One way of generating documentation for transformation is highlight transformation and press F1. Then its documentation will be opened as a local web page.
    I need these web pages for all transformations. This is my requirment.
    I came to know that RSO_METADATA_REPOSITORY is beeing used to generate this web page.
    The web link is something like below:
    http://ubw05.xxx.com:8005/SAP/BW/DOC/METADATA/?page=BW_O_D&SystemID=BWPCLNT100&ClassID=TRFN&ID=0KHR6J65AIIUTCJZEC093K6XDFV909PB&objectVersion=A&sap-language=EN&sap-client=100
    When i run this link seperately(not by selecting transformation and pressing F1) i need to enter login credentials to BW system.
    My challenges is how do i pass login credentials and multiple transformation IDs to generate multipe web pages with each page named by transformation ID?
    WHere to start? First of all is RSO_METADATA_REPOSITORY Webdynpro JAVA or webdynpro ABAP or can i use anything?
    Since it is beeing opened as local webpages i assume it is webdynpro JAVa is that correct?
    Thanks,
    Raghu

    hello,
    might be a problem with the version you are using.
    regards,
    the oracle reports team

  • Calling stored procedure in Access but data stored in SQL

    Our data is stored in SQL, but due to some restriction I need to make stored procedure in Access instead of SQL. I created the relevant link in Access to call the tables in SQL. Whenever I invoke the SQL database in Access, a login screen will appear which ask for password and user. This creates a problem for me when i execute the stored procedure in Access. It will create connection error to SQL database, just because I have no idea of how to write java code to fill in the username and password when the login dialog appears. Does anyone have any idea?

    Well, it still doesn't work. Here is part of the code, have a look please.
    public DisplayQueryResults() {
       String studattUrl = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:/StudAtt/StudAtt.mdb";
       String mustbUrl = "jdbc:odbc:mustb";          
       try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          studattConn = DriverManager.getConnection(studattUrl);
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          mustbConn = DriverManager.getConnection(mustbUrl, "sa", "");               
    private void getTable() {
       try {
          stmtStudAtt = studattConn.createStatement(resultSet.TYPE_SCROLL_SENSITIVE, resultSet.CONCUR_READ_ONLY);
          stmtMustb = mustbConn.createStatement();
          CallableStatement callSP = studattConn.prepareCall("{call mustbFaculty}");
          resultSet = callSP.executeQuery();
          displayResultSet(resultSet);
       }

  • Can i use Stored procedures and triggers with SDK

    hi all
    How to use the stored procedure and Triggers with SDK, can i get a sample code
    Regards
    Salah

    Hi, Salah.
    Use "Exec" in your query to run procedures.
    SAPbobsCOM.Recordset     oRS;
    oRS = (SAPbobsCOM.Recordset)pCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
    oRS.DoQuery ("EXEC YourStoredProcName");
    Triggers are not supported in SDK.
    Regards,
    Aleksey

  • How to start microsof access with parameter through runtime.exec

    Hi,
    I try to start access with parameter like this:
    String[] cmd = new String[4];
    cmd[0] = "C:\\Programme\\Microsoft Office\\OFFICE11\\MSACCESS.EXE";
    cmd[1]= "C:\\MyDB.mdb ";
    cmd[2] = "/cmd";
    cmd[3] = "parameter1 parameter2";
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(cmd);
    However the access mdb startet but it seems not to take the parameter i want to put in to access.
    Have anyone an Idea, what is wrong here?
    Thanks

    Hi
    What do you expect Access to do?
    The /cmd command line option sets the value that is returned by VBA Command function (see http://msdn2.microsoft.com/en-us/library/aa211469(office.11).aspx).
    If you want to start a macro, you would need the /x switch (see http://office.microsoft.com/en-us/access/HA101666051033.aspx).
    Hope this helps
    Christoph

  • Stored Procedure w/ binary data parameter problems in Visual Basic

    Howdy all.
    I am having a problem calling stored procedures with a BLOB parameter. I have tried changing the paramater other data types to see if it would work, but with no success. I am calling the stored procedure from Visual Basic using ADO. I am using the Oracle ODBC Driver, Release 9.2.0.4.0. I have tried changing the setup of the ODBC a good bit because that has fixed several problems for me in the past; however, it did not fix my current problem.
    Here is what I am trying to do. I have a function like the folowing:
    <BEGIN --------------------------------------->
    CREATE OR REPLACE FUNCTION PAGEFORMATSINSERT(
    p_ObjectFormatCode_ID      IN RAW DEFAULT NULL,
    p_PA_ID      IN RAW DEFAULT NULL,
    p_Name      IN VARCHAR2 DEFAULT NULL,
    p_FormatData      IN BLOB DEFAULT NULL,
    p_PF_ID      IN OUT RAW )
    RETURN INTEGER
    AS
    BEGIN
    INSERT INTO PAGEFORMATS (PF_ID, ObjectFormatCode_ID, PA_ID, Name, FormatData) /* <---- this FormatData column is a BLOB column */
    VALUES     (p_PF_ID, p_ObjectFormatCode_ID, p_PA_ID, p_Name, p_FormatData)
    END PAGEFORMATSINSERT;
    <END ----------------------------------------->
    The FormatData parameter has a data type of BLOB. In my Visual Basic, I have my ADODB.Command object. I am setting the CommandText of the Command object to "{? = call PageFormatsInsert(?, ?, ?, ?, ?)}". In order to set the parameter value for the BLOB data type, I am calling the AppendChunk function of the Command object - passing it a Byte array.
    I am getting the folling error:
         ERROR: -2147467259 [Oracle][ODBC][Ora]ORA-06550: line 1, column 13:
         PLS-00306: wrong number or types of arguments in call to 'PAGEFORMATSINSERT'
         ORA-06550: line 1, column 7:
         PL/SQL: Statement ignored
    If I change the FormatData parameter to a LONG RAW parameter, I get the following error:
         ERROR: -2147467259 [Oracle][ODBC][Ora]ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error
         ORA-06512: at line 1
    I am at a loss as to how to get binary data into by Oracle database. I need to do it using stored procedures. How can I set up my stored procedure or table to do what I want it to do? Should I change my table definition? Are there some settings in the ODBC connection I can tweak? How can I get the stored procedure to accept my call from VB ADO?
    Any help would be appreciated.
    wally

    Thanks for the idea, but I don't get how I am supposed to get my binary data to the stored procedure using the stream. I have a binary array that I want to pass to a stored procedure. I want to be able to use the same Visual Basic front end with out MSSQL database as with our Oracle database.
    I am using the ADODB Connection and Command and RecordSet objects. Currenlty our front end calls the ADODB.Command(ParamNumber).AppendChunk function passing it the binary array. Somehow, the SQL Server driver does the magic in order for the MSSQL stored procedure to work correctly. I need to know how to do one of the following:
    1. Get the Oracle driver to do the same magic.
    2. Set up the Oracle stored procedure so I don't have to change the VB front end.
    3. Change the VB front end so that it works with both MSSQL and Oracle.
    wally

  • Procedure or function expects parameter name which was not supplied

    SQL 2008R2 - BIDS
    I added an additional parameter to my SSRS Report.  I set it up identical to a couple other parameters already in the report.  I added the parameter to the dataset.  I added the parameter to the stored procedure and verified that it functions
    correctly in SSMS.
    When I Preview the report I get the Procedure expects parameter error even though the parameter is in the parameter list with a value (0) assigned.
    How can I make this work???

    Hi John,
    The most likely is the parameter name on the dataset , doesnt match the parameter you created ,the best was is to delete the parameters related to the dataset   and apply the stored procedure again  to a dataset it willl create the parameters  automatically,i
     have replicated the logic  below is  an example
    Create Procedure testp
    @Country Varchar(max),
    @Year Int
    as
    SELECT     DimSalesTerritory.SalesTerritoryCountry, DimDate.CalendarYear, FactInternetSales.SalesAmount
    FROM         FactInternetSales INNER JOIN
                          DimDate ON FactInternetSales.OrderDateKey = DimDate.DateKey INNER JOIN
                          DimSalesTerritory ON FactInternetSales.SalesTerritoryKey = DimSalesTerritory.SalesTerritoryKey
    where SalesTerritoryCountry =@Country
    And DimDate.CalendarYear=@Year
    I have just renamed one of the parameter  for year to YYear and it throws an error similar to yours 
    Many Thanks
    Chandra
    Please mark as answered If this helps to solve your issue.

  • ORABPEL-11809 - call a stored procedure - error in OUT parameter

    Hi all.
    I have a problem in a BPEL process that calls a stored procedure.
    I create a Partner Link that calls a stored procedure in the database. That procedure returns a type that is a table (is defined as a type of the database).
    When I deploy the process I have the following error:
    <messages>
    - <input>
    - <WC01_Pesquisa_Ut_InputVariable>
    - <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="InputParameters">
    - <InputParameters xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/IGIF/WC01/PESQUISA_UT/">
    <P_NIR xmlns="">
    165968274
    </P_NIR>
    <P_NOME_COMPLETO xmlns="">
    carla diogo
    </P_NOME_COMPLETO>
    <P_SEXO xmlns="">
    Feminino
    </P_SEXO>
    <P_DATA_NASC xmlns="">
    2007-03-01
    </P_DATA_NASC>
    <P_NATURALIDADE xmlns=""/>
    </InputParameters>
    </part>
    </WC01_Pesquisa_Ut_InputVariable>
    </input>
    - <fault>
    - <remoteFault xmlns="http://schemas.oracle.com/bpel/extension">
    - <part name="code">
    <code>
    17002
    </code>
    </part>
    - <part name="summary">
    <summary>
    file:/oracle/product/10.1.3/SOA/Integration10131/bpel/domains/default/tmp/.bpel_SaudeIdentificarCidadao_5.0_e3768f57d137443e1ba52d4a6d809426.tmp/WC01_Pesquisa_Ut.wsdl [ WC01_Pesquisa_Ut_ptt::WC01_Pesquisa_Ut(InputParameters,OutputParameters) ] - WSIF JCA Execute of operation 'WC01_Pesquisa_Ut' failed due to: Error registering an out parameter.
    An error occurred when registering parameter PESQUISA_UT as an out parameter of the IGIF.WC01.PESQUISA_UT API. Cause: java.sql.SQLException: Io exception: Connection reset [Caused by: Io exception: Connection reset]
    ; nested exception is:
         ORABPEL-11809
    Error registering an out parameter.
    An error occurred when registering parameter PESQUISA_UT as an out parameter of the IGIF.WC01.PESQUISA_UT API. Cause: java.sql.SQLException: Io exception: Connection reset [Caused by: Io exception: Connection reset]
    Check to ensure that the parameter is a valid IN/OUT or OUT parameter of the API. Contact oracle support if error is not fixable.
    </summary>
    </part>
    - <part name="detail">
    <detail>
    Internal Exception: java.sql.SQLException: Io exception: Connection resetError Code: 17002
    </detail>
    </part>
    </remoteFault>
    </fault>
    </messages>
    The code of the XSD created when I create the partner link is:
    <schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/IGIF/WC01/PESQUISA_UT/" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/IGIF/WC01/PESQUISA_UT/"
    elementFormDefault="unqualified" attributeFormDefault="unqualified">
    <element name="InputParameters">
    <complexType>
    <sequence>
    <element name="P_NIR" type="decimal" db:index="1" db:type="NUMBER" minOccurs="0" nillable="true"/>
    <element name="P_NOME_COMPLETO" type="string" db:index="2" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
    <element name="P_SEXO" type="string" db:index="3" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
    <element name="P_DATA_NASC" type="dateTime" db:index="4" db:type="DATE" minOccurs="0" nillable="true"/>
    <element name="P_NATURALIDADE" type="string" db:index="5" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
    </sequence>
    </complexType>
    </element>
    <element name="OutputParameters">
    <complexType>
    <sequence>
    <element name="PESQUISA_UT" type="db:TABELA_DE_IDS" db:index="0" db:type="Array" minOccurs="0" nillable="true"/>
    </sequence>
    </complexType>
    </element>
    <complexType name="TABELA_DE_IDS">
    <sequence>
    <element name="PESQUISA_UT_ITEM" type="decimal" db:type="NUMBER" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
    </sequence>
    </complexType>
    </schema>
    Any ideia?
    Thanks in advance.
    Carla

    I'd suggest that you turn on xml validation on the bpel boundaries to make sure that the xml being passed to the adapter is valid. You do this by logging in to bpel console, go to Manage Domain, at the bottom of the Configuration tab, set validateXml to true.
    Then see if it is an xml validation issue - in which case you will have to fix your maps to make sure it is valid indeed.
    Assuming your XML is valid and you are still seeing this error, couple of follow up questions:
    - are you using synonyms ?
    -- note that synonyms are not supported completely by the adapter at this time.
    - could you spell out where your types/sp-pkg resides and what are you connecting as at runtime ?
    -- just to keep things simple enough to debug, i'd do everything as just one user and slowly go to a scheme that you desire.
    HTH

  • How to call a stored procedure which has out parameter value

    my code is
    public Connection createConnection() {
                   Connection conn = null;
                        try {
                             Class.forName(DRIVER);
                             conn = DriverManager.getConnection(URL,USER,PASS);
                        } catch (ClassNotFoundException cnfe) {
                             System.err.print("Class not found");
                        } catch (SQLException sqle) {
                             System.err.print("SQLException");
                   return conn;
         public static void main(String args[]){
              StroedProcedure stp = new StroedProcedure();
              Connection con = stp.createConnection();
              try {
                   CallableStatement stproc_stmt = con.prepareCall("{call Account_Summary(?,?,?,?,?,?,?,?)}");
                   stproc_stmt.setString(1, "123456");
                   stproc_stmt.setDate(2, null);
                   stproc_stmt.setString(3, null);
                   stproc_stmt.setString(4, null);
                   stproc_stmt.setString(5, null);
                   stproc_stmt.setString(6, null);
                   stproc_stmt.setDate(7, null);
                   stproc_stmt.setDate(8, null);
                   stproc_stmt.registerOutParameter(1,Types.CHAR);
                   stproc_stmt.registerOutParameter(2,Types.DATE);
                   stproc_stmt.registerOutParameter(3,Types.CHAR);
                   stproc_stmt.registerOutParameter(4,Types.CHAR);
                   stproc_stmt.registerOutParameter(5,Types.CHAR);
                   stproc_stmt.registerOutParameter(6,Types.CHAR);
                   stproc_stmt.registerOutParameter(7,Types.DATE);
                   stproc_stmt.registerOutParameter(8,Types.DATE);
                   stproc_stmt.execute();
                   System.out.println("test "+stproc_stmt.getString(1));
                   ResultSet rs = stproc_stmt.executeQuery();
                  while (rs.next()){
                       System.out.println("result "+rs.getString("ACCPK"));
              } catch (SQLException e) {
                        e.printStackTrace();
         }And the stored procedure is
    CREATE OR REPLACE
    procedure Account_Summary (accpk in out char, incdt out date, bcur out char, bmark out char, tarTE out char, numHold out char, stDt out date, AsDt out date)
    is
    begin
    select account_pk, inception_date, base_currency, benchmark  into accpk, incdt, bcur, bmark
    from account a
    where a.Account_pk=accpk;
    select target_te, number_holdings, start_date, as_date into tarTE, numHold, StDt, AsDt
    from acc_summary asum
    where asum.account_pk=accpk;
    end Account_Summary;but it gives a exception ORA-01460: unimplemented or unreasonable conversion requested
    ORA-06512: at "REPRO.ACCOUNT_SUMMARY", line 4
    ORA-06512: at line 1
    i want to execute a stored procedure which has in , inout or out parameter
    but it can not work

    ========================
    In some contects varchar2 variable limit is 32512 characters... October 16, 2003
    Reviewer: Piotr Jarmuz from Poznan, Poland
    Interesting to note is the fact that varchar2 variables as parameters to stored
    procedures (in in/out out) may be "only" 32512 bytes long.
    I've checked this in Java and Perl. 32512 is the last value that works, for any
    bigger it throws:
    Exception in thread "main" java.sql.SQLException: ORA-01460: unimplemented or
    unreasonable conversion requested
    But in PL/SQL as you said 32767
    Regards,
    Piotr
    =================================
    This i got it from ask tom, well it make sense.... try checking your input with small numbers and strings
    Have fun

  • Is it possible to make stored procedure which results with only one row?

    Greetings community,
    I’m making the app in .NET, and I don’t really have the problem to get the result, but through watching videos I’ve realized that using LINQ isn’t always the best way of doing things, because it requires pulling too much data through the
    network to do some LINQ over it. There’s also the issue of security, so I was advised to use stored procedures and functions on SQL server to accomplish what I need without disturbing client machines too much.
    I’m absolute beginner in TSQL, so I need your help. I need to extract last order of particular customer and I wonder if that could be accomplished. To make things simple, let’s imagine that my orders table has only these three columns:
    OrderID (int, primary key, identity incremented), CustomerID (int), and DateOfOrder(datetime). I need a procedure that would take CustomerID as parameter, and return one single row which represent the last order of that customer.
    I would also be very grateful to see the extended procedure that would take LastCount additional parameter and return several rows which would represent last several orders of that customer.
    Last thing, if it’s not too much already, I would very appreciate some link to educational videos about SQL server for beginners. There were great videos on msdev.com, but this web address doesn’t exist anymore.

    There are many tutorials on MSDN with Linq including SQL Server Express. A good start is this here:
    http://msdn.microsoft.com/en-us/library/bb399349(v=vs.110).aspx
    -Jens
    Jens K. Suessmeyer http://blogs.msdn.com/Jenss

  • Ref Cursor - how to access through parameter name

    Hi,
    I'm using the below table and sample data. The below script named 'Script1' works well, my concern is values for the first and second parameters need to be used for the thrid and fourth one as well.
    When I try with 'Script2' it gives "ORA-01008: not all variables bound ORA-06512: at line 17" error. I know Paramterized cursor can handle this effecively, since it is a dynamic SQL, I need to use from a parameter table, I don't have any control over the number of parameteters, parameter name, type and other things. So, I cannot go for parameterized cursor.
    As of now, for my requirement, Script1 works fine, is there any way to make Script2 to work as well, I need to pass paramters by name, not by position, please give your suggestions, thank you.
    CREATE TABLE T1
    F1 NUMBER(5),
    F2 VARCHAR2(100),
    F3 DATE
    Insert into T1
    (F1, F2, F3)
    Values
    (1, 'One', TO_DATE('08/02/2012 07:43:34', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into T1
    (F1, F2, F3)
    Values
    (2, 'Two', TO_DATE('08/02/2012 08:15:24', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into T1
    (F1, F2, F3)
    Values
    (3, 'Three', TO_DATE('08/02/2012 08:16:34', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    Script1:
    declare
    TYPE t_ref_cursor IS REF CURSOR;
    v_cursor t_ref_cursor;
    v_query_str varchar2(3000);
    v_f1 number(5);
    v_f2 varchar2(100);
    v_f3 date;
    begin
    v_query_str := 'SELECT f1, f2, f3 from t1 where f1 = :p1 and f3 = to_date(:p2, ''DD-MON-YYYY hh24:mi:ss'') union ';
    v_query_str := v_query_str || 'select 1, ''c1'', sysdate from dual where not exists (select 1 from t1 where f1 = :p3 and f3 = to_date(:p4, ''DD-MON-YYYY hh24:mi:ss''))';
    --dbms_output.put_line(v_query_str);
    open v_cursor for v_query_str using 1, '02-AUG-2012 07:43:34', 1, '02-AUG-2012 07:43:34';
    loop
    fetch v_cursor into v_f1, v_f2, v_f3;
    exit when v_cursor%notfound;
    dbms_output.put_line(v_f1 || ' ' || v_f2 || '' || v_f3);
    end loop;
    dbms_output.put_line('rowcount ' || v_cursor%rowcount);
    close v_cursor;
    end;
    Script2:
    declare
    TYPE t_ref_cursor IS REF CURSOR;
    v_cursor t_ref_cursor;
    v_query_str varchar2(3000);
    v_f1 number(5);
    v_f2 varchar2(100);
    v_f3 date;
    begin
    v_query_str := 'SELECT f1, f2, f3 from t1 where f1 = :p1 and f3 = to_date(:p2, ''DD-MON-YYYY hh24:mi:ss'') union ';
    v_query_str := v_query_str || 'select 1, ''c1'', sysdate from dual where not exists (select 1 from t1 where f1 = :p1 and f3 = to_date(:p2, ''DD-MON-YYYY hh24:mi:ss''))';
    --dbms_output.put_line(v_query_str);
    open v_cursor for v_query_str using 1, '02-AUG-2012 07:43:34';
    loop
    fetch v_cursor into v_f1, v_f2, v_f3;
    exit when v_cursor%notfound;
    dbms_output.put_line(v_f1 || ' ' || v_f2 || '' || v_f3);
    end loop;
    dbms_output.put_line('rowcount ' || v_cursor%rowcount);
    close v_cursor;
    end;
    /

    This link shall answer your Question. PL/SQL Dynamic SQL.
    If it had been an Anonymous Block, your code would work through.
    Please see demonstration below:
    create or replace procedure emp_data (dep_id    number, sal   number, emp_id    number)
    is
      l_cnt   number;
    begin
      select count(*)
        into l_cnt
        from hr.employees
       where department_id = dep_id
         and salary >= sal
         and employee_id > emp_id;
      dbms_output.put_line('Count :: ' || l_cnt);
    end;
    declare
      l_cnt           number;
    begin
      execute immediate 'begin emp_data(:1, :2, :2); end;' using 20, 100;
    end;
    anonymous block completed
    Count :: 2
    --Trying the Similar example as in your OP.
    --Execute the same Select statement as in emp_Data with Bind Variables;
    declare
      l_cnt           number;
    begin
      --execute immediate 'begin emp_data(:1, :2, :2); end;' using 20, 100;
      execute immediate 'select count(*)
        from hr.employees
       where department_id = :1
         and salary >= :2
         and employee_id > :2' into l_cnt using 20, 100;
      dbms_output.put_line('Count :: ' || l_cnt);
    end;
    Results in error :- ORA-01008: not all variables bound

  • MSSQL Stored Procedure has duplicate OUT parameter

    Hi All;
    I am using the WLS MSSQL jdbc driver (mssqlserver4v70rel510sp8) for wls
    5.1 sp 12. The following code generates a duplicate OUT parameter.
    Parameters 4 and 5 are duplicated. I went over the stored procedure in
    ISQL, and the problem is not occurring there. Has anyone seen this sort of
    problem? I noticed this problem does not occur when I have the "?=" in
    front.
    stmt = con.prepareCall("{ ?= call webactivate..ValidatePromoCode(?, ?,
    stmt.registerOutParameter(1, java.sql.Types.INTEGER);
    stmt.setString(2, marketingCode);
    stmt.setString(3, activationData.getRawServiceNumber());
    stmt.registerOutParameter(4, java.sql.Types.VARCHAR);
    stmt.registerOutParameter(5, java.sql.Types.INTEGER);
    stmt.registerOutParameter(6, java.sql.Types.INTEGER);
    stmt.execute();
    Log.putDebug("#1="+stmt.getString(1));
    Log.putDebug("#4="+stmt.getString(4));
    Log.putDebug("#5="+stmt.getString(5));
    Log.putDebug("#6="+stmt.getString(6));
    Paul Rowe

    Thanks Joseph. I was hoping you would get back to me on this. You are the
    king of this newsgroup. Here's what I got, which indicates some type of
    problem on my end:
    Update count = 1
    Update count = 1
    Update count = 1
    Update count = 1
    Update count = 1
    Output status: 4
    Output param 1: 4
    Output param 2: marketingCode activationData.getRawServiceNumber()
    Output param 3: 2
    "Joseph Weinstein" <[email protected]> wrote in message
    news:[email protected]...
    Paul Rowe wrote:
    Hi All;
    I am using the WLS MSSQL jdbc driver (mssqlserver4v70rel510sp8) for
    wls
    5.1 sp 12. The following code generates a duplicate OUT parameter.
    Parameters 4 and 5 are duplicated. I went over the stored procedure in
    ISQL, and the problem is not occurring there. Has anyone seen this sortof
    problem? I noticed this problem does not occur when I have the "?=" in
    front.Hi Paul. Please run this sample program below with the driver you have,and
    let me know the output. it works with the latest driver I have. I get:
    C:\joe\70bugs>java foo
    Update count = 1
    Output status: 4
    Output param 1: marketingCode activationData.getRawServiceNumber()
    Output param 2: 2
    Output param 3: 3
    The code:
    import java.sql.*;
    import java.util.*;
    class foo {
    public static void main(String[] args) throws Exception
    Properties props = new Properties();
    props.put("user", "sa");
    props.put("password", "");
    props.put("server", "natoma");
    try {
    Driver myDriver = (Driver)
    Class.forName("weblogic.jdbc.mssqlserver4.Driver").newInstance();
    Connection con = myDriver.connect("jdbc:weblogic:mssqlserver4",props);
    >
    String proc = "create proc foojoe @bar varchar(60), @qwevarchar(60), "
    + " @asd varchar(60) output, @zxc int output, @ert intoutput "
    + " as select @asd = @bar + @qwe select @zxc = 2 select@ert = 3 "
    + " return 4";
    Statement s = con.createStatement();
    try { s.executeUpdate("drop proc foojoe"); } catch (Exceptionignore){}
    s.executeUpdate(proc);
    CallableStatement stmt = con.prepareCall("{ ?= callfoojoe(?,?,?,?,?) }");
    stmt.registerOutParameter(1, java.sql.Types.INTEGER);
    stmt.setString(2, "marketingCode");
    stmt.setString(3, " activationData.getRawServiceNumber()");
    stmt.registerOutParameter(4, java.sql.Types.VARCHAR);
    stmt.registerOutParameter(5, java.sql.Types.INTEGER);
    stmt.registerOutParameter(6, java.sql.Types.INTEGER);
    stmt.execute();
    while (true) // how to handle any callable statement...
    ResultSet rs = stmt.getResultSet();
    int updateCount = stmt.getUpdateCount();
    // If there are no more results or counts, we're done.
    if (rs == null && updateCount == -1)
    break;
    // Check to see if there is a ResultSet
    if (rs != null) {
    while (rs.next()) {
    System.out.println("Get first resultset col by id:" +rs.getString(1));
    rs.close();
    } // Otherwise, there will be an update count
    else {
    System.out.println("Update count = " + updateCount);
    stmt.getMoreResults();
    // Best to retrieve status and output parameters
    // after all result sets and update counts have been retrieved.
    System.out.println( "Output status: " + stmt.getInt(1));
    System.out.println( "Output param 1: " + stmt.getString(4));
    System.out.println( "Output param 2: " + stmt.getString(5));
    System.out.println( "Output param 3: " + stmt.getString(6));
    catch(Exception e) { e.printStackTrace(); }

Maybe you are looking for

  • Variable list updates in cli with cdb.vs.mod when values have spaces

    Hi - I keep variable lists for composite components in SVN - stored in the same format they're downloaded from the variables settings screen (don't forget to restore the missing semi-colon on the next-to-last line). Then the build scripts run this:  

  • Invalid Number?

    Hello, I have created some functions and a procedure to call them. I cannot seem to find the error that is being generated by SQLPlus when I execute the procedure. It seems to be a simple one, but I need at least one more pair of eyes to look for the

  • What is a "short code" and how do I stop them from texting me?

    I started getting texts from what is apparently a short code in December.  Now I am getting them daily. I really need this to stop.  And yes, I tried replying "stop" and that hasn't helped.

  • Moving playlists from iPhone or iPad into iTunes

    Is there a good solution to move my playlists from either my iPhone or iPad into iTunes? I backed up to computer but I see that it only backed up purchased music.

  • Cost centre report with all GL expense accounts

    Hi Gurus; Can you please give a cost centre report that gives all GL expense accounts with the correponding Cost centres or functional areas ni the next column? Example: Column A                        B                C                          D GL