Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9107285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:32:06+00:00 2026-06-17T02:32:06+00:00

I am currently looking a way to have my database under version control. To

  • 0

I am currently looking a way to have my database under version control. To achieve so, I wanted to have deterministic procedures that can only be run only once (with corresponding undo).

I have a problem building my first script which is riddled with small bugs.

Here are the 3 main parts :

Condition to execute query (if field doesn’t exists)

SELECT *
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'my_database'
  AND TABLE_NAME = 'my_table'
  AND COLUMN_NAME = 'full_name'

The table alteration:

ALTER TABLE
  my_table
  ADD full_name VARCHAR(255) NOT NULL;

And finally the data migration

UPDATE candidat dest JOIN candidat src ON dest.id = src.id
      SET dest.full_name = CONCAT(src.first_name, ' ', IF(src.middle_name='', '', CONCAT(src.middle_name, ' ')), src.last_name);

I’am trying to make this work in this form:

DELIMITER $$
DROP PROCEDURE IF EXISTS migration_001;

CREATE PROCEDURE migration_001()

BEGIN
  IF NOT EXISTS (
    SELECT *
    FROM information_schema.COLUMNS
    WHERE TABLE_SCHEMA = 'my_database'
      AND TABLE_NAME = 'my_table'
      AND COLUMN_NAME = 'full_name') 
   THEN

     ALTER TABLE
      my_table
      ADD full_name VARCHAR(255) NOT NULL;

    UPDATE candidat dest JOIN candidat src ON dest.id = src.id
          SET dest.full_name = CONCAT(src.first_name, ' ', IF(src.middle_name='', '', CONCAT(src.middle_name, ' ')), src.last_name);
  END IF
END;
$$

Current error I am getting:

1064 : ...  right syntax to use near 'CREATE PROCEDURE migration_001() BEGIN IF NOT EXISTS ( SELECT * ' at line 3

Can anyone point me in the right direction for solving this?

BTW I am using 5.5.16-log - MySQL Community Server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:32:07+00:00Added an answer on June 17, 2026 at 2:32 am

    Change the order of

    DELIMITER $$
    

    and

    DROP PROCEDURE IF EXISTS migration_001;
    

    Currently you are using the wrong delimiter to drop the procedure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a way to control which monitors are currently being used via
I'm currently looking for a way to search a big database (500MB - 10GB
We have a database that is currently 1.5TB in size and grows by a
Currently I'm looking for a way to either extend a standard <asp:TextBox /> control
I currently have a page that generates a table from an SQL database using
I am looking for a way that would allow me to have a column
Hey all, I am looking for a way to query my database table only
I am currently looking for a way to remove fullstops from a string in
I'm currently looking for a way to provide the user with being able to
I'm currently looking for a way to launch the default browser application on Android

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.