SQL Query Error Help !!

Here is the Query:
<cfquery name="get_facilities" dbtype="query">
SELECT
shopid, name, address, city, zip, phone, keyword
FROM get_shops
WHERE(
<cfloop index="i" list="#form.keywords#" delimiters="
">
UPPER(keywords_#request.language#) LIKE UPPER('%#i#%') AND
</cfloop>
UPPER(keywords_#request.language#) LIKE '%%')
ORDER BYzip
</cfquery>
Here is the error:
"The Pattern of the LIKE conditional is malformed"
Here is what was entered in the keyword field in the form,
the person was searching for "star auto[obile".
automobile was misspelled with a [.
How do I fix this? Can I fix it in the query?

Joe Science wrote:
>
> How do I fix this? Can I fix it in the query?
>
Most likely this can be fixed with the recommended used of
the
<cfqueryparam...> tag for all user variables input into
a SQL statement.
It will protect you from SQL injection as well.
UPPER(keyword_#request.languate#_ LIKE
UPPPER(<cfqueryparam
value="%#i#%" cfsqltype="cf_sql_varchar">) AND

Similar Messages

  • HOW TO FIND AND CORRECT THE SQL QUERY ERRORS ????

    Sometimes I get the errors while executing the sql queries.
    I just wanted to know about the various ways by which I can find the sql query errors .
    Any suggestions will be deeply appreciated.

    If you get the an error from SSMS and you can't comprehend it, you can google the error message and google would always lead you to the correction. Or you can post the error in this forum, people
    here are always kind and ready to help :).
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Cluster bar chart- sql query please help-

    Hi,
    I am trying to create cluster bar chart and am stumped with this sql query.Any help is appreciated.
    Here is my table
    city     region      issue     value
    c1     north     i1     y
    c1     north     i2     y
    c2     north     i1     n
    c2     north     i2     y
    c3     south     i1     y
    c3     south     i2     n
    c4     east     i1     n
    c4     east     i2     n
    The bar chart will have 3 series, north south and east.
    And labels will be i1 and i2. value will be number of times this issue was encountered(y) in this region.
    How can I get something like this from the above table-
    region     issue     count(yes)
    north     i1     1
    north     i2     2
    south     i1     1
    south     i2     0
    east     i1     0
    east     i2     0
    thanks

    WITH table1 AS
    (SELECT 1435177 qte_id, 2 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 5 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 7 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 8 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 12 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 14 seq_no
    FROM dual
    table2 AS
    SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
    FROM dual
    SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
    FROM
    (SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
    FROM table1 t1, table2 t2
    WHERE t2.qte_id = t1.qte_id (+)
    AND t2.seq_no = t1.seq_no(+)
    ORDER BY 1,2
    WHERE t1_seq_no IS NOT NULL
    ORDER BY 1,2
    QTE_ID T2_SEQ_NO DIFF
    1435177 2 0
    1435177 5 0
    1435177 7 0
    1435177 8 0
    1435177 12 0
    1435177 14 0

  • SQL Query (PL/SQL function body returning SQL query) Error

    I'm an ApEx newbie, not a PL/SQL developer (more of a Web application developer) and I'm getting an error that prevents me from saving some PL/SQL code. I've looked over it all afternoon, but can't tell what's wrong. I may even be trying to do something inappropriately, or really stupid.
    The code is below. The error I get is - "Function returning SQL query: Query cannot be parsed within the Builder". Any help is appreciated, and thanks in advance. If you need more details of what I'm trying to do let me know.
    = = = = = = =
    DECLARE
    v_ID NUMBER;
    v_SITE_ID NUMBER;
    v_SITE_CODE VARCHAR2(15);
    v_ADDR1 VARCHAR2(240);
    v_CITY VARCHAR2(25);
    v_STATE VARCHAR2(150);
    v_ZIP VARCHAR2(20);
    v_ORG_ID VARCHAR2(10);
    BEGIN
    IF :G_ORG_ID = '' THEN
    SELECT "VENDOR_ID", "VENDOR_SITE_ID", "VENDOR_SITE_CODE", "ADDRESS_LINE1", "CITY", "STATE", "ZIP", "ORG_ID"
    INTO v_ID, v_SITE_ID, v_SITE_CODE, v_ADDR1, v_CITY, v_STATE, v_ZIP, v_ORG_ID
    FROM "PO_VENDOR_SITES_ALL_V"
    WHERE ("VENDOR_ID" = :P4_VENDOR_ID);
    ELSE
    SELECT "VENDOR_ID", "VENDOR_SITE_ID", "VENDOR_SITE_CODE", "ADDRESS_LINE1", "CITY", "STATE", "ZIP", "ORG_ID"
    INTO v_ID, v_SITE_ID, v_SITE_CODE, v_ADDR1, v_CITY, v_STATE, v_ZIP, v_ORG_ID
    FROM "PO_VENDOR_SITES_ALL_V"
    WHERE (("VENDOR_ID" = :P4_VENDOR_ID) AND ("ORG_ID" = :G_ORG_ID));
    END IF;
    END;

    Denes,
    Good question.
    Before I answer that question I'll give some detail on the application. That may help too. The application is a supplier search which searches the Oracle vendor tables (po.vendors, po_vendor_sites_all, po_vendor_contacts). The vendor/vendor site relationship is one to many. The site is based on the Org_ID. The supplier search is built to work solo, or to be called by another application. If it is called by another application one of the values passed is the Org_ID, so that only the sites that pertain to the user's org_id are shown. If the appl is called solo the Org_ID is not known, so the SQL should return all sites.
    I figured the easiest way to check if the program was running solo or was called was to check the G_ORG_ID value in my PL/SQL that builds the site report. You helped me with that code. (I am hiding buttons by checking if the G_ORG_ID field is null and they display/hide properly.)
    So, how is G_ORG_ID populated? It is on Page Zero, and is populated via the URL when the appl is called. (That aspect works great.) If it is called by another application G_ORG_ID is populated and my PL/SQL works. But, if the appl is called solo the field is not populated. When the PL/SQL runs I cannot get it to run the code for when G_ORG_ID is not populated.
    I am at the point that I don't know if I need to populate G_ORG_ID in some way when the appl is running solo (kinda tricky, because I need to use that field to determine if it is running solo), or if I need to check it differently in the PL/SQL IF.
    I have experimented with both the default value, and have checked for different values in the PL/SQL IF, but nothing works.
    Thanks for your help, and let me know if you have any other questions on this matter.
    Thanks, Tony

  • Passing parameter to a SQL query - Please help

    Hi All,
    I am new to JDBC. I have been trying to pass an external variable to an SQL Query.
    The query is
    String username1="le";
    PreparedStatement pstmt = null;
    pstmt = c.prepareStatement("select * from users where USER_NAME like '%?%'");
         pstmt.setString(1, username1);
         pstmt.executeQuery();
         ResultSet rs = pstmt.getResultSet();
    I am trying to retrieve values from the users table where the USER_NAME column value that is a String contains the supplied value username1.
    I am using the question mark (?) character to pass the value from the variable username1. I am also using the '%' substitution character which matches for any number of characters. So, the above query should retrieve rows where the USER_NAME is something like "charles","leander","Elena" etc.( that contains "le")
    I am getting the error:
    SQLException: java.sql.SQLException: ORA-01006: bind variable does not exist
    I changed the query to
    PreparedStatement pstmt = null;
    pstmt = c.prepareStatement("select * from users where USER_NAME like '% " + username1 + "%'");
         //pstmt.setString(1, username1);
         pstmt.executeQuery();
    This time , it is not giving the error and retrieving properly.
    But I want to use the original query and use the "pstmt.setString(1, username1); " . Is there any way of achieving this?
    Please help.
    Cheers,
    charles_am

    hi,
    try this...
    String username1="%le%";
    pstmt = c.prepareStatement("select * from users where USER_NAME like ?")
    pstmt.setString(1,username1);
    cheers,
    rpk

  • Unable to run Direct SQL Query - Error Odbc driver returned an error (SQLEx

    Hi,
    I have created some answers/reports and dashboards which are working fine.
    However when I try to run an SQL statement on "Create Direct Request" under "Direct Database Request" I get the following error:
    error : State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27022] Unresolved Connection Pool object: "rnd1.Connection Pool". (HY000)
    error : SQL Issued: {call NQSGetQueryColumnInfo('EXECUTE PHYSICAL CONNECTION POOL "rnd1.Connection Pool" select count(*) from dim_issue')}
    I am working as an admin user who has the rights to create direct sql query.
    Any help here will be highly appreciated.
    Thanks, Rohit

    hi,
    27022 Unresolved Connection Pool object: "rnd1.Connection Pool". (HY000
    have you declared correctly your Connention Pool?Or the query you write is it correct?
    check again you connection pool

  • SQL query error

    I have a complicated SQL query which looks like the following:
    UPDATE SeqPick
    SET SeqPick.AceTopAge = SEQS.TopAge, SeqPick.AceBaseAge = SEQS.BaseAge
    FROM T_Well_SeqPick SeqPick INNER JOIN (SELECT TOPS.Sequence_Name, TOPS.Sequence_ID, TOPS.TopAge, BASES.BaseAge FROM (SELECT dd.Sequence_Name, dd.Sequence_ID, Age_Top+(Age_Base-Age_Top)*Top_Ratio As TopAge FROM T_Sequences dd, T_Stages WHERE(dd.SeqScheme_ID
    = 3) And T_Stages.Stage_Name_ID=Top_Stage_ID And T_Stages.Timescale_ID=1) TOPS INNER JOIN (SELECT BaseSeq.Sequence_Name, BaseSeq.Sequence_ID, Age_Top+(T_Stages.Age_Base-T_Stages.Age_Top)*Base_Ratio As BaseAge FROM T_Sequences BaseSeq, T_Stages Where SeqScheme_ID=3
    AND Stage_Name_ID=Base_Stage_ID AND Timescale_ID=1) BASES ON TOPS.Sequence_ID=BASES.Sequence_ID ORDER BY TopAge, BaseAge) SEQS ON SeqPick.Seq_ID = SEQS.Sequence_ID
    When I run it on a SQL Server 2008, I get the following error message:
    SQL Server Exception Error:
    System.Data.SqlClient.SqlException: The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified.
    Are there any other ways of re-writing the above query to resolve the issue?

    As Erland said, query should be readable. You can easily format it by using
    http://poorsql.com/
    It formats your query like below:
    UPDATE SeqPick
    SET SeqPick.AceTopAge = SEQS.TopAge
    , SeqPick.AceBaseAge = SEQS.BaseAge
    FROM T_Well_SeqPick SeqPick
    INNER JOIN (
    SELECT TOPS.Sequence_Name
    , TOPS.Sequence_ID
    , TOPS.TopAge
    , BASES.BaseAge
    FROM (
    SELECT dd.Sequence_Name
    , dd.Sequence_ID
    , Age_Top + (Age_Base - Age_Top) * Top_Ratio AS TopAge
    FROM T_Sequences dd
    , T_Stages
    WHERE (dd.SeqScheme_ID = 3)
    AND T_Stages.Stage_Name_ID = Top_Stage_ID
    AND T_Stages.Timescale_ID = 1
    ) TOPS
    INNER JOIN (
    SELECT BaseSeq.Sequence_Name
    , BaseSeq.Sequence_ID
    , Age_Top + (T_Stages.Age_Base - T_Stages.Age_Top) * Base_Ratio AS BaseAge
    FROM T_Sequences BaseSeq
    , T_Stages
    WHERE SeqScheme_ID = 3
    AND Stage_Name_ID = Base_Stage_ID
    AND Timescale_ID = 1
    ) BASES ON TOPS.Sequence_ID = BASES.Sequence_ID
    --ORDER BY TopAge
    -- , BaseAge
    ) SEQS ON SeqPick.Seq_ID = SEQS.Sequence_ID
    -Vaibhav Chaudhari

  • SQL query tunning help

    Hi All,
    Could you please help me out the below SQL query tuning .
    Temp table is having 1 Million records
    Master table is having 60 Million records
    Query :
    SELECT B.*,U.ID, SD, LE, LAE
    FROM client.Temp B, client.Master
    U WHERE U.policyno = B.policyno
    AND B.UPFLAG = 0
    1.     Indexes are created on both email columns and Upflag for both tables.
    2.     Gathered DBMS Stats for MASTER Table
    Data is loading 100k/hour on production .

    When your query takes too long ...
    When your query takes too long ...
    HOW TO: Post a SQL statement tuning request - template posting
    HOW TO: Post a SQL statement tuning request - template posting

  • JSTL, MySQL, Tomcat sql:query error

    Hi to everyone...
    This is my first post, but since im employed now as a java developer ill be here regulary.
    Right now im trying to use the JSTL to make some simple sql selects in my JSPs....
    Here�s the JSP code:
    <%@ page language="java" import="java.lang.*,java.util.*" %>
    <%@ taglib uri="/jstl-core" prefix="c" %>
    <%@ taglib uri="/jstl-sql" prefix="sql" %>
    <html>
    <head>
    <title> A first JSP database </title>
    </head>
    <body>
    <sql:setDataSource scope="session" var="dataSource"
    url="jdbc:mysql://127.0.0.1/zolltek" driver="com.mysql.jdbc.Driver"
    user="root" password="root"/>
    <!-- The following UPDATE works fine.. -->
    <sql:update var="users" dataSource="${dataSource}" scope="session">
    INSERT INTO test VALUES (7,'Paul Oakenfold')
    </sql:update>
    <!-- But the select screws up.... -->
    <sql:query var="users" dataSource="${dataSource}" scope="session">
    SELECT * FROM test WHERE 1
    </sql:query>
    </body>
    </html>
    ...and the error message:
    exception :
    org.apache.jasper.JasperException:
    SELECT * FROM test WHERE 1
    : null
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
    root cause
    javax.servlet.ServletException:
    SELECT * FROM test WHERE 1
    : null
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:531)
    at org.apache.jsp.index_jsp._jspService(index_jsp.java:84)
    ...and just for completion the importent part of my web.xml:
    <taglib>
    <taglib-uri>/jstl-core</taglib-uri>
    <taglib-location>/WEB-INF/c-1_0.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/jstl-sql</taglib-uri>
    <taglib-location>/WEB-INF/sql-1_0.tld</taglib-location>
    </taglib>
    i am using the jboss 3.2.3 tomcat bundle (tomcat 4.1.29)
    and mysql 4.0.18 on W32 System....
    the JSTL is installed and working - i can make <sql:update>Inserts without any problems, but any <sql:query>selects result in that error... so i guess the setDataSource is okay...
    Any idea would be appreciated....
    Thx
    J�rg

    Those URIs you've got in your JSPs aren't correct. They should be:
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    These are the URIs defined in the standard.jar.
    You'd be better off setting up a Tomcat JNDI data source for your application. That will externalize the connection parameters and make it unnecessary to refer to a data source in your JSPs.
    You'd be even better off not putting SQL code in your JSPs. They're for presentation. Better to write a Java object that will communicate with the database on the JSP's behalf.
    If you just want to select all the rows in the table, the query should be "SELECT * FROM test". You don't need a WHERE clause in that case.
    If you change the URIs in your JSPs you should remove the <taglib> from your web.xml. It's not necessary. Tomcat will find the TLD by looking in the JARs in the CLASSPATH and matching the URIs.

  • ReportViewer using SQL Query error states: Incorrect syntax near ','.

    Hello Community
        Using Visual Studio 2008 and SQL Server 2008 I created a Windows Application
    that uses SQL Server Reporting Services.  The application uses ReportViewer and
    calls a method written using SQL query.
                1-First I created the form.
                2-Next I dragged the ReportViewer (Toolbox) and Table (from DataSource) onto the form.
    The problem is that when it reaches the last line of the SQL query (ie, da.Fill(ds, "TableOne");)
    the code fails stating the error message:
                "Incorrect syntax near ','."
         The following is the code behind the form containing the query:
            private void ReportPgm1_Load(object sender, EventArgs e)
                // TODO: This line of code loads data into the 'ReportDBDataSet.TableOne' table. You can move, or remove it, as needed.
                this.TableOneTableAdapter.Fill(this.ReportDBDataSet.TableOne);  
                reportViewer1.ProcessingMode = ProcessingMode.Local;
                LocalReport ReportOneLocalReport = reportViewer1.LocalReport;
                DataSet ds = new DataSet("ReportDBDataSet.TableOne");
                pgmReportOne(FromDate, ToDate,   ds);
                ReportDataSource ds = new ReportDataSource("ReportDBDataSet.TableOne");
                ds.Value = dataset.Tables["TableOne"];
                ReportOneLocalReport.DataSources.Clear();
                ReportOneLocalReport.DataSources.Add(ds);
                this.reportViewer1.RefreshReport();
            private void pgmReportOne(DateTime FromDate, DateTime ToDate, DataSet ds)
                SqlConnection connection = new SqlConnection("Data Source=ReportDBServer;Initial Catalog=ReportDB;Uid=sa;pwd=Password");
                string sqlReportOne = "Select ([InDate], [FirstName], [LastName], [AGe]" +
                                   "from TableOne";
                SqlCommand command = new SqlCommand(sqlReportONe, connection);
                command.Parameters.Add(new SqlParameter("paramFDate", FromDate));
                command.Parameters.Add(new SqlParameter("paramTDate", ToDate));
                SqlDataAdapter da = new SqlDataAdapter(command);
                da.Fill(ds, "TableOne");
        Why does the last line throw an error?
        Thank you
        Shabeaut

    --NOTE: The statement below cannot be run on SQL Server 2012
    --If you have an earlier version and can set the compatibility
    --level to 80, it can be run.
    SELECT sso.SpecialOfferID, Description, DiscountPct, ProductID
    FROM Sales.SpecialOffer sso,
    Sales.SpecialOfferProduct ssop
    WHERE sso.SpecialOfferID *= ssop.SpecialOfferID
    AND sso.SpecialOfferID != 1
    Hi Scott
    The *= is old syntax and not compatible with SQL Server 2012 (as stated in the comments). 
    You could do something like this instead
    SELECT sso.SpecialOfferID
    ,Description
    ,DiscountPct
    ,ProductID
    FROM Sales.SpecialOffer sso
    left outer join Sales.SpecialOfferProduct ssop on sso.SpecialOfferID = ssop.SpecialOfferID
    WHERE sso.SpecialOfferID != 1

  • Validate and Edit SQL Query Errors

    I am trying to "Validate or Edit SQL Query" in APEX 3.0. When I open up the SQL Query its highlighted in red and when I click on the Validate or Edit button it gives me an error.
    I modified my marvel.conf file to include:
    AddType text/xml xbl
    AddType text/x-component htc
    and this still didnt take care of it. Any ideas and thank you in advance.
    PS: OPS - Windows Server 2003
    Upgraded from 1.6 to 3.0

    I've gotten so used to command line editing, that I rarely us "ed". back in the days of DOS, the default editor was EDLIN - one of those goofy editors that only showed one line at a time, so it wasn't much of an improvement. you could switch to the old dos editor, but that wasn't much better (just checked, it's still there)
    some nice things with command line editing
    to change everthing between the first two single quotes
    c/'...'/'new criteria'to remove everything after a specific string
    c/from.../fromto change a string that contains (or will contain) slashes
    c.1/2.1/4.

  • Native SQL query - Need help

    Hi All,
    We have a native SQL query accessing Oracle database(given below).
    Can anyone please let me know what this query is about and how can we fine tune the query?
    SELECT O.OBJECT_NAME ,
                   H.SID,
                   HS.MACHINE,
                   HS.PROCESS,
                   W.SID,
                   WS.MACHINE,
                   WS.PROCESS,
                   H.CTIME,
                   W.CTIME,
                   WS.ROW_WAIT_OBJ#,
                   WS.ROW_WAIT_FILE#,
                   WS.ROW_WAIT_BLOCK#,
                   WS.ROW_WAIT_ROW#,
                   HP.SPID,
                   WP.SPID
            FROM V$LOCK H, V$LOCK W, V$LOCK I, V$LOCK I2, ALL_OBJECTS O,
                 V$SESSION HS, V$SESSION WS, V$PROCESS HP, V$PROCESS WP
            WHERE   H.ID1 = W.ID1
            AND     H.SID <> W.SID
            AND     H.TYPE IN ('TX','DL')
            AND     H.REQUEST = 0
            AND     H.SID = I.SID
            AND     I.TYPE = 'TM'
            AND     I.ID1 = O.OBJECT_ID
            AND     I.ID1 = I2.ID1
            AND     W.SID = I2.SID
            AND     I2.TYPE = 'TM'
            AND     H.SID = HS.SID
            AND     W.SID = WS.SID
            AND     HS.PADDR = HP.ADDR
            AND     WS.PADDR = WP.ADDR
            INTO :EXCL_LOCK_WAITERS-OBJ_NAME   ,
                 :EXCL_LOCK_WAITERS-HOLDER_SID ,
                 :EXCL_LOCK_WAITERS-H_HOSTNAME ,
                :EXCL_LOCK_WAITERS-HOLDER_PID ,
                 :HOLDER_PID ,
                 :EXCL_LOCK_WAITERS-WAITER_SID ,
                 :EXCL_LOCK_WAITERS-W_HOSTNAME ,
                :EXCL_LOCK_WAITERS-WAITER_PID ,
                 :WAITER_PID ,
                 :EXCL_LOCK_WAITERS-HELD_SINCE ,
                 :EXCL_LOCK_WAITERS-WAITSSINCE,
                 :ROW_WAIT_OBJ,
                 :ROW_WAIT_FILE,
                 :ROW_WAIT_BLOCK,
                 :ROW_WAIT_ROW,
                 :H_PROCESS,
                 :W_PROCESS
          ENDEXEC
    Thanks in advance.
    Neethu Mohan

    Hi Neethu,
    It gives you an overwiew of blocking Oracle sessions.
    1. In general, the SQL checks Oracle sessions (SID's) that were requirering a DML lock ('TM') and now holding row locks (TX)  to prevent destructive interference of simultaneous conflicting DML or DDL operations. DML statements automatically acquire both table-level locks and row-level locks ('TX')  => holders
    It joins these with the sessions that are waiting of releasing the lock by the holders  => waiters.
    2. it retrieves the detail information wich  Oracle process , the object (table) , it's row , block  and file
    are affected by the locks.
    3. Normally, the locks are only hold for a short period of time. If you have blocking sessions it may be of a log running task (i.e. mass data update of a table) ; but it could also be a application bug due to improper handling of concurrent updates of the same object.
    4. Tuning
    V$tables are expensive to query: Why?
    v$ tables are generally Oracle memory structures.
    v$ tables are not read consistent.
    v$ tables require latches to access -- cannot modify and read memory at the same
    time.
    heavy access to v$ tables like this may cause some serious heavy duty contention.
    Especially if you self join V$lock several times.
    So the best would be to save the contents of V$LOCK in some table:
    Create table mylocks as select * from v$lock;
    Use that table for self-joining and joins to the other tables.
    You can also CTAS the other v$ tables to bypass the performance bottleneck while retrieving
    v$ directly.
    You can empty or drop the created tables any time for new data.
    Because you want to investigate only lock hold for a longert time  to copy the v$ memory structures into
    physical tables is not a disadvantage. You certainly will wait longer on finishing your query
    instead of copy them into the tables.
    Hope this helped
    yk

  • Native SQL Query Error: DBIF_DSQL2_SQL_ERROR -- ORA-00936: missing express

    Hi,
    I tried to read data using the following SQL Query,
    fp_work = 'ABCD'.
      EXEC SQL PERFORMING WRITE_TO_ITAB .
      SELECT fp_code, bank_acc_code, bank_acc_num,
      INTO :gs_cds_data-FP_CODE,
               :gs_cds_data-BANK_ACC_CODE,
               :gs_cds_data-BANK_ACC_NUM,
       FROM  BANK_TABLE
      WHERE fp_code = :fp_wrk
      ENDEXEC.
    *&      Form  WRITE_to_itab
    FORM write_to_itab.
    To move the data into the Internal Table.
      APPEND gs_cds_data TO gt_cds_data.
      CLEAR  gs_cds_data.
    ENDFORM.                    "WRITE_to_itab
    and im getting the run time error..
    What happened?                                                                               
    The error occurred in the current database connection "SAPABC".                                                                               
    How to correct the error                                                                               
    Database error text........: "ORA-00936: missing expression"             
    Triggering SQL statement...: "FETCH NEXT "                               
    Internal call code.........: "[DBDS/NEW DSQL]"                           
    Please check the entries in the system log (Transaction SM21).                                                                               
    You may able to find an interim solution to the problem                  
    in the SAP note system. If you have access to the note system yourself,  
    use the following search criteria:                                                                               
    "DBIF_DSQL2_SQL_ERROR" C                                                                               
    If you cannot solve the problem yourself, please send the                
    following documents to SAP:
    Can anyone give me a solution to correct this error?
    In addition, Can i omit the WHERE clause, as i need to get all the data in the oracle database?

    BUT,
          EXEC SQL.
            connect to :LV_DB_NAME as :sy-uname
          ENDEXEC.
          EXEC SQL.
            SET CONNECTION :sy-uname
          ENDEXEC.
         check sy-subrc..
    connection is happening.. with sy-subrc value as ZERO

  • SQL query performace help

    Hi,
    I have a question about the performace of this SQL query. I have to display only 8 rows from this query. How is this query will be executed? What happens if the inside query returns more than 500 rows? Will it slow down?
    SELECT * FROM (SELECT prod_date, create_date, prod_name, priority, status FROM CUST_PROD
    WHERE cust_id = 100 and Status in(1, 5) order by priority, prod_name ) WHERE ROWNUM < = 8
    Thank you..

    Its hard to tell what effect more data will have on a query until it happens. As BluShadow pointed out you're not talking about huge amounts of data; with luck the numbers you mentioned will not make any difference.
    It looks like you're using the inline view to a top N query. You could look into using the RANK() function to do something similar.

  • SQL Query error in java swing Application

    hi,
    I'm getting the following error when i try to manipulate the date in query.I have set of tuples and would like to retrieve with respect to the date given.Please do help me to get rid of this error.This is the error.
    MY QUERY:
    ResultSet rsdate=st1.executeQuery("select * from phy_stock where date = "+d1+"");
    Where d1 is given like this:
    String startdate[2]="11/31/2008";
    DateFormat df = new SimpleDateFormat ("MM/dd/yyyy"); //converting a string to DATE format.
    Date d1 = df.parse(startdate[2]);
    ERROR:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'date = Mon Sep 01 00:00:00 IST 2008'
    thanks,
    kumar.

    Dates do not have formats. When referencing a Date in String concatenation, which is what you are doing here,
    ResultSet rsdate=st1.executeQuery("select * from phy_stock where date = " + d1 + "");you will get what Date's toString method produces, which will not work for that (or any) query. For one, it wouldn't be surrounded by single quotes ('), and for two, the String format of the Date would not be acceptable by the DB (unless you had changed the DBs defaults).
    Use a PreparedStatement, as suggessted above, and this problem goes away.
    Edit: And make sure to use the setDate method, of course.

Maybe you are looking for