Problem with LIMIT in my query...

I am sending this query with JSP to my Oracle database:
SELECT pub, class, startdate, adtext FROM classifieds WHERE (pub='KWR') AND
(startdate<='03-Jan-02') ORDER BY pub LIMIT 0, 25
I keep getting the error:
"Exception=java.sql.SQLException: ORA-00933: SQL command not properly ended"
If I remove the LIMIT 0, 25 it works just fine and returns all records, what am I doing wrong?

numrows=>26 AND numrows<=50 I doubt that that will work either. But you can try. Oracle has something like that (although I am not sure is is called 'numrows'). However, it doesn't allow ranges. It allows you to return only the top ones (the less than expression) And it doesn't work with order by clauses.
Someone, sometime ago, suggested a solution in this forum which solved both of these problems. If you search for the correct keyword (not 'numrows') you will likely find it.

Similar Messages

  • Hi! Everyone, I have some problems with JOIN and Sub-query; Could you help me, Please?

    Dear Sir/Madam
    I'm a student who is interested in Oracle Database and
    I have some problems with JOIN and Sub-query.
    I hope so many of you could help me.
    if i use JOIN without sub-query, may it be faster or not?
    SELECT field1, field2 FROM tableA INNER JOIN tableB
    if i use JOIN with sub-query, may it be faster or not?
    SELECT field1,field2,field3 FROM tableA INNER JOIN (SELECT field1,field2 FROM tableB)
    Thanks in advance!

    Hi,
    fac30d8e-74d3-42aa-b643-e30a3780e00f wrote:
    Dear Sir/Madam
    I'm a student who is interested in Oracle Database and
    I have some problems with JOIN and Sub-query.
    I hope so many of you could help me.
    if i use JOIN without sub-query, may it be faster or not?
    SELECT field1, field2 FROM tableA INNER JOIN tableB
    if i use JOIN with sub-query, may it be faster or not?
    SELECT field1,field2,field3 FROM tableA INNER JOIN (SELECT field1,field2 FROM tableB)
    Thanks in advance!
    As the others have said, the execution plan will give you a better idea about which is faster.
    If you're trying to see how using (or not using) a sub-query affects performance, make the rest of the queries as similar as possible.  For example, include field3 in both queries, or ignore field3 in both queries.
    In this particular case, I guess the optimizer would do the same thing either way, but that's just a guess.  I can't see your execution plans.
    In general, simpler code is faster, and better in other ways, too.  In this case
    tableB
    is simpler than
    (SELECT field1, field2  FROM tableB)
    Why do you want a sub-query in this example?

  • Problem with parameter and sql query

    I've a problem with te query of my report. The query is:
    SELECT [DESCRIPTN]
          ,[LOGTIME]
          ,[STATUS]
          ,[CARDNO]
          ,[LOGDATE]
    FROM [Granta5P0].[dbo].[TIMELOG32]
    where cardno in ({?cardNo})
    the parameter as multiple values checked so I can query for more than one card.
    If i put just one parameter everything works fine but when I put 2 or more I have his error
    [http://www.megagaleria.com/pictures/Pic_10074_25.jpg]
    I realized that the field as no ' delimiting the parameters, I have a function that already does it but I don't know how to put it in my sql command.
    If anyone can help I appreciate

    Yes, because your parameter is only looking for one card.
    where cardno in ({?cardNo})
    Will you only be creating querys on two cards or less ?
    Are you trying to create an Array?
    If two or less you could
    where cardno = ({?cardNo}) or cardno = ({?cardNo2})

  • A problem with LOV and my query. Help to solve, please...

    Hello!
    Here is a query:
    SELECT FULLNAME||', '||(SELECT NAMEOFGROUP||', '||(SELECT CITY FROM CITY WHERE PRKEY=TLL.CITY) FROM GROUPS TLL WHERE PRKEY=TL.GROUPOF) t ,PRKEY r FROM MINEUSERS TL
    In SQL DEVELOPER it works fine. But in APEX - when I try to save my "SELECT LIST" - it falls with error - "If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query."
    How can I reassemble my query to fix this problem - I have no idea... :(
    Thanks

    You may create a pipelined function returning two values, display and return, to return
    the result from your query. After that, your LOV should work. See example here:
    http://htmldb.oracle.com/pls/otn/f?p=31517:146
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Problem with performance of a query having order by, distinct clause

    Hi,
    I have a problem with queries having order by, distinct clause.
    While its executing its taking lot of time. With DBMS_PROFILER identified the queries taking long time.
    The table is having approximately 70 million rows.
    Problem -1
    select * from table_name order by col1;
    select distinct col1,col2 from table_name;
    Here i am having 2 solutions request to let me know whether i am right if not suggest me right solution.
    Solution1:
    Max parallel servers is 8.
    select /* + parallel(table_name,8) */ * from table_name order by col1;
    select /* + parallel(table_name,8) */ distinct col1, col2 from table_name ;
    Solution-2:
    select /* + first_rows */ * from table_name order by col1;
    select /* + first_rows */ distinct col1, col2 from table_name ;
    Problem-2
    I am having a query with where condition on columns.
    Select * from table_name where col1='value1' and col2!='value2';
    Index created on col1 and col2.
    As we no that not equal won't use index as it is a composite index it should use the lead column. but its not using the index.
    Should i forcibly use index with hint or suggest me better solution.
    Any help really appreciated.
    Thanks in advance

    unique wrote:
    The table is having approximately 70 million rows.
    select * from table_name order by col1;Do you really want 70,000,000 rows from your table without any restrictions ? And furthermore ordered output ? I honestly understand the slowness of that query.
    Here i am having 2 solutions request to let me know whether i am right if not suggest me right solution.Who knows if you choosed the right solution. I would suggest to reconsider your query and the need of 70,000,000 returned rows.
    Problem-2
    I am having a query with where condition on columns.
    Select * from table_name where col1='value1' and col2!='value2';Please, provide the explain plan, eventually the tkprof output could also help. And tables descirption AND indexes description.
    And OS and Oracle version.
    Nicolas.

  • Problems with OLE Container in QUERY

    Hi all,
    I have problem with OLE Container when I am trying to retrieve data from the database. Inserting is no problem and commit is done. I am doing it with
    initialize_container('block.ole_object','C:\test.doc');
    I have only one column of BLOB type and it is last in the block as it was suggested somewhere on the forum.
    When I am trying to retrieve the already inserted data I get error with the following
    Description:
    FRM-40505: Oracle ERROR: unable to perform query and CTRL+F1 says the following:
    ORA-00932: inconsistent data types: expected got
    The forms and the database are as follow:
    Forms [32 Bit] Version 6.0.8.24.1 (Production)
    Oracle Database 10g Enterprise Edition Release 10.1.0.4.2 - Production
    I need immediate help!!!

    This may be related to the 10g database, I'm not sure as there is no way for me to test it. I know that it works with a 9i database.
    One thing to check is to make sure that you don't have the FORMS60_DISABLE_DESCRIBE set to 1 within the Oracle registry.
    If this doesn't work, your only option might be to use a LONG RAW instead of a BLOB column type in the database.

  • Problem with user defined approval query

    Hi
    Sorry me for my english
    I have a problem with approval query
    DECLARE @DocDate DATETIME
    SET @DocDate = (SELECT $[OINV.DocDate])
    IF (DATEDIFF(DAY,@DocDate,GETDATE())) != 0
    BEGIN
    SELECT DISTINCT 'TRUE'
    END
    the query works with the previous invoices, but today's invoices show me a error colud not commit transaction
    Can Help me?
    Thanks
    Felipe Loyola

    Hi Felipe Loyola,
    Try this:
    SELECT DISTINCT 'TRUE' FROM OINV T0
    WHERE DATEDIFF(DD,T0.DocDate,GETDATE()) != 0 AND T0.DocNum = '$[$8.0.0\]'
    Thanks,
    Gordon

  • Problem with Spin control in query pane

    I have a problem with the Spin controller (increment /decrement) in the query pane.
    It is not working for fields with decimals, but working properly for fields which do not have decimals.
    How to overcome this problem?

    Can you help me to reproduce the issue(Do you have any simple application illustrating the issue)? It works in the sample I tried

  • Problem with cascading dependent LOV query running when it should not

    I have a page fragment with a regular ADF form on it that I use to add new entries to a table. This form has many fields on it with LOV’s associated with them. I have dependent LOV’s on some of them. The one case I have is I have three fields A, B, and C. Field C is dependent on A and B. The problem I seem to be having is when I enter a value for field A using it’s LOV, I get an hourglass for a long time after I select it and before it is displayed on the form. If I delete field C from the form the problem goes away. If I change the query behind the view for the LOV for field C to include a rownum < 20 in the where clause the problem goes away. My question is, why would the selection of a value for field A cause the query to fire for field C’s LOV view and how can I stop it. I don’t really want to use the rownum in the where clause.

    i had lot of question?
    The problem I seem to be having is when I enter a value for field A using it’s LOV, I get an hourglass for a long time
    ok. are using? any complex query to pick the lov 'a' .
    Answer: The LOV for A is based on a read only non-EO view with a SQL that is not really very complex. The LOV definition does set multiple values when the selection is made to blank out dependent fields in the data model used by the main form.
    after I select it and before it is displayed on the form.
    here i cant undestud?
    Answer. The order of things is I open the main form, I click the mag glass to open the LOV popup, I select the row I want and click the OK button. Navigation returns to the main form where I get the hourglass waiting for the selected value to be displayed in the field on the main form.
    If I delete field C from the form the problem goes away. If I change the query behind the view for the LOV for field C to include a rownum < 20 in the where clause the problem goes away.
    ok.
    why are you going to delete the value of c?. At intial stage you can make empty after selecting a and/or b you can load into c.
    Answer: I physically deleted field C from the main form to see if that was what was causing the long delay. When I run the main form without field C I do not get the hourglass. That is how I know they are related.
    My question is, why would the selection of a value for field A cause the query to fire for field C’s LOV view and how can I stop it.
    you may set partial trigger to c depends for 'a'.
    or else lov 'c' query depends on 'a'
    Answer. The query for C's LOV does depend on the value returned when I select a value for A. They are cascading LOV's. Will setting the partial trigger stop the SQL for field C from running? Is the SQL running because I'm blanking out field C when I change the value for field A?
    am not sure i understud correctly. can you pictuarize you problem with an example.

  • Problem with Conditions in a Query

    Hello All,
                 I have the following Condition in My Query.
    Applied Amount Equals to 0.   When I run the Query I receive a message 'No Records Exists with the given conditions'.   But when I remove the condition and place 'Applied Amount' in the Columns Section I see there are numerous records that Have 'Applied Amount' as 0.   What might be the problem?
    Thanks

    Hi,
    Check out the zero suppression in your BEx analyser and also make sure that when you have defined conditions then you have to select only Applied Amount Charecteristic rather than all the charecteristics.
    Hope tis helps...
    Assign points if it helps..
    Thanks,
    Gattu.

  • Problem with exceptions in the query designer

    Hi all,
    i got this problem, there is a formula, than calculate  "A"   %A   "B", This bring a value %, ok.
    in my exceptions i got this ranges:
    1  to  99,4  Bad 9
    99,5 to 100  Good 1,
    i execute the query and this bring the results, when there is a line with value 99,5, this appear without color, the rest is ok,
    why this happend? whats the solution? please guys, i'll award you

    i m sorry the values are
    0 to 99,4 Bad 9
    99,5 to 100 Good 1
    i solve it by this way
    0  to 99,49999999999  Bad 9
    99,5000000001 to 100 Good 1
    i looks like the internal value of the KF is with a lot of decimal, the problem here is, when the value is 99,5 exactly, dont appear color, but i dont know how else solve it, any advice?

  • Problem with formula in the query

    HI ,
    In cube I have 2 fileds EU date and US date .
    For example :
    In cube EU date  =07/02/2008
               US date = 23/02/2008
    In the query we have a formula with these 2 fields
    formula is DUE date =  DATE ( ( 'Enter 1 = US; 2 = EU - Asia' == 1 ) * 'Due date US' + ( 'Enter 1 = US; 2 = EU - Asia' == 2 ) * 'Due date EU' )
    In the varaible screeen we have a '"Enter 1 = US; 2 = EU - Asia' == 1"
    So if u enter 1 it takes EU date and display as due date if u enter 2 it take US date and display as due date.
    Problem is :
    When we give  "'Enter 1 = US; 2 = EU - Asia' == 1"---this value 2
    in the report in some cases we get due date as 02/07/2008 instead of 07/02/2008. This is not for all records only few we get like this . and for US  due date this problem  is not there.
    Please suggest what might be the problem.

    Hi,
    Please check again the cell value because it may contain correct value but display may be different.
    You can apply the common display property fot the whole column using the workbook properties and saving the workbook.
    Regards,
    Anil

  • Problems with Database Link in query

    When I run this code:
    SELECT NVL2(wbs1.wbs1_seq, wbs1.wbs1, pcn.pron) AS pron
         , h.fy AS data_fy
    FROM pcn_list@THE_LINK pcn
         JOIN project@THE_LINK x
         ON x.pcn_seq = pcn.pcn_seq
         JOIN
           SELECT h.project_seq
                , EXTRACT(year FROM (h.data_dt + 92)) AS fy
           FROM pcn_data@THE_LINK h
                JOIN setup@THE_LINK
                ON (
                     setup.data_dt = h.data_dt
                     OR (
                          EXTRACT(year FROM h.data_dt) > DECODE(setup.site, 'TYAD', 2006, 2007)
                          AND h.data_dt < setup.data_dt
                          AND TO_CHAR(h.data_dt, 'MMDD') = '0930'
                     OR (
                          EXTRACT(year FROM h.data_dt) BETWEEN 2000 AND DECODE(setup.site, 'TYAD', 2006, 2007)
                          AND TO_CHAR(h.data_dt, 'MM') = '09'
                          AND h.data_dt = NEXT_DAY(LAST_DAY(h.data_dt) - 7, 'FRIDAY')
           WHERE h.data_dt BETWEEN '01-SEP-06' AND '31-OCT-08'
         ) h
         ON h.project_seq = x.project_seq
         LEFT JOIN wbs1_list@THE_LINK wbs1
         ON (
                wbs1.fiscal_yr = pcn.fiscal_yr
                AND (
                      wbs1.legacy_pron = pcn.pron
                      OR SUBSTR(wbs1.legacy_pron, 1, 2) || SUBSTR(wbs1.legacy_pron, 4) = pcn.pron
              OR (
                   TRIM(wbs1.legacy_pron) IS NULL
                   AND wbs1.wbs1 = SUBSTR(pcn.pron, 1, 2)
                                   || SUBSTR(TO_CHAR(wbs1.start_dt + 92, 'YY'), 1, 1)
                                   || SUBSTR(pcn.pron, 3, 1)
                                   || SUBSTR(pcn.mission, 1, 1)
                                   || SUBSTR(pcn.pron, 4, 5)
                                   || DECODE(
                                              SUBSTR(pcn.pron, 12, 1)
                                            , '0', SUBSTR(pcn.pron, 13, 2) || SUBSTR(pcn.pron, 13, 2)
                                            , SUBSTR(pcn.pron, 11, 4)
         LEFT JOIN xref_pron_command cmd1
         ON cmd1.command_cd = SUBSTR(pcn.pron, 11, 2)
         LEFT JOIN xref_pron_command cmd2
         ON cmd2.command_cd = SUBSTR(pcn.pron, 1, 2)
         LEFT JOIN mdms@THE_LINK mdms
         ON mdms.pron = SUBSTR(pcn.pron, 1, 8) || SUBSTR(pcn.pron, 11, 1)
         LEFT JOIN if_fedlog fedlog
         ON fedlog.fsc || fedlog.niin = SUBSTR(pcn.nsn, 1, 13)
         LEFT JOIN awpsammo@THE_LINK ammo
         ON ammo.pron = pcn.pron
         LEFT JOIN if_core_workload c
         ON (
              c.site = 'SITE'
              AND NVL2(wbs1.wbs1_seq, wbs1.wbs1, pcn.pron) = c.pron
              AND h.fy = c.data_fy
    WHERE pcn.mission != 'NOP'
    AND   x.pmc_cancel_fg = 'F'
    AND   NVL(wbs1.cancel_fg, 'F') = 'F'
    AND   NVL2(wbs1.wbs1_seq, wbs1.wpc, pcn.wpc) <> 'ZZ'I get:
    ORA-00904: "SETUP"."SITE": invalid identifier
    ORA-02063: preceding line from THE_LINK
    However, if I remove any of the cmd1, cmd2, fedlog, mdms, or ammo joins, it runs properly.
    It also runs properly if I remove both "WHERE h.data_dt BETWEEN '01-SEP-06' AND '31-OCT-08'" (line 25) and "AND x.pmc_cancel_fg = 'F'" (third line from the end).
    Also, there are three different external sites; the problems happen on two of them, but on a third, the code works as is.
    The query also works if:
    * I remove the links and run it directly on the external sites
    * I add something that makes it return no rows immediately (for example, "AND 0 = 1" as the last line)
    * "WHERE h.data_dt BETWEEN '01-SEP-06' AND '31-OCT-08'" is replaced by "WHERE h.data_dt = '30-SEP-09'" (which returns rows)
    * For that matter, at one of the problem sites, changing the first date in that WHERE clause to anything between '19-JUN-09' and '29-SEP-09' works, but '18-JUN-09' and earlier causes the error; at the other, the earliest working date is '02-NOV-08'.
    All three external databases, as well as the database on which this is run, are running 11.2.0.1.0 64-bit Production.
    Any ideas as to what is happening?

    sb92075 wrote:
    WHERE h.data_dt BETWEEN '01-SEP-06' AND '31-OCT-08'With Oracle characters between single quote marks are STRINGS!
    'This is a string, 2009-12-31, not a date'
    When a DATE datatype is desired, then use TO_DATE() function.Actually, usually I do (since there's no guarantee as to what the "default" date format will be - besides, the default tends to be 2-year dates). The one line where I don't is really just something I added to speed up the query when testing for the error.
    However changing that line to:
    WHERE h.data_dt BETWEEN TO_DATE('09/01/2006', 'MM/DD/YYYY') AND TO_DATE('10/31/2008', 'MM/DD/YYYY')causes the same results.

  • Problem with using a Spatial Query in a report region

    All: I am trying to create a report region using the below query. The query is syntactically correct and returns 10 rows. I have checked it out in SQL Developer AND in APEX SQL Workshop. It returns rows in 1-2 seconds.
    However, after putting the query into a report region, the APEX page locks up when it runs. I've tried masking it in a view, using other functions. I can places the spatial function in the select clause and it works. However, placing the function in the Where clause causes the page to lock up.
    Any thoughts?
    Thanks,
    John
    select lastname, address
    from changetracking.individuals
    where sdo_nn (spatiallocation, MDSYS.SDO_GEOMETRY(2001,8265,MDSYS.SDO_POINT_TYPE(-87.55728,33.137569,null),null,null), 'sdo_batch_size=10') = 'T

    QImaging is not officially supported in the Measurement & Automation (MAX) toolkit, though you may find some luck with our free legacy QImaging LabView interface here: http://www.qimaging.com/support/downloads/software/windows/QCamLabViewInstaller221.exe depending on the version lf LabView you're using.If you're looking for something that is actively updated and supported, you may want to get back in touch with Fred at +1.800.874.9789 and ask about our SITK LabView interface as well.
      PMQI_Josh,
    Yes I've already installed the LabVIEW interface beforehand. Also the version of LabVIEW I'm currently using is 8.6. I'll get in contact with Fred to see if there's a solution to this problem. Thank you.

  • URGENT: Problem with lexical reference in query statement!

    I am modifying the seeded Receipt Traveler report.
    The query I need to modify is the receipts query (Q_RECEIPTS). The entire query statement for this is a lexical reference - &P_SELECT_RECEIPTS. The actual query is being set in the After Parameter Form trigger. I need to add a few columns to the select clause and tables to the from clause. Modifying the query in the trigger alone did not help. I got the error - REP 0498 "selected columns differ from report definition"
    => How do I add these new columns to the report now? Do I need to put them in the initial value of the parameter &P_SELECT_RECEIPTS?
    => I tried modifying P_SELECT_RECEIPTS, but I get a REP 1070 error saying the file cannot be saved.
    => In addition, P_SELECT_RECEIPTS does not have a from clause, which causes a problem for me, but I am wondering how the report was originally saved
    Any help with this rather lengthy question will be greatly appreciated.
    Thanks,
    P.S.
    The initial value of &P_SELECT_RECEIPTS is set to:
    SELECT rrp.item_id,rrp.organization_id rrp_organization_id,MSI.SEGMENT1||''||MSI.SEGMENT2||''||MSI.SEGMENT3||''||MSI.SEGMENT19||''||MSI.SEGMENT20 C_FLEX_ITEM,MCA.SEGMENT1||''||MCA.SEGMENT2||''||MCA.SEGMENT3||''||MCA.SEGMENT19||''||MCA.SEGMENT20 C_FLEX_CAT,rrp.revision_num,rrp.category_id,rrp.item_description,rrp.un_num,rrp.un_description,rrp.hazard_class,rrp.routing_name,rrp.document_type_code,rrp.document_number,rrp.release_num,rrp.line_num,rrp.buyer_preparer_name,rrp.source_type,rrp.source,rrp.source_unit_of_measure,rrp.vendor_product_num,fnd_date.date_to_canonical(rrp.due_date) due_date,round(rrp.quantity_ordered,:P_qty_precision) quantity_ordered,rrp.note_to_receiver,rrp.pll_note_to_receiver,decode(psp.manual_receipt_num_type,'ALPHANUMERIC',rrp.receipt_num,decode(rtrim(rrp.receipt_num,'0123456789'),NULL,to_number(rrp.receipt_num),rrp.receipt_num)) RECEIPT_NUM,rrp.receipt_unit_of_measure,fnd_date.date_to_canonical(rrp.receipt_date) receipt_date,rrp.receipt_location,rrp.receiver_first_name,rrp.receiver_last_name,rrp.freight_carrier,round(rrp.quantity_received,:P_qty_precision) quantity_received,rrp.primary_quantity parent_primary_quantity,round(rrp.quantity_remaining,:P_qty_precision) quantity_remaining,rrp.shipment_num,rrp.bill_of_lading,rrp.vendor_lot_num,rrp.packing_slip_num,rrp.containers,rrp.receiver_comment,rrp.transaction_type rrp_transaction_type,rrp.transaction_id rrp_transaction_id,rrp.shipment_line_id rrp_shipment_line_id,rrp.shipment_header_id rrp_shipment_header_id,rrp.distribution_id rrp_distribution_id,rrp.po_header_id,rrp.po_line_id,rrp.po_line_location_id,rrp.requisition_header_id,rrp.requisition_line_id,rrp.from_interface rrp_from_interface,rrp.deliver_to_location,rrp.license_plate_number

    You can see the query being bulit within the BUILD_QRECIEPTS Program Unit

Maybe you are looking for