아래 SP는 다음 오류를 반환합니다. varchar 값 'AR118'을 데이터 유형 int로 변환 할 때 변환하지 못했습니다.varchar 값 'AR118'을 데이터 유형 int로 변환 할 때 변환에 실패했습니다
바닥을 호출하는 테스트 SP에서 무슨 일이 일어나고 있는지 아니 생각 ...
ALTER PROCEDURE [dbo가]. [pa_ProyectoIngresar]
@IDUsuario varchar(20),
@CodigoPais char(2),
@Nombre varchar(255),
@Alias char(25),
@Sector char(3),
@AporteFonPlata decimal(9),
@AporteLocal decimal(9),
@IDResponsable varchar(20),
@Reembolsable char(1),
@NoProyecto char(5) OUT
AS
BEGIN
SET NOCOUNT ON;
declare @Fecha datetime
declare @No int
set @No = 0
set @Fecha = GetUtcDate()
set @NoProyecto = ''
Select @NoProyecto = max(NoProyecto) from Proyectos WHERE Substring(NoProyecto,1,2) = @CodigoPais
if @NoProyecto is NULL
BEGIN
SET @NoProyecto = @CodigoPais + '101'
END
else
begin
set @No = CAST(SUBSTRING(@NoProyecto, 3, 3) as int) + 1
set @NoProyecto = @CodigoPais + RIGHT('000' + CAST(@No AS Varchar(3)), 3)
end
Insert Into Proyectos
(
NoProyecto, Estado, FechaEstado, HoraEstado, Nombre, Alias, Sector,
AporteFonPlata, AporteLocal, AporteOtros,
AprobacionEstimada, AprobacionProbabilidad, IDResponsable,
FechaAbstracto, EstadoAbstracto, FechaPerfil, EstadoPerfil,
FechaPOperativa, EstadoPOperativa, FechaNegociacion, EstadoNegociacion,
FechaAprobacion, EstadoAprobacion, Reembolsable,
Objetivo, Componentes, Beneficiarios, Ubicacion, NoResolucion,
IDingresado, FechaIngresado, IDModificado, FechaModificado
)
VALUES (
@NoProyecto, 'INA', @Fecha, '', @Nombre, @Alias, @Sector,
@AporteFonPlata, @AporteLocal, 0, 0, '', @IDResponsable,
@Fecha, 'N', @Fecha, 'N', @Fecha, 'N', @Fecha, 'N', @Fecha, 'N',
@Reembolsable, '', '', '', '', '',
@IDUsuario, @Fecha, @IDUsuario, @Fecha
)
if scope_identity() is NULL
begin
set @NoProyecto = ''
end
return @NoProyecto
END
테스팅 SP
declare @IDUsuario varchar(20)
declare @CodigoPais char(2)
declare @Nombre varchar(255)
declare @Alias char(25)
declare @Sector char(3)
declare @AporteFonplata decimal(9,0)
declare @AporteLocal decimal(9,0)
declare @Reembolsable char(1)
declare @IDResponsable varchar(20)
declare @NoProyecto char(5)
set @IDUsuario = 'TRESPONSABLE'
set @CodigoPais = 'AR'
set @Nombre = 'Ingreso Nuevo Proyecto'
set @Alias = 'NUEVO'
set @Sector = 'SOC'
set @AporteFonplata = 25000000
set @AporteLocal = 5000000
set @Reembolsable = 'S'
set @IDresponsable = 'TRESPONSABLE'
set @NoProyecto = ''
EXEC PA_ProyectoIngresar @IDUsuario, @CodigoPais, @Nombre, @Alias, @Sector, @AporteFonplata, @AporteLocal, @IDresponsable, @Reembolsable, @NoProyecto
단서 코드를 int 값으로'AR118'' 문자열로 변환하려고 오류 메시지에 있으며이 부르는 것들은'AR'가 INT로 변환 할 수 있기 때문에 그것은 불가능합니다. –
그것이 내 문제입니다. SP가 char에서 int 로의 변환을 시도하는 곳을 찾을 수 없습니다. 무엇을 간과합니까? – user3238418
Proyectos 테이블에있는 'NoProyecto'열의 데이터 유형은 무엇입니까? –