Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2012
    Posts
    3

    Unanswered: Execute a script with mySQL

    Hi the team,

    i would like to execute a mySQL under SQL Developper, but i do not achieve to do it.
    With Oracle, it is quite simple doing:

    DECLARE
    BEGIN
    INSERT ....
    END;

    But it does not work in mySQL.
    I did not find any information about it.

    Could you tell if it is possible to execute a mySQL script?

    Thank you,
    berni.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    yes, it's possible to execute a "script"

    please show exactly what you tried to execute, and the error message you got
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Aug 2012
    Posts
    3
    i tried to insert this example:

    DECLARE
    BEGIN

    INSERT MY_TABLE (field1, field2...) values (value1, value2...);

    END;

    I saw that we cannot do this with a mySQL DB.
    We must pass through a file which contains these commands.

    Is it true?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    okay, could you please explain why you cannot just do the INSERT statement by itself? why do you need the DECLARE and BEGIN/END?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    have a look at MySQL stored procedures. Although that would be overkill fro a simple inster statement
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Aug 2012
    Posts
    3
    Hi guys and thank you for your help.

    r937:
    I would like to insert a lot of INSERT statement, that's why i needed a script.

    healdem and r937:
    contrary to Oracle, it appears that it is not possible to use a script (with DECLARE...BEGIN...END) in mySQL. Except using a file or a procedure.

    Fanally, i did it using a procedure

    Tahk you for your help.

    Regards,
    berni.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •