Results 1 to 1 of 1

Thread: how set result of prepare stmt (MYSQL)

  1. #1
    Join Date
    Oct 2008
    Posts
    40
    Thanks
    3
    Thanked 1 Time in 1 Post

    Smile how set result of prepare stmt (MYSQL)

    hello everyone,

    MYSQL query ............

    how to set prepare stmt result in variable

    i have written prepare stmt in store procedure and i want to set result of prepare stmt in variable

    Code:
    CREATE PROCEDURE `sp_countrows`(in_table_name varchar(30))
    READS SQL DATA
    BEGIN
    SET @s = CONCAT('SELECT sum(QuotaUsage) AS "', in_table_name, '(QTY)" FROM ', in_table_name);
    PREPARE stmt FROM @s;
    EXECUTE stmt;
    END
    i am passing table name as a parameter to procedure because the tables are generated dynamically after every month (that kind of script is written on linux OS). so the table name is not fix.
    Last edited by pankaj.ghadge; 11-26-2008 at 11:46 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •