In the below SQL, data is written to SOURCE and from there to TARGET.
The DECIMAL columns in TARGET are deliberately smaller than those in SOURCE (eg a DECIMAL (12, 2) column populated from a DECIMAL (19,11) source).
When I run this in an Query tool (eg, SqlDbx) I get the messages:
"Truncation error occurred
Command has been aborted"
But when I run this using the .net Client (supplied with the Developer Edition of ASE 16.0) no exception is thrown (the INSERT fails though). The method is AseCommand.ExecuteNonQuery().
Is this deliberate?
Is this believed to be correct?
How can I tell that a truncation error has been raised?
Thanks
IF OBJECT_ID ('dbo.TARGET') IS NOT NULL
DROP TABLE dbo.TARGET
GO
CREATE TABLE dbo.TARGET
(
S_Name_NVARCHAR NVARCHAR (50) null,
S_RedComponent_DEC_15_6 decimal(15, 6) NULL,
S_BlueComponent_DEC_12_2 decimal(12, 2) NULL,
S_GreenComponent_DEC_18_10 decimal(18, 10) NULL
)
GO
IF OBJECT_ID ('dbo.SOURCE') IS NOT NULL
DROP TABLE dbo.SOURCE
GO
CREATE TABLE dbo.SOURCE
(
Name_NVARCHAR NVARCHAR (2000) NULL,
RedComponent_DEC DECIMAL (19,11) NULL,
GreenComponent_DEC DECIMAL (19,11) NULL,
BlueComponent_DEC DECIMAL (19,11) NULL
)
GO
INSERT INTO dbo.SOURCE (Name_NVARCHAR, RedComponent_DEC, GreenComponent_DEC, BlueComponent_DEC)
VALUES ('Beige', 272.195, 272.195, 244.42)
GO
INSERT INTO dbo.SOURCE (Name_NVARCHAR, RedComponent_DEC, GreenComponent_DEC, BlueComponent_DEC)
VALUES ('Bisque', 283.305, 253.308, 217.756)
GO
INSERT INTO dbo.SOURCE (Name_NVARCHAR, RedComponent_DEC, GreenComponent_DEC, BlueComponent_DEC)
VALUES ('Black', 0, 0, 0)
GO
INSERT INTO dbo.SOURCE (Name_NVARCHAR, RedComponent_DEC, GreenComponent_DEC, BlueComponent_DEC)
VALUES ('BlanchedAlmond', 283.305, 261.085, 227.755)
GO
--Is there data to migrate?
SELECT LEFT( S.Name_NVARCHAR,8000),S.GreenComponent_DEC,S.GreenComponent_DEC,S.GreenComponent_DEC
FROM (
SELECT * FROM SOURCE
) S
--Yes.migrate away!
--Next line gives a truncation error occurred in Sybase (gives a truncation error occurred in a query tool
--but fails silently in AseCommand.ExecuteNonQuery).
INSERT dbo.TARGET (S_Name_NVARCHAR,S_RedComponent_DEC_15_6,S_BlueComponent_DEC_12_2,S_GreenComponent_DEC_18_10)
SELECT LEFT( S.Name_NVARCHAR,8000),S.GreenComponent_DEC,S.GreenComponent_DEC,S.GreenComponent_DEC
FROM (
SELECT * FROM SOURCE
) S
select * from dbo.TARGET