Subject RE: [firebird-support] Help with query
Author Planles
Thanks for the idea, Milan.

Regards,
Primoz

> -----Original Message-----
> From: Milan Babuskov [mailto:milanb@...]
> Sent: Tuesday, April 12, 2005 8:41 PM
> To: firebird-support@yahoogroups.com
> Subject: Re: [firebird-support] Help with query
>
>
>
> Planles wrote:
> > is it possible to do following table update with a querry ?
>
> It is.
>
> > 1.4.05 0
> > 1.4.05 0
> >
> > update to:
> >
> > 1.4.05 8
> > 1.4.05 0
> >
> > Basicaly there could be one or more records for a date, and I
> want to update
> > Field to one specific value (in upper example to 8), but only
> one record of
> > each day. It does not matter, if it is the first one or second one...
>
> Add another field. Create a generator and fill the field with it.
> You'll have
> distinct values for that column, so you can issue the update
> statement. You
> could do it from your client program, or inside some stored
> procedure. You get
> the idea, I leave the rest to you for homework :)
>
> > How is it possible to insert missing days in the following table:
>
> It is. :)
>
> > Date Field
> > 1.4.05 3424
> > 3.4.05 3565
> > 4.4.05 6235
> > 7.4.05 3563
> > 9.4.05 9096
> >
> > and I want to get
> > 1.4.05 3424
> > 2.4.05 0
> > 3.4.05 3565
> > 4.4.05 6235
> > 5.4.05 0
> > 6.4.05 0
> > 7.4.05 3563
> > 8.4.05 0
> > 9.4.05 9096
>
> Again, a stored procedure or client program. SP example:
>
> Declare variable dt date;
> Declare variable dt_from date;
> Declare variable dt_to date;
>
> dt = dt_from;
> while (dt <= dt_to) do
> begin
> if (not exists (select 1 from table1 where date = :dt)) then
> insert into table1 values (:dt, 0);
> dt = dt + 1;
> end
>
> Note that it is not optimal, but will do the job.
>
> --
> Milan Babuskov
> http://fbexport.sourceforge.net
> http://www.flamerobin.org
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>