I have a MySQL trigger that I would like to be modified. The only changes are in the trigger body.
Will updating the ACTION_STATEMENT Column in INFORMATION_SCHEMA.TRIGGERS suffice? Is this the right way to update a trigger? Specifically, I am looking for any problems that might arise by doing this.
That won't work.
You need to drop the trigger and recreate it.
http://dev.mysql.com/doc/refman/5.1/en/create-trigger.html
Download dbForge express (is free as in Beer).
Connect with that and edit the trigger.
Download page
http://www.devart.com/dbforge/mysql/studio/download.html
Direct link
https://www.devart.com/dbforge/mysql/studio/dbforgemysql80exp.exe
Don't muck about in the information_schema.
Oh and don't use MySQL workbench 5.2 I've had that one eat my work twice (..gone..) never again.
No I don't have shares, just a happy dbForge user
The ACTION_STATEMENT column contains the statement to be executed when the trigger is invoked. This is the same as the text displayed in the Statement column of the output from SHOW TRIGGERS. Note that this text uses UTF-8 encoding.
MYSQL TRIGGERS SCHEMA TABLE
You're right, if you edit the ACTION_STATEMENT field, you modify the SQL action.
Related
I've noticed some quirks with MySQL Workbench when I try to update table data directly through the MSW table editor. One example is that I have a table with a BIT column. If I change the value from 0 to 1 or from 1 to 0 and then click the Apply button, MSW opens a dialog with the Update SQL to be executed. When I click the OK button to execute the auto-generated SQL, MSW reports that the update SQL statement is invalid.
When I take a look at the generated SQL, the problem is that MySQL wraps the updated BIT value in quotes. So obviously that's a type mismatch. Any idea why I might be experiencing this quirk in MSW? This seems like a pretty straightforward use case for a mature technology?
I'm not that good at mysql but some of my tables has this line where I can edit and delete the row easy without writing any SQL? How can I make that row inside another table?
You can use any GUI editor like phpmyadmin or the tools which P.Salmon mentioned.
Using GUI editor, you can connect to the database using connection string and you can view tables and see the result which can edited and deleted.
I am getting the following message while creating a stored procedure in MySQL Workbench:
"Review the SQL script to be applied on the database"
I have several tables inside the database but the stored procedure I am writing will be
used only for one table. Since, the SQL script of stored procedure is gonna apply on the whole database, I am wondering if it's gonna affect other tables as well? I don't want other tables to get disturbed because of this script.
Please provide your inputs as I am doing this for the first time.
Question #2:
Why do I see "DELIMITER $$" as the first statement while creating a routine before the following statement?
CREATE PROCEDURE `mydatabase`.`myfirstroutine` ()
BEGIN
Thanks
1) MySQL Workbench offers the option to review the generated SQL script before it is sent to the server. This way you can check it for possible problems.
2) The DELIMITER command is usually necessary to switch the current delimiter that ends a single statement (which is by default a semicolon) to something else because the stored procedure code itself needs the semicolon to separate individual commands. However the sp code must be sent as a whole to the server.
A few more details: the DELIMITER keywword is a client keyword only, that means the server doesn't know it and doesn't need it. It's an invention for clients to properly separate sql commands before sending them to the server (you cannot send a list of commands to a server, only individual statements).
In MySQL Workbench however, especially in the object editors where you edit e.g. the sp text, adding the DELIMITER command is essentially nonsense, because there's only this sp code, hence nothing to separate. This might disappear in future version but for now just ignore it.
I'm working with MySQL 5.1.39 and Visual Studio 2008 and connecting both with MySQL Connector Net 6.1.2.
What I'd like to do is once a MySqlConnection object is created, be able to handle the "event raised" when a field in a specific row in a given table is updated.
I mean, when that value in that table has been manually changed or modified from any other application, I'd like to receive a signal in my opened VB.NET application. Until now, I do it from opened VB.NET application checking that table every X seconds, but I wonder if it could be done in a better way.
Many thanks for your attention and time.
Ideally, there is the SIGNAL construct, which you can use to field SQL logic errors, but that is not available until MySQL 5.5. It would be best to upgrade to 5.5, if at all possible.
EDIT: There isn't really a good solution for this before 5.5. The TRIGGER works for getting the updates, but not for sending them outside of the database. Be careful, though, as this doesn't work if you're updating through FOREIGN KEY actions, such as CASCADE or UPDATE, as TRIGGERs are not called for these actions. So watch out for that.
DELIMITER $$
CREATE TRIGGER my_trigger_name AFTER UPDATE ON my_table_name
FOR EACH ROW BEGIN
CALL my_on_update_procedure(NEW.entry_name, NEW.whatever_else)
END $$
DELIMITER ;
What my_on_update_procedure does is up to you. Your solution is probably the best bet for 5.1.39 (I would not recommend locking due to scalability issues), but 5.5 would give you the SIGNAL construct, which is exactly what you want (so upgrade!).
I never worked with that but I think "TRIGGER" could be what you're looking for.
http://dev.mysql.com/doc/refman/5.1/en/create-trigger.html
My first thought was to use a database trigger to trigger some sort of notification: message through email, MOM or anything else. Googling didn't turn much up though. I found one approach based on notification through locks: linky. Could be a sane approach...
Oh, and in that blog post they also talk about MySQL UDFs which lets you execute arbitary code when triggers fire. Apparently there is libs to various languages. There is also a duplicate question here on stackoverflow. Cheers
I am trying to programmatically drop a column in a table inside of an access database and found myself unable to do so! Is it at all possible? it makes me think that i don't have any clear idea of things linq to sql can't do.
Any ideas?
There's nothing in LINQ to SQL that allows you to do that without writing T-SQL, no.
Similarly, you can't do straight updates or deletes without selecting the data you want to alter first and manipulating the objects. You'd have to write stored procedures for those things and add them to your model to be called. See this MSDN page for an overview.
Using DataContext.ExecuteQuery should also work if you don't mind T-SQL in your source code.
You can do it.
Here's an example:
ALTER TABLE Import
Alter column [Tot_Val] DECIMAL(10,2) ;
GO