zinon
zinon

Reputation: 4664

MySQL said: #1064 - You have an error in your SQL syntax creating a stored procedure

I'm trying to create a stored procedure using phpmyadmin.

This is my code:

SELECT *
FROM patient_data
WHERE patient_data.patient_id = p_id AND patient_data.date_of_birth = dob

See a screenshot of my window: enter image description here

I get the following error:enter image description here

This is my patient_data table:enter image description here

Do you have any idea what is wrong?

Thank you in advance!

Upvotes: 0

Views: 77

Answers (2)

Nigel Ren
Nigel Ren

Reputation: 57131

It looks as though there is some problem with creating the script from that dialog. When you see the parameters being created, the second one is missing (and therefore an extra , with no field name.

The problem seems to have been cleared by deleting the second parameter and re-adding it.

Upvotes: 1

Floaterz
Floaterz

Reputation: 128

Try adding another parameter:

  • Direction: OUT
  • Name: cl_cursor (Can be any name you want)
  • Type: SYS_REFCURSOR

In the code do the following:

open cl_cursor for
    SELECT * 
    FROM patient_data
    WHERE patient_id = p_id AND
          date_of_birth = dob; 

If the above solution does not work try adding

begin

open cl_cursor for
    SELECT * 
    FROM patient_data
    WHERE patient_id = p_id AND
          date_of_birth = dob; 

end;

Upvotes: 0

Related Questions