If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Execute a script with mySQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-13-12, 11:04
bernidupont bernidupont is offline
Registered User
 
Join Date: Aug 2012
Posts: 3
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.
Reply With Quote
  #2 (permalink)  
Old 08-13-12, 11:28
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 20,000
yes, it's possible to execute a "script"

please show exactly what you tried to execute, and the error message you got
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-14-12, 04:06
bernidupont bernidupont is offline
Registered User
 
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?
Reply With Quote
  #4 (permalink)  
Old 08-14-12, 06:20
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 20,000
okay, could you please explain why you cannot just do the INSERT statement by itself? why do you need the DECLARE and BEGIN/END?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 08-14-12, 08:29
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 10,508
have a look at MySQL stored procedures. Although that would be overkill fro a simple inster statement
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #6 (permalink)  
Old 08-24-12, 10:48
bernidupont bernidupont is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On