我刚刚加入一家新公司的存储过程中发现了一个有趣的问题。
如下所示,表格pxvehiclehistory
有一个名为range
的列。范围是MySQL中的保留字,因此开发人员用后面的刻度包围它。所有好东西,除了执行插入时,range
列始终为空。
由于这个存储过程只是执行插入,我已将其移入我们的代码中,而我的老板不在我的背后。
我想知道,甚至可以在参数中获得range
的值吗?
CREATE `pxvehiclehistory_insert`(
in pxvehiclehistoryid char(38),
in regno varchar(50),
in makeid char(38),
in modelid char(38),
in rangeid char(38),
in derivativeid char(38),
in colour varchar(50),
in transmissionid char(38),
in fueltypeid char(38),
in customerid char(38),
in enginesize varchar(50),
in engineno varchar(50),
in dfr datetime,
in createdby char(38),
in noofdoors varchar(50),
in vinno varchar(100),
in createddatetime datetime,
in make varchar(50),
in model varchar(50),
in derivative varchar(100),
in `range` varchar(50)
)
BEGIN
insert into pxvehiclehistory
( pxvehiclehistoryid
,regno
,makeid
,modelid
,rangeid
,derivativeid
,colourid
,transmissionid
,fueltypeid
,customerid
,enginesize
,engineno
,dfr
,noofdoors
,vinno
,createddatetime
,createdby
,make
,model
,derivative
,`range`
)
values
(
pxvehiclehistoryid
,regno
,makeid
,modelid
,rangeid
,derivativeid
,(select colourid from colour where upper(description)=upper(colour))
,transmissionid
,fueltypeid
,customerid
,enginesize
,engineno
,dfr
,noofdoors
,vinno
,createddatetime
,createdby
,make
,model
,derivative
,`range`
);
END