Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on Stored Procedure Usage #291

Closed
zachgersh opened this issue Nov 19, 2014 · 1 comment
Closed

Question on Stored Procedure Usage #291

zachgersh opened this issue Nov 19, 2014 · 1 comment
Labels

Comments

@zachgersh
Copy link

Was conditionally trying to add a column to a table with something along the lines of this:

DROP PROCEDURE IF EXISTS foo;
CREATE PROCEDURE foo() BEGIN
    DECLARE CONTINUE HANDLER FOR 1060 BEGIN END;
    ALTER TABLE `tableName` ADD `columnName` int(10) NULL AFTER `otherColumn`;
END;
CALL foo();
DROP PROCEDURE foo;

I have read that go-sql-driver does not support some forms of stored procedures but I thought the above was completely acceptable (believe this only returns one value).

@arnehormann
Copy link
Member

The driver does not support creating any kind of stored procedure.
You can try to declare it externally, maybe just using CALL is possible.
As a rule of thumb, queries containing semicolons won't work (except for strings or comments).
Have a look at the comments in #66. Maybe adding clientMultiStatements works for you.

Btw, why the stored procedure and not just ALTER?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants