【发布时间】:2018-12-28 05:39:25
【问题描述】:
当我通过条形码扫描仪扫描车辆的条形码时,我想显示车辆的所有属性。每辆车的条形码条目都存储在 Microsoft SQL 数据库中。是否可以为此编写程序?如果是的话,请给我一些想法。
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[vq_proc]
@Vehicle_id varchar(50),
@L1_Employee varchar(50) output,
@L2_Employee varchar(50) output,
@L3_Employee varchar(50) output,
@L4_Employee varchar(50) output,
@R1_Employee varchar(50) output,
@R2_Employee varchar(50) output,
@R3_Employee varchar(50) output,
@AF_Date varchar(50) output,
@AF_Time varchar(50) output,
@LWR varchar(50) output,
@Noise varchar(50) output,
@LWL varchar(50) output,
@Elec varchar(50) output
AS
BEGIN
--L1 employee
Select @L1_Employee= emp.Employee_name From log_Station s1,HVQ_Employee emp where s1.station_code='L1' and s1.Employee_id=emp.Employee_id and s1.Vehicle_id= @Vehicle_id
--L2
Select @L2_Employee= emp.Employee_name From log_Station s1,HVQ_Employee emp where s1.station_code='L2' and s1.Employee_id=emp.Employee_id and s1.Vehicle_id= @Vehicle_id
--L3
Select @L3_Employee= emp.Employee_name From log_Station s1,HVQ_Employee emp where s1.station_code='L3' and s1.Employee_id=emp.Employee_id and s1.Vehicle_id= @Vehicle_id
--L4
Select @L4_Employee= emp.Employee_name From log_Station s1,HVQ_Employee emp where s1.station_code='L4' and s1.Employee_id=emp.Employee_id and s1.Vehicle_id= @Vehicle_id
--R1
select @R1_Employee= emp.Employee_name from log_Station s1,HVQ_Employee emp where s1.station_code='R1' and s1.Employee_id=emp.Employee_id and s1.Vehicle_id= @Vehicle_id
--R2
select @R2_Employee= emp.Employee_name from log_Station s1,HVQ_Employee emp where s1.station_code='R2' and s1.Employee_id=emp.Employee_id and s1.Vehicle_id= @Vehicle_id
--R3
Select @R3_Employee= Employee_name From log_Station s1,HVQ_Employee emp where s1.station_code='R3' and s1.Employee_id=emp.Employee_id and s1.Vehicle_id= @Vehicle_id
--Aq
Select @AF_Date= CONVERT(VARCHAR(10),timestamp,101),@AF_Time= CONVERT(VARCHAR(10),timestamp,108)/*, */ FROM log_Station s1 where @Vehicle_id= s1.Vehicle_id/*HVQ_Vehicle*/
--LW &R
Select @LWR= Employee_name From log_Station s1,HVQ_Employee emp where s1.station_code='LW' and s1.Employee_id=emp.Employee_id and s1.Vehicle_id= @Vehicle_id
--Noise
Select @Noise= Employee_name From log_Station s1,HVQ_Employee emp where s1.station_code='Noise' and s1.Employee_id=emp.Employee_id and s1.Vehicle_id= @Vehicle_id
--LW & L
Select @LWL= Employee_name From log_Station s1,HVQ_Employee emp where s1.station_code='LW' and s1.Employee_id=emp.Employee_id and s1.Vehicle_id= @Vehicle_id
--Elc
Select @Elec= Employee_name From log_Station s1,HVQ_Employee emp where s1.station_code='Elc' and s1.Employee_id=emp.Employee_id and s1.Vehicle_id= @Vehicle_id
SELECT @L1_Employee as N'@L1_Employee',
@L2_Employee as N'@L2_Employee',
@L3_Employee as N'@L3_Employee',
@L4_Employee as N'@L4_Employee',
@R1_Employee as N'@R1_Employee',
@R2_Employee as N'@R2_Employee',
@R3_Employee as N'@R3_Employee',
@AF_Date as N'@AF_Date',
@AF_Time as N'@AF_Time',
@LWR as N'@LWR',
@Noise as N'@Noise',
@LWL as N'@LWL',
@Elec as N'@Elec'
END
【问题讨论】:
-
是的,您必须将车辆 ID 传递给程序,程序将返回具有该车辆属性的光标。
-
@Pirate,谢谢先生。能详细点吗?
-
这是 sqlserver 代码。您是在尝试转换为 mysql 还是问题标记不正确?
-
@P.Salmon,标签错误。
-
为此,您需要输入条形码和包含汽车属性的输出数据集。这只是一个
select声明。我不知道您发布的存储过程是什么意思。您实际上尝试过什么。你写过代码吗?你用什么来获取条形码值?
标签: sql-server database stored-procedures