Page 1 of 2

TZQuery opens a temporary table, all fields are read-only?

Posted: 16.12.2021, 11:34
by zhuyl
hello.
I use ZQuery to create a temporary table, and then open it, the fields are all read-only.
The database is mssql, zeos is 8.0

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 16.12.2021, 15:04
by marsupilami
Hello,

yes - that might happen. I seem to rememeber something like this. The problem seems to be that we cannot get metadata for temporary tables - or at least we don't know how to get metadata for temporary tables.

Best regards,

Jan

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 17.12.2021, 05:28
by zhuyl
hello
Is there a way to solve this problem? Temporary tables are often used to read and write data.
Metadata can be obtained from tempdb. Before exec sp_columns, use tempdb to get no metadata.

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 18.12.2021, 14:20
by MJFShark
[Redacted thing I posted when I thought this was for MySQL and not SQLServer! Apologies!]

-Mark

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 18.12.2021, 14:39
by zhuyl
The database I use is MS SQL Server, and the temporary table created is in the database tempdb, from which the metadata of the table can be obtained.

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 18.12.2021, 18:57
by aehimself
I have zero experience with temporary tables but I have a MSSQL server at home to test on.
If you can provide the queries to execute I can try to take a look at the issue.

P.s.: I'm using DBLib to connect, not ODBC or ADO.

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 19.12.2021, 03:23
by zhuyl
hello
I made a test example, you can test it, the database is ms sql server.

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 19.12.2021, 08:19
by aehimself
...and where can I find it, exactly? :)

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 20.12.2021, 12:59
by zhuyl
hello
I forgot to upload, I am uploading now.

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 27.12.2021, 09:04
by zhuyl
Hello
Can the problem be solved?

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 27.12.2021, 22:59
by marsupilami
Hello zhuyl,

I introduced some changes in Zeos 8.0 to allow writing top temporary tables. Please note that currently autoinc fields are not supported by the code. I don't plan to backport these changes to Zeos 7.2. So please upgrade to Zoes 8.0.

Best regards,

Jan

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 29.12.2021, 11:46
by zhuyl
Thanks

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 29.12.2021, 13:40
by aehimself
Merry Christmas to everyone!

@ zhuyl,
I'm sorry; I promised myself that I'll spend every free minute of my vacation time with my daughter, therefore I had zero time to look into the issue deeply enough. I see Jan jumped on the topic too, so no worries.

@ Jan,
Taking the example from here, with your modifications included the fields are still read only.

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 29.12.2021, 18:25
by miab3
Hi aehimself, All,

Merry Christmas to everyone!

1. It works for me (in conjunction with TZUpdateSQL).
I am enclosing an example:
22a.zip
2. What do you think about:
viewtopic.php?f=50&p=185826#p185826

Michał

Re: TZQuery opens a temporary table, all fields are read-only?

Posted: 30.12.2021, 05:53
by zhuyl
Merry Christmas to everyone!

test has the following problems:
1. There is a problem with the SQL statement without a table, such as ‘select getdate()’. Debugging to unit ZSybaseAnalyser.pas: TZSybaseStatementAnalyser.DefineSelectSchemaFromQuery error.
2. Using temporary tables under SQL 2000 will cause errors. Debugging to the unit ZDbcDbLibMetadata.pas: exec tempdb.sys.sp_columns has an error, can you change it to exec tempdb.dbo.sp_columns to be compatible with SQL2000?
3. When the data has non-English characters (such as Chinese), it will be wrong to save to the temporary table.

In addition, I found a problem that caused garbled characters, ZQuery1.FieldByName('CName').AsString:='程序abcd员', when garbled characters appeared when posting, debug to unit ZEncoding.pas: ZDetectUTF8Encoding function: if (EndPtr-Source > SizeOf(PCardinal)) and (PCardinal(Source)^ and $80808080 = 0) //Check quad block ASCII again
then inc(Source, SizeOf(PCardinal)) //SizeOf(PCardinal) here should be changed to: SizeOf(Cardinal)
else Inc(Source);