Subject | Re: How To: Write a Store Proc. for the following |
---|---|
Author | Dorin Vasilescu |
Post date | 2004-04-19T06:15:55Z |
Hi
Firebird hasn't so many programming features as VFP
What you can do is to get what you need and do the
evaluation/parsing/textmerge at client side
Something like (in VFP)
SQLEXEC(nHandle, [SELECT * FROM MY_PROCEDURE(?iID, ?cFlag)],'XROW')
cRetValue = EVALUATE(xrow.narrtemplate)
If you really need dynamic parsing/concatenation to be done by
Firebird, you need some UDFs for this.
CREATE PROCEDURE MY_PROCEDURE (
TIID INTEGER,
TCFLAG CHAR(1))
RETURNS (
FLD1 VARCHAR(250),
FLD2 VARCHAR(250),
FLD3 VARCHAR(250),
NARRTEMPLATE VARCHAR(250))
AS
begin
if (tcflag = 'X') then begin
SELECT xc.fld1, xc.fld2, xc.fld3 FROM xchild xc
WHERE xc.iPID = tiID INTO :fld1, :fld2, :fld3 ;
SELECT n.NarrTemplate FROM NarrMaster n
WHERE n = 'XCHILDTEMPLATE' INTO :narrtemplate ;
SUSPEND;
end
if (TCFLAG = 'Y') then begin
end
end
--- In firebird-support@yahoogroups.com, Namit Nathwani
<namitnathwani@h...> wrote:
Firebird hasn't so many programming features as VFP
What you can do is to get what you need and do the
evaluation/parsing/textmerge at client side
Something like (in VFP)
SQLEXEC(nHandle, [SELECT * FROM MY_PROCEDURE(?iID, ?cFlag)],'XROW')
cRetValue = EVALUATE(xrow.narrtemplate)
If you really need dynamic parsing/concatenation to be done by
Firebird, you need some UDFs for this.
CREATE PROCEDURE MY_PROCEDURE (
TIID INTEGER,
TCFLAG CHAR(1))
RETURNS (
FLD1 VARCHAR(250),
FLD2 VARCHAR(250),
FLD3 VARCHAR(250),
NARRTEMPLATE VARCHAR(250))
AS
begin
if (tcflag = 'X') then begin
SELECT xc.fld1, xc.fld2, xc.fld3 FROM xchild xc
WHERE xc.iPID = tiID INTO :fld1, :fld2, :fld3 ;
SELECT n.NarrTemplate FROM NarrMaster n
WHERE n = 'XCHILDTEMPLATE' INTO :narrtemplate ;
SUSPEND;
end
if (TCFLAG = 'Y') then begin
end
end
--- In firebird-support@yahoogroups.com, Namit Nathwani
<namitnathwani@h...> wrote:
> Hi allReport
>
> I am pretty new to RDBMS's and come from a Visual FoxPro background. I
> would like to write a Stored Procedure that I can use the results in
> Manager in such a manner:record has
>
> SELECT NarrationField FROM MY_STOREDPROCEDURE(:iID, :cFlag)
>
> I will be sending 2 parameters 1st will be the ID to which the
> to belong and 2nd a Flag so that I can do a CASE statement in thestored
> proc. to execute the related SELECT statement. The resulting cursorI will
> then convert to a narration using another table meant to help generatethis
> narrations, something like this pseudo / FoxPro code:
>
> PARAMETERS tiID, tcFlag
>
> lcRetVal
>
> DO CASE
> CASE tcFlag = "X"
> SELECT xc.fld1, xc.fld2, xc.fld3 FROM xchild xc WHERE
> xc.iPID = tiID INTO CURSOR xrow
>
> SELECT n.NarrTemplate FROM NarrMaster n WHERE n =
> "XCHILDTEMPLATE" INTO CURSOR xnarr
>
> now xnarr.NarrTemplate will contain something like
> "'Bill no. ' + xrow.fld1 + ' Bill dt. ' + xrow.fld2 + 'so on'"would
>
> lcRetVal = translated xnarr.NarrTemplate in VFP I
> assign it to a variable and macro substitute it.
>
> CASE tcFlag = "Y"
> ...
> ...
> OTHERWISE
> lcRetVal = "Unknown Flag can't create narrations"
> ENDCASE
>
> RETURN lcRetVal
>
>
> Hoping this is possible or another alternative to get it done.
>
> Please advise.
>
>
>
>
> Regards
> Bhavbhuti
> ___________________________________________
> Softwares for Indian Businesses at:
> http://venussoftop.tripod.com
> namitbn@p...
> ___________________________________________
>
> ----------
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.659 / Virus Database: 423 - Release Date: 15/04/2004
>
>
> [Non-text portions of this message have been removed]