🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #816

Re: Syntax problem

#816
From: philhege
Date: Fri, 11 May 2007 12:43
65 lines
3360 bytes
Thanks for the reply, Wayne.  I'm just having a bit of cognitive
dissonance between SQL dialects.  In MSSQL, I can construct a stored
procedure that returns a query result without declaring or populating
any return parameters.  IOW

CREATE PROCEDURE MyProc
AS
BEGIN
Select * from MyTable
END

is perfectly legitimate and returns a result set to the caller.

The IB procedure I'm writing will ultimately DELETE records from a
table, not SELECT them, so will the approach be any different?
Furthermore, where can I find decent online guidance for writing IB
SPs?  The docs at http://www.firebirdsql.org/index.php?op=doc leave a
lot to be desired.

Tks again,
PH
On May 10, 12:37 pm, "Wayne Niddery [TeamB]" <wnidd...@chaffaci.on.ca>
wrote:

> That's because, in the context of a stored procedure, the Select statement
> is incomplete. I assume you are expecting one or more rows to be returned
> from this procedure? The procedure must declare return variables, and the
> select statement must place values into those variables.
>
> CREATE PROCEDURE name
> returns (
>   fld1 integer,
>   fld2 varchar(10),
>   fld3 <whatever ...>
> )
> AS
>     [...]
>  SELECT fldA, fldB, fldC FROM Mytable WHERE CAST(datetime AS DATE) <
> :variable_name
>  INTO fld1, fld2, fld2;
>
> That will return *ONE* row (and if the select results in more than one, an
> error).
>
> If you need to allow for more than one row then it needs to be:
>
>  FOR
>     SELECT fldA, fldB, fldC FROM Mytable WHERE CAST(datetime AS DATE) <
> :variable_name
>     INTO fld1, fld2, fld2
>  DO BEGIN
>     SUSPEND;
>  END;
>
> And the calling application needs to select from this procedure rather than
> simply executing it:
>
>     select * from name;
>
> --
> Wayne Niddery - Winwright, Inc (www.winwright.ca)
> "If there is any principle of the Constitution that more imperatively
> calls for attachment than any other, it is the principle of free
> thought - not free thought for those who agree with us, but freedom for
> the thought that we hate." - Oliver Wendell Holmes
Technical Details
Message-ID: <1178887419.884867.142090@q75g2000hsh.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!q75g2000hsh.googlegroups.com!not-for-mail
References: <1178811432.614753.73230@e51g2000hsg.googlegroups.com> <46434a66@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,24b201d9e19c2a2b
X-Google-Attributes: gid114a0e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!q75g2000hsh.googlegroups.com!not-for-mail
From: philhege <pdhpoolplayer1957@yahoo.com>
Newsgroups: borland.public.interbase.sql
Subject: Re: Syntax problem
Date: 11 May 2007 05:43:39 -0700
Organization: http://groups.google.com
Lines: 67
Message-ID: <1178887419.884867.142090@q75g2000hsh.googlegroups.com>
References: <1178811432.614753.73230@e51g2000hsg.googlegroups.com>
   <46434a66@newsgroups.borland.com>
NNTP-Posting-Host: 12.145.217.134
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1178887420 5049 127.0.0.1 (11 May 2007 12:43:40 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 11 May 2007 12:43:40 +0000 (UTC)
In-Reply-To: <46434a66@newsgroups.borland.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: q75g2000hsh.googlegroups.com; posting-host=12.145.217.134;
   posting-account=6VBDSAwAAAAR9naoA1h3dK3aczBNdhIN