Subject | Re: [firebird-support] Help with query |
---|---|
Author | Milan Babuskov |
Post date | 2005-04-12T18:41:02Z |
Planles wrote:
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 :)
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
> is it possible to do following table update with a querry ?It is.
> 1.4.05 0Add another field. Create a generator and fill the field with it. You'll have
> 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...
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 FieldAgain, a stored procedure or client program. SP example:
> 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
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