Tablename as Parameter in stored function

Bart Pietercil bart.pietercil at gmail.com
Thu Oct 18 09:02:57 CDT 2007


On 18-okt-07, at 15:54, Martin S. wrote:

> How can I pass a table name into a stored procedure?
>
> This is my function:
>
> CREATE FUNCTION NextAutoID(inValue string)
> RETURNS ULONG
> begin
>    DECLARE max_autoid ULONG ;
>    select MAX(AutoID) INTO max_autoid from  inValue ;
>    RETURN max_autoid + 1 ;
> end;
>
>
> but I get this error:
> error: Table "inValue" not found.

you can't pass variables as "placeholders" for the real thing :(

However, you can wrap the functionality in a case structure.
A bit cumbersome but it works

hth

Bart





More information about the Valentina mailing list