Subject | Varchar assigned to varchar -> "Conversion error from string" |
---|---|
Author | Jorge Andrés Brugger |
Post date | 2009-09-14T17:34:31Z |
Following there are two versions of a simple SP (stripped down of a more
complex real case):
1)
CREATE PROCEDURE SP_GENERAR_TRANSFERENCIA (
OBSERVACIONES Varchar(2500)
)
AS
insert into transferencias values(:observaciones);
end
2)
CREATE PROCEDURE SP_GENERAR_TRANSFERENCIA (
OBSERVACIONES Varchar(2500)
)
AS
insert into transferencias values(cast(:observaciones as varchar(2500)));
end
When the parameter is empty, first one generates a "conversion error
from string". Second one works fine.
I´ve already solved the problem (using cast), but I´m curious about the
reason of the error at the first case ...
Thaniks
--
Jorge Andrés Brugger
Informática
DASU - Obra Social del Personal de la Universidad Nacional de la Patagonia
Comodoro Rivadavia, Chubut, Argentina
Teléfono (0297) 446-4444 int. 103
Correo electrónico: jbrugger@...
Website: www.dasu.com.ar
complex real case):
1)
CREATE PROCEDURE SP_GENERAR_TRANSFERENCIA (
OBSERVACIONES Varchar(2500)
)
AS
insert into transferencias values(:observaciones);
end
2)
CREATE PROCEDURE SP_GENERAR_TRANSFERENCIA (
OBSERVACIONES Varchar(2500)
)
AS
insert into transferencias values(cast(:observaciones as varchar(2500)));
end
When the parameter is empty, first one generates a "conversion error
from string". Second one works fine.
I´ve already solved the problem (using cast), but I´m curious about the
reason of the error at the first case ...
Thaniks
--
Jorge Andrés Brugger
Informática
DASU - Obra Social del Personal de la Universidad Nacional de la Patagonia
Comodoro Rivadavia, Chubut, Argentina
Teléfono (0297) 446-4444 int. 103
Correo electrónico: jbrugger@...
Website: www.dasu.com.ar