asking MySql Variable change from Zeos6.x and Zeos 7

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
DavideAmelio
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 03.11.2006, 13:57

asking MySql Variable change from Zeos6.x and Zeos 7

Post by DavideAmelio »

Hello with Zeos 6.x i made a function that Result the size ( integer )r of max_allowed_packet and worked, now with zeos 7.x the same function give me back a Bytes result...is there a way to change back or any other walk around?

thnks
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Re: asking MySql Variable change from Zeos6.x and Zeos 7

Post by marsupilami »

Hello, could you show us the source code, you are talking about?
Best regards, Jan
DavideAmelio
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 03.11.2006, 13:57

Re: asking MySql Variable change from Zeos6.x and Zeos 7

Post by DavideAmelio »

Thanks, very simple

Qry := TZReadOnlyQuery.Create(nil);
Qry.Connection := pCon;
with Qry do begin
SQL.Text := 'Show variables like '+QuotedStr(pVarName);
Open;
case Fields[1].DataType of
ftString: Result := Fields[1].Value;
ftBlob: Result := Fields[1].Value;
ftMemo: Result := Fields[1].Value;
ftFmtMemo: Result := Fields[1].Value;
ftFixedChar: Result := Fields[1].Value;
ftWideString : Result := Fields[1].Value;
ftVarBytes : Result := Fields[1].Value;
ftBytes : Result := Fields[1].Value; // <======= in the past was Integer
ftInteger
,ftLargeint
,ftAutoInc
,ftSmallint
,ftFloat
,ftCurrency
,ftDateTime
,ftDate : Result := Fields[1].Value;
else Result := Fields[1].Value;

end;
// Result := Fields[1].Value; // <==== Previous and Worked on Zeos6.x
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 787
Joined: 18.11.2018, 17:37
Location: Hungary

Re: asking MySql Variable change from Zeos6.x and Zeos 7

Post by aehimself »

I don't know what exactly you are trying to achieve, but this is BAD code.
TField.Value is variant type, which means it can contain almost anything. When you assign a variant to an other variable Delphi will try to convert it for you; therefore a Result := Query.Fields[0].Value will always work (until the data in the database can be converted to your desired type, that is).

So in order to be able to help:
- What is the problem with your code? Does it throw an exception? Does it not compile? What errors you receive, what do you expect to happen and what happens instead?
- What do you mean ftBytes were Integer in the past...? I don't think a byte array was handled as integer ever.
- What is the return type of the function? Is Result a String or a Variant? (I hope nothing else...)
- Are you absolutely sure that ALL results can be converted to this type? If you are expecting a number then you are in for some nasty surprises. In this sample output your code will throw a variant conversion exception for sure:
Variables.PNG
- Why are you using .Value? Why not .AsString or .AsInteger?
You do not have the required permissions to view the files attached to this post.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
Post Reply