Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CREATE PROCEDURE `CalendarMessage_GetBydateUC`(
_date varchar(255),
_usercode varchar(255),
_title varchar(255)
)
BEGIN
select * from CONCAT(_usercode, "_Timeline") where dateCreated=_date and userTo = _usercode and operation = _title;
END;
Posted
Updated 13-Mar-14 22:31pm
v3

1 solution

SQL
DECLARE query1 TEXT;
SET query1 =  CONCAT('select * from ', _usercode, '_Timeline','where dateCreated=_date and userTo = _usercode and operation = _title;')
SET @Sql = query1;
PREPARE STMT FROM @Sql;
EXECUTE STMT;
DEALLOCATE PREPARE STMT;
 
Share this answer
 
Comments
[no name] 14-Mar-14 1:35am    
CREATE PROCEDURE `CalendarMessage_GetBydateUC`(
_date varchar(255),
_usercode varchar(255),
_title varchar(255)
)
BEGIN
DECLARE query1 TEXT;
SET query1 = CONCAT('select * from ', _usercode, '_Timeline','where dateCreated=_date and userTo = _usercode and operation = _title;')
SET @Sql = query1;
PREPARE STMT FROM @Sql;
EXECUTE STMT;
DEALLOCATE PREPARE STMT;
END;



I am getting ERROR !!!!

You have an error in your SQL suntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'SET @Sql=query1;
PREPARE STMT FROM @Sql;
EXEDUTE STMT;
D' at line 9

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900