![]() |
Datenbank: Absolute Database • Zugriff über: SQL
Update Database via SQL
Hello friends,
My problem is that how to update database with SQL? First for example i create items in DB but that just keeps adding them becouse the code is launched from timer. Possible? |
Re: Update Database via SQL
Hm ?
More info please. Show us some code. Update Table TabXXX Set Name='Hoika' Where Id=10 Heiko |
Re: Update Database via SQL
Well this is concept code but it should do the trick...but how should it look for SQL?
Delphi-Quellcode:
if item then begin
for i:=0 to 9 do begin ABSTable1.Open; ABSTable1.Insert; // adds new record into table ABSTable1.Fields.FieldByName('FirstName').AsString:='John'; ABSTable1.Fields.FieldByName('LastName').AsString:='Heyho'; ABSTable1.Fields.FieldByName('Sallary').AsString:='20.200'; ABSTable1.Post; // saves newly created record to the table ABSTable1.Next; end; Item:=false; end; end else begin for i:=0 to 9 do begin ABSTable1.Locate('ID',i,[]); ABSTable1.Edit; // starts updating of current record ABSTable1.Fields.FieldByName('FirstName').AsString:='John'; ABSTable1.Fields.FieldByName('LastName').AsString:='Heyho'; ABSTable1.Fields.FieldByName('Sallary').AsString:='20.200'; ABSTable1.Post; // saves newly created record to the table end; |
Re: Update Database via SQL
|
Re: Update Database via SQL
Exactly but how should this look in SQL with Query.I am not very familiar with SQL..
|
Re: Update Database via SQL
SQL-Code:
But you can also use paramters:
insert into <Tablename> (FirstName, LastName, Sallary) values ( 'John', 'HeyHo', 20100);
SQL-Code:
insert into <Tablename> (FirstName, LastName, Sallary) values ( :firstname, :lastname, :sallary );
Delphi-Quellcode:
ABSQuery1.ParamByName( 'firstname').Value := 'John';
... |
Re: Update Database via SQL
Auu okay thank you.
Can i use update also with autoinc? |
Re: Update Database via SQL
This is an insert and in this case don't set the specific field
|
Re: Update Database via SQL
And updating an existing record looks like this:
SQL-Code:
Parameters can be used here as well.
UPDATE <tablename> SET FirstName = 'John', LastName = 'HeyHo', Sallary = 20100 WHERE <conditions>
|
Re: Update Database via SQL
Thanks again what about if we say table has ID property for example
So that it updates based on EmployeeID Autoinc EmployeeID Firstname 0 John 1 Lisa 2 Kimberly 3 Stephanie Also could Autoinc start from 0? Like in the above example with Absolute Database. Thanks |
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:23 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz