Subject | SQL problem |
---|---|
Author | Duilio Foschi |
Post date | 2002-02-26T00:19:42Z |
during the last 2 months I studied SQL.
I can appreciate its power: you just state the data you want, you don't
need to state how to get the data.
These days I like to go thru old applications and replace the old
navigational code with a few sql lines.
However, the following lines of code were too much for me:
var
i:integer;
v,Part_New:string;
begin
...
with ATable do
while not eof do
begin
i:=FieldByName('singolo').AsInteger;
v:=Part_New+Format('%8.8d',[i]);
Edit;
FieldByName('partita').AsString:=v;
Post;
Next;
end;
...
end;
I can write this:
update atable set partita=:part_new || cast (singolo as char(8) )
but this gives me something like 'foo1', while I need 'foo00000001'
Any help ?
Thank you
Duilio Foschi
I can appreciate its power: you just state the data you want, you don't
need to state how to get the data.
These days I like to go thru old applications and replace the old
navigational code with a few sql lines.
However, the following lines of code were too much for me:
var
i:integer;
v,Part_New:string;
begin
...
with ATable do
while not eof do
begin
i:=FieldByName('singolo').AsInteger;
v:=Part_New+Format('%8.8d',[i]);
Edit;
FieldByName('partita').AsString:=v;
Post;
Next;
end;
...
end;
I can write this:
update atable set partita=:part_new || cast (singolo as char(8) )
but this gives me something like 'foo1', while I need 'foo00000001'
Any help ?
Thank you
Duilio Foschi