Subject | Re: [firebird-support] Date compare in firebird |
---|---|
Author | Tetram Corp |
Post date | 2007-08-16T16:12:19Z |
i don't know if it will be faster but did you try to replace your if (at
least, the comparision between a date and a string) with a "case" in the
select?
declare variable calculation integer;
for select .... case when itmdate between ... and ... then 1 when
itmdate <= ... then 2 end
into ...., :calculation
do
if calculation = 1 then
if calculation = 2 then
end
By the way, you don't need to use " unless your fields names are case
sensitive
and in this case, you can miss them for return parameters and variables
Thierry
redtneen a écrit :
least, the comparision between a date and a string) with a "case" in the
select?
declare variable calculation integer;
for select .... case when itmdate between ... and ... then 1 when
itmdate <= ... then 2 end
into ...., :calculation
do
if calculation = 1 then
if calculation = 2 then
end
By the way, you don't need to use " unless your fields names are case
sensitive
and in this case, you can miss them for return parameters and variables
Thierry
redtneen a écrit :
> hi
> i made this statement
>
> execute block
> returns (
> "Account" integer,
> "Debit" numeric(18,4),
> "Credit" numeric(18,4),
> "PriorBalance" numeric(18,4),
> "Balance" numeric(18,4)
> )
> as
> declare variable "aAcc" integer;
> declare variable "ItmSite" integer;
> declare variable "ItmDate" date;
> declare variable "aDebit" numeric(18,4);
> declare variable "aCredit" numeric(18,4);
>
> begin
>
> for
> select "ItmSite", "ItmDate", "ItmAccount", "ItmLocalDebit",
> "ItmLocalCredit"
> from "VouItems"
> where ("ItmAccount"=11)
>
> into :"ItmSite", :"ItmDate", :"aAcc", :"aDebit", :"aCredit"
> do
> begin
> if ( ("ItmDate" between '05/01/2006' and '06/30/2006') or
> ("ItmDate" between '08/01/2006' and '08/31/2006')) then
> begin
> --some calculations
> end
> if ( ("ItmDate"<='04/30/2006')) then
> begin
> --some calculations
> end
> end
>
> end
>
> i take about 8 seconds to execute about 800000 records
>
> when i removed just if statement the time decrease to about 4 seconds
>
> is there any way to speed up this code ????
>
> notice: this code is made in run time so i don't know how many dates
> i would comapre
>
> my regards to u
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>