Home Delphi/Query component - assign a long string (800 char) to a sql.text property trim the sql to 326 char only
Reply: 2

Delphi/Query component - assign a long string (800 char) to a sql.text property trim the sql to 326 char only

Wel
1#
Wel Published in 2012-02-11 04:11:40Z

I use Delphi/NexusDB and I build SQL (about 800 char long) at run time then I pass it to the nexusdb query.sql.text property to execute it but I found error of invalid token on execution.

I pass SQL like this

Query.SQL.Text := VarStrSQL; // <<---- string variable holding the SQL

when I traced I found SQL string in the Query.SQL.Text is trimmed to 326 character !! While the string variable that hold the SQL is complete and fine but when I assign that variable to query.sql.text only 326 character passed and of course this result in an error for invalid SQL syntax

Please advise why the SQL string trimmed like that ?

Update: *I tried memo1.lines.text := VarStrSQL and the memo component also display the string trimmed !! is it possible a character in my string cause that !! a bug in Delphi 2010 that cause TStrings to trim my string ?*

Thanks

Arnaud Bouchez
2#
Arnaud Bouchez Reply to 2012-02-11 08:49:33Z

Sounds like a bug in DB provider itself. There is no such limitation in TQuery.

My advice shall be to use small SQL, but bound parameters to set the data.

Instead of

Query.SQL.Text := 'INSERT INTO Store_Information (store_name, Sales, Date)
VALUES ('Los Angeles ... ... ...', 900, '10-Jan-1999')';

code

Query.FieldByName('store').AsString := 'Los Angeles ... ... ...'; // here you should have no limitation
Query.FieldByName('sales').AsInteger := 900;
Query.FIeldByName('Date').AsDAteTime := Now;
Query.SQL.Text := 'INSERT INTO Store_Information (store_name, Sales, Date)
VALUES (:store,:sales,:date)';

And your request will be faster, since the statement could be preparated by the engine, then reused.

Wel
3#
Wel Reply to 2012-02-11 12:28:08Z

I found the problem: It is nxtChar Fields when they are null they have the value #0 and that cause string trimming

however although I check for null like this varisnull() the char fields was able to skip this trap function !!! which makes me go around myself for hours finally I now check them like this

If <nxtChar field> = #0 then <nxtChar field> = '' (or <nxtChar field> = null)
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.56707 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO