MySQL Forums
Forum List  »  Stored Procedures

The second parameter in a Stored procedure does not work
Posted by: Peter He
Date: December 03, 2010 03:59PM

Here is the code to create the schema Tool and the stored procedure tool.get_table_definitions. When you try the SP, the parameter schema_name works but table_name does not. Colum for all the tables in the schema are returned;

create schema tool;
DELIMITER //
CREATE PROCEDURE tool.get_table_definitions (IN schema_name varchar(64), IN table_name varchar(64))
BEGIN
SELECT ORDINAL_POSITION AS `No`,
COLUMN_NAME AS `Column Name`,
COLUMN_TYPE AS `Data Type`,
CASE WHEN IS_NULLABLE='NO' THEN 'NOT NULL' ELSE 'NULL' END AS `Nullable`,
CASE WHEN EXTRA<>'' THEN EXTRA ELSE '' END AS `Column Extra`,
CASE WHEN COLUMN_DEFAULT IS NOT NULL THEN CONCAT('''',COLUMN_DEFAULT,'''') ELSE '' END AS `Default`,
CASE WHEN COLUMN_KEY<>'' THEN COLUMN_KEY ELSE '' END AS `Key`,
COLUMN_COMMENT AS `Comments`
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME=table_name AND TABLE_SCHEMA=schema_name
ORDER BY `No`;
END//

DELIMITER ;

call tool.get_table_definitions ('test','test_table');

Options: ReplyQuote


Subject
Views
Written By
Posted
The second parameter in a Stored procedure does not work
2457
December 03, 2010 03:59PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.