🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.databases
Article #174

Re: (Q): SQL-Queries

#174
From: Benoit Chailler
Date: Mon, 20 Oct 1997 00:00
122 lines
4057 bytes
This is a multi-part message in MIME format.
--------------D31BAC72435AC748BEF2D0A5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit



Heinz A. Krebs Dipl.-Ing. wrote:

> servas!
>
> i have three small questions about sql-queries:
>
> 1. how can i make a case-insensitive selection? if i make the following:
>      SELECT titel FROM database WHERE titel LIKE '%apple%'
>    i don't get the entries with 'Apple', but i want them all!
>
> 2. can i retrieve a record by his recordnumber like
>      SELECT titel, rezept FROM database WHERE recordnumber=4162
>

The record number is not support in SQL.But you can do something
similar.When a select return you a set, be sure you always sort the result
set by
the same field and   do that

declare @field varchar(10)   <- the same lenght and datatype of the field
you need
declare @rownumber

select @rownumber = 4162

declare scur scroll cursor for
  select field from table order by field

open scur

fetch first from scur into @field
if @@CURSOR_ROWS >= @rownumber
begin
   fetch absolute @rownumber from scur into @field
end
else
begin
   select @field = null
end

close scur
deallocate scur

if @field is not null
begin
  select * from table where field = @field   <- it's the 4162nd row
end
else
begin
   print 'This row does not exist.'
end

with this example, you use CURSOR statement. It's look like a recno.





> 3. where can i get a good explanation of SQL-statements on the web to
>    avoid further boring questions by me?  ;-)
>

Search for a book of SQL 92    by   C.J. Date (the one who think SQL)


> ciao
>   H.
>
> ***********************************************************************
>                    KOS - Kochbuch Online System
>
>   45000 Kochrezepte online  siehe unter http://www.styria.co.at/kos/
> ***********************************************************************
> Heinz A. Krebs Dipl.Ing.        voice:  43-1-4077234 or 43-1-58801-5011
> Vienna University               fax:                       43-1-4077235
>   of Technology                 email:         hkrebs@fbch.tuwien.ac.at
> Institute of Organic Chemistry  WWW: http://info.tuwien.ac.at/
>   Department Naturstoffsynthese                      orgchem/krebs/
> Getreidemarkt 9/9/154           fido:                          2:310/67
> A - 1060 Wien                   mailbox:                   43-1-4077235
> ***********************************************************************



--
Benoit Chailler
mailto:benoit@ic2c.com
Images Coast 2 Coast
http://www.ic2c.com


--------------D31BAC72435AC748BEF2D0A5
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Benoit Chailler
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Benoit Chailler
n:              Chailler;Benoit
org:            Images Coast 2 Coast
adr:            1000 St-Antoine #303;;;Montreal;Quebec;H3C 3R7;Canada
email;internet: benoit@ic2c.com
title:          DBA
tel;work:       (514) 868-0874
tel;fax:        (514) 868-0875
tel;home:       (514) 237-3141
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------D31BAC72435AC748BEF2D0A5--
Technical Details
Message-ID: <344B6B9D.7851F65@ic2c.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <344B1EAD.E25@fbch.tuwien.ac.at>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: ffff5,c6b02df51994e2b0
X-Google-Attributes: gidffff5,public
X-Google-Thread: 10de66,c6b02df51994e2b0
X-Google-Attributes: gid10de66,public
X-Google-Thread: 11301e,c6b02df51994e2b0
X-Google-Attributes: gid11301e,public
From: Benoit Chailler <benoit@ic2c.com>
Subject: Re: (Q): SQL-Queries
Date: 1997/10/20
Message-ID: <344B6B9D.7851F65@ic2c.com>
X-Deja-AN: 282040216
References: <344B1EAD.E25@fbch.tuwien.ac.at>
Organization: Images Coast 2 Coast
NNTP-Posting-Date: 20 Oct 1997 10:32:08 EDT
Newsgroups: comp.lang.pascal.delphi.databases,borland.public.delphi.database.sqlservers,microsoft.public.sqlserver.programming