Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Pro*C       sql query to retrive n'th row in sorted order??

Posted on 2001-07-30
5
531 Views
Last Modified: 2012-08-13
when i compile this embedded sql with oracle 8.1.6 Pro*C compiler in SUN-SOLARIS environment. I am getting the following error.

EXEC SQL select min(mobile_id), max(mobile_id) into :FromMIN INDICATOR :FromMINInd, :ToMIN INDICATOR :To
MINInd from (select mobile_id from customerTable order by mobile_id)  where rownum < (:n);



Syntax error at line 76, column 187, file minrange.pc:
Error at line 76, column 187 in file minrange.pc
EXEC SQL select min(mobile_id), max(mobile_id) into :FromMIN INDICATOR :FromMINInd, :ToMIN INDICATOR :ToMINInd from (select mobile_id from customerTable order by mobile_id)  where rownum < (:n);
..........................................................................................................................................................................................1
PCC-S-02201, Encountered the symbol "by" when expecting one of the following:

   , ) union, connect, group, having, intersect, minus, start,
   where, with,
The symbol "group," was substituted for "by" to continue.

Error at line 0, column 0 in file minrange.pc
PCC-F-02102, Fatal error while doing C preprocessing



Above sql stmt. has to retrieve the n'th mobile-id from table customerTable. Is there any other way of retrieving n'th mobile id number without the inner query. Pls. Remember we cannot use rownum = :n in oracle. & Result should be based on sorted order of mobile-id.
Thanks,
0
Comment
Question by:mogunek
5 Comments
 
LVL 2

Expert Comment

by:dbaora
ID: 6339609
Hi,
you cannot use an order by experssion when selecting from select clause (just like creating a view with a order by).
try using:
EXEC SQL select min(mobile_id), max(mobile_id) into :FromMIN INDICATOR :FromMINInd, :ToMIN INDICATOR
:To
MINInd from (select mobile_id from customerTable) where rownum < (:n) order by mobile_id;

regards,
dbaora.
0
 

Author Comment

by:mogunek
ID: 6346841
dbaora,
You know "order by" will work after the where clause, So if the table is not in sorted order then it will pickup the first n records and finds n'th record out of these.

If you have some other query, Pls. give me.
Thanks,
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6402602
This question was LOCKED with a PROPOSED ANSWER and awaits your decision today.  Once a question is LOCKED with a Proposed Answer, few new experts will step in to help on that question, since the assumption is, you've been helped.  If the Proposed Answer helped you, please accept it and award that expert.  If it did not help you, please reject it and add comments as to status and what else is needed.
 
If you wish to award multiple experts, just comment here with detail, I'll respond as soon as possible.  As it stands today, you asked the question, got help and not one expert was awarded for the contribution(s) made.  Your response is needed.  I'll monitor through month end, and if you've not returned to complete this, we'll need to decide.  Expert input is welcome (as always) to determine the outcome here if the Asker does not respond.
 
Your response in finalizing this (and ALL) your question(s) is appreciated.
 
Moondancer
Community Support Moderator @ Experts Exchange
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7284070

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - PAQ'd and pts refunded
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 7315803
This question will be placed in PAQ and points refunded.

Best regards,
ComTech
Community Support
Administrator @ EE
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best RAID for a BDD Oracle 4 78
RDBMS and No sql database 4 63
Question about Relationship and Userform in Access Database 17 62
MIcrosoft SQL 2014 Database Copy Question 16 51
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question