Use of ON COMPLETION PRESERVE Clause in Event Creation

Arjun Thakur
Updated on 22-Jun-2020 12:37:00

3K+ Views

As we know that an event is automatically dropped when it is expired and we would not be able to see it from SHOW EVENTS statement. To change such kind of behavior we can use ON COMPLETION PRESERVE while creating the event. It can be understood from the following example −Examplemysql> Create table event_messages(ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, MESSAGE VARCHAR(255) NOT NULL, Generated_at DATETIME NOT NULL); Query OK, 0 rows affected (0.61 sec)The below query will create an event without the use of ON COMPLETION PRESERVE hence it would not be seen in the output of SHOW EVENTS ... Read More

Inherit a Class in C#

Chandu yadav
Updated on 22-Jun-2020 12:36:17

141 Views

Inheritance allows us to define a class in terms of another class, which makes it easier to create and maintain an application.When creating a class, instead of writing completely new data members and member functions, the programmer can designate that the new class should inherit the members of an existing class. This existing class is called the base class, and the new class is referred to as the derived class. A class can be derived from more than one class or interface, which means that it can inherit data and functions from multiple base classes or interfaces.Let us see an ... Read More

Delete Duplicate Values from MySQL Table in Reverse Order

Govinda Sai
Updated on 22-Jun-2020 12:35:57

326 Views

To understand this concept, we are using the data from table ‘Details_city’ as follows −mysql> Select * from details_city; +--------+--------+ | City1  | City2  | +--------+--------+ | Delhi  | Nagpur | | Delhi  | Mumbai | | Nagpur | Delhi  | | Katak  | Delhi  | | Delhi  | Katak  | +--------+--------+ 5 rows in set (0.00 sec)Now, the following query will delete the reverse duplicate values from details_city table −mysql> Select a.city1,a.city2 from details_city a WHERE a.city1

File Objects in C#

George John
Updated on 22-Jun-2020 12:35:19

1K+ Views

To create a new file in C#, use the FileStream object.The following is the syntax −FileStream = new FileStream( , , , );Let us see an example for a file “test.dat”, which is created/ opened using File object −FileStream F = new FileStream("test.dat", FileMode.OpenOrCreate,FileAccess.ReadWrite);The following is an example −Exampleusing System; using System.IO; namespace FileIOApplication {    class Program {       static void Main(string[] args) {          FileStream F = new FileStream("test.dat", FileMode.OpenOrCreate,          FileAccess.ReadWrite);          for (int i = 1; i

Simulate MySQL INTERSECT Query Returning Multiple Expressions

Giri Raju
Updated on 22-Jun-2020 12:35:18

220 Views

Since we cannot use the INTERSECT query in MySQL, we will use the EXIST operator to simulate the INTERSECT query. It can be understood with the help of the following example −ExampleIn this example, we are two tables namely Student_detail and Student_info having the following data −mysql> Select * from Student_detail; +-----------+---------+------------+------------+ | studentid | Name    | Address    | Subject    | +-----------+---------+------------+------------+ |       101 | YashPal | Amritsar   | History    | |       105 | Gaurav  | Chandigarh | Literature | |       130 | Ram     ... Read More

Truncate a File in C#

Ankith Reddy
Updated on 22-Jun-2020 12:34:29

1K+ Views

To truncate a file in C#, use the FileStream.SetLength method.Here is the syntax −public override void SetLength (long value);Here, int64 = Length of the streamValue < current LengthIf the value is less than the current length of the stream: The stream is truncated. If the current position is greater than the new length, the current position is moved to the last byte of the stream.Value > current LengthThe stream is expanded, and the current position remains the same. If the stream is expanded, the contents of the stream between the old and the new length are undefined.The following is an ... Read More

Modify an Existing MySQL Event

Samual Sam
Updated on 22-Jun-2020 12:34:23

542 Views

With the help of ALTER EVENT statement, we can modify an existing MySQL event. We can change the various attributes of an event. ALTER EVENT has the following syntax −   ALTER EVENT event_name     ON SCHEDULE schedule ON COMPLETION [NOT] PRESERVE   RENAME TO new_event_name     ENABLE | DISABLE            DO        event_bodyTo understand it we are illustrating the example as below −ExampleSuppose we have an event as follows −mysql> Create event hello ON SCHEDULE EVERY 1 Minute DO INSERT INTO event_messages(message, generated_at) Values ('Alter event testing', NOW()); Query OK, 0 rows ... Read More

Declaring an Array in C#

karthikeya Boyini
Updated on 22-Jun-2020 12:33:45

102 Views

Declaring an array does not initialize the array in the memory. When the array variable is initialized, you can assign values to the array.The following is a declaration and it will not create an array −int[] id;The following create an array of integers. The array is a reference type, so you need to use the new keyword to create an instance of the array −Int[] id = new int[5] {};Let us see an example −Example Live Demousing System; namespace ArrayApplication {    public class MyArray {       public static void Main(string[] args) {          int ... Read More

Rename an Existing MySQL Event

Paul Richard
Updated on 22-Jun-2020 12:33:25

182 Views

With the help of ALTER EVENT statement along with the RENAME keyword, we can RENAME an existing event. To illustrate it we are having the following example in which we are renaming the event ‘Hello’ to ‘Hello_renamed’ −Examplemysql> ALTER EVENT Hello RENAME TO Hello_renamed; Query OK, 0 rows affected (0.00 sec)To confirm that event has been renamed we can try to delete the event with the old name, MySQL will throw an error as follows −mysql> DROP EVENT hello; ERROR 1539 (HY000): Unknown event 'hello'

Make a C# Program Sleep for X Milliseconds

Samual Sam
Updated on 22-Jun-2020 12:32:53

1K+ Views

To make a C# program sleep for x milliseconds, use the Thread.Sleep() method.To set it for 1000 milliseconds −Thread.Sleep(1000);The following is the code showing how to set a counter for the thread and set it to sleep for 1000 milliseconds on every iteration of for loop −Example Live Demousing System; using System.Threading; namespace MultithreadingApplication {    public class ThreadCreationProgram {       public static void CallToChildThread() {          try {             Console.WriteLine("Child thread starts");             for (int counter = 0; counter

Advertisements