| | |
Passing Variable Values as a parameter Name in MySQL
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2007
Posts: 24
Reputation:
Solved Threads: 0
Hello All,
I have been trying to pass variable values as a parameter name in MySQL Stored Procedure Insert Statement when i directly pass the parameter name it works fine, but when i asign the paramter name from a variable value it is passing those values as a value not as a parameter.
DELIMITER $$
DROP PROCEDURE IF EXISTS `test`.`Insert` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `Insert`(IN param1 VARCHAR(50), IN param2 VARCHAR(50))
BEGIN
declare @var1 CHAR(6);
set @var1:=concat('param',2);
INSERT INTO message(Name, Message) VALUES(param1,@var1);
END $$
DELIMITER ;
the above stamenet takes param2 which is coming from var1 as a value to the param2, and i want it as a param2 to be passed.
any idea?
Khaled
I have been trying to pass variable values as a parameter name in MySQL Stored Procedure Insert Statement when i directly pass the parameter name it works fine, but when i asign the paramter name from a variable value it is passing those values as a value not as a parameter.
DELIMITER $$
DROP PROCEDURE IF EXISTS `test`.`Insert` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `Insert`(IN param1 VARCHAR(50), IN param2 VARCHAR(50))
BEGIN
declare @var1 CHAR(6);
set @var1:=concat('param',2);
INSERT INTO message(Name, Message) VALUES(param1,@var1);
END $$
DELIMITER ;
the above stamenet takes param2 which is coming from var1 as a value to the param2, and i want it as a param2 to be passed.
any idea?
Khaled
![]() |
Similar Threads
- Parameter error for executeNonQuery() (VB.NET)
- variable arguments in C (C)
- Passing formname as variable (Visual Basic 4 / 5 / 6)
- Selecting MYSQL into fields (HTML and CSS)
- Return values from a method by not using return (Java)
- Passing variables to and from PHP (JavaScript / DHTML / AJAX)
- Passing Variables/Parameters - By Ref/Value? (Computer Science)
- Array Values not found in Methods (Java)
- Variable Validation & MYSQL (PHP)
Other Threads in the MySQL Forum
- Previous Thread: how do i import data from a csv file to my mysql database
- Next Thread: MySql installing problem
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





