On Mon, 22 Oct 2012 16:44:12 -0400, Guillaume Saumure
<gsaumur...@videotron.ca> wrote:

>. Anyway Something I can 
>do with
>PureBasic is :
>
>Procedure.b TruncateDatabaseTable(DataBaseID.l, TableName.s)
>
>   If DatabaseUpdate(DatabaseID, "TRUNCATE TABLE " + TableName)
>     Protected Success.b = #True
>   Else
>     If DatabaseUpdate(DatabaseID, "DELETE * FROM " + TableName)
>       Success = #True
>     Else
>       If DatabaseUpdate(DatabaseID, "DELETE FROM " + TableName)
>         Success = #True
>       Else
>         Success = #False
>       EndIf
>     EndIf
>   EndIf
>
>   ProcedureReturn Success
>EndProcedure

That would work, but you don't need the "DELETE * FROM " + TableName ,
it's not valid SQL syntax, although some platforms might accept it.

SQLite version 3.7.15 2012-10-07 05:34:39
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table x (i integer primary key, t text);
sqlite> insert into x (i,t) values (1,'texts here');
sqlite> delete * from x;
Error: near "*": syntax error
sqlite>

Also, take care with foreign key relationships with ON DELETE CASCADE
clauses. If TRUNCATE bypasses them, you may end up with destroyed
referential integrity. Faster is not always better.

-- 
Groet, Cordialement, Pozdrawiam, Regards,

Kees Nuyt

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to