Subject Re: Duplication records
Author Leeway
svein,
I tried this but got errors in the prepare.
'Token unknown EMP'
What is wrong with this statement ?
The where statement on its own works.

QTIB_Pim.SQL.Clear;
QTIB_Pim.SQL.Add('insert into PIM EMP,DATE_START,DATE_END,PIMAGE');
QTIB_Pim.SQL.Add('select EMP,DATE_START + :DaysToMove,DATE_END
+ :DaysToMove,PIMAGE from PIM');
QTIB_Pim.SQL.Add('where DATE_START >= ' + Date_Start_String + ' and
DATE_START <= ' + Date_End_String);
QTIB_Pim.SQL.Add('parambyname(:daystomove).AsInteger := 2;');
QTIB_Pim.Prepare;
QTIB_Pim.Execute;

Thanks aforehand
Lee

--- In ib-support@y..., Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
> Hi Lee,
>
> INSERT INTO PIM (listoffieldstoinsert)
> SELECT somefields, DATE_START + :DaysToMove, morefields
> FROM PIM
> WHERE keyfield = :SomeValue
> Prepare the statement, set the parameters
> (ParamByName(:DaysToMove).AsInteger:=something;) and execute the
statement.
>
> Simple and easy,
> Set
>
> >In a database I got appointments with a timestamp field.
> >How can I duplicate a specific appointment to another date ?
> >So suppose I got a appointment on 2001/01/01 and I want to
duplicate
> >this appointment to 2001/02/01 how do I write a sql command for
this ?
> >The appointment fields are the same, only the timestamp field is
> >different.
> >I know how to move :
> >('update PIM set DATE_START = DATE_START + ' + IntTostr
(Days_To_Move)
> >+ ' where DATE_START = ' + Date_Start_String);
> >But what is the syntax for duplicating a record?