求帮忙解决存储过程问题
我在 sql server 2005 数据库中建了这样一个存储过程
create PROCEDURE [dbo].[pro_a] @AS_IN VARCHAR(200), @AS_OUT VARCHAR(200) OUT, @AI_DO INT OUT
AS
BEGIN
DECLARE @CARDID VARCHAR(8)
DECLARE @AMOUNT DECIMAL(10,2)
DECLARE @BUSNUM VARCHAR(12)
DECLARE @DBNUM VARCHAR(12)
DECLARE @BDATE VARCHAR(14)
DECLARE @BDATEA VARCHAR(20)
DECLARE @LS_VAL VARCHAR(10)
declare @aa varchar(10)
IF LEN(@AS_IN) >66
BEGIN
SET @LS_VAL = SUBSTRING(@AS_IN,5,2)
SET @CARDID = SUBSTRING(@AS_IN,12,8)
SET @BUSNUM = SUBSTRING(@AS_IN,42,12)
SET @DBNUM = SUBSTRING(@AS_IN,54,12)
SET @BDATE = SUBSTRING(@AS_IN,20,14)
IF @LS_VAL <> 'XV'
BEGIN
SET @AS_OUT = '写入失败'
RETURN 0
END
SET @AMOUNT = CONVERT(DECIMAL(10,2),CAST(SUBSTRING(@AS_IN,34,8) AS FLOAT)/100)
SET @BDATEA = LEFT(@BDATE,4)+'-'+SUBSTRING(@BDATE,5,2)+'-'+SUBSTRING(@BDATE,7,2)+' '+ SUBSTRING(@BDATE,9,2)+':'+SUBSTRING(@BDATE,11,2)+':'+SUBSTRING(@BDATE,13,2)
BEGIN TRANSACTION
INSERT INTO DBO.table1(CARDID,AMOUNT,BUSNUM,BDATE,DBNUM) VALUES (@CARDID,@AMOUNT,@BUSNUM,@BDATEA,@DBNUM)
IF @@ERROR = 0
BEGIN
COMMIT TRANSACTION
SET @AS_OUT = '写入成功'
RETURN 0
END
ELSE
BEGIN
ROLLBACK TRANSACTION
SET @AS_OUT = '写入失败'
RETURN 0
END
END
ELSE
BEGIN
SET @AS_OUT = '写入失败'
RETURN 0
END
END
GO
我通过程序调用这个存储过程,获得存储过程返回值‘写入成功’,但是我在数据库table1表里面却找不到这条数据,然后在数据库里面用同样的条件执行存储过程,存储过程返回值是‘写入成功’,数据库表里面也会有这个数据。并且通过程序调用存储过程,也不是所有的数据都不能写入数据表,只是部分有数据有这样的问题。请问这个是什么原因啊,该怎样解决? 在这里先谢谢了 , 都纠结一下午了 。。。。。。
------解决方案--------------------create PROCEDURE [dbo].[pro_a] @AS_IN VARCHAR(200), @AS_OUT VARCHAR(200) OUT, @AI_DO INT OUT
AS
BEGIN
DECLARE @CARDID VARCHAR(8)
DECLARE @AMOUNT DECIMAL(10,2)
DECLARE @BUSNUM VARCHAR(12)
DECLARE @DBNUM VARCHAR(12)
DECLARE @BDATE VARCHAR(14)
DECLARE @BDATEA VARCHAR(20)
DECLARE @LS_VAL VARCHAR(10)
declare @aa varchar(10)
IF LEN(@AS_IN) >66
BEGIN
SET @LS_VAL = SUBSTRING(@AS_IN,5,2)
SET @CARDID = SUBSTRING(@AS_IN,12,8)
SET @BUSNUM = SUBSTRING(