Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2001-07-30
5
Medium Priority
?
568 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

721 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