Create MySQL Stored Procedures Without BEGIN and END

Vrundesha Joshi
Updated on 22-Jun-2020 07:20:52

545 Views

We can create MySQL stored procedures without ‘BEGIN’ and ‘END’ just in the same way created with both of them only thing is to omit to BEGIN and END. In the following example, we are creating a stored procedure without ‘BEGIN’ and ‘END’ to get all the rows from a table −Examplemysql> Delimiter // mysql> CREATE PROCEDURE Hello()     -> SELECT * from Student_info; // Query OK, 0 rows affected (0.08 sec)We can see MySQL created stored procedures without BEGIN and END. Now invoke this by CALL statement −mysql> Delimiter ; mysql> CALL Hello(); +-----+---------+------------+------------+ | id  | ... Read More

Difference Between Mutable and Immutable Strings in C#

karthikeya Boyini
Updated on 22-Jun-2020 07:18:45

4K+ Views

Mutable stringStringBuilder is a mutable string in C#. With StringBuilder, you can expand the number of characters in the string. The string cannot be changed once it is created, but StringBuilder can be expanded. It does not create a new object in the memory.Set StringBuilder −StringBuilder str = new StringBuilder();Let us see an example to learn how to work with StringBuilder in C# −Example Live Demousing System; using System.Text; public class Program {    public static void Main() {       StringBuilder str = new StringBuilder("Web World!!", 30);       str.Replace("World", "Arena");       Console.WriteLine(str);   ... Read More

Difference Between Interface and Abstract Class in C#

Samual Sam
Updated on 22-Jun-2020 07:17:37

593 Views

Interfaces define properties, methods, and events, which are the members of the interface. Interfaces contain only the declaration of the members. It is the responsibility of the deriving class to define the members.Abstract classes to some extent serve the same purpose, however, they are mostly used when only a few methods are to be declared by the base class and the deriving class implements the functionalities.The following are the differences −A class may inherit more than one interface, whereas a class may inherit only one abstract class.Multiple Inheritance cannot be achieved using Abstract whereas with Interface we can achieve it.You ... Read More

Properties of the Thread Class

Ankith Reddy
Updated on 22-Jun-2020 07:17:04

6K+ Views

A thread is defined as the execution path of a program. Each thread defines a unique flow of control.The following are the properties of the Thread class −Sr.No.Property & Description1CurrentContextGets the current context in which the thread is executing.2CurrentCultureGets or sets the culture for the current thread.3CurrentPrincipleGets or sets the thread's current principal (for role-based security).4currentThreadGets the currently running thread.5CurrentUICultureGets or sets the current culture used by the Resource Manager to look up culture-specific resources at run-time.6ExecutionContextGets an ExecutionContext object that contains information about the various contexts of the current thread.7IsAliveGets a value indicating the execution status of the current ... Read More

Access Tables Through MySQL Stored Procedures

Krantik Chavan
Updated on 22-Jun-2020 07:02:44

389 Views

We can access one or all the tables from the MySQL stored procedure. Following is an example in which we created a stored procedure that will accept the name of the table as a parameter and after invoking it, will produce the result set with all the details from the table.Examplemysql> Delimiter // mysql> Create procedure access(tablename varchar(30))    -> BEGIN    -> SET @X := CONCAT('Select * from', ' ', tablename);    -> Prepare statement from @X;    -> Execute statement;    -> END// Query OK, 0 rows affected (0.16 sec)Now invoke the procedure with the table name, we ... Read More

Perform COMMIT Transactions Inside MySQL Stored Procedure

mkotla
Updated on 22-Jun-2020 07:02:12

860 Views

As we know the START transaction will start the transaction and COMMIT is used to made any changes made after starting the transaction. In the following example, we have created a stored procedure with COMMIT along with START transaction which will insert a new record and commit changes in table ‘employee.tbl’ having the following data −mysql> Select * from employee.tbl; +----+---------+ | Id | Name    | +----+---------+ |  1 | Mohan   | |  2 | Gaurav  | |  3 | Rahul   | |  4 | Saurabh | +----+---------+ 4 rows in set (0.00 sec)Examplemysql> Delimiter // mysql> ... Read More

Use REPLACE with UPDATE Clause for Permanent Changes to a Table

Manikanth Mani
Updated on 22-Jun-2020 07:01:25

238 Views

As we know that REPLACE () function is used to replace the occurrences of a substring with another substring within a string. We can also use the REPLACE function with the UPDATE statement to update the table. Following example will demonstrate it −Examplemysql> Update Student set Father_Name = REPLACE(Father_Name, 'Mr.', 'Shri '); Query OK, 5 rows affected (0.06 sec) Rows matched: 5 Changed: 5 Warnings: 0 mysql> Select Name, Father_Name from Student; +---------+-----------------+ | Name    | Father_Name     | +---------+-----------------+ | Gaurav  | Shri Ramesh     | | Aarav   | Shri Sanjay     | ... Read More

Default Return Type of MySQL IFNULL Control Flow Operator

Ankith Reddy
Updated on 22-Jun-2020 07:00:29

133 Views

Actually, the default return type of IFNULL(expression1, expression2) is more general of the two expressions, in the order STRING, REAL or INTEGER. It can be understood from the following example −Examplemysql> Create table testing Select IFNULL(100, 'testing123'); Query OK, 1 row affected (0.18 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> Select * from testing568; +-----------------------+ | IFNULL(100, 'testing') | +-----------------------+ | 100                   | +-----------------------+ 1 row in set (0.00 sec) mysql> Describe testing568; +-----------------------+------------+------+-----+---------+-------+ | Field                 | Type     ... Read More

Use of MySQL IFNULL Control Flow Function

Jai Janardhan
Updated on 22-Jun-2020 06:59:50

267 Views

MySQL IFNULL() control flow function will return the first argument if it is not NULL otherwise it returns the second argument.SyntaxIFNULL(expression1, expression2)Here if expression1 is not NULL then IFNULL() will return expression1 otherwise expression2. It will return NULL if both of the arguments are NULL. Following example will exhibit this −mysql> Select IFNULL(NULL, 'Ram'); +--------------------+ | IFNULL(NULL, 'Ram') | +--------------------+ | Ram                | +--------------------+ 1 row in set (0.00 sec) mysql> Select IFNULL('Shyam', 'Ram'); +-----------------------+ | IFNULL('Shyam', 'Ram') | +-----------------------+ | Shyam                 | +-----------------------+ ... Read More

Difference Between Comparison and Assignment Operators

karthikeya Boyini
Updated on 22-Jun-2020 06:58:55

827 Views

Actually, they both are assignment operator and used to assign values but the significant difference between them is as follows −= operator assigns a value either as a part of the SET statement or as a part of the SET clause in an UPDATE statement, in any other case = operator is interpreted as a comparison operator. On the other hand, := operator assigns a value and it is never interpreted as a comparison operator.mysql> Update estimated_cost1 SET Tender_value = '8570.000' where id = 2; Query OK, 1 row affected (0.06 sec) Rows matched: 1 Changed: 1 Warnings: 0 ... Read More

Advertisements