Page 1 of 1

problems with param for limit clause (in Zquery)

Posted: 05.05.2011, 09:16
by railgun3r
Does anyone know how use param for limit clause in Zquery?
In example:
SELECT *
FROM production
LIMIT :l
Its not works. And I dont understand why.

Posted: 05.05.2011, 10:19
by jeremicm

Code: Select all

zquery.SQL.Add('SELECT * ')
zquery.SQL.Add('FROM production ');
zquery.SQL.Add('LIMIT :param1');
zquery.ParamByName('param1').Value := 100;
try this?

Posted: 05.05.2011, 11:06
by railgun3r
I can't!!!
cuz I use stored Zquery table with lookup columns
of course I can always clean Zquery.SQL and then refill it. but its not good for me

Posted: 05.05.2011, 11:09
by railgun3r
may be I can make paging using another method? does somebody knows how make paging in DBgrid without limit?
but amount of columns in paging - variable param

Posted: 05.05.2011, 14:53
by trupka
railgun3r,
This works fine for me:
- Mysql 5.0
- Delphi 2007
- zeos 6.6.6-stable
Code sample attached in post, maybe this will help you.

Posted: 05.05.2011, 19:07
by railgun3r
wtf!!! same shit!
dont works =) really. dont understand why.
I cant change Zquery in active mode.

I can use param everywhere: In COALESCE operator, in WHERE clause... but why it not works in LIMIT?

this shows when i try to change Zquery to active mode
http://img859.imageshack.us/img859/2323/32973743.jpg

but! I use Delphi 7.0 and mysql 5.1 CE

Posted: 05.05.2011, 19:48
by trupka
Interesting...
I don't think Delphi 7 makes the difference... Currently I don't have it but lets try something else (see attach).
You should see generated sql and then you can test it inside mysql console and see is it realy (not) working.
If you wish, you can post generated SQL so I can test it inside MySQL 5.0.

Posted: 05.05.2011, 21:39
by railgun3r
YES!
I resolve trouble.
LIMIT just was NULL on form show
thank you very very much )

but! anyway! parser dont give any chance to activate Zquery if "LIMIT :param" inside SQL script. very strange

Posted: 06.05.2011, 08:17
by trupka
railgun3r wrote: but! anyway! parser dont give any chance to activate Zquery if "LIMIT :param" inside SQL script. very strange
Did you try to set additional properties for param in design time:
Object inspector -> select ZQuery ->Open params collection
Select param in param collection editor and in Object inspector set something like:
DataType := ftInteger
ParamType := ptInput
Value := 10 // or whatever your limit is
Value.type := integer
NumericScale, Precision and size shoud be 0

After that, close and reopen zquery in design time...

Posted: 10.05.2011, 13:27
by railgun3r
thanks! it works now

Posted: 19.05.2011, 22:23
by mdaems
When debugging this kind of trouble a TZSQLMonitor is very usefull. I guess you 'll seen quotes appear when you're not specifying your parameter is numeric.

Mark