Solved

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

Posted on 2001-07-30
5
540 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
[X]
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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
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…

735 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