problems with param for limit clause (in Zquery)

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
railgun3r
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 03.05.2011, 19:20

problems with param for limit clause (in Zquery)

Post 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.
jeremicm
Senior Boarder
Senior Boarder
Posts: 61
Joined: 18.10.2006, 17:07
Contact:

Post 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?
railgun3r
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 03.05.2011, 19:20

Post 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
railgun3r
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 03.05.2011, 19:20

Post 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
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post 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.
You do not have the required permissions to view the files attached to this post.
railgun3r
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 03.05.2011, 19:20

Post 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
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post 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.
You do not have the required permissions to view the files attached to this post.
railgun3r
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 03.05.2011, 19:20

Post 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
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post 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...
railgun3r
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 03.05.2011, 19:20

Post by railgun3r »

thanks! it works now
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
Post Reply