List:General Discussion« Previous MessageNext Message »
From:Jon Date:July 31 2006 6:38am
Subject:Re: Stored procedures
View as plain text  
Thanks both Devanada and Peter, your replies helped me resolve it.

/Jon

On 7/30/06, Peter Brawley <peter.brawley@stripped> wrote:
>
>  *>I'm trying to make stored procedures use parameters for limit and
> tables, I
> >guess this is either me using the wrong datatype or it's not possible.
> I'm
> >having the same issue with seting the table for the query:
> *
> SET @sql = CONCAT( 'select * from some_table limit ', some_limit );
> PREPARE stmt FROM @sql
> etc.
>
> PB
>
> -----
>
>
> Devananda wrote:
>
> Jon wrote:
>
> Hi list
>
> I'm trying to make stored procedures use parameters for limit and tables,
> I
> guess this is either me using the wrong datatype or it's not possible.
> I'm
> having the same issue with seting the table for the query:
>
> CREATE  PROCEDURE sp_test1 (IN some_limit int)
> select * from some_table limit some_limit;
>
> and
> CREATE  PROCEDURE sp_test2 (IN some_table table)
> select * from some_table;
>
>
> Both fail with "ERROR 1064 (42000)".
>
> Can someone please shed some light on this for me? Is this a problem with
> procedures not being able to do this or is it wrong datatypes or something
>
> completely different?
>
> Thanks in advance
> Jon
>
>
> It sounds like what you need is dynamic SQL in your stored procedures.
> Check out http://forge.mysql.com/snippets/view.php?id=13 for some good
> examples, more complex than what you're asking about, but they should shed
> light on what you need to do.
>
>
> Regards,
> Devananda
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.394 / Virus Database: 268.10.5/403 - Release Date: 7/28/2006
>
>
>

Thread
Stored proceduresJon25 Jul
  • Re: Stored proceduresVisolve DB Team25 Jul
    • Re: Stored proceduresJon25 Jul
  • Re: Stored proceduresChris White25 Jul
    • Re: Stored proceduresJon Molin25 Jul
  • Re: Stored proceduresDevananda30 Jul
    • Re: Stored proceduresPeter Brawley30 Jul
      • Re: Stored proceduresJon31 Jul
RE: Stored proceduresDan Burke25 Jul
  • Re: Stored proceduresJon25 Jul
RE: Stored proceduresDan Burke26 Jul