Hi all,
i have been using zeos version 6.1.5 for quite some time, i have been having trouble trying to migrate one of my old applications to use the new version of zeos 6.6.5.
One of the problems, is that i cant do a simple insert in the following way.
Iam using c++builder 6, with postgresql 8.2.13, zeos component 6.6.5, protocol "postgresql-8".
ZQuery1->SQL->Text = "INSERT INTO cars(model) VALUES('A3');";
ZQuery1->ExecSQL();
i get an memory access error.
I can execute the query in this way thow, but iam under the impression this is not correct way to execute i INSERT, UPDATE OR DELETE query.
ZQuery1->Close();
ZQuery1->SQL->Text = "INSERT INTO cars(model) VALUES('A3');";
ZQuery1->Open();
because this way the zquery remains Active, after executing the SQL code.
Hope someone can point me to the right direction.
Thanks in advanced
execSQL with POSTGRESQL
Moderators: gto, EgonHugeist
After my previous experience using queries, I can tell that you need to close, clear, assign new command to SQL property, and then call ExecSQL for anything else than a SELECT command. Because they didn't return record sets to be shown, only the number of affected rows.
When you send a SELECT command, you create a cursor view that allows you to explore or examine a record set, that's why you open a SELECT to keep the recordset alive.
By the way, that works the same with BDE, and I even see same behavior in PowerBuilder or VB. You must expect that C/C++ does the same.
When you send a SELECT command, you create a cursor view that allows you to explore or examine a record set, that's why you open a SELECT to keep the recordset alive.
By the way, that works the same with BDE, and I even see same behavior in PowerBuilder or VB. You must expect that C/C++ does the same.
Thank you for your reply's
>I think you using the wrong command,
>ZQuery1->Close();
>ZQuery1->SQL->Text = "INSERT INTO cars(model) VALUES('A3');";
>ZQuery1->Open(); <-- sohuld be ZQuery1->ExecSQL( );
i know that's why i post this.
>... I can tell that you need to close, >clear, assign new command to SQL property, and then call ExecSQL for >anything else than a SELECT command. Because they didn't return record >sets to be shown, only the number of affected rows.
when using ZQuery1->SQL->Text = "";
it closes the zquery anyway, the problem is when executing the ExecSQL(), memory access error appears.
thank you all
>I think you using the wrong command,
>ZQuery1->Close();
>ZQuery1->SQL->Text = "INSERT INTO cars(model) VALUES('A3');";
>ZQuery1->Open(); <-- sohuld be ZQuery1->ExecSQL( );
i know that's why i post this.
>... I can tell that you need to close, >clear, assign new command to SQL property, and then call ExecSQL for >anything else than a SELECT command. Because they didn't return record >sets to be shown, only the number of affected rows.
when using ZQuery1->SQL->Text = "";
it closes the zquery anyway, the problem is when executing the ExecSQL(), memory access error appears.
thank you all