Page 1 of 1

How to pass a variable in LIMIT clause in function

Posted: Tue 10 Nov 2020 11:25
by sandip109
Hello,
I am creating a function.
And I have a requirement to fetch some % of the total number of rows fetch of a selectt statement.
So I have the value in a variable.

I have a simple select statement and in that I want to pass this variable in LIMIT clause.

Something like this: How can I use this v_count in a LIMIT clause ?

Create Function (va varchar,va2 varchar)
.....
...
Begin
select count(*) into v_count
from table1;

select *
from table2
limit v_count;
End;

Re: How to pass a variable in LIMIT clause in function

Posted: Tue 10 Nov 2020 14:43
by alexa
We recommend you to refer to dedicated SQL forums on this.