Table

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
secs
Posts: 4
Joined: Sat 24 Mar 2012 01:42

Table

Post by secs » Sun 25 Mar 2012 06:54

Guys I have a Delphi 7 program and I use a Mytable together with Myconnection. Now the database is some 300,000 records and rising some 8000 a day.

So does the Table component load the complete table when its active? All I do is add a record every 10 seconds to the table so if it is loading the complete table, can I do this some other way as the database is remote and takes a bit to fire up.

Peter

AndreyZ

Post by AndreyZ » Mon 26 Mar 2012 08:39

Hello,

The TMyTable component stores all records that you add to it in the memory (it allows working with these records). To avoid this, you can directly execute INSERT SQL statements using the TMyQuery component. Here is an example:

Code: Select all

MyQuery.SQL.Text := 'INSERT INTO DEPT(DEPTNO, DNAME, LOC) VALUES(1, ''TESTNAME'', ''TESTLOC'')';
MyQuery.Execute;
using parameters:

Code: Select all

MyQuery.SQL.Text := 'INSERT INTO DEPT(DEPTNO, DNAME, LOC) VALUES(:deptno, :dname, :loc)';
MyQuery.ParamByName('deptno').AsInteger := 1;
MyQuery.ParamByName('dname').AsString := 'TESTNAME';
MyQuery.ParamByName('loc').AsString := 'TESTLOC';
MyQuery.Execute;

secs
Posts: 4
Joined: Sat 24 Mar 2012 01:42

Post by secs » Wed 28 Mar 2012 01:55

Thanks heaps. I will edit the program and give it a go.
Peter

AndreyZ

Post by AndreyZ » Wed 28 Mar 2012 12:25

If any other questions come up, please contact us.

secs
Posts: 4
Joined: Sat 24 Mar 2012 01:42

Re: Table

Post by secs » Sat 28 Apr 2012 01:39

I finally have found enough time to sit down and attack the problem. I guess this may really be a SQL statement problem and I am off searching google but:

I have 2 fields in the database that are an interger filed that auto incroments simply used as an ID and another field thats a time stamp

I am preaty sure I have to include these fields in the statement t get the correct number of fields but what do I do as a value? I seem to remember I can use NIL or NUll or something...

Peter

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Table

Post by AlexP » Sat 28 Apr 2012 12:47

hello,

If there are autoincrement fields in the table, or there are fields that have a default value, than such fields do not need to be specified in the fields list of the INSERT command, i.e. for the table

Code: Select all

CREATE TABLE dept(
  DEPTNO INT(11) NOT NULL AUTO_INCREMENT,
  DNAME VARCHAR(14) DEFAULT NULL,
  LOC VARCHAR(13) DEFAULT NULL
)
it is enough to call the following operator INSERT

Code: Select all

MyQuery.SQL.Text := 'INSERT INTO DEPT(DNAME, LOC) VALUES( ''TESTNAME'', ''TESTLOC'')';
the DEPTNO field will be filled in automatically

secs
Posts: 4
Joined: Sat 24 Mar 2012 01:42

Re: Table

Post by secs » Sat 28 Apr 2012 17:47

Thanks for that. I have it up and running. Will check the database to make sure its adding info but no errors etc so lets see.

Pete

Post Reply