SQL statement with union clause

Hi,
I have a scenario where i need to generate a sql statement with UNION .
Eg:
SELECT B.YY_ID,
FROM XXXX.YY B
WHERE (B.YY_TY= 'as')
UNION
SELECT B.YY_ID
FROM XXXX.YY_ALT_NAME A, XXXX.YY B
WHERE (A.YY_TY= 'zx'
AND (B.YY_ID=A.YY_ID)"
I tried ns1:table1() union ns3:table2() in XQuery.
But it is pushdown as 2 seperate sqls.
Is it possible to create XQuery that pushdown as SINGLE SQL statement with union clause ?
Thanks

No. See 3.1.1.5 in the document I referenced in your previous post.

Similar Messages

  • SQL error with LIKE clause in statement

    Can anyone explain how an SQL statement with a LIKE clause is executed properly?
    Seems like it ought to be cut and dried, no pun intended!
    When I run the following and set the requestor name = ?, and correctly type in the entire name, a result set (albeit abbreviated) will return.
    But if I try to set the request param to LIKE I get an error of some kind, either invalid cursor state or NullPointer exception.
    Here's my code.
    Statement selstmt = connection.createStatement();          
    String preparedQuery = "SELECT DISTINCT AID, ACTIVE, REQUESTOR_NAME,REQUESTOR_EMAIL" +
    " FROM CHANGE_CONTROL_USER, CHANGE_CONTROL_ADMIN " +
    " WHERE REQUESTOR_NAME LIKE '%?%';";
      String reqName = request.getParameter("requestor_name");
    PreparedStatement prepstmt = connection.prepareStatement(preparedQuery);
    prepstmt.setString(1, reqName);
    ResultSet rslts = prepstmt.executeQuery();
    rslts.next();
    int aidn = rslts.getInt(1);          
    int actbox = rslts.getInt(2);      
    String reqname = rslts.getString(3);
    String reqemails = rslts.getString(4);It's also returning only 1 record for some reason, as I have the following:
    <% while (rslts.next()) { %>
      <tr class="style17">
        <td><%=reqname%></td>
    <td><%=reqemails%></td>
       <td><%=actbox %></td>
        <td><%=aidn %></td>
      </tr>
      <%
    rslts.close();
    selstmt.close();
    %>If I use
    " FROM CHANGE_CONTROL_USER, CHANGE_CONTROL_ADMIN " +
    " WHERE REQUESTOR_NAME = ?;";it will actually spit out the name and corresponding email properly, albeit just one record like I said.
    Is there some kind of escape sequence I should be using that I'm not?
    And why just the one record?
    Any help or direction is appreciated!
    Thanks.

    I have working code for LIKE in PreparedStatement, and its equivalent in your case is something like this:Statement selstmt = connection.createStatement();          
    String preparedQuery = "SELECT DISTINCT AID, ACTIVE, REQUESTOR_NAME,REQUESTOR_EMAIL" +
    " FROM CHANGE_CONTROL_USER, CHANGE_CONTROL_ADMIN " +
    " WHERE REQUESTOR_NAME LIKE ?";
      String reqName = request.getParameter("requestor_name");
    PreparedStatement prepstmt = connection.prepareStatement(preparedQuery);
    prepstmt.setString(1, "%" + reqName.trim() + "%");
    ResultSet rslts = prepstmt.executeQuery();
    rslts.next();
    int aidn = rslts.getInt(1);          
    int actbox = rslts.getInt(2);      
    String reqname = rslts.getString(3);
    String reqemails = rslts.getString(4);

  • Select query with UNION clause in database adapter

    Friends,
    I have got a SQL query with two UNION clause withing it. like
    select a,b,c
    from a
    union
    select a,b,c
    from b
    The schema generated is like below in sequence
    <element>a</element>
    <element>b</element>
    <element>c</element>
    <element>a</element>
    <element>b</element>
    <element>c</element>
    So, the columns from different select queries joined with UNION clause are all appeared in schema instead of the distinct columns.
    Is there any way around to solve this issue ? or will need to with DB function/procedure.

    I think I know what you are saying but your example doesn't make sense, your SQL should produce something like
    I had to change a, b, c with elementA, elementB, elementC as a and b are reserved html tags.
    <elementA>DateA</elementA>
    <elementB>DataB</elementB>
    <elementC>DataC</elementC>
    ...What is the result of the query when you run it in SQLPlus? Is it what you expect?
    cheers
    James

  • Pl/sql statement with output in reports

    Hello,
    I am quite new to reports and pl/sql, i have built a pl/sql statement with some loops that works fine when running it in sqlplus.
    I would really like to have this running in reports with the variables (v_year, v_month and v_sumvalue) in a table/record in the data view, so i can use them just like any ordinary fields in a table for example in a diagram.
    I have tried to create a package spec, setting up a record with the variables as fields. And then a pl/sql function with the following sql (which was a bit modified to work in the pl/sql function). Everything seemed to work since the pl/sql table/record was there with the variables as fields in it, but it never returned anything... just fatal error.
    Here is the original pl/sql statement which is working in sqlplus, any help/directions in how to get this working so i can use the variables like fileds in a regular table would be fantastic:
    DECLARE
       v_year number(4);
       v_month number(2);
       v_sumvalue number(9,3);
       v_sta varchar2(10);
       v_end varchar2(10);
       v_stopmonth number(2);
    BEGIN
       --## Get last 5 years ##--
       select
          to_char(add_months(sysdate,-60),'YYYY'),
          to_char(sysdate,'MM')
          into v_year, v_stopmonth
       from
          dual;
       --dbms_output.put_line(v_year);
       --## Loop 5 years ##--
       for i in 1..5 loop
          v_year := v_year + 1;
          --dbms_output.put_line(v_year);
          --## Loop 12 times (months) ##--
          for k in 0..11 loop
             v_month := k +1;
             --dbms_output.put_line(v_year ||'-'|| v_month);
             select
                sum(nvl(p.value,0)) / 3,
                last_day(add_months(to_date(v_year ||'-'|| v_month ||'-01','YYYY-MM-DD'),-3))+1,
                last_day(to_date(v_year ||'-'|| v_month ||'-01','YYYY-MM-DD'))
                into v_sumvalue, v_sta, v_end
             from
                project p
             where
                p.country_code = 'SWE'
             and
                p.project_type_code = 'P'
             and
                p.start_date between last_day(add_months(to_date(v_year ||'-'|| v_month ||'-01','YYYY-MM-DD'),-3))+1 and last_day(to_date(v_year ||'-'|| v_month ||'-01','YYYY-MM-DD'))
             and
                p.q_category_code between 1000 and 1299
             and
                p.geography_code between 2100 and 2199;
             dbms_output.put_line(v_year ||'-'|| v_month ||' '|| v_sumvalue);
             --dbms_output.put_line(v_year ||'-'|| v_month ||' '|| v_sumvalue ||' '|| v_sta ||' '|| v_end);
          --## Stop monthloop ##--
          end loop;
       --## Stop yearloop ##-
       end loop;
    END;Output:
    2003-1 19.1
    2003-2 20.1
    2007-11 164.5
    2007-12 135.167Best regards,
    Olle

    Hi,
    Maybe pipelined functions will be useful for you:
    http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/x/Table_Functions_Cursor_Expressions/Pipelined_Table_Functions.htm
    Regards
    Jakub Flejmer

  • Dynamic SQL Statement with table name

    Dear all
    i like to have a SQL statement with a dynamic tablename. Is this possible? If yes, how?
    should be something like "select * from <mytablename>"
    Thank you
    Herbert

    Yes this is possible. use the below reference code for this.
    data: g_tablename type w_tabname,
            gv_dref TYPE REF TO data.
    FIELD-SYMBOLS: <g_itab> TYPE STANDARD TABLE.
    gv_tabname = p_tablename (take table name form selection screen or as per ur requirement)
    CREATE DATA gv_dref TYPE TABLE OF (g_tabname).
    ASSIGN gv_dref->* TO <g_itab>.
    now use the below select query to fetch the data
      SELECT * FROM (gv_tabname) INTO TABLE <g_itab>.
    Hope this will help

  • How to find sql statement with Unix process pid

    Hi
    how to find sql statement with Unix process pid
    is there any view to find that.
    please if so let me know
    Thanks in advance

    this is how I am doing this:
    oracle 7352340 7459066 0 07:47:10 - 0:00 oracleJDERED (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
    oracle 7459066 5386396 2 07:47:10 pts/1 0:01 sqlplus
    select sid,serial# from v$session where process='7459066';
    SID SERIAL#
    2178 6067
    select sql_text
    from
    v$sqlarea a,
    v$session b
    where a.hash_value = b.sql_hash_value
    and b.sid = 2178
    ;

  • SQL-Statement with OO4O

    Hello together,
    I post this Question here in
    Re: SQL-Statement with OO4O
    and i should paste my question again in an another database forum.
    now here again:
    I have here following Problem:
    Everthime I make a connection to my database with this code
    Set oSess = Server.CreateObject("OracleInProcServer.XOraSession")
    Set oDB = oSess.DbOpenDatabase(tnsname, user/PWD, 4)
    I get always this Statement in the DB-queue
    SELECT parameter, VALUE
    FROM SYS.nls_database_parameters
    WHERE parameter IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET')
    Can me anyone tell me why I get this statement and how I can disable it?
    Best Regards
    Andy

    Hi,
    What can you do/change?I must ask next week my boss when he is back,
    what kind of changes I can do.
    Can you add a PL/SQL call to DBMS_APPLICATION_INFO into application?my boss must give me the permission to do a call to DBMS_APPLICATION_INFO.
    A way to identify the source of the badly behaving code is required; whether that be within the DB or external of it.I think so too.
    So please wait, until I have talk with my boss, than I will give you the answer you want. Sorry.
    Any other ideas, what I can do without call/changes on the database to find the problem?
    Best Regards
    Andy

  • In a SQL statement, the SELECT clause is used to

    In a SQL statement, the SELECT clause is used to select
    (a) columns
    (b) rows
    (c) tables
    (d) none of the above
    can any one help Immediately

    Is used to select rows of specified column...
    SELECT column_name(s) FROM table_name

  • ABAP/4 Open SQL statement with WHERE ... LIKE and pattern too long

    Dear All,
    I am getting an error "ABAP/4 Open SQL statement with WHERE ... LIKE and pattern too long" while executing the following statement:
    CLEAR LS_RANGE.
    LS_RANGE-SIGN     = 'I'
    +LS_RANGE-OPTION     = 'CP'     +
    LS_RANGE-LOW     = 'S_ADMI_FCD'
    LS_RANGE-HIGH     = 'S_ADMI_FCD'
    COLLECT LS_RANGE INTO LT_RANGE.
    SELECT *
               FROM UST12
               INTO CORRESPONDING FIELDS OF TABLE LT_OBJECT_VALUES
               WHERE FIELD IN LT_RANGE
               AND AKTPS   = 'A'.
    For options like BT(Between), EQ(Equal) in range table, this above query is executing without dump. But for option CP, it simply dumps & in dump what i found is, it is concatenating the value in low & high.
    Does anyone have any idea regarding open sql using range tables.
    Thanks,
    Bhupinder

    Hi,
    I commented as follows:
    If  LS_RANGE-HIGH is empty, you can use EQ, NE, GT, LE, LT,CP, and NP. These operators are the same as those that are used for logical expressions. Yet operators CP and NP do not have the full functional scope they have in normal logical expressions. They are only allowed if wildcards ( '*' or '+' ) are used in the input fields. If wildcards are entered on the selection screen, the system automatically uses the operator CP.
    If  LS_RANGE-HIGH  is filled, you can use BT (BeTween) and NB (Not Between). These operators correspond to BETWEEN and NOT BETWEEN that you use when you check if a field belongs to a range. You cannot use wildcard characters.
    You can try:
    CLEAR LS_RANGE.
    LS_RANGE-SIGN = 'I'.
    +LS_RANGE-OPTION = 'CP' +
    LS_RANGE-LOW = 'S_ADMI_FCD'.
    LS_RANGE-HIGH = 'S_ADMI_FCD'.
    FIND '*' IN LS_RANGE.
    IF sy-subrc = 0.
      LS_RANGE-OPTION = 'CP'.
    ELSE.
      LS_RANGE-OPTION = 'EQ'.
    ENDIF.
    COLLECT LS_RANGE INTO LT_RANGE.
    SELECT *
    FROM UST12
    INTO CORRESPONDING FIELDS OF TABLE LT_OBJECT_VALUES
    WHERE FIELD IN LT_RANGE
    AND AKTPS = 'A'.
    If you use wildcards the LS_RANGE  length should not exceed 10 characters.
    Hope this information is help to you.
    Regards,
    José

  • Display the sql statement with arguments with ojdbc14_g.jar

    Hi,
    I'd like to display the sql statements with ojdbc14_g.jar.
    So I've followed the documentation and set an OracleLog.properties file which is linked to my java program.
    The problem is the trace generated is huge and I only need the SQL requests wich are made with the arguments but I don't know how to configure that.
    Have you got a sample file which handle that ?
    I've tried that :
    oracle.jdbc.handlers=java.util.logging.ConsoleHandler
    java.util.logging.ConsoleHandler.level=CONFIG
    java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
    oracle.level=INFO
    oracle.jdbc.driver.level=OFF
    oracle.jdbc.driver.OraclePreparedStatement.level=OFF
    oracle.jdbc.pool.level=OFF
    oracle.jdbc.util.level=OFF
    oracle.sql.level=INFO
    But that doesn't display only the SQL and args :(
    Regards.

    The fact is the statement are made by ejb entities on JBoss so I don't have a way to make specific logger to display the sql order. The only thing I can do is to set the log4j org.jboss.ejb.plugins.cmp to a trace level in order to see the sql order but without the arguments.
    I tried those traces however I see stuff like that without any SQL orders :
    <<
    10:10:53,833 INFO [STDOUT] NFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:52 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:52 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=VIEW_ACTION_NAMES)
    29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:52 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:52 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
    INFO: PhysicalConnection.getCatalog()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=PROCESS_TYPE_HIERARCHY)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
    INFO: PhysicalConnection.getCatalog()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=PROCESS_TYPE_HIERARCHY)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
    INFO: PhysicalConnection.getCatalog()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=FORM_EMBEDDED_VIEWS)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
    INFO: PhysicalConnection.getCatalog()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=FORM_EMBEDDED_VIEWS)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 20>>

  • Hosting company does not support SQL query with OUTFILE clause

    From my mysql database, I want to allow the user to run a query and produce a csv / text file of our membership database.   Unfortunately,  I just found out my hosting company does not support the SQL query with OUTFILE clause for MySQL database.
    Are there any other options available to produce a file besides me running the query in phpadmin and making the file available to users.
    Thanks.  George

    Maybe this external Export Mysql data to CSV - PHP tutorial will be of help
    Cheers,
    Günter

  • How to Run SQL Tuning Advisor on the SQL statement with SQL_ID?

    Can you give the steps to run the SQL tuning advisor on the SQL statement with SQL_ID?
    Database version: 10g Release 2

    Hi,
    You can use either the automatic SQL tuning features that are accessible from Enterprise Manager Database Console on the "Advisor Central" page or trough SQL*PLUS using the DBMS_SQLTUNE pakage:
    -- creating the tuning task
    set serveroutput on
    declare
      l_sql_tune_task_id  varchar2(100);
    begin
      l_sql_tune_task_id := dbms_sqltune.create_tuning_task (
                              sql_id      => '<your_sql_id>',
                              scope       => dbms_sqltune.scope_comprehensive,
                              time_limit  => 60,
                              task_name   => '<your_tuning_task_name>',
                              description => 'tuning task for statement your_sql_id.');
      dbms_output.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
    end;
    -- executing the tuning task
    exec dbms_sqltune.execute_tuning_task(task_name => '<your_tuning_task_name>');
    -- displaying the recommendations
    set long 100000;
    set longchunksize 1000
    set pagesize 10000
    set linesize 100
    select dbms_sqltune.report_tuning_task('<your_tuning_task_name>') as recommendations from dual;For more information, take a look at link provided by Jaffy.
    Cheers
    Legatti

  • SQL statement with Function returns slow in Interactive Report

    I have an Interactive Report that returns well but when I add in a function call in the where clause that does nothing but return a hard coded string of primary keys and is compared to a table's primary key with a like operator the performance tanks. Here is the example:
    get_school2_section(Y.pk_id,M.pk_id,I.section,:P577_SECTION_SHUTTLE) LIKE '%:' || I.pk_id || ':%'
    I have the values hard coded in the return of the function. There are no cursors run in the function, there is no processing done in the function. It only declares a variable. Sets the variable, and returns that variable back to the SQL statement.
    I can hard code the where clause value to look like this:
    ':90D8D830A877CCFFE040010A347D1A50:8ED0BBFDEAACC629E040010A347D6471:9800B8FDBD22B761E040010A347D0D9A:' LIKE '%:' || I.pk_id || ':%'
    This returns fast. When I add in the function call which returns the same hard coded values, the page goes from returning in 1 to 2 seconds to 45 or more seconds.
    Why does adding a simple function call into the where clause cause such a deterioration in performance.
    Edited by: alamantia on Aug 17, 2011 7:39 AM
    Edited by: alamantia on Aug 17, 2011 7:40 AM

    So you are telling me that the where clause with a function call will NOT run the function on every row? Please explain that to me further?
    if you have code that is the following:
    select a,b,c from a_table where a > 2 and b < 3 and function_call(c) > 0You are telling me that Oracle will NOT call that function on EVERY row it tries to process in the select?
    Thank you,
    Tony Miller
    Webster, TX
    I cried because I did not have an office with a door until I met a man who had no cubicle.
    -Dilbert
    If this question is answered, please mark the thread as closed and assign points where earned..

  • Single select query or any sql statement with o/p

    Hi,
    I have one table test_tab with column names empno,empname.The test_tab values is as follows,
    empno empname
    01 siva
    02 ram
    03 kamal
    04 sathish
    i will give the empname values like 'siva,kamal,roshan,sathish' and empno >03,but in the table roshan name is not there.I need the below mentioned o/p
    example qry: select empno,empname from test_tab where empname in('siva','kamal','roshan','sathish') and empno>03;
    my o/p should be like this,
    empname empno
    sathish 04
    roshan ''
    But the empname 'roshan' is not there in table.I need the empname as 'roshan' and empno is null value in a single select query or subquery or any sql statements.
    Please help me the resolve this issue.
    Thanks
    Sivaraman

    Hi,
    Do you want this?
    with data as
    (select 1 EMPNO, 'siva' as empname from  DUAL union all
    select 2 EMPNO, 'ram' from  DUAL union all
    select 3 EMPNO, 'kamal' from  DUAL union all
    select 4 EMPNO, 'sathish' from  DUAL union all
    select null EMPNO, 'roshan' from  DUAL )
    select *  from data
    where EMPNAME in ('siva','kamal','roshan','sathish')
       and nvl2(empno,empno,4) > 3 

  • Order by decode statement with Union all

    Hi
    I use Database Version: Oracle 9.2.0.1.0
    OCI version 9.2
    I try to use order by decode while i have a select base on union and I get en error:
    ORA-01785: ORDER BY item must be the number of a SELECT-list expression
    Here is my code:
    select catalog_type, catalog_id, item_id, item_name
    from items_catalog
    union all
    select catalog_type, catalog_id, organisation_unit_id, organisation_unit_name
    from units_catalog
    order by decode(catalog_type, 1, item_id, organisation_unit_id)
    If I use the decode on a select statement without union, it works.
    What I have to do in order to make it work on union all select?
    Tnx

    Hi,
    Here's a slightly different way:
    COLUMN     sort_key   NOPRINT
    VARIABLE     catalog_type_wanted     VARCHAR2 (5)
    EXEC         :catalog_type_wanted := '4'; 
    SELECT       catalog_id, item_id, item_name
    ,       CASE
               WHEN  :catalog_type_wanted = '1'  THEN  '1'
                                               ELSE  '2'
           END || item_id          AS sort_key
    FROM       items_catalog
          UNION ALL
    SELECT    catalog_id, organisation_unit_id, organisation_unit_name
    ,       CASE
               WHEN  :catalog_type_wanted = '1'  THEN  '2'
                                               ELSE  '1'
           END || organisation_unit_name     AS sort_key
    FROM       units_catalog
    ORDER BY  sort_key
    ;This way guarantees that (for example) 'SHOP50' comes before 'SHOP58', whether or not they are in the first half of the output or the second half.
    Notice that this uses the SQL*Plus COLUMN ... NOPRINT command to hide the sort_key column.
    If you're not using SQL*Plus, then whatever front end you are using may have a similar feature.
    If not, then you can do the UNION in a sub-query, as Daniel did, but do the ORDER BY in the main query (only).

Maybe you are looking for

  • Does Google  ignore the privacy settings of iOS ?

    In the privacy settings of iOS I have disabled access to my pictures for the Google+ App on my iPhone and on my iPad. However I still get emails from Google+ that it uploaded pictures I took with my iPhone. Is Google cheating here ?

  • Where is the wish list show up at in theiTunes 11.1.4 update.

    I have updated iTunes to 11.1.4. The info on the update says you can view your Wish List in the Library. I do not see it anywhere other than in the iTunes Store. Can someone help me find this. Thanks!!

  • Recovery not working, system not supported

    I have an x205-s9800 and after upgrading from vista to windows 7, I decided to go back to vista cause there seems to be no fix to the nvlddmkm blue screen. Now I get this error when I run the system recovery discs that came with the laptop when I pur

  • Type tool anchor and pen tool problems CS4

    I have been working in In-design for my classes and everything is working fine. But recently I needed to do some work in Illustrator but when I opened the program up, some of my tools seems to be slightly bugged or something. The type tool will not m

  • TV Shows Won't Display

    Hi, I just bought the season pass of Supernatural from the iTunes site. The episodes work fine on my computer, but they come up in "podcast" form on my 30GB iPod Video. I've already tried to change my widescreen settings, and nothing seems to work. H