ZUpdateSQL & ZQuery Problem

The stable tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.
Post Reply
bukem
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 25.03.2013, 10:52

ZUpdateSQL & ZQuery Problem

Post by bukem »

I have ZQuery and connected with ZUpdateSQL.
my SQL for Insert, update, and delete was create by Generate SQL on ZUpdateSQL component,
when inserting statement, the data is save correctly.
but, when I try to delete the data of ZQuery by ZQuery.delete,
when I execute ApplyUpdates, its causes an Error - 'Convertion Error',
I've tried to trace this error, its stuck at TZParamsSQLDA.UpdateString procedure, the result of SQLCode, gave an out of range sqltype

any body found same problem with me, or help me to solve this problem.

thanks before.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Post by marsupilami »

Hello bukem,

it seems that in your use case you don't need to use the ZUpdateSQL. ZUpdateSQL is meant to be used, if you want to do special things like updating read-only data, that is gathered by a non-updateable view or by a join, where you might want to update more than one table. In the normal use case you simply don't connect any UpdateSQL to a ZQuery.
The error given by you means that Firebird cannot convert some data. Maybe it is a good idea to provide sample data and a sample table structure for us to help you?
Best regards,

Jan
bukem
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 25.03.2013, 10:52

Post by bukem »

hello marsupilami, thanks for reply.

before I working on firebird and zeos, usually I using mssql and BDE component, and I always use the same schema to inserting, updating, and deleting data, and its always works.
but this time I had a task to create an application using embedded database then I chose Firebird, and based on most recommendation, I chose zeos too. okay, to make it all clear, I will describe my table structure and coding schema.

lets say, I have one table that its named, user_menu, and has ddl like script below

create table user_menu
( id_user varchar(16),
menu_name varchar(50)
)

In my application, I was add insert and delete record transaction.
To get and change data in that table, I was use ZQuery that connect with ZUpdateSQL. In ZUpdateSQL, I was describe the insert update and delete script by generating SQL.

To inserting data, I just wrote append and post statement.
== ZQuery1.Append;
== ZQuery1.FieldbyName('id_user').AsString := 'Some ID';
== ZQuery1.FieldByName('menu_name').AsString := 'Some Menu Name';
== ZQuery1.Post;

To deleting data, I using Delete statement
== ZQuery1.delete;

To commit, I give these statement
== ZQuery1.Connection.StartTransaction;
== if ZQuery1.UpdatesPending then
== begin
== ZQuery1.ApplyUpdates;
== ZQuery1.CommitUpdates;
== end;
== ZQuery1.Connection.Commit;

when inserting data, all process goes fine.
but, when deleting data, process stopped at line ZQuery1.ApplyUpdates; with error message 'Convertion Error',
I think its raises by zeos, CMIIW

yesterday, I've tried using commit data directly from ZQuery1, without connect to ZUpdateSQL. For inserting and deleting data, all proses was goes fine, but, after the first commit, then I continue to altering data, the variable of UpdatesPending always give False value, that makes no data change was commit.
but, in some case, I still need using ZUpdateSQL to process the data.
so, if there's a solution of ZUpdateSQL problem, I really appreciate it.

thanks.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Post by marsupilami »

Hello bukem,

the convertion error normally is something that is created by Firebird. The first thing, I see is that you did no define a primary key for your table. Did you just forget to copy this part here this or did you really not do it in your database?
Also I have some additional questions: What is the default character set, you specified for your Database? And what is the value of the TZConnection.Codepage property? How are the values for ID_User and menu_name created?
Best regards,

Jan
Post Reply