Multiple Resultset

I tried to get multiple result sets in query by using sql query string like this, for example:
"select * from A; select * from B"
But I got oracl error: ORA-00911: Invalid character.
I thought we can do multiple result sets. Does anyone know correct way?
Thanks

if i have a bunch of simple select sql, doing multiple
resultset can reduce the trafficI'm not real big on sql, but it sounds to me like you need a stored procedure. Just a thought. I realize not all databases allow them.

Similar Messages

  • Calling stored procedure and returning multiple resultsets

    Hello,
    Is it possible to create a procedure that return multiple result sets?
    e.g.
    procedure GetDataFromTables() is
    begin
    select * from table_one;
    select * from table_two;
    end GetDataFromTables;
    And I want to call this procedure that returns multiple resultsets (one for table_one and another for table_two)
    I have referred to the OCCI sample occiproc.cpp, but I am not sure how to handle multiple resultsets.
    Your help is highly appreciated.

    Thank You,
    Got the REF cursor in storedproc.cpp.
    But as it is documented, getCursor() gets the REF CURSOR value of an OUT parameter as a ResultSet.
    So, is it true that if I have to write a procedure that selects * from 50 tables (50 SQL statements) , I have to set 50 OUT parameters to get the result sets.?
    Is there any better way of doing this?
    e.g. in DB2, we can open multiple cursors in the procedure body and then get the result set one after another.
    CREATE PROCEDURE get_staging_data ()
    RESULT SETS 1 <no. of result sets>
    LANGUAGE SQL
    BEGIN ATOMIC
    DECLARE L_SQL varchar(5000);
    DECLARE c CURSOR WITH RETURN TO CLIENT FOR L_STMT;
    SET L_SQL = '';
    SET L_SQL = 'SELECT * FROM ';
    SET L_SQL = L_SQL || IN_Tab_Name ;
    SET L_SQL = L_SQL || ' WHERE VERIFY_FLAG=''S'' FOR READ ONLY OPTIMIZE FOR 2000 ROWS' ;
    PREPARE L_STMT FROM L_SQL;
    OPEN c; < can open multiple cursors in the prodedure body>
    END

  • Multiple ResultSets with Oracle Thin Driver.

    Hi,
    I am using Oracle Thin Driver to Connect to the Oracle Database (8.1.7). I wanted to take advantage
    of the multiple Resultsets Scenario for fetching Data from the DB. Please have a look at the code
    fragment below.
    String sql = "select * from TAB1; select * from TAB2";
    Connection conn = getConnection();
    PreparedStatement stmnt = conn.prepareStatement(sql);
    stmnt.execute();
    However , I am getting the following Error.
    java.sql.SQLException: ORA-00911: invalid character
    Could anyone give me the possible reason/corrected syntax for the SQL.
    Thanks for any help in advance.

    It's unclear what your problem is...
    However...
    Oracle will only execute one SQL statement at a time in a Statement or PreparedStatement; therefore these can only return a single ResultSet.
    However, an Oracle stored procedure can be written to return multiple results; it can therefore be run from a CallableStatement and getMoreResults() is then used to get the additional ResultSet data.
    An example of doing this is here:
    http://edocs.beasys.com/wls/docs81/jdbc_drivers/oracle.html
    scroll towards the bottom and look for Listing 5-3

  • JDBC Adapter - Multiple Resultsets

    Hello,
    Does anyone know if the JDBC adapter can return multiple resultsets?
    So something like the following JDBC Code:
    CallableStatement cstmt;
    ResultSet rs;
    int i;
    String s;
    cstmt.execute();       //Call the stored procedure      
    rs = cstmt.getResultSet(); //Get the first resultset
    while (rs.next()) {
    i = rs.getInt(1);                          System.out.println("Value from first set = " + i); 
    cstmt.getMoreResults();//Point to the second resultset  rs = cstmt.getResultSet();// Get the second resultset
    while (rs.next()) {
    s = rs.getString(1);                 
    System.out.println("Value from second resultset = " + s);
    Greetings,
    Bart

    Hi Bart,
    sure you can select more than one table either with Stored Procedue or with Query Statement for example (also if you concate more than one SQL statement) like:
    update table1 set STATUS = 4 where STATUS = 3 select *
    from table1 bk inner join table2 on (KEY = BZ_KEY) where KEY = 449070
    - or you create an View onb DB side that makes all of your Data selection:
    select * from view where status = 4
    - but you also can use stored procedure - in my opinion the most powerfuel tool...
    If their is something left -keep asking
    Regards Matt

  • Multiple resultset - strange problem

    Hi,
    I have a stored procedure that returns a single resultset correctly.
    ResultSet rs = cstmt.executeQuery();
    while(rs.next()).......
    Now, I have to change this stored proc, to return multiple resultsets. To test if my code works, I did not change the stored proc(it still returns 1 resultset), but changed my code to -
    boolean results = cstmt.execute();
    System.out.print("do resultsets exist - "+results);
    System.out.print("update count- "+cstmt.getUpdateCount());
    For some strange reason, the boolean value is false! And the updatecount value is 1.
    Can someone pls. explain this? I have the code for retrieving multiple resultsets, but it does not get executed because the initial 'results' value is false.
    Thanks in advance.

    I've never done what you're doing. I do it like this:
            CallableStatement cs = conn.prepareCall("{call PKG_BLAH.MY_FUNCTION(?,?,?)}");
            cs.setLong(1, someKey);
            cs.setString(2, someId's);
            cs.registerOutParameter(3, ORACLECURSORVALUE);
            cs.execute();
            ResultSet rs = (ResultSet) cs.getObject(3);
            while (rs.next()) {
    }

  • Having multiple resultsets open at the same time

    Hi,
    I have the following piece of code to populate multiple resultsets returned by a call to a stored procedure in Sybase.
    int l_noOfResultSetsReturned = 0;
    int l_nextResultSetToPopulate = 1;
    boolean l_isResultSet = l_CallableStatement.execute();
            while( l_isResultSet )
                switch ( l_nextResultSetToPopulate )
                    case 1:
                        l_reportListResultSet =  l_CallableStatement.getResultSet();
                        break;
                    case 2:
                        l_inputSetterResultSet = l_CallableStatement.getResultSet();
                        break;
                    case 3:
                        l_outputGetterResultSet = l_CallableStatement.getResultSet();
                        break;
                    case 4:
                        l_outputColumnHeaderResultSet = l_CallableStatement.getResultSet();
                        break;                     
                    default:
                        //throw new CubeInvalidNumberOfResultSetsException();
                        System.out.println(" More than 4 RS returned");
                l_noOfResultSetsReturned++;
                l_nextResultSetToPopulate++;
                l_isResultSet = l_CallableStatement.getMoreResults(PreparedStatement.KEEP_CURRENT_RESULT);
            }The problem is that when I try to run this, I get the following error:
    java.lang.AbstractMethodError: com.sybase.jdbc.SybCallableStatement.getMoreResults(I)Z
    I am using NetBeans 3.6 as the IDE with the java version 1.4.2_06. I got this error when I tried using jconnect45.jar for the driver part. I also tried the same with jconn2.jar. It also gave me the same error.
    I need someway to ensure that the four resultsets are open for further down the line processing. Any help would be most welcome.
    Thanks and regards,
    Ganesh

    I think the AbstractMethod Error is caused by calling a method which is not available on your JDBC Driver. This means you are using a JDBC 3 method on a JDBC 2 driver (or JDBC 2 on JDBC 1 driver). Check the JDBC version of your driver and use only the methods allowed for the JDBC driver version you have (or get a newer one).
    Good Luck!

  • How to return Multiple ResultSets Using Callable Statement

    hi everybody,
    while i was working with callable statements i came across a problem of how to fetch Multiple Resultsets by means of Stored Procedures written for tables in Oracle.
    If any one can help me, pls do help me with a detailed explanation, and if possible do get me a example source code too.
    khumaar

    I have a similar problem with oracle and jdbc:
    I want to send a sql query like:
    sqlQuery = "select n1, n2 from table1; select n1, n2
    from table2"
    I used a prepared statement, but when I call
    .execute(sqlQuery)
    oracle doesn't like this,
    can someone help on this?Try putting a begin/end around it. Play with the syntax first in sqlplus.
    You do realize that you MUST extract using the syntax for extracting multiple result sets correct? It will NOT work as one result set.

  • Calling a SP from MSSQL and retrieving multiple resultsets

    I have a SP on MSSQL and I am making a call to SP using CallableStatement.
    here a snippet
    <%! static Connection connection = null;%>
    <%! private static CallableStatement cs1,cs2; %>
    <%! private static ResultSet rs1,rs2; %>
    <%
    try{
    Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
    connection = DriverManager.getConnection("","username", "password");
    System.out.println("Database connected");
    cs1 = connection.prepareCall("{call GetTasksForCalendar (?,?)}");
    System.out.println("1");
    cs1.setString(1,"testts");
    cs1.setString(2,"12/20/2006");
    System.out.println("2");
    boolean resultsetsavailable = cs1.execute();
    while(resultsetsavailable)
         System.out.println("a");
         ResultSet rs = cs1.getResultSet();
         ResultSetMetaData rsmd = rs.getMetaData();
    System.out.println("Column count"+rsmd.getColumnCount());
         System.out.println("b");
         while(rs.next())
         System.out.println("c");
         System.out.println("d");
         System.out.println("e");
         resultsetsavailable = cs1.getMoreResults();
         System.out.println("f");
         System.out.println("3");
    %>
    <%}catch(Exception e){}
    finally{
    %>The out put is like this (it returns totally 8 result sets)
    Database connected
    1
    2
    a
    Column count8
    b
    e
    f
    a
    Column count8
    b
    e
    f
    a
    Column count8
    b
    e
    f
    a
    Column count8
    b
    e
    f
    a
    Column count8
    b
    e
    f
    a
    Column count8
    b
    e
    f
    a
    Column count8
    b
    e
    f
    3You can observe that the code within while(rs.next()) is not getting executed. When I print rs.next() it is printed "false".
    the store procedure is returning multiple result set values.
    Any suggestions or help i can expect for???
    thanks so much
    Rk.

    Try setting rs to null after each loop.As i
    faced the same problem with ms access and it
    worked.Hopefully it helps you out.You wrote a stored procedure in MS AccessMS-SQL Server, nobody said anything about Access.Okay never mind I misread your post and I have no clue what Ashitosh is on about.

  • Multiple ResultSets from the same connection occuring at the same time

    Is it possible to have the following code? The issue is that you are iterating through two result sets created from the same connection at the same time.
    try {
    Connection conn=createConnection();
    Statement s=conn.createStatement();
    ResultSet rs=s.executeQuery(someSQL);
    while (rs.next()) {
         Statement s2=conn.createStatement();
          ResultSet rs2=s2.executeQuery(someOtherSQL);
          while (rs2.next()) {
               //do something
    } catch (SQLException sqle) {
    } finally {
    freeConnection(conn);

    Joel,
    The code compiles, but I have not tried running it. It is a question I need to know, designing a program.
    The question is whether some error would come up or the first ResultSet would be corrupted because a second were created before the first one was closed.
    --Gabe                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Cannot read multiple resultsets from transaction datasource

    I get a SQL exception "This object was closed() and cannot be used anymore."
    when I try to access the first row of the second result set from a stored procedure.
    This occurs when the code is running within an EJB using a transaction-capable
    datasource hooked to a connection pool that uses the MSSQLSERVERv7 JDriver
    to talk to SQL Server 7.0.
    I noted that the resultset class used is weblogic.jdbc20.rmi.SerialResultSet.
    The error occurs during the resultSet.next() call even though the resultset is
    not null and getUpdateCount() returns -1.
    However, the same code works correctly when run in a simple main() procedure from
    the DOS command line, connecting directly to the database using only the classes
    supplied with the JDriver product. The resultset class used in this case is
    weblogic.jdbc.mssqlserver4.TdsResultSet.
    The stored procedure is very simple, it just has two lines: SELECT 'Hello' and
    SELECT 'World'. The Java code follows.
    <PRE>
    // ... code to get the connection ...
    CallableStatement callableStatement = connection.prepareCall("{CALL spTest}");
    callableStatement.execute();
    ResultSet resultSet = callableStatement.getResultSet();
    if ((resultSet != null) && resultSet.next())
    System.out.println("Row from first result set:" + resultSet.getString(1));
    callableStatement.getMoreResults();
    resultSet = callableStatement.getResultSet();
    if ((resultSet != null) && resultSet.next()) // this call to next() throws the
    exception
    System.out.println("Row from second result set:" + resultSet.getString(1));
    resultSet.close();
    callableStatement.close();
    connection.close();
    </PRE>
    I am running WL5.10sp11 with mssqlserver4v70sp11 on NT4.0sp6a and JDK1.3.0_02
    (HotSpot Client VM).
    Regards,
    Tom B.

    Tom Bechtold wrote:
    >
    Joe,
    Here is the debug messages and trace with your diagnostic jar.
    I hope this helps - Tom
    we got Hello
    java.sql.SQLException: java.lang.Exception: ResultSet originally closed at:
    at weblogic.jdbcbase.mssqlserver4.TdsResultSet.close(TdsResultSet.java,
    Compiled Code)
    at java.lang.Exception.<init>(Unknown Source)
    at weblogic.jdbcbase.mssqlserver4.TdsResultSet.close(TdsResultSet.java,
    Compiled Code)
    at weblogic.jdbcbase.jts.ResultSet.close(ResultSet.java:260)
    at weblogic.jdbc20.rmi.internal.ResultSetImpl.close(ResultSetImpl.java:53)
    at weblogic.jdbc20.rmi.SerialResultSet.close(SerialResultSet.java:54)
    ... rest of EJB call stack ...Hi. I do want to see the whole stack trace please, and also the EJB code.
    thanks,
    Joe
    >
    Joseph Weinstein <[email protected]> wrote:
    Tom Bechtold wrote:
    Hi Joe,
    I pasted your sample program into my bean and ran it under
    WL510sp11 and JDriver 5.1.0sp11, and it did exhibit the error
    as my code did.
    But it runs fine under WL510sp10 with JDriver 5.1.0sp11.
    Thanks for your great support,
    TomYou're very welcome. Please take the attached jar file, and add it
    at the front of the server's weblogic.classpath, by editting the
    startWebLogic script, and let me know what happens. This jar contains
    the ResultSet class, with a hack to remember where it was closed, and
    print that out if/when it is closed a second time.
    Joe
    Joseph Weinstein <[email protected]> wrote:
    Tom Bechtold wrote:
    A follow-on note: when I back out to Service Pack 10, the problem
    is
    not there,
    so it seems that it is an issue with Service Pack 11.
    - Tom Bechtold
    "Tom Bechtold" <[email protected]> wrote:
    I get a SQL exception "This object was closed() and cannot be used
    anymore."
    when I try to access the first row of the second result set from
    a
    stored
    procedure.
    This occurs when the code is running within an EJB using a transaction-capable
    datasource hooked to a connection pool that uses the MSSQLSERVERv7JDriver
    to talk to SQL Server 7.0.
    I noted that the resultset class used is weblogic.jdbc20.rmi.SerialResultSet.
    The error occurs during the resultSet.next() call even though theresultset
    is not null and getUpdateCount() returns -1.Hi. You say that getUpdateCount() returns -1. I don't see that inthe
    code you sent,
    so you probably just gave us a representative sample of the code you
    run. I did
    runs uch code with the driver alone, and it works as you say. I will
    see if I can
    set up a server to do this via a DataSource, but in case anyone wants
    to help/race with
    me :-), here's simple code to run. If you convert it to a DataSource
    connection,
    and it behaves differently, I'll send you a diagnostic class to seewhat's
    up...
    Joe
    Connection connection = null;
    try
    Properties properties = new Properties();
    properties.put("user", "sa");
    properties.put("password", "");
    Driver d = (Driver)Class.forName("weblogic.jdbc.mssqlserver4.Driver").newInstance();
    connection = d.connect("jdbc:weblogic:mssqlserver4:JOE:1433",
    properties);
    // or get connection from DataSource...
    Statement statement = connection.createStatement();
    try {
    statement.execute("drop procedure bla");
    } catch (Exception e){}
    statement.execute("create procedure bla as select 'Hello
    ' select 'world'");
    CallableStatement c = connection.prepareCall("{ call bla()
    c.execute();
    ResultSet resultset = c.getResultSet();
    while(resultset.next())
    System.out.println("we got " + resultset.getString(1));
    resultset.close();
    c.getMoreResults();
    resultset = c.getResultSet();
    while(resultset.next())
    System.out.println("we got " + resultset.getString(1));
    resultset.close();
    catch(SQLException exception1)
    exception1.printStackTrace();
    finally
    try { connection.close();} catch(Exception ex) {}
    However, the same code works correctly when run in a simple main()procedure
    from the DOS command line, connecting directly to the database
    using
    only
    the classes supplied with the JDriver product. The resultset classused in this
    case
    is weblogic.jdbc.mssqlserver4.TdsResultSet.
    The stored procedure is very simple, it just has two lines: SELECT
    'Hello'
    and SELECT 'World'. The Java code follows.
    // ... code to get the connection ...
    CallableStatement callableStatement = connection.prepareCall("{CALLspTest}");
    callableStatement.execute();
    ResultSet resultSet = callableStatement.getResultSet();
    if ((resultSet != null) && resultSet.next())
    System.out.println("Row from first result set:" + resultSet.getString(1));
    callableStatement.getMoreResults();
    resultSet = callableStatement.getResultSet();
    if ((resultSet != null) && resultSet.next()) // this call to next()throws the
    exception
    System.out.println("Row from second result set:" + resultSet.getString(1));
    resultSet.close();
    callableStatement.close();
    connection.close();
    I am running WL5.10sp11 with mssqlserver4v70sp11 on NT4.0sp6a and
    JDK1.3.0_02
    (HotSpot Client VM).
    Regards,
    Tom B.--
    B.E.A. is now hiring! (12/14/01) If interested send a resume to [email protected]
    DIRECTOR OF PRODUCT PLANS AND STRATEGY San Francisco,
    CA
    E-SALES BUSINESS DEVELOPMENT REPRESENTATIVE Dallas, TX
    SOFTWARE ENGINEER (DBA) Liberty Corner,
    NJ
    SENIOR WEB DEVELOPER San Jose,CA
    SOFTWARE ENGINEER (ALL LEVELS), CARY, NORTHCAROLINA
    San Jose, CA
    SR. PRODUCT MANAGER Bellevue,WA
    SR. WEB DESIGNER San Jose,CA
    Channel Marketing Manager - EMEA Region London, GBR
    DIRECTOR OF MARKETING STRATEGY, APPLICATION SERVERS San Jose,CA
    SENIOR SOFTWARE ENGINEER (PLATFORM) San Jose,CA
    E-COMMERCE INTEGRATION ARCHITECT San Jose,CA
    QUALITY ASSURANCE ENGINEER Redmond, WA
    Services Development Manager (Business Development Manager - Services)
    Paris, FRA; Munich, DEU
    SENIOR SOFTWARE ENGINEER (PLATFORM) Redmond, WA
    E-Marketing Programs Specialist EMEA London, GBR
    BUSINESS DEVELOPMENT DIRECTOR - E COMMERCE INTEGRATION San Jose,CA
    MANAGER, E-SALES Plano, TX--
    B.E.A. is now hiring! (12/14/01) If interested send a resume to [email protected]
    DIRECTOR OF PRODUCT PLANS AND STRATEGY San Francisco,
    CA
    E-SALES BUSINESS DEVELOPMENT REPRESENTATIVE Dallas, TX
    SOFTWARE ENGINEER (DBA) Liberty Corner,
    NJ
    SENIOR WEB DEVELOPER San Jose, CA
    SOFTWARE ENGINEER (ALL LEVELS), CARY, NORTH CAROLINA
    San Jose, CA
    SR. PRODUCT MANAGER Bellevue, WA
    SR. WEB DESIGNER San Jose, CA
    Channel Marketing Manager - EMEA Region London, GBR
    DIRECTOR OF MARKETING STRATEGY, APPLICATION SERVERS San Jose, CA
    SENIOR SOFTWARE ENGINEER (PLATFORM) San Jose, CA
    E-COMMERCE INTEGRATION ARCHITECT San Jose, CA
    QUALITY ASSURANCE ENGINEER Redmond, WA
    Services Development Manager (Business Development Manager - Services)
    Paris, FRA; Munich, DEU
    SENIOR SOFTWARE ENGINEER (PLATFORM) Redmond, WA
    E-Marketing Programs Specialist EMEA London, GBR
    BUSINESS DEVELOPMENT DIRECTOR - E COMMERCE INTEGRATION San Jose, CA
    MANAGER, E-SALES Plano, TX
    B.E.A. is now hiring! (12/14/01) If interested send a resume to [email protected]
    DIRECTOR OF PRODUCT PLANS AND STRATEGY San Francisco, CA
    E-SALES BUSINESS DEVELOPMENT REPRESENTATIVE Dallas, TX
    SOFTWARE ENGINEER (DBA) Liberty Corner, NJ
    SENIOR WEB DEVELOPER San Jose, CA
    SOFTWARE ENGINEER (ALL LEVELS), CARY, NORTH CAROLINA San Jose, CA
    SR. PRODUCT MANAGER Bellevue, WA
    SR. WEB DESIGNER San Jose, CA
    Channel Marketing Manager - EMEA Region London, GBR
    DIRECTOR OF MARKETING STRATEGY, APPLICATION SERVERS San Jose, CA
    SENIOR SOFTWARE ENGINEER (PLATFORM) San Jose, CA
    E-COMMERCE INTEGRATION ARCHITECT San Jose, CA
    QUALITY ASSURANCE ENGINEER Redmond, WA
    Services Development Manager (Business Development Manager - Services) Paris, FRA; Munich, DEU
    SENIOR SOFTWARE ENGINEER (PLATFORM) Redmond, WA
    E-Marketing Programs Specialist EMEA London, GBR
    BUSINESS DEVELOPMENT DIRECTOR - E COMMERCE INTEGRATION San Jose, CA
    MANAGER, E-SALES Plano, TX

  • (multiple) ResultSet problem

    I'm quite new to Java, but I couldn't find the answer to my question anywhere.
    1. It's an applet
    2. I'm using a MS Access 2000 ODBC/JDBC database
    3. Everything seems to work. I can connect, I can see the database entry if using the first ResultSet ("SELECT * FROM PARKEERGARAGE WHERE DATUM ='" + datum + "';"). But my 2nd resultset doesn't work. ( else { if (x == 5 || x == 6 || x == 7 || x == 1 || x == 2) {  ......... )
    4. This is only a small part of a huge applet.
    This is what I want:
    1. Check if the string is in the database (if yes, show it... that works)
    2. If it isn't, calculate (using GregorianCalendar) if it it is a Week or Weekend. (this doesn't work)
    3. Whatever it is, retrieve the row with Date = Week or Weekend.
    public void zoekOpeningstijden() {
    GregorianCalendar calendar;
    calendar = new GregorianCalendar(2004,12,30);
    int i = 0;
    String datum = beh_textfield_openingstijden_datum.getText();
    int x = calendar.get(calendar.DAY_OF_WEEK);
    connect();
    try {
    ResultSet rs = dbDAS.executeQuery("SELECT * FROM PARKEERGARAGE WHERE DATUM ='" + datum + "';");
    while (rs.next()) {
    i++;
    if (i == 1) {
    rs.previous();
    panel_beh_openingstijden_textarea.setText(rs.getString("DATUM"));
    rs.close();
    else {
    if (x == 5 || x == 6 || x == 7 || x == 1 || x == 2) {
    rs = dbDAS.executeQuery("SELECT * FROM PARKEERGARAGE WHERE DATUM = 'Week';");
    System.out.println(x);
    System.out.println(rs.getString("DATUM"));
    panel_beh_openingstijden_textarea.setText(rs.getString("DATUM"));
    rs.close();
    } else if (x == 3 || x == 4) {
    rs = dbDAS.executeQuery("SELECT * FROM PARKEERGARAGE WHERE DATUM = 'Weekend';");
    panel_beh_openingstijden_textarea.setText(rs.getString("DATUM"));
    rs.close();
    } catch (IOException ex) {} catch (SQLException ex) {}
    close();
    }

    You are not correctly using the ResultSet.
    1) In the case where i ==1, calling rs.previous() returns the cursor before the first record. Remove the rs.previous() call.
    2) The general use of a ResultSet is:
       ResultSet rs = connection.executeXXXX("SELECT ...");
       while (rs.next()) {
          // At each iteration of the loop, the cursor is positionned on the next record
          // so, here you will read the fields and do your stuff with them
          // For example:
          String productCode = rs.getString(1);  // first field  of current record
          int productQty = rs.getInt(2);         // second field of current record
          double productPrice = rs.getDouble(3); // third field of current record
       }3) Concerning the date problem, read more carefully the API Javadoc for the GregorianCalendar constructor:
    public GregorianCalendar(int year, int month, int date)
    Constructs a GregorianCalendar with the given date set in the default time zone with the default locale.
    Parameters:
    year - the value used to set the YEAR time field in the calendar.
    month - the value used to set the MONTH time field in the calendar. Month value is 0-based. e.g., 0 for January.
    date - the value used to set the DATE time field in the calendar.
    So, for DECEMBER you should use 11 instead of 12.
    Hope this helped,
    regards.

  • Multiple resultsets from the same query?

    Hi all,
         Can I define a query that will show more than one resultset (of similar structure), based on the different values of a particular characteristic?
         Say, characteristic C1 has 3 different values x1, x2 and x3. Is it possible to output 3 different resulsets based on x1, x2 and x3?
    Thanks,
    Satyajit.

    Hi Satyajit,
    I hope i am getting your problem right.
    By saying "3 different resulsets based on x1, x2 and x3"
    did u mean to say that the list of key figures u have specified in your columns portion of your query should be displayed 3 times,First with x1, then with x2 and then x3.?
    If thats the case what u can do is drag the characteristic C1 into the columns section of your query designer and keep it in top , followed by the key figures.
    Then you can achieve the desired result..
    Hope it helps.
    Regards,
    Parth.

  • Unable to Return multiple ResultSet

    Can someone please tell me why the following code doesn't work?
    It sets each String to the query return, but not every subsequent return.
    In other words, it sets it the first time, and that's it. It appears to continue
    continue looping for each of the following query returns, but never sets the
    Strings to those other values.
    calls_change_pstmt.execute();
                /* Retrieving results */
                ResultSet rs = calls_change_pstmt.getResultSet();
                while(rs.next() ) {
                    beat = rs.getString("BEAT");
                    call_descr = rs.getString("CALL_DESCR");
                    priority = rs.getString("PRIORITY");
                    date = rs.getString("DATE");
                    time = rs.getString("TIME");
                    location = rs.getString("LOCATION");
                    status = rs.getString("STATUS");
                    System.out.print(beat);
                }

    You'll have to excuse me, but I don't understand your answers. I've posted a more detailed example of my code:
    calls_change_pstmt = conn.prepareStatement
                        ("SELECT BEAT,CALL_DESCR,PRIORITY,DATE,TIME,LOCATION," +
                        "STATUS FROM SWEATY_BALLSAK.CALLS WHERE CALL_NUM = ?");
         * Detects a change between
         * the stored call and this call
         * @param call a String array
         * @return true if this call matches a stored call; false otherwise
        private boolean calls_change(String call[] ) {
            boolean change_found = false;
            boolean more_results = false;
            String beat = new String();
            String call_descr = new String();
            String priority = new String();
            String date = new String();
            String time = new String();
            String location = new String();
            String status = new String();
            try{
                calls_change_pstmt.setString(1, call[5]);
                calls_change_pstmt.execute();
                /* Retrieving results */
                ResultSet rs = calls_change_pstmt.getResultSet();
                while(rs.next() ) {
                    beat = rs.getString("BEAT");
                    call_descr = rs.getString("CALL_DESCR");
                    priority = rs.getString("PRIORITY");
                    date = rs.getString("DATE");
                    time = rs.getString("TIME");
                    location = rs.getString("LOCATION");
                    status = rs.getString("STATUS");
                    System.out.print(beat);
                rs.close(); 
                return change_found;
            catch(SQLException sqle_calls_change) {
                System.out.println("sqle_calls_change " +
                        sqle_calls_change.getMessage() );
                System.exit(0);
                return change_found;
        }I've taken out my logic to find a duplicate, and inserted a System.out.println instead. For clarity. Each of the Strings gets the correct value, the problem is each return after the first. How would I create more resultsets if I have no idea beforehand how many results i'm going to get? In this particular example it is suppose to return 3 sets, but at some point it could possibly be many many more.

  • Multiple Field field search with multiple resultset

    I have 10 controls in a form and when a control is selected the rest of controls are re-populated
    Here's my table structure
    Field1
    Field2
    Field3
    Field4
    Field5
    Field6
    Field7
    Field8
    Field9
    Field10
    Bus
    Tyre
    Steering
    Engine
    Gear
    Fuel
    MultiSeat
    Bus
    Door
    Steering
    Engine
    Gear
    Fuel
    MultiSeat
    Car
    Tyre
    Steering
    Engine
    Gear
    Fuel
    2 Row Seat
    Car
    Door
    Steering
    Engine
    Gear
    Fuel
    2 Row Seat
    Bike
    Tyre
    Handbar
    Engine
    Gear
    Fuel
    Single Seat
    Pillion
    Cycle
    Tyre
    Handbar
    Pedalling
    Single Seat
    Carrier
    Each field is dependent on other field. By default DISTINCT rows in each field is returned as a result set as below:
    select distinct(field1) from table
    select distinct(field2) from table
    Upon selecting any of the item from the dropdown rest of the dropdowns are bound.
    Is there any simplistic approach available?

    Hi
    Try this
    Create a
    datraview for above table in .net
    Then use
    ToTable() method of datagridview  which return datatable
    to get distinct value pass true in
    toTable() method which return distinct row set for column specified in toTable method
    Mark as answer if you find it useful
    Shridhar J Joshi Thanks a lot

  • HELP: SSIS 2012 - Execute SQL Task with resultset to populate user variables produces DBNull error

    I am experiencing an unexplainable behavior with the Execute SQL Task control in SSIS 2012. The following is a description of how to simulate
    the issue I will attempt to describe:
    1. Create a package and add two variables User::varTest1 and User::varTest2 both of String type with default value of "Select GetDate()"
    for each, have shown this to not matter as the same behavior occurs when using a fixed string value or empty string value.
    2. Add a new Execute SQL Task to the control flow.
    3. Configure an OLE DB connection.
    4. Set SQLSourceType = "Direct Input"
    5. Set the ResultSet property of the task to "Single Row"
    6. In the ResultSet tab add two results as follows: 
    Result Name: returnvalue1, Variable Name: User::varTest1
    Result Name: returnvalue2, Variable Name: User::varTest2
    7. Set an expression for the SqlStatementSource property with a string value of "Select 'Test' returnvalue1, 'Testing' returnvalue2'"
    The idea is that the source would be dynamically set in order to run a t-sql statement which would have dynamic values for database name
    or object that would be created at runtime and then executed to set the user variable values from its resultset. Instead what occurs is that a DBNull error occurs.
    I am not sure if anyone else has experienced this behavior performing similiar actions with the Execute SQL Task or not. Any help would be
    appreciated. The exact message is as follows:
    [Execute SQL Task] Error: An error occurred while assigning a value to variable "varRestoreScript": "The type of the value
    (DBNull) being assigned to variable "User::varRestoreScript" differs from the current variable type (String). Variables may not change type during execution. Variable types are strict, except for variables of type Object.
    User::varRestoreScript is the first return value. And even with the a dummy select the same result occurs. I have narrowed the issue down
    to the T-SQL Statement structure itself. 
    The following works just fine within the execute sql task control as long as no resultset is configured for return:
    "Declare @dynamicSQL nvarchar(max)
    Select @dynamicSQL = name 
    From sys.databases 
    Where name = 'master'
    Select atest_var1=@dynamicSQL, atest_var2='static'"
    I have tried various iterations of the script above with no success. However, if I use the following derivative of it the task completes
    successfully and variables are set as expected.  This will not work for my scenario however as I need to dynamically build a string spanning multiple resultsets to build one of the variable values.
    "Select atest_var1=name, atest_var2='static'
    From sys.databases
    Where name = 'master'
    I have a sample package which can reproduce this issue using the above code.  You can get to that through the post on www.sqlservercentral.com/Forums/Topic1582670-364-1.aspx
    Scott

    Arthur,  the query when executed doesn't return a null value for the @dynamicSQL variable.  It returns "master" as a string value.  Even the following fails which implements that suggestion:
    Declare @dynamicSQL as nvarchar(max)
    Select @dynamicSQL = name
    From master.sys.databases 
    Where name = 'master' -- (or any other DB name)
    I believe I have found the cause of the issue.  It is datatype and size related.  The above script will properly set the variables in the resultset as long as you don't use nvarchar(max) or varchar(max).  This makes the maximum data size for
    a String variable 4000 characters whether unicode or non-unicode typed.

Maybe you are looking for

  • Uncheck "Fill screen with one page at a time"

    Is it possible to set a javascript to turn off the preference "Fill screen with one page at a time" when entering in Full Screen mode? So that way, it will override Acrobat or Reader application preferences when the PDF is open on users computers.

  • Apps not transferring from iTunes to iPod

    I tried to find a thread about this but couldn't so here goes: I just bought an iPhone and have found a bunch of apps that i downloaded on my computer's iTunes. But when I sync my iPhone the apps are not transferred onto the phone. I tried downloadin

  • Itunes / Multiple speakers / airport Express

    When I select multiple speakes in Itunes i get an error saying "an unknown error occurred (-3256)." I can select the remote speakers by them self and they work fine but when I select all speakers or multiple speakers I get the error message. what can

  • Task Manager for HTC One

    What is the best task manager for the HTC one?

  • Iterative Development when using JSPX/JSFF in a Library?

    Using JDeveloper 11.1.1.6.0 - We have a WebCenter project that is utilizing a separate project that is compiled as a ADF Shared Library - to allow for reusable taskflows. We're trying to find a fast/convenient way of seeing changes to this shared lib