I'm trying to use the following stored procedure.
DELIMITER $$
CREATE DEFINER=`root`@`localhost`
PROCEDURE `DeleteField`( IN _TABLENAME Text, IN _FIELDNAME text)
BEGIN
if exists (select * from information_schema.Columns
where table_name = _TABLENAME and column_name = _FIELDNAME)
then
alter table _TABLENAME drop column _FIELDNAME;
end if;
END
So I do Call('anytable','Anyfield') and I get the Error Error Code:1146Table'Database._tablename'doesn't exist This _tablename should be my parameter, not a string.
Plz some help before I hang myself, I love my life far too much.
Stored procedures introduce a cliff (or disconnect) between coherent functionality, because the domain logic gets split between the application- and the database layer. It's rarely clear where the line is drawn (e.g. which part of a query should go into the application layer and which part into the database layer?).
MySQL Stored Procedure DisadvantagesRestricted for complex business logic − Actually, stored procedure's constructs are not designed for developing complex and flexible business logic. Difficult to debug − It is difficult to debug stored procedures.
BEGIN select "error message '%s' and errorno '%d'"; -- use missed the semicolon ROLLBACK; END; Save this answer.
The quick and simple way to monitor the stored procedures execution is setting up a Trace with SQL Server Profiler. This is probably good for a quick check when a user runs a process in Test and you want to capture what is he/she running.
I expect you will need to create a dynamic SQL query to do this.
An example of how to do this is at:
http://www.java2s.com/Code/SQL/Procedure-Function/Createadynamicstatementinaprocedure.htm
This would be the alter table replacement, though I have tested this.
DECLARE l_sql VARCHAR(4000);
SET l_sql=CONCAT_ws(' ',
'ALTER table ',_TABLENAME,' drop column ',_FIELDNAME);
SET @sql=l_sql;
PREPARE s1 FROM @sql;
EXECUTE s1;
DEALLOCATE PREPARE s1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With