如何写一个mysql程序来插入数据?

时间:2015-10-08 05:35:22

标签: php mysql

CREATE PROCEDURE dasd (

IN aSupplierID varchar(4),
IN aSupplierName varchar(100),
IN aSupplierAddress varchar(255),
IN aSupplierTelPhone varchar(10))

BEGIN

insert 
into 
supplier
(SupplierID,SupplierName,SupplierAddress,SupplierTelPhone)
values 
(aSupplierID,aSupplierName,aSupplierAddress,aSupplierTelPhone);

END
  

我在行'值(aSupplierID,aSupplierName,aSupplierAddress,aSupplierTelPhone)中发现错误;   END”。

2 个答案:

答案 0 :(得分:0)

请你试试一下

CREATE PROCEDURE dasd (

IN aSupplierID varchar(4),
IN aSupplierName varchar(100),
IN aSupplierAddress varchar(255),
IN aSupplierTelPhone varchar(10))

BEGIN

insert 
into 
supplier
(SupplierID,SupplierName,SupplierAddress,SupplierTelPhone)
values 
(in_aSupplierID,in_aSupplierName,in_aSupplierAddress,in_aSupplierTelPhone);    
END

答案 1 :(得分:0)

试试这个

DELIMITER $$

CREATE PROCEDURE das1d (

IN aSupplierID VARCHAR(4),
IN aSupplierName VARCHAR(100),
IN aSupplierAddress VARCHAR(255),
IN aSupplierTelPhone VARCHAR(10))

BEGIN

INSERT 
INTO 
supplier
(SupplierID,SupplierName,SupplierAddress,SupplierTelPhone)
VALUES 
(aSupplierID,aSupplierName,aSupplierAddress,aSupplierTelPhone);

END$$

DELIMITER ;

将分隔符更改为$$以使整个定义作为单个语句传递给服务器,然后还原到;在调用该过程之前。这使得;过程体中使用的分隔符将被传递给服务器,而不是由mysql本身解释。单击here以获取有关定义存储过程的更多详细信息。