0

Here is my code:

 DELIMITER $$
    begin
    declare var a int;
    set a="select biology from app.students where studname="ganesh";
    select concat('the student name is' a);
    end$$

I want to create storeprodure in mysql for java. In the above code i gave anything after begin it shows error. I am not well in stored procedure.

2
  • 1
    put like 'ganesh'"; Commented Dec 30, 2013 at 13:31
  • also a comma on concat('the student name is', a): Commented Dec 30, 2013 at 13:32

2 Answers 2

3

Try this,you had mistake in "ganesh" and also in concat function , missing

DELIMITER $$
        begin
        declare var a int;
        set a="select biology from app.students where studname='ganesh'";
        select concat('the student name is', a);
        end$$
Sign up to request clarification or add additional context in comments.

Comments

1

Just create the stored procedure in the MySql workbench exactly the same as you normally would. It doesn't matter that you are calling it from Java or anywhere else. Your stored procedure looks very messy and makes very little sense though, so I think you need to work on that!

Try just using the query analyzer and build the query not inside a stored procedure first.

Once the statement is written embed it in a stored procedure and then check you can still call it and it works from query analyzer.

Once the stored procedure is written you can just use a PreparedStatement to call it exactly the same as for any other SQL statement.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.