Page 1 of 1

ZQuery.MacroByName()

Posted: 15.10.2009, 13:12
by rodrigosd
In a "very old" version of Zeos we had the property "Macros" and we could use "MacroByName()" ...
There is some way to do that in Zeos 6.6.5 ?
Thanks

Posted: 16.10.2009, 19:06
by mdaems
No idea what the functionality of this property was. That's long before my zeoslib time, I'm afraid.
If you explain the function we could see
- if there's something similar
- if it would be right to re-implement

Of course, if you still have the right version where it existed, that could be very helpful.

Mark

Posted: 16.10.2009, 20:20
by rodrigosd
I'm using the version '50300' as zeos.inc. Now I'm tring to update to the newest one. I know that I could reformulate all the querys to use "query.sql[X] := something", but all the system is implemented using macros and params. An example:

SQL

Code: Select all

 SELECT *
 FROM people
 WHERE age > 30
 %macro
CODE

Code: Select all

if z then 
  query.MacroByName('macro').AsString := 'AND gender = ''M'''
else
  query.MacroByName('macro').AsString := '';
if true the result query will be:

Code: Select all

SELECT *
 FROM people
 WHERE age > 30
 and gender = 'M'
else, just:

Code: Select all

SELECT *
 FROM people
 WHERE age > 30
I think that explains the use of macros.
Rodrigo

Posted: 18.10.2009, 12:42
by mdaems
Thanks. That explains the use of macro's very well.

Now, I have some little problems.
The main one is time. Just take it as a fact I can't spend time building new stuff at the moment. Just merging patches and getting/keeping the current stuff working is enough for me.

The second problem (compared to the original implementation that I don't know) might be the way to implement it in the current design. If you do it : keep it in the components layer. It might be a relatively easy job when you add a FRawSQL field to the TZReadOnly Query component and use it to set the FSQL property using Setter functions for a MacroParameters Array.

Would you think about adding the functionality? It's certainly not the same as using parameters. Parameters usually don't allow changes to the structure of the query. Your macro's would also allow new parts being added to the query.

Mark

Posted: 20.10.2009, 13:06
by rodrigosd
I'll try to add that.

Rodrigo

Posted: 20.10.2009, 22:51
by designshouse
hi

i didnt test it but maybe this may work

query.Sql.Add('SELECT * FROM people');
query.Sql.Add('WHERE age > 30');
query.Sql.Add(':macro ');

if z then
query.ParamByName('macro').AsString := 'AND gender = ''M'''
else
query.ParamByName('macro').AsString := '';

Posted: 24.10.2009, 14:36
by mdaems
designshouse,
This can't work. When substituting the parameter zeoslib will add quotes around the value to be inserted in the string.

Mark

Posted: 28.10.2009, 20:41
by rodrigosd
So...
I already did the Macro's implementation.
Now I have to test it and all the other differences between the new version and the old version of zeos that I was ussing.

When I finish all that, how could I "commit" my implementations?!

Rodrigo

Posted: 01.11.2009, 22:50
by mdaems
Rodrigo,

You can send your changes to zeoslib at gmail dot com.
You're talking about 'other changes' you did. You'll have to explain them too when you want those applied as well.
So please, provide different patches for different changes. Normally the base version I'm working on is Testing branch, but when you provide patches against trunk or even 6.6-Patches that will do as well.
When you become more active and want SVN access I can arrange that, but you'll have to 'prove' your intensions first. Too much people have asked for it and when they got it they didn't use it.

Mark

Mark

Re: ZQuery.MacroByName()

Posted: 21.07.2014, 19:31
by tomazeli
Hi Mark,

I know that is long time ago but I'm wondering if this functionality was implemented later on.
Did Rodrigo committed the actual code?

I'm converting an huge application from Delphi 6 +MySQL 4.01 + ZeosDB 5 with this feature and is heavy used to Delphi 6 + MySQL 5.6 + ZeosDB 6.6.6.

Any information will be very useful.

Thanks