Re: SQL question: How to select by keyword and returned dataset size ?

From: Mark Woytus <mwoytus_at_divcomp.com>
Date: Wed, 20 May 1998 02:57:13 GMT
Message-ID: <3562448e.2299832_at_news.dave-world.net>


On Mon, 18 May 1998 13:01:14 -0700, Charles Sun <csun_at_geneve.arc.nasa.gov> wrote:

>I have a table with 2 fields (Date time_stamp, Double data) and I would
>like to
>construct a query statement Query(Date start_time, Integer x) that will
>return
>at most x records that are timestamped after the start_time.

The basic query, in plain SQL, is

select time_stamp, data
from table_name
where time_stamp > start_time;

but this won't limit the number of rows. To do that, you have to implement the query in embedded SQL in a general programming language, which is what it sounds like you want do do anyway. The Oracle programmer's reference for your language should give guidance on how to implement a cursor, which is a kind of loop that takes a query like that above which returns more than one row, and allows you to use a loop structure to handle one row at a time. You can use the loop to control how many rows you get back.
Mark Woytus (w)309.888.8423 (f)309.888.8246 Diversified Computer Consultants
mwoytus_at_divcomp.com woytus_at_acm.org Received on Wed May 20 1998 - 04:57:13 CEST

Original text of this message