SQL statements:help

here is a sample code of my application....
int initialDelay = 10000; // start after 10 second
int period = 10000*60*60*24*30; // repeat every month
Timer timer = new Timer();
TimerTask task = new TimerTask() {
public void run() {
try {
MyDBConnection jdbc = new MyDBConnection();
jdbc.init();
Connection conn = jdbc.getMyConnection();
Statement stmt = conn.createStatement();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String[] tbl = {"emticket","emattachment","emhistory","emtracker"};
progTxt.setText("");
Logs l = new Logs();
l.append("Auto Archive");
date.getTime();
//Archive data
progTxt.append("\n\n");
progTxt.append(" Archiving Data...\n ");
stmt.execute("select * into outfile 'c:/emticket " + dateFormat.format(date) + ".csv' fields terminated by ',' enclosed by '\"' lines terminated by '\\n' from emticket where RcvDateTime between date_sub(curdate(),interval 90 day) and curdate()");
stmt.execute("select * into outfile 'c:/emattachment " + dateFormat.format(date) + ".csv' fields terminated by ',' enclosed by '\"' lines terminated by '\\n' from emattachment where EmID in (select EmID from emticket where RcvDateTime between date_sub(curdate(),interval 90 day) and curdate())");
stmt.execute("select * into outfile 'c:/emhistory " + dateFormat.format(date) + ".csv' fields terminated by ',' enclosed by '\"' lines terminated by '\\n' from emhistory where TicketID in (select TicketID from emticket where RcvDateTime between date_sub(curdate(),interval 90 day) and curdate())");
stmt.execute("select * into outfile 'c:/emtracker " + dateFormat.format(date) + ".csv' fields terminated by ',' enclosed by '\"' lines terminated by '\\n' from emtracker where TicketID in (select TicketID from emticket where RcvDateTime between date_sub(curdate(),interval 90 day) and curdate())");
progTxt.append("Done.\n\n");
//Delete data
progTxt.append(" Deleting Data... ");
stmt.execute("delete emticket, emattachment, emhistory, emtracker from emticket, emattachment, emhistory, emtracker where emattachment.EmID=emticket.EmID and emhistory.TicketID=emticket.TicketID and emtracker.TicketID=emtracker.TicketID and where RcvDateTime
"_______"DATE_SUB(CURDATE(),INTERVAL 90 DAY) and CURDATE())");
System.out.println(stmt.getUpdateCount());
progTxt.append("Done.\n\n");
Here's what i want to do....I want to backup file for the current date back to 3 mos...e.g 2007-05-23 down to 2007-02-23...then delete the remaining records...before"02-23-2007 to 05-23-2007"....this is where the query part i that doesn't work....
Delete data
progTxt.append(" Deleting Data... ");
stmt.execute("delete emticket, emattachment, emhistory, emtracker from emticket, emattachment, emhistory, emtracker where emattachment.EmID=emticket.EmID and emhistory.TicketID=emticket.TicketID and emtracker.TicketID=emtracker.TicketID and where RcvDateTime
"_______"DATE_SUB(CURDATE(),INTERVAL 90 DAY) and CURDATE())");
System.out.println(stmt.getUpdateCount());
progTxt.append("Done.\n\n")
I tried putting <>=which means not equal in the "_____"but it fails to work..can somebody help me to work out with this query.

I don't know MySQL, but shouldn't you just use <= ? I also don't understand what the final part 'and CURDATE()' is for...

Similar Messages

  • Oracle Spatial operator SQL statement help

    I have a 3D elevation point feature class (elev) and a polygon feature class (Building) loaded in Oracle Spatial. I am trying to update the "HEIGHT" attribute of the "Building" Feature class using the average elevation of "elev" feature class. Here below is the SQL statement I used, which generated the same value for all buildings. The avg(elevation) returns the average elevation of all points within all building polygons, not all points within ONE polygon.
    Please help and thanks.
    update building
    set height = (select avg(elevation)
    from elev e, building b
    where sdo_anyinteract(e.shape, b.shape) = 'TRUE');

    Hi,
    try this
    update building b
    set height = (select avg(elevation)
    from elev e where sdo_anyinteract(e.shape, b.shape) = 'TRUE');
    Udo

  • SQL statement help

    If someone would be so kind, I need help in formulating a SQL statement.
    Table A - employees(empoyee_id, employee_name, status)
    This table contains all employees
    employee status can be one of three values (A=active, T=temporary, I=inactive)
    Table B - savings_program(employee_id, plan_type)
    This table only has employee_id's of those that participate in a savings program (subset of all employees).
    plan_type can be one of three numeric values (30,35,40)
    I need SQL to report a.employee_id,a.employee_name,b.plan_type (return plan_type 30,35, or none)of all active employees in Table A that don't participate in Table B plan_type 40.
    Working with version 9iR2. Thanks!
    Edited by: fosterk on Nov 21, 2008 12:59 PM

    The tables and columns above were for demo purposes but actual code I'm trying is below. Please excuse me I'm more of an SA type so SQL is not my thing.
    As you can see from the first SQL statement below I know that I have exactly
    3,000 employees that meet this criteria. The second SQL statement is my attempt to return the rows I want (I'm just nesting it in a count(*) until the numbers look right)
    The last statement is what was given to me by someone else (seeking my help haha) trying to resolve it and it only returns 3 rows. This SQL shows the actual columns that we're trying to return from both tables.
    HR> select count(*) from ps_All_employees where empl_status != 'T'
    2 and emplid not in
    3 (select emplid from ps_savings_pt_vw where plan_type = 40)
    4 /
    COUNT(*)
    3000
    HR> select count(*) from (
    2 (select * from ps_all_employees where empl_status != 'T') a left outer join
    3 (select emplid from ps_savings_pt_vw where plan_type != 40) s
    4 on a.emplid = s.emplid
    5 )
    6 /
    COUNT(*)
    4587
    select count(*) from (
    select a.location, a.ssn, a.first_name, a.last_name, a.birthdate, a.orig_hire_dt, a.hire_dt, a.location, a.street1,
    a.street2, a.city, a.state, a.zip, s.plan_type
    from ps_all_employees a, ps_savings_pt_vw s
    where a.empl_status != 'T' and
    a.emplid = s.emplid and
    a.emplid not in (select s.emplid from ps_savings_pt_vw s where s.plan_type = 40)
    COUNT(*)
    3

  • Native SQL Statement help!

    Hi guys,
    I need some help here.
    I have a requirement to select from Microsoft SQL database
    Question
    How do I select with RANGE internal tables? As you can see, I have 4 range tables for this.
    BElow are my codes
    EXEC SQL.
        CONNECT TO 'CONNECTION_NAME'
      ENDEXEC.
      IF sy-subrc <> 0.
        MESSAGE 'Unable to connect to CONNECTION_NAME' TYPE 'E' DISPLAY LIKE 'I'.
        RETURN.
      ENDIF.
    * Define database cursor
      EXEC SQL.
        OPEN dbcur FOR
                SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
                       qty, zopcd, bstnk, wekunnr
                  FROM <TABLE_NAME>
                 WHERE month IN i_month
                   AND yyear IN i_year
                   AND kunnr IN i_kunnr
                   AND bstnk IN i_bstnk
      ENDEXEC.
    * Fill itab
      DO.
        EXEC SQL.
          FETCH NEXT dbcur INTO :l_dest-name1,
                                :l_dest-zvctk,
                                :l_dest-kunnr,
                                :l_dest-yyear,
                                :l_dest-mmonth,
                                :l_dest-matnr,
                                :l_dest-qty,
                                :l_dest-zopcd,
                                :l_dest-bstnk,
                                :l_dest-wekunnr
        ENDEXEC.
        IF sy-subrc <> 0.
          EXIT.
        ELSE.
          APPEND l_dest TO it_dest.
        ENDIF.
      ENDDO.
    its giving me a shortdump
    >>>>>     OPEN dbcur FOR
       35             SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
       36                    qty, zopcd, bstnk, wekunnr
       37               FROM v_promise_sa
       38              WHERE month IN i_month[]
       39                AND yyear IN i_year[]
       40                AND kunnr IN i_kunnr[]
       41                AND bstnk IN i_bstnk[]
    Error message:
    Database error text........: "[Microsoft][SQL Server Native Client 10.0][SQL
    Server]Incorrect syntax near 'i_month'."
    Database error code........: 102
    Triggering SQL statement...: "SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
    qty, zopcd, bstnk, wekunnr FROM <TABLE_NAME> WHERE month IN i_month[] AND
    yyear IN i_year[] AND kunnr IN i_kunnr[] AND bstnk IN i_bstnk[]"
    Internal call code.........: "[DBDS/NEW DSQL]"
    Please check the entries in the system log (Transaction SM21).
    Can anyone guide me? If I do not enter the where clause, it is selecting fine.
    Appreciate it guys! Thanks in advance!

    lol, Come guys, don't judge me by just my forum nick man. It was just something random during registration a few years back...was indeed new in ABAP language :P
    But anyway, the table v_promimse_sa is not in the DDIC, its some microsoft MYSQL database or something.
    anyway what I did now:
    EXEC SQL.
        CONNECT TO 'MSSQL_PROMISE'
      ENDEXEC.
      IF sy-subrc <> 0.
        MESSAGE 'Unable to connect to MSSQL_PROMISE' TYPE 'E' DISPLAY LIKE 'I'.
        RETURN.
      ENDIF.
    * Define database cursor
      EXEC SQL.
        OPEN dbcur FOR
                SELECT name1, zvctk, kunnr, yyear, mmonth, matnr,
                       qty, zopcd, bstnk, wekunnr
                  FROM v_promise_sa
                 WHERE mmonth = :i_month
                   AND yyear  = :i_year
    *               AND ( kunnr BETWEEN :i_kunnr-low AND :i_kunnr-high )
    *               AND ( bstnk BETWEEN :i_bstnk-low AND :i_bstnk-high )
      ENDEXEC.
    * Fill itab
      DO.
        EXEC SQL.
          FETCH NEXT dbcur INTO :l_dest-name1,
                                :l_dest-zvctk,
                                :l_dest-kunnr,
                                :l_dest-yyear,
                                :l_dest-mmonth,
                                :l_dest-matnr,
                                :l_dest-qty,
                                :l_dest-zopcd,
                                :l_dest-bstnk,
                                :l_dest-wekunnr
        ENDEXEC.
        IF sy-subrc <> 0.
          EXIT.
        ELSE.
          APPEND l_dest TO it_dest.
        ENDIF.
      ENDDO.
    *    EXEC SQL.
    *      CLOSE dbcur
    *    ENDEXEC.
      DELETE it_dest WHERE kunnr NOT IN i_kunnr
                       AND bstnk NOT IN i_bstnk.
    Well, after checking with the functional person, there are only 3 records so I guess the selection + filtering is working.

  • EarlyWatch - Expensive SQL Statements help

    Hi all,
    i need to analyze an EWA report and i don't know how exactly can i identify an "expensive SQL statement".
    The report says:
    During this session, the following expensive SQL statements were identified as causing a database load of at least 1%.
    The corresponding stored procedure names are referenced in the table below.
    And in the table with stored procedure names, a row looks like this:
    ID     Stored Procedure Name
    1     ##Y4DCWWES7EHY100000053960000254832042037
    What does it mean and how can i identify the name of program and the exact statement (probably select) that is causing this problem?
    Thank you,
    Ondrej

    Hi Ondrej,
    you're running on SQL Server. SAP creates stored procedures for each and every statement run against the database. The name you get seems to be a temporary stored procedure which (if I'm not wrong) is marked by the two # characters at the beginning. You may be still find it in the stored procedures of your system.
    Open the Enterprise Manager and open your database, then the stored procedure link (you should run the Enterprise Manager on the server or on a PC with enough RAM). The search for the procedure and double click on it. I think that should show you the SQL statement. There should also the report name is a comment.
    Regards
    Ralph

  • SQL statement help needed

    I am sure some of you will laugh lol, but I am drawing a blank and need some assistance if anyone is willing to help:
    I have this query:
    SELECT DISTINCT ID
    FROM (SELECT productcode
    FROM sforce_product2
    WHERE productcode NOT LIKE 'DSXXX%'
    AND productcode NOT LIKE 'DO NOT USE%'
    AND productcode NOT LIKE 'MAXXXX%'
    AND isactive = 'true'
    MINUS
    SELECT productcode
    FROM vew_product_export) a,
    sforce_product2
    WHERE a.productcode = sforce_product2.productcode
    which returns 112 ID's (which is wrong)
    The inner SELECT statement:
    SELECT productcode
    FROM sforce_product2
    WHERE productcode NOT LIKE 'DSXXX%'
    AND productcode NOT LIKE 'DO NOT USE%'
    AND productcode NOT LIKE 'MAXXXX%'
    AND isactive = 'true'
    MINUS
    SELECT productcode
    FROM vew_product_export
    returns 106.
    Am I doing something simple wrong or is my query just mangled!
    TIA,
    Mike

      SELECT DISTINCT ID
        FROM (SELECT productcode
                FROM sforce_product2
               WHERE productcode NOT LIKE 'DSXXX%'
                 AND productcode NOT LIKE 'DO NOT USE%'
                 AND productcode NOT LIKE 'MAXXXX%'
                 AND isactive = 'true'
              MINUS
              SELECT productcode
                FROM vew_product_export) a,
              sforce_product2
       WHERE a.productcode = sforce_product2.productcodethe above code is returning an ID column which i think most probable from the sforce_product2 table
    while this query below returns the 106 value that is coming from the column productcode.
      SELECT productcode
        FROM sforce_product2
       WHERE productcode NOT LIKE 'DSXXX%'
         AND productcode NOT LIKE 'DO NOT USE%'
         AND productcode NOT LIKE 'MAXXXX%'
         AND isactive = 'true'
      MINUS
      SELECT productcode
        FROM vew_product_exportso i think there is nothing wrong because if you will review the 112 is from the column ID while the 106 is from the column productcode.

  • Simple SQl statement help needed!!!

    New to SQL..Please can you advice where is the problem..
    select file_id, a.file_name, a.sum(bytes/1024/1024) Used_space, b.sum(bytes/1024
    /1024) Free_space from dba_data_files a, dba_free_space b where tablespace_name
    ='DATA_TS' OR tablespace_name='INDEX_TS' OR tablespace_name='LOB_TS' group by fi
    le_id
    ERROR at line 1:
    ORA-00918: column ambiguously defined
    Thanks!

    Hi,
    Should you chose to format your SQL the problem is easily seen:
    SQL>select file_id
      2          ,a.file_name
      3          ,a.sum(bytes / 1024 / 1024) used_space
      4          ,b.sum(bytes / 1024 / 1024) free_space
      5      from dba_data_files a, dba_free_space b
      6     where tablespace_name = 'DATA_TS'
      7        or tablespace_name = 'INDEX_TS'
      8        or tablespace_name = 'LOB_TS'
      9  group by file_id;
    group by file_id
    ERROR at line 9:
    ORA-00918: column ambiguously defined
    SQL>So, which file_id do you want - a or b?
    Regards
    Peter

  • Add sql statements in SGA

    select a.address address,
    s.hash_value hash_value,
    s.piece piece,
    s.sql_text sql_text,
    u.username parsing_user_id,
    c.username parsing_schema_id
    from v$sqlarea a,
    v$sqltext_with_newlines s,
    dba_users u,
    dba_users c
    where a.address=s.address
    and a.hash_value=s.hash_value
    and a.parsing_user_id=u.user_id
    and a.parsing_schema_id=c.user_id
    and exists (select 'x'
    from v$sqltext_with_newlines x
    where x.address=a.address
    and x.hash_value=a.hash_value
    and upper(x.sql_text) like '%UNION%')
    order by 1,2,3
    On executing the above statement the server display list of sqltext present in sga. We know that the server first search for the record in sga and if it is not
    present in SGA it searches in data files.
    My question is ,adding all the sql statements in sga manually is advisable? will that improve the performance?

    Vinodh2 wrote:
    In production the users uses some sql statement frequently. So those statements should be in the sga for better performance. The dbms package said by you takes object as input. What is object here?
    Did you check the last line I pasted from document?
    The value for this identifier is the concatenation of the address and hash_value columns from the v$sqlarea view.Each SQL in SQL AREA has a hash_value to identify it. You can use this hash value to decide which SQL want to keep in shared pool.
    Having Dynamic sql statements(records fetched based on varying filter condtion) called from interfaces will not help.
    But having static sql statements helps.
    In that case how to include those sql.Like said, you are introducing some more problems instead of any real gain by trying to micro manage how shared pool work. You should let Oracle take care it with it's own algorithm. Unless some rare cases, that you have limited shared pool and super busy system you want to pin some SQL in the shared pool with provide package.

  • Can someone help me correct this sql statement in a jsp page?

    ive been getting the java.sql.SQLException: Incorrect syntax error for one of my sql nested statements. i cant seem to find similar egs online, so reckon if anyone here could help, really appreciate it.
    as im putting the nested sql in jsp page, it has to be with lots of " " n crap. very confusing if there are nested.
    heres the sql statement without those "" that i want to use:
    select top 5 * from(
    select top+"'"+offset+"'"+" * from prod where cat=" +"'" cat "'"+"
    )order by prodID desc
    when i put this in my jsp pg, i had to add "" to become:
    String sql = "select top 5 * from("+"select top"+"'"+offset+"'"+" * from prod where cat=" +"'" +cat+ "'"+")order by prodID desc";cat=" +"'" cat "'"+")order by prodID desc";
    all those "" are confusing me to no end, so i cant figure out what should be the correct syntax. the error says the syntax error is near the offset.

    If offset is, say, 10, and cat is, say, "new", then it looks like you're going to produce the SQL:
    select top 5 * from(
      select top '10' * from prod where cat='new'
    )order by prodID descThat looks exactly like incorrect syntax to me... top almost certainly can't handle a string literal as its operand... you almost certainly would want "top 10" instead of "top '10'"...
    If you use PreparedStatement, you don't have to remember what you quote and what you don't and you can have your SQL in a single static final string to boot...

  • Need help in resolving the below error - SQL statement to execute cannot be

    Here is my CO as below , which creates a callable statement.
    try {
    OAApplicationModule oaapplicationmodule = pageContext.getApplicationModule(webBean);
    OADBTransactionImpl t = (OADBTransactionImpl)oaapplicationmodule.getOADBTransaction();
    OracleCallableStatement proc = (OracleCallableStatement)t.createCallableStatement(lquery, -1);
    proc.execute();
    t.commit();
    catch(SQLException sqlexception)
    throw OAException.wrapperException(sqlexception);
    After running the page , getting the below error ... ( Please find the below error stack )
    I reffered the developement guide but did not get helpful things.
    Please provide me any clues on the same.
    Regards Raghu
    -- Error Stack ---------------------------------------------------------
    Error Page
    Exception Details.
    oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27123: SQL error during call statement preparation. Statement: null
         at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:888)
         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(OAPageErrorHandler.java:1145)
         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(OAPageErrorHandler.java:1408)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2637)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418)
         at OA.jspService(OA.jsp:40)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)
    ## Detail 0 ##
    java.sql.SQLException: SQL statement to execute cannot be empty or null
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
         at oracle.jdbc.driver.OracleConnection.privatePrepareCall(OracleConnection.java:1138)
         at oracle.jdbc.driver.OracleConnection.prepareCall(OracleConnection.java:1054)
         at oracle.jbo.server.DBTransactionImpl.createCallableStatement(DBTransactionImpl.java:3033)
         at cisco.oracle.apps.xxchr.element.server.webui.XXCHRElementSetSearchCO.processFormRequest(XXCHRElementSetSearchCO.java:343)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:799)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1118)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2633)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418)
         at OA.jspService(OA.jsp:40)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)
    java.sql.SQLException: SQL statement to execute cannot be empty or null
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
         at oracle.jdbc.driver.OracleConnection.privatePrepareCall(OracleConnection.java:1138)
         at oracle.jdbc.driver.OracleConnection.prepareCall(OracleConnection.java:1054)
         at oracle.jbo.server.DBTransactionImpl.createCallableStatement(DBTransactionImpl.java:3033)
         at cisco.oracle.apps.xxchr.element.server.webui.XXCHRElementSetSearchCO.processFormRequest(XXCHRElementSetSearchCO.java:343)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:799)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1118)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2633)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418)
         at OA.jspService(OA.jsp:40)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)
    Edited by: Raghu on Sep 14, 2010 2:58 AM

    check the code pasted by me again
    Connection conn = pageContext.getApplicationModule(webBean).getOADBTransaction().getJdbcConnection();
    Connection conn = oaapplicationmodule.getOADBTransaction().getJdbcConnection(); //Right oneThanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Help needed in SQL statement

    Hi,
    From the SQL statement below, i need help in explaining what does the line "WHERE ( lims_sys.result.result_template_id = lims_sys.result_template_limit.result_template_id (+))" do?
    This statement was written by a vendor and now i have problem displaying some new data. Only a portion of what i need is displayed.
    SELECT "LIMS_SYS"."RESULT"."DESCRIPTION",
    "LIMS_SYS"."RESULT_TEMPLATE_LIMIT"."NUMERIC_LIMIT",
    "LIMS_SYS"."RESULT"."FORMATTED_RESULT",
    "LIMS_SYS"."RESULT"."CONCLUSION",
    "LIMS_SYS"."RESULT_USER"."U_RESULT_SEQUENCE" ,
    "LIMS_SYS"."RESULT"."RESULT_ID"
    FROM "LIMS_SYS"."RESULT",
    "LIMS_SYS"."RESULT_TEMPLATE_LIMIT",
    "LIMS_SYS"."RESULT_USER",
    "LIMS_SYS"."ALIQUOT",
    "LIMS_SYS"."SAMPLE",
    "LIMS_SYS"."SDG",
    "LIMS_SYS"."TEST"
    WHERE ( lims_sys.result.result_template_id = lims_sys.result_template_limit.result_template_id (+)) and
    ( "LIMS_SYS"."RESULT"."RESULT_ID" = "LIMS_SYS"."RESULT_USER"."RESULT_ID" ) and
    ( "LIMS_SYS"."SDG"."SDG_ID" = "LIMS_SYS"."SAMPLE"."SDG_ID" ) and
    ( "LIMS_SYS"."SAMPLE"."SAMPLE_ID" = "LIMS_SYS"."ALIQUOT"."SAMPLE_ID" ) and
    ( "LIMS_SYS"."ALIQUOT"."ALIQUOT_ID" = "LIMS_SYS"."TEST"."ALIQUOT_ID" ) and
    ( "LIMS_SYS"."TEST"."TEST_ID" = "LIMS_SYS"."RESULT"."TEST_ID" ) and
    ( ( LIMS_SYS."SDG"."SDG_ID" = :sdg_id ) AND
    ( LIMS_SYS."RESULT"."STATUS" <> 'X' ) AND
    ( LIMS_SYS."RESULT"."REPORTED" = 'T' ) AND
    ( LIMS_SYS."RESULT_USER"."U_RESULT_CATEGORY" in ( 'Metal' , 'Mean Metal', 'Range Metal')) )
    Thanks for all your help.

    Hi,
    After WHERE .......... is indicates an OUTER Join condition.
    In this type of join, system retrieves the data for matched and
    as well as unmatched.
    Example:
    EMP table have a column DEPTNO with the data 10, 20, 30 (total rows=14)
    DEPT table have a column DEPTNO with the data 10, 20, 30, 40, 50 (total rows=5)
    If the WHERE clause contained EMP.DEPTNO(+) = DEPT.DEPTNO
    then the output contain the data relative to 10, 20, 30, 40, 50 (total rows = 16)
    i.e. 14 rows (with matching data) and 2 rows (with unmatching data)
    Regards,
    Sailaja

  • Need help on how to code this SQL statement! (one key has leading zeros)

    Good day, everyone!
    First of all, I apologize if this isn't the best forum.  I thought of putting it in the SAP Oracle database forum, but the messages there seemed to be geared outside of ABAP SELECTs and programming.  Here's my question:
    I would like to join the tables FMIFIIT and AUFK.  The INNER JOIN will be done between FMIFIIT's MEASURE (Funded Program) field, which is char(24), and AUFK's AUFNR (Order Number) field, which is char(12).
    The problem I'm having is this:  All of the values in AUFNR are preceeded by two zeros.  For example, if I have a MEASURE value of '5200000017', the corresponding value in AUFNR is '005200000017'.  Because I have my SQL statement coded to just match the two fields, I obviously get no records returned because, I assume, of those leading zeros.
    Unfortunately, I don't have a lot of experience coding SQL, so I'm not sure how to resolve this.
    Please help!  As always, I will award points to ALL helpful responses!
    Thanks!!
    Dave

    >
    Dave Packard wrote:
    > Good day, everyone!
    > I would like to join the tables FMIFIIT and AUFK.  The INNER JOIN will be done between FMIFIIT's MEASURE (Funded Program) field, which is char(24), and AUFK's AUFNR (Order Number) field, which is char(12).
    >
    > The problem I'm having is this:  All of the values in AUFNR are preceeded by two zeros.  For example, if I have a MEASURE value of '5200000017', the corresponding value in AUFNR is '005200000017'.  Because I have my SQL statement coded to just match the two fields, I obviously get no records returned because, I assume, of those leading zeros.
    > Dave
    You can't do a join like this in SAP's open SQL.  You could do it in real SQL ie EXEC.... ENDEXEC by using SUSBTR to strip off the leading zeros from AUFNR but this would not be a good idea because a)  modifying a column in the WHERE clause will stop any index on that column being used and b) using real SQL rather than open SQL is really not something that should be encouraged for database portability reasons etc. 
    Forget about a database join and do it in two stages; get your AUFK data into an itab, strip off the leading zeros, and then use FAE to get the FMIFIIT data (or do it the other way round). 
    I do hope you've got an index on your FMIFIIT MEASURE field (we don't have one here); otherwise your SELECT could be slow if the table holds a lot of data.

  • SQL STATEMENT , PLEASE HELP

    Hi,
    I want some help in writing a SQL Query .Its besically a hierarchical query. Let me lay down the table structure first to explain my requirements better.
    PORP_TABLE(NODE_LEVEL int, WBS_ID int, WBS_NUMBER varchar(60), LFT int,RGT int)
    SELECT NODE_LEVEL, WBS_ID, LFT,RGT FROM PROPOSAL_WBS PW WHERE PROPOSAL_REV_ID = 7000
    (SAMPLE DATA)
    NODE WBS
    LEVEL WBS_ID NUMBER LFT RGT
    0 7055 ROOT 1 24
    1 7056 1 2 5
    1 7088 2 6 9
    2 7057 1.1 3 4
    2 7089 2.1 7 8
    2 7091 3.1 11 14
    2 7103 3.2 15 16
    2 7105 4.1 19 20
    1 7090 3 10 17
    3 7092 3.1.1 12 13
    1 7104 4 18 23
    2 7106 4.2 21 22
    ALLOCATION_DETAIL( WBS_ID int, COST_ID int, PERIOD Date, AMOUNT Float)
    sample data
    WBS_ID , COST_ID , PERIOD , AMOUNT
    7057 100 01-jan-2005 5000
    7057 100 01-feb-2005 2000
    7057 100 01-mar-2005 1000
    7057 100 01-apr-2005 6000
    7057 100 01-may-2005 3000
    7057 100 01-jun-2005 45000
    7106 100 01-mar-2005 8000
    7106 100 01-apr-2005 7000
    7106 100 01-may-2005 9000
    Now the PORP_TABLE has got the parents and childs. Only the leaf nodes in the hierarchy has the values stored in the ALLOCATION_DETAIL table. Now here is the scenario
    In the example 7055 is the root WBS . The Leaf WBS are the one with max extension in the wbs number ( in this case it is 1.1, 2.1, 3.1.1, 3.2, 4.1 and 4.2)
    Now the Starting period for each leaf node in the ALLOCATION_TABLE could be differrent . What that means is WBS 1.1 could start in Jan -2003 and WBS 3.1 Could be Jul-2005 . So the ending perios are also differrent for differrent WBS . Some can span 2 years some can 5 years.
    So how to write a query so it retrieves the value for all the Wbs starting from the MIN ( PERIOD ) upto the MAX(PERIOD), and it should roll up also. Now there is No connect by Prior or any analytic functions available for this . THIS NEEDS TO BE DONE ONLY THROUGH TRADITIONAL SQL STATEMENT . And NO DB FUNCTIONS CAN BE USED .
    Now if the WBS is a parent node then it should have the sum of all its child nodes for the COST category.
    SO THE RESULT SET SHOULD BRING LIKE THIS
    WBS_NUMBER, PERIOD_NUMER, COST_CATEGORY , AMOUNT
    ROOT
    1
    1.1
    2
    2.1
    3
    3.1
    3.1.1
    3.2
    4
    4.1
    4.2
    ......

    Thanks for all your thoughtfull replies and feedbacks. Yes it is in Sybase platform . Though I have been woking all along in Oracle , Unfortunately this one is in Sybase, and no the customer cant and wont move to Oracle. So I have to work with it . And if you want to see the table structure . Here are they :
    CREATE TABLE PROPOSAL_WBS (
    BURDEN_CENTER_ID      numeric(18,0) NULL,
    START_DATE      datetime NULL,
    END_DATE      datetime NULL,
    WBS_ID      int NOT NULL,
    MODIFIED_DATE      datetime NULL,
    CREATED_DATE      datetime NULL,
    MODIFIED_BY      varchar(127) NULL,
    CREATED_BY      varchar(127) NULL,
    FEE_PERCENT      float NULL,
    PROPOSAL_REV_ID      int NOT NULL,
    PARENT_WBS_ID      int NULL,
    NAME      varchar(127) NULL,
    COMMENT      varchar(255) NULL,
    TARGET_COST      float NULL,
    MONTHS_REMAINING      int NULL,
    DEFAULT_STAFF_FTE      float NULL,
    ANNUAL_GRA_SALARY      float NULL,
    NUMBER_OF_GRA      int NULL,
    MANAGEMENT_ADJUSTMENT_TOTAL     float NULL,
    MA_UNALLOCATED_FUNDS      float NULL,
    FEE_TOTAL      float NULL,
    FEE_UNALLOCATED_FUNDS      float NULL,
    TRAVEL_COMMENTS      varchar(255) NULL,
    ODC_COMMENTS      varchar(255) NULL,
    SORT_ORDER      int NULL,
    LFT      int NULL,
    RGT      int NULL,
    NODE_LEVEL      int NULL,
    WBS_NUMBER      varchar(50) NOT NULL,
    TOTAL_COST      float NULL,
    TOTAL_COST_PLUS_FEE      float NULL,
    PER_MILE_COST      float NULL,
    PER_DIEM      float NULL,
    TAX_RATE      float NULL,
    RENTAL_CAR_PER_DAY_COST      float NULL,
    TAXI_PER_TRIP_COST      float NULL,
    CONSTRAINT PK_PROPOSAL_WBS PRIMARY KEY(WBS_ID)
    CREATE TABLE PROPOSAL_WBS_ALLOC_DETAIL (
    WBS_ID      int NOT NULL,
    OBJECT_CODE_ID      numeric(18,0) NOT NULL,
    PERIOD_NUMBER      int NOT NULL,
    ALLOCATION_AMOUNT     float NULL,
    PERIOD_YEAR      datetime NULL,
    CONSTRAINT PK_PROPOSAL_WBS_AD PRIMARY KEY(WBS_ID,OBJECT_CODE_ID,PERIOD_NUMBER)
    CREATE TABLE WBS_PERIOD (
    PERIOD_NUMBER     int NOT NULL
    CREATE VIEW WBS_COST_CAT AS
    SELECT PROPOSAL_WBS.PROPOSAL_REV_ID,
    PROPOSAL_WBS.WBS_ID,
    PROPOSAL_WBS.NAME, PROPOSAL_WBS.SORT_ORDER,
    PROPOSAL_WBS.NODE_LEVEL, PROPOSAL_WBS.WBS_NUMBER,
    CODES.CODE_ID COST_CATEGORY, CODES.CODE_NAME COST_CAT_NAME
    FROM PROPOSAL_WBS, CODES
    CREATE TABLE CODES (
    CODE_ID      numeric(18,0) NOT NULL,
    CODE_VALUE      varchar(254) NULL,
    CODE_NAME      varchar(254) NULL,
    CODE_TYPE      numeric(18,0) NULL,
    CODE_PARENT_ID     numeric(18,0) NULL,
    CONSTRAINT PK_CODE_ID PRIMARY KEY(CODE_ID)
    So let me explain little bit more . The WBSs are categorized into two differrent types. One as INPUT and the second one as NON INPUT. Now assme the the WBS in a tree structure . So only the LEAF WBSs will have the AMOUNT and they are the INPUT WBSs and all non leaf WBSs are NON INPUT. Now lets say there are 5 LEAF WBSs. Each LEAF WBS will have differrent start period ex: WBS 1.1 starts in January 2003 and goes for 48 periods . WBS 2.1 starts in November 2003 and goes for 35 periods . WBS 3.1 starts in March 2004 and goes for 52 periods. and so on .
    Now as there is no Allocation Amount entry for all other WBSs except the LEAF WBSs. So how do I get the roll up . For example if you imagine the parent of WBS 1.1 is WBS 1 , and the parent of WBS 2.1 is WBS 2 and the Parent of WBS 3.1 is WBS 3 , and the parent for WBS 1, WBS 2, WBS 3 is "ROOT WBS". As I said there is no entry for WBS 1, WBS 2 , WBS 3 and the "ROOT WBS". So how do I have a roll up of the Leaf WBS data for their parent WBSs.
    Now if u think of the data in a matrix report, the WBSs and the COST CATEGORY will be the row values, the Period Numbers will the column values and the Allocation Amount will be the cross values. so lets say the WBS 1 has got two leaf nodes, WBS 1.1 and WBS 1.2 then WBS 1 will have the summed amount for each period starting the minumum period of the two of its leaf nodes and for all the cost categories of both the leaf nodes. and the "ROOT WBS" will have all the cost categories of al the Leaf nodes . for all the periods , period wise.

  • Urgent Help - SQL Statement..

    hai everybody,
    i need ur help in writing a SQL statement..
    i have 2 tables say
    CATEGORY
    cat_id cat_name
    B001 IT
    B002 Accounts
    B003 Clerk
    SUB CATEGORY
    sub_cat_id sub_cat_name cat_id
    S001 programming B001
    S002 Admin B001,B002
    S003 HR B001,B002,B003
    i want to display one as liek ths
    sub_cat_name cat_name
    Programming IT
    admin IT,Accounts
    HR IT,Accounts,Clerk
    how to write a qry for this..pl help..
    thanx in advance
    regards
    koel

    This is just a natural join between two tables.
    The query can be like this:
    select b.sub_cat_name, a.cat_name
    from category a, sub_category b
    where a.cat_id = b.cat_id
    Pl. let me know whether this solves your problem.

  • Help creating sql statement

    I need help in creating a sql statement. For example lets say i have 3 tables one(key_id, os), two(key_id, type, desc), three(type, desc). I need to create a statement that is kind of like this but i need all rows in table one returned also.
    select a.key_id, b.key_id, c.desc
    from one a, two b, three c
    where a.key_id = b.key_id and b.type = c.type;
    Message was edited by:
    user457357

    Or
    michaels>  with one as
    (select 10 key_id from dual union all
      select 20 from dual union all
      select 30 from dual union all
      select 40 from dual union all
      select 50 from dual),
    two as
    (select 10 key_id,'aa' type from dual union all
      select 20, 'aa' from dual union all
      select 30, 'bb' from dual),
    three as
    (select 'aa' type ,'Artificial' des from dual union all
      select 'bb','Bulk' from dual)
    select a.*, b.key_id, c.des
      from one a, two b, three c
    where a.key_id = b.key_id(+)
        and b.type = c.type(+)
        KEY_ID   KEY_ID_1 DES      
            10         10 Artificial
            20         20 Artificial
            30         30 Bulk     
            40                     
            50                     

Maybe you are looking for