Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 13 of 13 total
Thread Problem using onnewrecord
Wed, Aug 14 2013 12:40 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Juan,

<< Tim I try to use the comand copy table with the copydata parameter but i
receive error: too many parameters >>

The CopyData parameter was added in 4.35, so if you're using an older
version, that's why the compiler is reporting an error.

Tim Young
Elevate Software
www.elevatesoft.com
Sat, Aug 17 2013 6:55 PMPermanent Link

jccarta

I solve the problem with this code:

        m:=1  ;
                    while (Not Tablatemp.Eof) do
                    Begin
                          tablatemp.edit;
                          tablatemp.FieldByName(xcampo).Clear;
                          tablatemp.post;
                          m:=m+1;

                     End;
                     End;
                     tablatemp.SaveToStream(fx);
                     TempTable.LOADFROMstream(Fx);

But i have two more question :

Theres something sentence or command to optimize speed for this part of the code

while (Not Tablatemp.Eof) do
                    Begin
                          tablatemp.edit;
                          tablatemp.FieldByName(xcampo).Clear;
                          tablatemp.post;
                          m:=m+1;

                     End;

maybe select script or command. to clear the autoinc field.

The second question is : i create the memory table with this set of commands without problems

tabla := temptable.TableName;
                     localquery.sql.clear  ;
                     localquery.sql.add('Select * into "\memory\tmp_'+tabla+'" from '+tabla) ;
                     localquery.execsql;
                     localquery.close;
                     tablatemp.DatabaseName:='memory';

theres any simple way to use this sentence:

localquery.sql.add('Select * into "\memory\tmp_'+tabla+'" from '+tabla) ; but that rsulting table is empty?

Roy Lambert wrote:

jccarta

>localquery.sql.clear ;
>
> tabla := temptable.TableName;
> TablaTemp:=TDBISAMTable.Create(nil);
> localquery.sql.add('Select * into memory\tmp_'+tabla+' from '+tabla) ;
> localquery.Active:=True;
> tablatemp.DatabaseName:='memory';
> TABLATEMP.Name:='tmp_'+TABLA;
> tablatemp.LOADFROMstream(FS);

I'm not 100% sure what's going on here.

1. I'd use ExecSQL rather than Active := True (personal preference as much as anything)
2. I think you'll probably need to close the query (I'm not sure if the table is still being kept exclusive until you do)
3. I don't know if you have to open the table before calling LoadFromStream - I've never used it.
4. I'm not sure where the memory table is going to reside - on the server or the local client (how have you set up the sessions for localquery and tablatemp?)

Roy Lambert [Team Elevate]
Sun, Aug 18 2013 3:19 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

jccarta

>I solve the problem with this code:
>
> m:=1 ;
> while (Not Tablatemp.Eof) do
> Begin
> tablatemp.edit;
> tablatemp.FieldByName(xcampo).Clear;
> tablatemp.post;
> m:=m+1;
>
> End;
> End;
> tablatemp.SaveToStream(fx);
> TempTable.LOADFROMstream(Fx);
>
>But i have two more question :
>
>Theres something sentence or command to optimize speed for this part of the code
>
> while (Not Tablatemp.Eof) do
> Begin
> tablatemp.edit;
> tablatemp.FieldByName(xcampo).Clear;
> tablatemp.post;
> m:=m+1;
>
> End;

I've never tried it on an Autoinc field but try the SQL UPDATE eh

UPDATE whateveryourtablenameis SET xcampo = NULL

I don't know what the m := m+1 is for but you can simple assign Tablatemp.RecordCount + 1 to it

>maybe select script or command. to clear the autoinc field.
>
>The second question is : i create the memory table with this set of commands without problems
>
> tabla := temptable.TableName;
> localquery.sql.clear ;
> localquery.sql.add('Select * into "\memory\tmp_'+tabla+'" from '+tabla) ;
> localquery.execsql;
> localquery.close;
> tablatemp.DatabaseName:='memory';
>
>theres any simple way to use this sentence:
>
>localquery.sql.add('Select * into "\memory\tmp_'+tabla+'" from '+tabla) ; but that rsulting table is empty?

My version of DBISAM doesn't have any qualifiers to sat don't copy the data, later ones may have, so I'd use a script.

In DBISAM a script is a series of SQL statements separated by a semicolon so something like

localquery.sql.add(''Select * into "\memory\tmp_'+tabla+'" from '+tabla+';empty table memory\tmp_'+tabla);

should work

Roy Lambert [Team Elevate]
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image