Houston we have a problem!
Hi Folks, I'm trying to improve the performance of my app. What I'm trying to do is to prepare the sql statement just once and, after that, just change the parameters to execute. Without preparing another time.
For this I wrote this piece of code. It runs!
// Show Items' Note
If not DataModule_SmCube.SQLQuery_Notes.Prepared Then
Begin
// Se o campo note possuir até 8190 bytes, retorna como Varchar, caso contrário como Blob - Gambiarra Carlos H. Cantú
DataModule_SmCube.SQLQuery_Notes.ReadOnly:=True;
DataModule_SmCube.SQLQuery_Notes.SQL.Clear;
DataModule_SmCube.SQLQuery_Notes.SQL.Add('SELECT sourceItemID, iif(octet_length(items.note) <= 8190, cast(items.note as varchar(8190)),null) as blob_txt, iif(octet_length(items.note) > 8190, items.note, null) as blob_blob FROM items WHERE item = :item;');
DataModule_SmCube.SQLQuery_Notes.Prepare;
End;
DataModule_SmCube.SQLQuery_Notes.Close;
DataModule_SmCube.SQLQuery_Notes.Params.ParamByName('item').AsString := Main.GridView_Notes.Columns.Items[0].Field.Text;
DataModule_SmCube.SQLQuery_Notes.Open;
But When I trace the server activity (with FB Tracemanager) I see that everytime I OPEN the query it prepare it automatically.
I'm I missing something? What I have to do to change this behavior? Is it a component problem? I'm using SQLdb native lazarus component 1.6 + Free pascal 3.0
P.S. If I do not call Close and Open procedures the query is not updated...
Aucun commentaire:
Enregistrer un commentaire