[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Fetching data



You can give an order by clause and put loops=1 after begin select
Xample:
begin-procedure Select_Data ($key, :$data)
let $data = '' !in case your select will have no results
begin-select loops=1
datacolumn  &data
        Let $data = &data
Where keycolumn = $key
End-Select
end-procedure Select_Data

it would be little bit nicer than exiting select in the middle.

have a nice day,
   Dima


*********** REPLY SEPARATOR  ***********

On 19/10/99 at 11:37 Dray, Adam wrote:

>This falls into the "extremely basic" question category.  I'm a
>fairly experienced SQR user, but I haven't really seen other people's
>code, so I'm wondering if there is a cleaner solution.
>
>
>I want to fetch a single element of data from a table, given a key.
>Theoretically, the key should be unique, but it might not be.  I
>want the first row if it isn't.
>
>Do you typically use a Begin-Select with an Exit-Select inside it?
>Like this?
>
>    Begin-Procedure Get-Data ( $key, :$data )
>    Begin-Select
>    datacolumn  &data
>        Let $data = &data
>        Exit-Select
>    Where keycolumn = $key
>    End-Select
>    End-Procedure
>
>Is this how people typically do it?


If we lose much by having things go wrong, take all possible care.
If we have nothing to lose by change, relax.
If we have everything to gain by change, relax.
If it doesn't matter, it does not matter.

tkdima@classnet.co.il
tkdima@hotmail.com
                     Dima Etkin