MySQLi Articles

Page 69 of 341

What is the advantage of CONCAT_WS() function over CONCAT() function when we want to concatenate the values from the column and any of the columns have NULL as its value?

Paul Richard
Paul Richard
Updated on 22-Jun-2020 189 Views

As we know that CONCAT() function returns NULL if any of the arguments is NULL but CONCAT_WS() function returns NULL only if the first argument i.e. the separator is NULL and it ignores any other NULL. We can say this is the advantage of CONCAT_WS() function over CONCAT() function when we want to concatenate the values from the column and any of the columns have NULL as its value. To understand it, we consider the example from the table ‘Student_name; which have the following data −mysql> Select * from Student_Name; +---------+-------+---------+ | FName   | Mname | Lname   | ...

Read More

Why is it necessary to declare NOT FOUND handler while using MySQL cursor?\\n

varun
varun
Updated on 22-Jun-2020 2K+ Views

We must have to declare NOT FOUND handler while working with MySQL cursor because it handles the situation when cursor could not find any row. It also handles the situation when the cursor reaches the end of the row because every time we call FETCH statement the cursor finds to attempt the next row in the result set. Following is the syntax to declare NOT FOUND handler −DECLARE CONTINUE HANDLER FOR NOT FOUND SET var_name = value;Here var_name is the name of any variable and value would be the value of that variable. For example, we can declare it as ...

Read More

How can we retrieve the output having decimal values of a column in a specified format?

Arjun Thakur
Arjun Thakur
Updated on 22-Jun-2020 595 Views

MySQL FORMAT() function, converts a number to a format like #, ###, ###.### which is rounded up to the number of decimal places specified and returns the result as a string, can be used to retrieve the output having decimal values of a column in a specified format. To understand it, we are taking an example of table ‘estimated_cost’ which have the following data −mysql> Select * from estimated_cost; +----+-----------------+-----------+---------------+ | Id | Name_Company    | Tender_id | Tender_value  | +----+-----------------+-----------+---------------+ | 1  | ABC Ltd.        | 110       | 256.3256879   | | 2 ...

Read More

How are actions that take place inside stored procedure and functions replicated?

Nancy Den
Nancy Den
Updated on 22-Jun-2020 227 Views

Actually standard actions carried out in stored procedures and functions are replicated from a master MySQL server to a slave MySQL server. Even the creation of stored procedures and functions carried out through normal DDL statements on a master MySQL server are replicated to a slave MySQL server. In this way, objects will exist on both the servers.The actions that take place inside the stored procedure and functions are replicated because MySQL records each DDL event that occurs inside stored procedures and functions. After recording the events it is replicated to the slave MySQL server. But the actual calls made ...

Read More

How can we perform ROLLBACK transactions inside a MySQL stored procedure?

mkotla
mkotla
Updated on 22-Jun-2020 3K+ Views

As we know that ROLLBACK will revert any changes made to the database after the transaction has been started. To perform the ROLLBACK in MySQL stored procedure we must have to declare EXIT handler. We can use a handler for either sqlexception or SQL warnings. It can be understood with the help of an example in which stored procedure having ROLLBACK created for the table having the following details −mysql> SHOW CREATE table gg\G *************************** 1. row ***************************        Table: gg Create Table: CREATE TABLE `gg` (    `Id` int(11) NOT NULL AUTO_INCREMENT,    `Name` varchar(30) NOT NULL,    PRIMARY KEY ...

Read More

What are the limitations for replicating stored procedure and functions?

Rishi Rathor
Rishi Rathor
Updated on 22-Jun-2020 301 Views

Followings are the limitations for replicating stored procedure and functions −Type of Action − Actually the replication of stored procedure and functions depends upon the type of action. If the action, embedded in stored procedures, is nondeterministic (random) or time-based then it may not replicate properly. By their very nature, randomly produced results are not predictable and cannot be exactly reproduced, and therefore, random actions replicated to a slave will not mirror those performed on a master.Type of transaction − non-transactional tables for which errors occur during large DML actions (such as bulk inserts) may experience replication issues in that ...

Read More

What are the special security requirements for using stored procedures and functions together with replication?

radhakrishna
radhakrishna
Updated on 22-Jun-2020 276 Views

Actually, a MySQL slave server has the authority to execute any statement read from a master's MySQL server binary log, hence some special security constraints exist for using stored functions with replication. If replication or binary logging in general (for the purpose of point-in-time recovery) is active, then MySQL DBAs have two security options open to them −Option of SUPER privilegeAny user wishing to create stored functions must be granted the SUPER privilege by DBA.log_bin_trust_function_creators modeActually, log_bin_trust_function_creators enables anyone with the standard CREATE ROUTINE privilege to create stored functions hence a DBA can set the log_bin_trust_function_creators system variable to 1.

Read More

While linking two strings, if I will add a NULL value then what would be the output of a CONCAT() function?

Chandu yadav
Chandu yadav
Updated on 22-Jun-2020 144 Views

MySQL CONCAT() function will return a NULL if you will add a NULL value while linking two strings. Following example will demonstrate it −Examplemysql> Select CONCAT('Tutorials',NULL,'Point'); +----------------------------------+ | CONCAT('Tutorials',NULL,'Point') | +----------------------------------+ | NULL                             | +----------------------------------+ 1 row in set (0.06 sec) mysql> Select CONCAT('TutorialsPoint','.com',NULL); +--------------------------------------+ | CONCAT('TutorialsPoint','.com',NULL) | +--------------------------------------+ | NULL                                 | +--------------------------------------+ 1 row in set (0.00 sec)

Read More

Create a procedure to find out the factorial of a number?

vanithasree
vanithasree
Updated on 22-Jun-2020 4K+ Views

It can be created with the help of the following query −mysql> Delimiter // mysql> CREATE PROCEDURE fact(IN x INT)     -> BEGIN     -> DECLARE result INT;     -> DECLARE i INT;     -> SET result = 1;     -> SET i = 1;     -> WHILE i SET result = result * i;     -> SET i = i + 1;     -> END WHILE;     -> SELECT x AS Number, result as Factorial;     -> END// Query OK, 0 rows affected (0.17 sec)Now when invoking this ...

Read More

How can we create MySQL stored procedures without ‘BEGIN’ and ‘END’?

Vrundesha Joshi
Vrundesha Joshi
Updated on 22-Jun-2020 584 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
Showing 681–690 of 3,404 articles
« Prev 1 67 68 69 70 71 341 Next »
Advertisements