Executing Multiple SQL queries in one connection

I'm trying to do, 2 queries in a single connection to my MySQL database.
At the moment I'm just passing a String into execute query.
I want to do another check in the database just after I get the first query's results.
Right now, I'm closing the connection and creating a whole new one again as it doesn't seem to work otherwise.
Do I just need to create a new "Statement" & "ResultSet" and then do my thing within the connection brackets?
I did that but was getting no response. Perhaps I'm missing something?
Code to SELECT all Documentaries from the database:
String getDocs = "SELECT * from podDir WHERE genre='Documentaries'";
    try {
      Connection con = DriverManager.getConnection("jdbc:mysql://localhost/jspod", "root", "pass");
      System.out.println("got connection");
      Statement s = con.createStatement();
      ResultSet r2 = s.executeQuery(getDocs);
      while (r2.next()) {
        out.println("<TD>" + StringUtil.encodeHtmlTag(r2.getString(1)) + "</TD>");
        out.println("<TD><A href='" + StringUtil.encodeHtmlTag(r2.getString(3)) + "'>" + StringUtil.encodeHtmlTag(r2.getString(2)) + "</a></TD>");
        out.println("<TD>" + StringUtil.encodeHtmlTag(r2.getString(4)) + "</TD>");
        out.println("<TD>Subscribe</TD>");
        out.println("</TR>");
        out.println("<TR><TD></TD><TD>" + StringUtil.encodeHtmlTag(r2.getString(6)) + "</TD>");
        out.println("</TR>");
      r2.close();
      s.close();
      con.close();
    catch (SQLException e) {
    catch (Exception e) {
    }

Thanks ram..
I'm now finding I'm facing a situation, however where
I need two executions ongoing at one time.
I need to select all listings from a directory table
and then check if the person logged in has subscribed
to that listing from a "Mysubs" table concurrently to
display "You are/not subscribed to this
listing".
Is it possible to have two ongoing executions?Some would prefer to do all that in a single query - but then one has to be pretty good in sql for that.
You can do the stuff with 2 or more queries too. Open a Connection, create a PreparedStatement(or a Statement) with your first query for the listings. Get the result set, hold the output in a ListingModel object. You would then close the result set and the statement and then open new ones for your second query which can be supplemented with data from the model object. Or you can retrieve the entire data and compare with the listing info in the ListingModel object. Close everything in a finally block.
ram.

Similar Messages

  • Execute multiple sql queries in plsql

    Hello All,
    I have two queries, How to execute multiple sql queries in plsql. Once the query completed in sql+ that report/output has to come in html.
    Please guide to how to do that.
    Thanks and Regards,
    Muthu
    [email protected]

    There are several ways to do what you are wanting, but you should consider posting your question in the correct forum (PL/SQL). This forum is for question about Oracle Forms! :)
    As to your question, take a look at this: How to output query results as HTML.
    Craig...

  • How to execute multiple sql query in one time?

    HI
    I'm trying to convert my sql project In Oracle. In sql i could run multiple select statement/query in once and they return in multiple table result respectively. but in oracle its not executed.
    like:
    sqlQry := "Select * from abc; select * from qwe; select * from kkk; select * from xyz"
    its return 4 table abc, qwe,kkk,xyz to my dataset result
    how it is possible in oracle 10g

    Saten Chamoli wrote:
    I'm trying to convert my sql project In Oracle. In sql i could run multiple select statement/query in once and they return in multiple table result respectively. but in oracle its not executed.
    like:
    sqlQry := "Select * from abc; select * from qwe; select * from kkk; select * from xyz"
    its return 4 table abc, qwe,kkk,xyz to my dataset result That is pretty much a hack - there are no ANSI SQL standards supporting this syntax. It makes no sense either.
    If you want to combine 4 data sets, there are the UNION and UNION ALL set commands.
    If you want to create 4 cursors with a single call, then use the following (anonymous PL/SQL block) call:
    begin
      open :c1 for select * from abc;
      open :c2 for select * from qwe;
      open :c3 for select * from kkk;
      open :c4 for select * from xyz;
    end;Bind 4 client cursor variables to the ref cursors c1 to c4 and make the call to Oracle.
    And I suggest that you read up on Oracle concepts and fundamentals as your approach with you "sql project" shows ignorance in this regard.

  • How to execute multiple sql statements

    hi all
    i am wondering if i can execute multiple sql statements in one shot with >> execute immediate command
    for example:
    i define the variable as X := sql statement
    Y := sql statement
    z := sql statement
    can i do execute immediate (X,Y, Z);
    if yes how ?? and if not any possible alternate
    thanks

    Starting with Ganesh's code
    DECLARE
       l_statement                 VARCHAR2 (2000);
       v_passwd                    VARCHAR2 (200);
       v_username                  VARCHAR2 (200) := 'test';
       v_pwd_key                   VARCHAR2 (200) := 'lwty23';
       v_dblink_name               VARCHAR2 (2000);
       v_dblink_drop               VARCHAR2 (2000);
       v_dblink_create             VARCHAR2 (2000);
       v_dblink_check_connection   VARCHAR2 (2000);
       l_number                    NUMBER;
    BEGIN
       --<<c_instance>>
       FOR c_instance IN (SELECT *
                            FROM v_oracle_instances
                           WHERE environment = 'Developement')
       LOOP
          SELECT encpwd_owner.display_db_encpwd (v_username,
                                                 c_instance.host_name,
                                                 c_instance.instance_name,
                                                 v_pwd_key)
            INTO v_passwd
            FROM DUAL;
          v_dblink_name := c_instance.host_name || '_' || c_instance.instance_name;
          v_dblink_create :=
                ' CREATE DATABASE LINK '
             || v_dblink_name
             || ' CONNECT TO '
             || v_username
             || ' '
             || 'IDENTIFIED BY '
             || v_passwd
             || ' USING'
             || ' ''(DESCRIPTION=
    (ADDRESS=(PROTOCOL=TCP)(HOST= '
             || c_instance.host_name
             || ')(PORT='
             || c_instance.LISTENER_PORT
             || '))(CONNECT_DATA=(SID='
             || c_instance.instance_name
             || ')))''';
          v_dblink_check_connection := 'select 1 from global_name@' || v_dblink_name || '.QCM';    --- Notice this change. I am simply selecting 1. That should be enough to test the database link.
          v_dblink_drop := 'drop database link ' || v_dblink_name || '.QCMTLAF';
          -- l_statement := 'BEGIN ' || v_dblink_create ';' || v_dblink_check_connection ';' || v_dblink_drop '; END ;'
          BEGIN
              EXECUTE IMMEDIATE (v_dblink_create);
              DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Created');
         EXCEPTION
            WHEN others THEN
               dbms_output.put_line( 'Failed to create the database link ' || v_dblink_name  );
               dbms_output.put_line( dbms_utility.format_error_backtrace() );
               INSERT INTO error_table( column_list )
                 VALUES( <<list of values>> );
         END;
          EXECUTE IMMEDIATE (v_dblink_check_connection) INTO l_number;    --- Notice this.
          DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Tested');
          BEGIN
             EXECUTE IMMEDIATE (v_dblink_drop); 
             DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Dropped');
          EXCEPTION
             WHEN others THEN
               dbms_output.put_line( 'Failed to drop the database link ' || v_dblink_name  );
               dbms_output.put_line( dbms_utility.format_error_backtrace() );
               INSERT INTO error_table( column_list )
                 VALUES( <<list of values>> );
         END;
       END LOOP;
    END;But I agree with the point that others have brought up that it really doesn't make sense to create and drop a database link like this.
    Justin

  • Multiple SQL Queries in SAP BPC  5.1 EVMODIFY

    Hi All,
    We have multiple SQL Queries in Outlooksoft 4.2 which extracts data from Oracle source system with different set of selections and conditions and parameters. We were able to use multiple SQL Queries in Outlooksoft 4.2 using Transform Data Flow Task and paste parameters using evModify dynamic script task, where ever extract to source system is needed.
    According to  SAP BPC 5.1, all these multiple SQL Queries and extracts by passing parameters will be coded in EVMODIFY dynamic script editor.But, EVMODIFY dynamic script editor is not working with the sets of multiple SQL Queris.It's able to recognize and execute the first SQL Query, but not able to execute from the second SQL Query.
    Does any body, did multiple extracts using SQL Queries to the source system by passing parameters using SAP BPC 5.1 data  manager and SSIS Packages, please let me know, how you did achieve the above functionality.
    Regards,
    Sreekanth.

    Hi Sorin,
    Thanks for your update, I tried declaring the variable between %%....GLOBAL(%GTIMEID%,%SELECTION%) and the package runs now but the problem is that the package is executed using the default date value for the variable GTIMEID declared in the DTSX package and its not taken the date that I'm trying to pass from BPC.  As showed below, please if you could take a look to the ModifyScript and see the last line for the global variable and line 13  PROMTP(SELECTINPUT,%SELECTION%,,,%TIME_DIM%) where I am selecting the TIMEID:
    DEBUG(ON)
    PROMPT(INFILES,,"Import file:",)
    PROMPT(TRANSFORMATION,%TRANSFORMATION%,"Transformation file:",,,Import.xls)
    PROMPT(RADIOBUTTON,%CLEARDATA%,"Select the method for importing the data from the source file to the destination database",0,{"Merge data values (Imports all records, leaving all remaining records in the destination intact)","Replace && clear data values (Clears the data values for any existing records that mirror each entity/category/time combination defined in the source, then imports the source records)"},{"0","1"})
    PROMPT(RADIOBUTTON,%RUNLOGIC%,"Select whether to run default logic for stored values after importing",1,{"Yes","No"},{"1","0"})
    PROMPT(RADIOBUTTON,%CHECKLCK%,"Select whether to check work status settings when importing data.",1,{"Yes, check for work status settings before importing","No, do not check work status settings"},{"1","0"})
    INFO(%TEMPFILE%,%TEMPPATH%%RANDOMFILE%)
    PROMPT(SELECTINPUT,%SELECTION%,,,%TIME_DIM%)
    TASK(CONVERT Task,INPUTFILE,%FILE%)
    TASK(CONVERT Task,OUTPUTFILE,%TEMPFILE%)
    TASK(CONVERT Task,CONVERSIONFILE,%TRANSFORMATION%)
    TASK(CONVERT Task,STRAPPSET,%APPSET%)
    TASK(CONVERT Task,STRAPP,%APP%)
    TASK(CONVERT Task,STRUSERNAME,%USER%)
    TASK(Dumpload Task,APPSET,%APPSET%)
    TASK(Dumpload Task,APP,%APP%)
    TASK(Dumpload Task,USER,%USER%)
    TASK(Dumpload Task,DATATRANSFERMODE,1)
    TASK(Dumpload Task,CLEARDATA,1)
    TASK(Dumpload Task,FILE,%TEMPFILE%)
    TASK(Dumpload Task,RUNTHELOGIC,1)
    TASK(Dumpload Task,CHECKLCK,1)
    GLOBAL(%GTIMEID%,%SELECTION%)
    Do you guess That I am missing something?
    Thanks in advanced
    Regards

  • Executing multiple SQL statements fails using ODBC

    Executing multiple SQL statements will fail with error 'ORA-00911 invalid character' when connecting to an Oracle database using ODBC driver version 8.01.07.00.
    When I use either my application or the Oracle ODBC Test client utility connecting using ODBC driver version 8.01.07.00 I can only get a single CALL statement (as shown below) to execute:
    CALL BHInsert (TO_DATE('2003.07.23 10:04:28','YYYY.MM.DD HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','
    ','Event File
    Name','\\KILLIANS\BATCHCTL\SampleDemo1\JOURNALS\1.evt','','AREA1','','','','','','1','','','','','',' ','');
    When I try to execute the following string with multiple CALL statements (as shown below) it fails with the following error being returned - ORA-00911: invalid character
    CALL BHInsert (TO_DATE('2003.07.23 10:04:28','YYYY.MM.DD HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','
    ','Event File
    Name','\\KILLIANS\BATCHCTL\SampleDemo1\JOURNALS\1.evt','','AREA1','','','','','','1','','','','','',' ','');
    CALL BHInsert (TO_DATE('2003.07.23 10:04:28','YYYY.MM.DD
    HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','Version','Recipe Header','1.0','','AREA1',' ','
    ','','','','1','','','','','',' ','');
    CALL BHInsert (TO_DATE('2003.07.23 10:04:28','YYYY.MM.DD
    HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','Version Date','Recipe Header','5/18/2001 1:28:32
    PM','','AREA1',' ',' ','','','','1','','','','','',' ','');
    CALL BHInsert (TO_DATE('2003.07.23
    10:04:28','YYYY.MM.DD HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','Author','Recipe Header','Mark
    Shepard','','AREA1',' ',' ','','','','1','','','','','',' ','');
    I've tried adding a line feed in addition to the space at the end of each call but that doesn't seem to help. Also have tried unsuccessfully to change the seperator used between each call using various valid continuation characters.
    Executing multiple CALL statements from within Oracle's SQL Worksheet connecting as the same user and password, as my application executes successfully. However when I try this from within the Oracle ODBC test client, it fails with the same ORA-00911 error that I'm seeing in my application.
    I'm currently trying the more recent ODBC drivers, however any ideas or suggestions would be greatly appreciated.

    Can you take the begin ... end block and run it using SQL*Plus?
    I can't think of any documentation that would specifically answer this question. I'm sure if you read & absorbed the ODBC Programmers Reference (2000+ pages) you'd be able to find out, but I don't know of a quick way to find out.
    You can enable SQL*Net tracing. There are a fair number of options for enabling this tracing-- http://tahiti.oracle.com has all the Oracle manuals online, which should give you enough info to configure exactly what you want.
    I would suggest, however, that you look into more performant/ scalable alternatives rather than going too far down this path. A block with lots of SQL statements with literals isn't going to make your database happy even if you get it to work.
    Justin

  • Issue on execute multiple SQL Statement on MySQL

    Hi,I plan to execute dozenes of INSERT SQL statement on MySQL by JDBC:org.gjt.mm.mysql.Driver,But it throws the unkown exeption,pls kindly help
    The code is like the follwoing
    sql="insert into TEST values('100','test') ";
    stmt=cnMySQL.createStatement();
    stmt.addBatch(sql);
    stmt.addBatch(sql);
    stmt.executeBatch();
    //stmt.executeUpdate(sql);

    The Exception is very tough,paste for all
    javax.servlet.ServletException
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:497)
         at org.apache.jsp.testBean_jsp._jspService(testBean_jsp.java:293)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
         at java.lang.Thread.run(Thread.java:484)
    I have tried another way to execute multiple SQL.But the same Exception ocurred.
    String sql="insert into TEST('100','100V'); "+
    "insert into TEST('100','100V') ";
    stmt.executeUpdate(sql);
    Can't it the jdbc of MM support this kind of operation? And is there any better JDBC for mySQL?
    Apprieciated for all!!!

  • Recursive Java programming method for executing recursive SQL queries

    Anybody has a Java/JDBC example method to execute recursive SQL queries and print results? The method has to work for any number of queries and levels and the first query passes the parameter to the second query.
    Edited by: user4316962 on Jun 12, 2011 1:59 PM

    user4316962 wrote:
    Guys, the problem what I am trying to solve is much more complex and I don’t think SQL level recursion is enough. I am looking for Java solution with SQL queries in it to make it more flexible and DB independent.
    If you want to do recursion in SQL then it has nothing to do with Java.
    And if you want to do recursion in Java then the idiom itself has nothing to do with SQL.
    Other than that you have provided enough detail for anyone to even guess at what you are asking.
    As a start I am not even sure that you understand what recursion is nor how JDBC works. (But it could be that you are using the terms to mean something else.)
    And looking at your original post it could be nothing more than that you are looking for a design pattern - perhaps the interpreter.

  • How to execute multiple SQL statements thru frontend?

    With SQL Server database, you can execute multiple SQL statements.
    Ex.
    SQLCommand cmd = new SQLCommand();
    cmd.CommandText = "SELECT * FROM EMP; SELECT * FROM DEPT";
    cmd.ExecuteXXX();
    Note that for SQL Server, ";" (semocolon) is used as a separator.
    What separator is required for Oracle ? Or rather, can I execute multiple SQL statements against Oracle database (10g) ?
    (Why I want to do it is a totally diff. subject !)
    Thanks,
    Ami.

    Hello,
    You could use an anonymous PL/SQL block to batch multiple statements.
    If you want to use SELECT statements, you would open a REF CURSOR for each SELECT and return the REF CURSOR to your application. INSERT, UPDATE, and DELETE statements can just be passed as is.
    A simple REF CURSOR example might look like:
    begin
      open :v_refcursor1 for select * from emp;
      open :v_refcursor2 for select * from dept;
    end;Where v_refcursor1 and v_refcursor2 are parameters defined as a REF CURSOR type.
    Hope that helps a bit...
    - Mark

  • SQL Developer cannot execute multiple queries in one connection

    Hi,
    Using : SQL Developer 1.2.29.98, Oracle Database 9i on Windows XP.
    Currently I have TOAD and PL/SQL Developer to handle things related to Oracle Database.
    I found this SQL Developer tools as an interesting tool which might replace PL/SQL Developer (I assume).
    I opened two SQL Worksheets and tried to execute 2 queries (time consuming one) simultanously, suddenly it freezes (the window become grayed). Just like TOAD, we cannot smoothly execute multiple queries on single connection on SQL Developer
    I can monitor the query process using TOAD (Session Browser) and found both queries are running while SQL Developer window become grayed and seems not functioning. After the queries have been finished, I mean both of them, the SQL Developer window become normal and "alive" again showing the expected results.
    Well, however PL/SQL Developer could handle this. Executing multiple queries in single application is just its unbeatable features.
    We can view the query result once its finished instead of until the others being processed, by just only switch the SQL Windows.
    Is it true that SQL Developer doesn't support executing multiple queries?
    Or is it a feature which we should request?
    Or we have to activate this feature by doing some changes on configuration / preferences?
    (Do we need to open two SQL Developer instances? what a memory consuming solution).
    Regards,
    Buntoro

    SQLDeveloper connections are single threaded and also rather single minded (in that you can't do much else while a long query is running.)
    There is an existing feature request http://apex.oracle.com/pls/otn/f?p=42626:39:3685254426061901::NO::P39_ID:4202 for which you can vote.
    The workaround is to have multiple connections. Not brilliant but it works.

  • Run Multiple SQL's in one Database and record there counts automatically.

    Hi ,
    I have to run 33 Sql's in three databases seperately and then have to match there counts, manually if i do it takes 3+ hours, is there any way to automate this in Toad i.e all 33 Sql's run in different databases and in the end i get the result count of all of them and then i compare the results.
    The 33 queries are:-
    select count(*),'FND_LOOKUP_VALUES' as TABLE_NAME from FND_LOOKUP_VALUES a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'CSF_DEBRIEF_HEADERS' as TABLE_NAME from CSF_DEBRIEF_HEADERS a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'CSF_DEBRIEF_LINES' as TABLE_NAME from CSF_DEBRIEF_LINES a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'CS_INCIDENTS_AUDIT_B' as TABLE_NAME from CS_INCIDENTS_AUDIT_B a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'CS_INCIDENT_LINKS' as TABLE_NAME from CS.CS_INCIDENT_LINKS a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'CS_INCIDENT_SEVERITIES_TL' as TABLE_NAME from CS_INCIDENT_SEVERITIES_TL a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'CS_INCIDENT_STATUSES_TL' as TABLE_NAME from CS_INCIDENT_STATUSES_TL a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'CS_INCIDENT_TYPES_TL' as TABLE_NAME from CS_INCIDENT_TYPES_TL a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'CS_INCIDENT_URGENCIES_TL' as TABLE_NAME from CS_INCIDENT_URGENCIES_TL a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'CS_INCIDENTS_ALL_B' as TABLE_NAME from CS_INCIDENTS_ALL_B a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'CS_HZ_SR_CONTACT_POINTS' as TABLE_NAME from CS_HZ_SR_CONTACT_POINTS a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'CS_INCIDENTS_ALL_TL' as TABLE_NAME from CS_INCIDENTS_ALL_TL a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'CSI_ITEM_INSTANCES' as TABLE_NAME from CSI_ITEM_INSTANCES a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'JTF_RS_GROUPS_B' as TABLE_NAME from JTF_RS_GROUPS_B a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'JTF_TASK_REFERENCES_B' as TABLE_NAME from JTF_TASK_REFERENCES_B a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'OKC_K_LINES_B' as TABLE_NAME from OKC_K_LINES_B a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'OKC_K_ITEMS' as TABLE_NAME from OKC_K_ITEMS a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'HZ_RELATIONSHIPS' as TABLE_NAME from HZ_RELATIONSHIPS a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'HZ_CONTACT_POINTS' as TABLE_NAME from HZ_CONTACT_POINTS a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'HZ_PARTY_SITES' as TABLE_NAME from HZ_PARTY_SITES a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'MTL_SYSTEM_ITEMS_TL' as TABLE_NAME from MTL_SYSTEM_ITEMS_TL a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'JTF_TASK_ASSIGNMENTS' as TABLE_NAME from JTF_TASK_ASSIGNMENTS a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'JTF_TASK_PRIORITIES_TL' as TABLE_NAME from JTF_TASK_PRIORITIES_TL a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'JTF_TASK_PRIORITIES_B' as TABLE_NAME from JTF_TASK_PRIORITIES_B a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'JTF_TASK_STATUSES_TL' as TABLE_NAME from JTF_TASK_STATUSES_TL a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'JTF_TASKS_B' as TABLE_NAME from JTF_TASKS_B a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'JTF_OBJECTS_TL' as TABLE_NAME from JTF_OBJECTS_TL a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'JTF_TASK_TYPES_TL' as TABLE_NAME from JTF_TASK_TYPES_TL a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'JTF_TASK_AUDITS_B' as TABLE_NAME from JTF_TASK_AUDITS_B a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'JTF_TASK_ASSIGNMENTS' as TABLE_NAME from JTF_TASK_ASSIGNMENTS a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*),'EMCCS_SRLOG_ADD_AUDIT_COLMS' as TABLE_NAME from EMCCS_SRLOG_ADD_AUDIT_COLMS a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*), 'cs_incident_statuses_b' as TABLE_NAME from cs.cs_incident_statuses_b a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    select count(*), 'jtf_task_statuses_b' as TABLE_NAME from jtf.jtf_task_statuses_b a
    where a.creation_date > to_date('08/06/2010','mm/dd/yyyy')
    and a.creation_date <= to_date('08/07/2010','mm/dd/yyyy');
    Thanks in Advance.

    Hi,
    From TOAD you can connect to three different databases- that is different sessions with different DB's
    make a use of union operator and execute the queries.
    You can see the output in - output window.
    Select the output and right click save to excel sheet.
    Parallely you can run 33 sql in other sessions, do the same process as stated above and save to the same excel sheet but different instance (different sheet of excel)
    Now compare -- its demo for how to utilize the tool.
    Other way around, Create one table with two columns table_name, count.
    execute the select queries with union Operator and directly insert into the table.
    Perform the same above two steps in different databases.
    Now, from one database - create database link to other two dabases and provide select privilege on that table in order to access.
    Now, write a query to compare two tables using dblink.
    HTH
    - Pavan Kumar N
    OCP- Oracle 9i/10g
    http://oracleinternals.blogspot.com

  • Executing Multiple Select Queries in a Single attempt

    HI,
    I executed two select queries in a single statement execute. It is executing without any error. Hence there must be two resultset objects within that single statement.
    What the problem is that I m able to fetch the first resultset and its data, But I execute stmt.getMoreResults() to move to the next resultset, it returns false, which means there is no more results. I want to know what is the problem ?? (Record exist in the database for both queries)
    And How can I rertieve both the resultsets. ??
    Plz help me asap.
    For ur convenience I m posting the Java code also which I m trying.
    sql.delete(0, sql.length());
    sql.append("select FIRST_NAME , MIDDLE_NAME , LAST_NAME from USER_MASTER where USER_ID=4;");
    sql.append("select producttransaction_id, product_type from product_transaction where transaction_id=102 order by product_type desc");
    Statement stmt = con.createStatement();
    stmt.execute(sql.toString());
    int resultsetcount =1;
    ArrayList arrlist = new ArrayList();
    rs = stmt.getResultSet();
    if(rs !=null)
    if(rs.next())
    .........// logic here working properly
    //Now when I move to next resultset using the below statement
    //it returns false indicating that there r no more results.
    // Why this is so ?????
    boolean moreresultsets = stmt.getMoreResults();
    System.out.println("MoreResultsets::"+moreresultsets);
    if(moreresultsets)
    rs = stmt.getResultSet();          
    if(rs!=null)
    while(rs.next())
    //...Logic.......
         rs.close();
    Thanks

    I've never seen this used the way you are using it. In my experience the only way to do this would be to execute a single SQL statement that returns multiple result sets - you are trying to append two SQL statements.
    You could define an in-line procedure wrapping your two select statements, or you could define a stored procedure to do the same thing. Then (either way) use CallableStatement to execute the call to the procedure.

  • How do i access multiple bex queries in one crystal reports??

    Hello Experts,
    I have 10 cubes and 30 bex queries on it and i need to create 3 final crystal reports on these 30 queries.
    I am on BI 4.0 & CR 2011. but my client is not on correct SAP patch ie., he is on 15+ but he must be on 23+ to access multiple bex queries on CR 2011 Database expert. (I am unable to see bex queries in Database expert to link couple of bex queries)
    And my client env doesnt have SAP EP for SAP BW Netweaver Connection to create a connection to access cubes or queries in IDT.
    Do my client env need EP? so that SAP BICS Connection will work in IDT?
    How do i approach to achive this...
    Thank you...

    Hi,
    have you checked the option "allow external access" in your query? SAP Toolbar will find all queries but the database export needs this flag to be set.
    Using multiple queries within one crystal report is using the "multi database join feature" of crystal reports. You can link your queries by key fields and crystal will join them in memory. So when there are many queries or many datarows this can be a huge performance killer.
    Actuallly one of our customers is running a report which has more than 20 BEx queries linked together. It runs just fine.
    Please be sure to set your joins correctly. E.g. crystal will try to make a join on the "key figures" sturcture if you let it create a suggestion or it will try to link on all fields of an infoobject. This will bring MDX errors.
    So you should be setting your joins correctly - the [infoobject]-[20infoobject] fields are fine for that.
    I hope you can use some of my words.
    Regards
    Thorsten

  • How to execute multiple sql statements in oracle?

    I want to execute multiple statements in a single transaction in oracle. Following are my queries:
    Create table temp_table as Select * from table;
    SELECT * FROM temp_table d;
    drop table temp_table ;
    I am using sql comment text in asp.net
    I am using executenonquery command in asp.net.
    Thanks,
    Divya

    SigCle ,
    Here's an example that executes 3 statements;
    begin insert into foo values(1); insert into foo values(2); insert into foo values(3); end;
    923354,
    The block doesn't compile because temp_table doesn't exist at the point you're trying to compile the anonymous block. I'd recommend re-reading the doc link and forum link provided to get a better understanding of how temp tables work, as it's simply different with Oracle. You don't create Oracle temporary tables on the fly; you create them ahead of time and then just use them. The data itself is already specific to a particular session; you don't create and drop the table each time.
    Also, you can't just "select * from table" in plsql. The results have to GO SOMEWHERE. Usually you'd either open a cursor and process it in the block, or send out a ref cursor if you want to send the data to a client side app. The ref cursor data wouldn't actually be fetched until the block completes though, so you'd need to use ON COMMIT PRESERVE ROWS, which would also mean you'd need to clean up the data yourself (delete the data from the table when you're done with it).
    Corrections/comments welcome.
    Greg

  • How to execute multiple sql statement?

    In an single transaction I want to execute two update statements. I don't know how to break those statements and send to oracle from Asp.Net to execute.
    I tried go and ; .
    Below is myQuery string*
    update abc set One = 10 where Two = 3 ; update xyz set Three = 10 where Four = 3 ;
    Additional info
    I am using sql comment text in asp.net
    I am using executenonquery command in asp.net.

    Hi,
    If you want to execute multiple statements in a single transaction, you could either:
    a) create a local transaction (via an OracleTransaction object), then call executenonquery multiple times within that transaction, or
    b) pass them all in an anonymous block for a single round trip.. ie, begin update abc set One = 10 where Two = 3 ; update xyz set Three = 10 where Four = 3 ;end;
    The database doesn't permit multiple statements passed at once (other than in a plsql block).
    Hope it helps, corrections/comments welcome
    Greg
    PS, questions such as this would be better posted in the ODP.NET forum; this forum is for issues regarding ODT.NET (a VS plugin)
    ODP.NET

Maybe you are looking for

  • Why won't combined AND statement work

    I want to exclude records based on two criteria's: status = 'M' and the status reason = 52. The table contains records with status = 'M' and status reason other than 52. Also the table contains records with status other than 'M' and status reason = 5

  • Signature behavior

    What exactly is a signature? I know how to use it, but I am interested in more detail. Is it a separate entity from the email body? Is it just pasted into the body? Why are there problems sometimes, such as in an older version of mail, if there was a

  • Network Preferences keep changing

    Hello All Every time I start up my old G3 iMac (OS 10.2), the network preferences change from "USB Modem" to "Internal Modem", this is despite the preferences being locked. Also, when I try to change back, the USB Modem isn't even listed. It usually

  • Does anybody know whether Primavera Project Management software can be used under Mac OSX ?

    I itend to use the Primavera software which we are using under Windows with my Apple Notebook and would like to know whether there is an OS X version existing.

  • Track AP OU information in GL

    Hello all, Is it possible to transfer OU name from AP to GL reference field by using SLA. Please advise me to track that. Thanks and Regards, Muthu