mysql - How Do create insert query using procedure -


how create insert query using procedure

create definer=`root`@`localhost` procedure `insert_emp `() insert employee(id,name,salary,address) values (id,name,salary,address)  $name= $_post['name']; $salary= $_post['salary']; $address= $_post['address'];  $sql=mysql_query("call insert_emp ($name,$salary,$address)"); 

make sure field "id" set auto-increment inorder have easy inserting table.

delimiter $$  create /*[definer = { user | current_user }]*/ procedure `insert_emp`(in name varchar(15),in salary int,in address varchar(15))  begin insert `employee`(employee.`id`,employee.`name`,employee.`salary`,employee.`address`) values (id,name,salary,address); end$$  delimiter ; 

example query, call insert_emp('anish',18000,'mlre');


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -