Instead of Insert, Verify not inserting into identity column.

I am writing an Instead of Insert trigger. I would like to fire an error when inserting into an 'Identity' column.  Since UPDATE([ColumnName]) always returns TRUE for insert statements, is there an easy/fast way around this? I don't
want to use: 
IF(EXISTS(SELECT [i].[AS_ID] FROM [inserted] [i] WHERE [i].[AS_ID] IS NULL))
here is my pseudo-code...
CREATE VIEW [org].[Assets]
WITH SCHEMABINDING
AS
SELECT
[AS].[AS_ID], -- Identity field in base table
[AS].[Tag],
[AS].[Name]
FROM [org].[AS_Assets_Rewind](DEFAULT, DEFAULT, DEFAULT) [AS];
GO
CREATE TRIGGER [org].[Assets_Insert]
ON [org].[Assets]
INSTEAD OF INSERT
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
-- How does this statment need to be written to throw the error?
-- UPDATE([AS_ID]) always returns TRUE
IF(UPDATE([AS_ID]))
RAISERROR('INSERT into the anchor identity column ''AS_ID'' is not allowed.', 16, 1) WITH NOWAIT;
-- Is there a faster/better method than this?
IF(EXISTS(SELECT [i].[AS_ID] FROM [inserted] [i] WHERE [i].[AS_ID] IS NOT NULL))
RAISERROR('INSERT into the anchor identity column ''AS_ID'' is not allowed.', 16, 1) WITH NOWAIT;
-- Do Stuff
END;
-- Should error for inserting into [AS_ID] field (which is an identity field)
INSERT INTO [org].[Assets]([AS_ID], [Tag], [Name])
VALUES(1, 'f451', 'Paper burns'),
(2, 'k505.928', 'Paper burns in Chemistry');
-- No error should occur
INSERT INTO [org].[Assets]([Tag], [Name])
VALUES('f451', 'Paper burns'),
('k505.928', 'Paper burns in Chemistry');

IDENTITY is in single quotes, maybe i should have made it italics to indicate it is not the name of the column, but a logical reference to a column that has the identity property set.
the "_Rewind" suffix is to indicate the function "looks back into time".
Schema design is wrong? How do you recommend creating a SQL Server 2012 database that can
1) keep a history of data with respect to changing time and transaction time
2) update data that does not arrive at one time, aka, I may get your name and phone number today, but your e-mail address tomorrow - we need to be able to differentiate when different data was updated.
3) no physical deletes (due to needing to go back in time)
FYI: 
I have examined R. Snodgrass's, L. Rönnbäck's, and T. Johnston's bi-temporal design patterns.
here is the DDL:
CREATE SCHEMA [posit];
GO
CREATE SCHEMA [org];
GO
CREATE TABLE [posit].[PO_Positor]
[PO_PositorId] INT NOT NULL IDENTITY(1, 1),
[PO_PositorApp] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorApp] DEFAULT(APP_NAME()),
CONSTRAINT [CL__PO_Positor_PO_PositorApp] CHECK([PO_PositorApp] <> ''),
[PO_PositorName] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorName] DEFAULT(SUSER_SNAME()),
CONSTRAINT [CL__PO_Positor_PO_PositorName] CHECK([PO_PositorName] <> ''),
[PO_PositorHost] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorHost] DEFAULT(HOST_NAME()),
CONSTRAINT [CL__PO_Positor_PO_PositorHost] CHECK([PO_PositorHost] <> ''),
[PO_PositorSID] VARBINARY(85) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorSID] DEFAULT(SUSER_SID()),
[PO_PositorUID] INT NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorUID] DEFAULT(SUSER_ID()),
[PO_PositorNote] VARCHAR(348) NULL CONSTRAINT [CL__PO_Positor_PO_PositorNote] CHECK([PO_PositorNote] <> ''),
[PO_PositorInserted] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorInserted] DEFAULT(SYSDATETIMEOFFSET()),
[PO_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__PO_Positor_PO_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
CONSTRAINT [UX__PO_Positor_PO_RowGuid] UNIQUE NONCLUSTERED([PO_RowGuid]),
CONSTRAINT [PK__PO_Positor] PRIMARY KEY ([PO_PositorId] ASC),
CONSTRAINT [UK__PO_Positor] UNIQUE CLUSTERED ([PO_PositorApp] ASC, [PO_PositorHost] ASC, [PO_PositorUID] ASC)
GO
CREATE PROCEDURE [posit].[Insert_Positor]
@PositorNote NVARCHAR(348) = NULL
AS
BEGIN
DECLARE @ProcedureDesc NVARCHAR(261) = N'[' + OBJECT_SCHEMA_NAME(@@PROCID) + N'].[' + OBJECT_NAME(@@PROCID) + N']';
SET @PositorNote = COALESCE(@PositorNote, N'Automatically created by: ' + @ProcedureDesc);
DECLARE @Id TABLE
[Id] INT NOT NULL
INSERT INTO [posit].[PO_Positor]([PO_PositorNote])
OUTPUT [inserted].[PO_PositorId]
INTO @Id([Id])
VALUES (@PositorNote);
RETURN (SELECT TOP 1 [i].[Id] FROM @Id [i]);
END;
GO
CREATE PROCEDURE [posit].[Return_PositorId]
AS
BEGIN
DECLARE @PositorId INT = [posit].[Get_PositorId]();
IF (@PositorId IS NULL)
BEGIN
DECLARE @ProcedureDesc NVARCHAR(261) = N'[' + OBJECT_SCHEMA_NAME(@@PROCID) + N'].[' + OBJECT_NAME(@@PROCID) + N']';
DECLARE @PositorNote NVARCHAR(348) = N'Automatically created by: ' + @ProcedureDesc;
EXECUTE @PositorId = [posit].[Insert_Positor] @PositorNote;
END;
RETURN @PositorId;
END;
GO
CREATE FUNCTION [posit].[Get_PositorId]
RETURNS INT
AS
BEGIN
DECLARE @PositorId INT = NULL;
SELECT TOP 1
@PositorId = [p].[PO_PositorId]
FROM
[posit].[PO_Positor] [p]
WHERE [p].[PO_PositorApp] = APP_NAME()
AND [p].[PO_PositorHost] = HOST_NAME()
AND [p].[PO_PositorUID] = SUSER_ID();
RETURN @PositorId;
END;
GO
CREATE TABLE [org].[AS_Assets]
[AS_ID] INT NOT NULL IDENTITY(1, 1),
[AS_PositedBy] INT NOT NULL CONSTRAINT [DF__AS_Assets_PositedBy] DEFAULT([posit].[Get_PositorId]())
CONSTRAINT [FK__AS_Assets_PositedBy] REFERENCES [posit].[PO_Positor]([PO_PositorId]),
[AS_PositedAt] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__AS_Assets_PositedAt] DEFAULT(SYSDATETIMEOFFSET()),
[AS_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__AS_Assets_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
CONSTRAINT [UX__AS_Assets_RowGuid] UNIQUE([AS_RowGuid]),
CONSTRAINT [PK__AS_Assets] PRIMARY KEY CLUSTERED ([AS_ID] ASC)
GO
CREATE TABLE [org].[AS_NME_Assets_Name_Posit]
[AS_NME_ID] INT NOT NULL IDENTITY(1, 1),
[AS_NME_AS_ID] INT NOT NULL CONSTRAINT [FK__AS_NME_Assets_Name_Posit_AS_NME_AS_ID] REFERENCES [org].[AS_Assets]([AS_ID]),
[AS_NME_AssetTag] VARCHAR(12) NOT NULL CONSTRAINT [CL__AS_NME_Assets_Name_Posit_AS_NME_AssetTag] CHECK([AS_NME_AssetTag] <> ''),
[AS_NME_AssetName] NVARCHAR(24) NOT NULL CONSTRAINT [CL__AS_NME_Assets_Name_Posit_AS_NME_AssetName] CHECK([AS_NME_AssetName] <> ''),
[AS_NME_AssetDetail] NVARCHAR(48) NOT NULL CONSTRAINT [CL__AS_NME_Assets_Name_Posit_AS_NME_AssetDetail] CHECK([AS_NME_AssetDetail] <> ''),
[AS_NME_Checksum] AS BINARY_CHECKSUM([AS_NME_AssetTag], [AS_NME_AssetName], [AS_NME_AssetDetail])
PERSISTED NOT NULL,
[AS_NME_ChangedAt] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__AS_NME_Assets_Name_Posit_ChangedAt] DEFAULT(SYSDATETIMEOFFSET()),
[AS_NME_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__AS_NME_Assets_Name_Posit_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
CONSTRAINT [UX__AS_NME_Assets_Name_Posit_RowGuid] UNIQUE NONCLUSTERED([AS_NME_RowGuid]),
CONSTRAINT [PK__AS_NME_Assets_Name_Posit] PRIMARY KEY([AS_NME_ID] ASC),
CONSTRAINT [UK__AS_NME_Assets_Name_Posit] UNIQUE CLUSTERED([AS_NME_AS_ID] ASC, [AS_NME_ChangedAt] DESC, [AS_NME_Checksum] ASC)
WITH (FILLFACTOR = 95)
GO
CREATE TABLE [org].[AS_NME_Assets_Name_Annex]
[AS_NME_ID] INT NOT NULL CONSTRAINT [FK__AS_NME_Assets_Name_Annex_AS_NME_ID] REFERENCES [org].[AS_NME_Assets_Name_Posit]([AS_NME_ID]),
[AS_NME_PositedBy] INT NOT NULL CONSTRAINT [DF__AS_NME_Assets_Name_Annex_PositedBy] DEFAULT([posit].[Get_PositorId]())
CONSTRAINT [FK__AS_NME_Assets_Name_Annex_PositedBy] REFERENCES [posit].[PO_Positor]([PO_PositorId]),
[AS_NME_PositedAt] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__AS_NME_Assets_Name_Annex_PositedAt] DEFAULT(SYSDATETIMEOFFSET()),
[AS_NME_PositReliability] TINYINT NOT NULL CONSTRAINT [DF__AS_NME_Assets_Name_Annex_PositRel] DEFAULT(50),
[AS_NME_PositReliable] AS CONVERT(BIT, CASE WHEN [AS_NME_PositReliability] > 0 THEN 1 ELSE 0 END)
PERSISTED NOT NULL,
[AS_NME_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__AS_NME_Assets_Name_Annex_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
CONSTRAINT [UX__AS_NME_Assets_Name_Annex_RowGuid] UNIQUE NONCLUSTERED([AS_NME_RowGuid]),
CONSTRAINT [PK__AS_NME_Assets_Name_Annex] PRIMARY KEY CLUSTERED([AS_NME_ID] ASC, [AS_NME_PositedAt] DESC, [AS_NME_PositedBy] ASC)
WITH (FILLFACTOR = 95)
GO
CREATE TABLE [org].[AS_GEO_Assets_Location_Posit]
[AS_GEO_ID] INT NOT NULL IDENTITY(1, 1),
[AS_GEO_AS_ID] INT NOT NULL CONSTRAINT [FK__AS_GEO_Assets_Location_Posit_AS_GEO_AS_ID] REFERENCES [org].[AS_Assets]([AS_ID]),
[AS_GEO_Longitude_Deg] DECIMAL(17, 14) NOT NULL CONSTRAINT [CR__AS_GEO_Assets_Location_Posit_Longitude_Deg_L] CHECK([AS_GEO_Longitude_Deg] >= -180.0),
CONSTRAINT [CR__AS_GEO_Assets_Location_Posit_Longitude_Deg_U] CHECK([AS_GEO_Longitude_Deg] <= 180.0),
[AS_GEO_Latitude_Deg] DECIMAL(17, 14) NOT NULL CONSTRAINT [CR__AS_GEO_Assets_Location_Posit_Latitude_Deg_L] CHECK([AS_GEO_Latitude_Deg] >= -90.0),
CONSTRAINT [CR__AS_GEO_Assets_Location_Posit_Latitude_Deg_U] CHECK([AS_GEO_Latitude_Deg] <= 90.0),
[AS_GEO_Wgs84] AS geography::STPointFromText('POINT(' + CONVERT(VARCHAR(19), [AS_GEO_Longitude_Deg], 0) + ' ' + CONVERT(VARCHAR(19), [AS_GEO_Latitude_Deg], 0) + ')', 4326),
[AS_GEO_Checksum] AS BINARY_CHECKSUM([AS_GEO_Longitude_Deg], [AS_GEO_Latitude_Deg])
PERSISTED NOT NULL,
[AS_GEO_ChangedAt] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__AS_GEO_Assets_Location_Posit_ChangedAt] DEFAULT(SYSDATETIMEOFFSET()),
[AS_GEO_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__AS_GEO_Assets_Location_Posit_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
CONSTRAINT [UX__AS_GEO_Assets_Location_Posit_RowGuid] UNIQUE NONCLUSTERED([AS_GEO_RowGuid]),
CONSTRAINT [PK__AS_GEO_Assets_Location_Posit] PRIMARY KEY([AS_GEO_ID] ASC),
CONSTRAINT [UK__AS_GEO_Assets_Location_Posit] UNIQUE CLUSTERED([AS_GEO_AS_ID] ASC, [AS_GEO_ChangedAt] DESC, [AS_GEO_Checksum] ASC)
WITH (FILLFACTOR = 95)
GO
CREATE TABLE [org].[AS_GEO_Assets_Location_Annex]
[AS_GEO_ID] INT NOT NULL CONSTRAINT [FK__AS_GEO_Assets_Location_Annex_AS_GEO_ID] REFERENCES [org].[AS_GEO_Assets_Location_Posit]([AS_GEO_ID]),
[AS_GEO_PositedBy] INT NOT NULL CONSTRAINT [DF__AS_GEO_Assets_Location_Annex_PositedBy] DEFAULT([posit].[Get_PositorId]())
CONSTRAINT [FK__AS_GEO_Assets_Location_Annex_PositedBy] REFERENCES [posit].[PO_Positor]([PO_PositorId]),
[AS_GEO_PositedAt] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__AS_GEO_Assets_Location_Annex_PositedAt] DEFAULT(SYSDATETIMEOFFSET()),
[AS_GEO_PositReliability] TINYINT NOT NULL CONSTRAINT [DF__AS_GEO_Assets_Location_Annex_PositRel] DEFAULT(50),
[AS_GEO_PositReliable] AS CONVERT(BIT, CASE WHEN [AS_GEO_PositReliability] > 0 THEN 1 ELSE 0 END)
PERSISTED NOT NULL,
[AS_GEO_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__AS_GEO_Assets_Location_Annex_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
CONSTRAINT [UX__AS_GEO_Assets_Location_Annex_RowGuid] UNIQUE NONCLUSTERED([AS_GEO_RowGuid]),
CONSTRAINT [PK__AS_GEO_Assets_Location_Annex] PRIMARY KEY CLUSTERED([AS_GEO_ID] ASC, [AS_GEO_PositedAt] DESC, [AS_GEO_PositedBy] ASC)
WITH (FILLFACTOR = 95)
GO
CREATE FUNCTION [org].[AS_NME_Assets_Name_Posit_RW]
@ChangedBefore DATETIMEOFFSET(7) = '9999-12-31'
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN
SELECT
[p].[AS_NME_ID],
[p].[AS_NME_AS_ID],
[p].[AS_NME_AssetTag],
[p].[AS_NME_AssetName],
[p].[AS_NME_AssetDetail],
[p].[AS_NME_Checksum],
[p].[AS_NME_ChangedAt]
FROM
[org].[AS_NME_Assets_Name_Posit] [p]
WHERE
[p].[AS_NME_ChangedAt] < @ChangedBefore;
GO
CREATE FUNCTION [org].[AS_NME_Assets_Name_Annex_RW]
@PositedBefore DATETIMEOFFSET(7) = '9999-12-31'
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN
SELECT
[a].[AS_NME_ID],
[a].[AS_NME_PositedBy],
[a].[AS_NME_PositedAt],
[a].[AS_NME_PositReliability],
[a].[AS_NME_PositReliable]
FROM
[org].[AS_NME_Assets_Name_Annex] [a]
WHERE[a].[AS_NME_PositedAt] < @PositedBefore;
GO
CREATE FUNCTION [org].[AS_NME_Assets_Name_RW]
@ChangedBefore DATETIMEOFFSET(7) = '9999-12-31',
@PositedBefore DATETIMEOFFSET(7) = '9999-12-31'
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN
SELECT
[p].[AS_NME_ID],
[p].[AS_NME_AS_ID],
[p].[AS_NME_AssetTag],
[p].[AS_NME_AssetName],
[p].[AS_NME_AssetDetail],
[p].[AS_NME_Checksum],
[p].[AS_NME_ChangedAt],
[a].[AS_NME_PositedBy],
[a].[AS_NME_PositedAt],
[a].[AS_NME_PositReliability],
[a].[AS_NME_PositReliable]
FROM
[org].[AS_NME_Assets_Name_Posit_RW](@ChangedBefore) [p]
INNER JOIN
[org].[AS_NME_Assets_Name_Annex_RW](@PositedBefore) [a]
ON [a].[AS_NME_ID] = [p].[AS_NME_ID]
AND [a].[AS_NME_PositedAt] = (
SELECT TOP 1
[s].[AS_NME_PositedAt]
FROM
[org].[AS_NME_Assets_Name_Annex_RW](@PositedBefore) [s]
WHERE [s].[AS_NME_ID] = [p].[AS_NME_ID]
ORDER BY
[s].[AS_NME_PositedAt] DESC
GO
CREATE FUNCTION [org].[AS_GEO_Assets_Location_Posit_RW]
@ChangedBefore DATETIMEOFFSET(7) = '9999-12-31'
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN
SELECT
[p].[AS_GEO_ID],
[p].[AS_GEO_AS_ID],
[p].[AS_GEO_Longitude_Deg],
[p].[AS_GEO_Latitude_Deg],
[p].[AS_GEO_Wgs84],
[p].[AS_GEO_Checksum],
[p].[AS_GEO_ChangedAt]
FROM
[org].[AS_GEO_Assets_Location_Posit] [p]
WHERE
[p].[AS_GEO_ChangedAt] < @ChangedBefore;
GO
CREATE FUNCTION [org].[AS_GEO_Assets_Location_Annex_RW]
@PositedBefore DATETIMEOFFSET(7) = '9999-12-31'
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN
SELECT
[a].[AS_GEO_ID],
[a].[AS_GEO_PositedBy],
[a].[AS_GEO_PositedAt],
[a].[AS_GEO_PositReliability],
[a].[AS_GEO_PositReliable]
FROM
[org].[AS_GEO_Assets_Location_Annex] [a]
WHERE
[a].[AS_GEO_PositedAt] < @PositedBefore;
GO
CREATE FUNCTION [org].[AS_GEO_Assets_Location_RW]
@ChangedBefore DATETIMEOFFSET(7) = '9999-12-31',
@PositedBefore DATETIMEOFFSET(7) = '9999-12-31'
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN
SELECT
[p].[AS_GEO_ID],
[p].[AS_GEO_AS_ID],
[p].[AS_GEO_Longitude_Deg],
[p].[AS_GEO_Latitude_Deg],
[p].[AS_GEO_Wgs84],
[p].[AS_GEO_Checksum],
[p].[AS_GEO_ChangedAt],
[a].[AS_GEO_PositedBy],
[a].[AS_GEO_PositedAt],
[a].[AS_GEO_PositReliability],
[a].[AS_GEO_PositReliable]
FROM
[org].[AS_GEO_Assets_Location_Posit_RW](@ChangedBefore) [p]
INNER JOIN
[org].[AS_GEO_Assets_Location_Annex_RW](@PositedBefore) [a]
ON [a].[AS_GEO_ID] = [p].[AS_GEO_ID]
AND [a].[AS_GEO_PositedAt] = (
SELECT TOP 1
[s].[AS_GEO_PositedAt]
FROM
[org].[AS_GEO_Assets_Location_Annex_RW](@PositedBefore) [s]
WHERE [s].[AS_GEO_ID] = [p].[AS_GEO_ID]
ORDER BY
[s].[AS_GEO_PositedAt] DESC
GO
CREATE FUNCTION [org].[AS_Assets_Rewind]
@ChangedBefore DATETIMEOFFSET(7) = '9999-12-31',
@PositedBefore DATETIMEOFFSET(7) = '9999-12-31',
@Reliable BIT = 1
RETURNS TABLE
WITH SCHEMABINDING
AS
RETURN
SELECT
[AS].[AS_ID],
[AS].[AS_PositedBy],
[AS].[AS_PositedAt],
[NME].[AS_NME_ID],
[NME].[AS_NME_AS_ID],
[NME].[AS_NME_AssetTag],
[NME].[AS_NME_AssetName],
[NME].[AS_NME_AssetDetail],
[NME].[AS_NME_Checksum],
[NME].[AS_NME_ChangedAt],
[NME].[AS_NME_PositedBy],
[NME].[AS_NME_PositedAt],
[NME].[AS_NME_PositReliability],
[NME].[AS_NME_PositReliable],
[GEO].[AS_GEO_ID],
[GEO].[AS_GEO_AS_ID],
[GEO].[AS_GEO_Longitude_Deg],
[GEO].[AS_GEO_Latitude_Deg],
[GEO].[AS_GEO_Wgs84],
[GEO].[AS_GEO_Checksum],
[GEO].[AS_GEO_ChangedAt],
[GEO].[AS_GEO_PositedBy],
[GEO].[AS_GEO_PositedAt],
[GEO].[AS_GEO_PositReliability],
[GEO].[AS_GEO_PositReliable]
FROM
[org].[AS_Assets] [AS]
INNER JOIN
[org].[AS_NME_Assets_Name_RW](@ChangedBefore, @PositedBefore) [NME]
ON [NME].[AS_NME_AS_ID] = [AS].[AS_ID]
AND [NME].[AS_NME_PositReliable] = @Reliable
AND [NME].[AS_NME_ID] = (
SELECT TOP 1
[NME_s].[AS_NME_ID]
FROM
[org].[AS_NME_Assets_Name_RW](@ChangedBefore, @PositedBefore) [NME_s]
WHERE [NME_s].[AS_NME_AS_ID] = [AS].[AS_ID]
ORDER BY
[NME_s].[AS_NME_ChangedAt] DESC,
[NME_s].[AS_NME_PositedAt] DESC
LEFT OUTER JOIN
[org].[AS_GEO_Assets_Location_RW](@ChangedBefore, @PositedBefore) [GEO]
ON [GEO].[AS_GEO_AS_ID] = [AS].[AS_ID]
AND [GEO].[AS_GEO_PositReliable] = @Reliable
AND [GEO].[AS_GEO_ID] = (
SELECT TOP 1
[GEO_s].[AS_GEO_ID]
FROM
[org].[AS_GEO_Assets_Location_RW](@ChangedBefore, @PositedBefore) [GEO_s]
WHERE [GEO_s].[AS_GEO_AS_ID] = [AS].[AS_ID]
ORDER BY
[GEO_s].[AS_GEO_ChangedAt] DESC,
[GEO_s].[AS_GEO_PositedAt] DESC
GO
CREATE VIEW [org].[AS_NME_Assets_Name_SK]
WITH SCHEMABINDING
AS
SELECT
[p].[AS_NME_ID],
[p].[AS_NME_AS_ID],
[p].[AS_NME_AssetTag],
[p].[AS_NME_AssetName],
[p].[AS_NME_AssetDetail],
[p].[AS_NME_Checksum],
[p].[AS_NME_ChangedAt],
[a].[AS_NME_PositedBy],
[a].[AS_NME_PositedAt],
[a].[AS_NME_PositReliability],
[a].[AS_NME_PositReliable]
FROM
[org].[AS_NME_Assets_Name_Posit] [p]
INNER JOIN
[org].[AS_NME_Assets_Name_Annex] [a]
ON [a].[AS_NME_ID] = [p].[AS_NME_ID];
GO
CREATE UNIQUE CLUSTERED INDEX [PK__AS_NME_Assets_Name_SK]
ON [org].[AS_NME_Assets_Name_SK]
[AS_NME_AS_ID] ASC,
[AS_NME_ChangedAt] DESC,
[AS_NME_PositedAt] DESC,
[AS_NME_PositedBy] ASC,
[AS_NME_PositReliable] ASC
WITH (FILLFACTOR = 95);
GO
CREATE VIEW [org].[AS_GEO_Assets_Location_SK]
WITH SCHEMABINDING
AS
SELECT
[p].[AS_GEO_ID],
[p].[AS_GEO_AS_ID],
[p].[AS_GEO_Wgs84],
[p].[AS_GEO_Checksum],
[p].[AS_GEO_ChangedAt],
[a].[AS_GEO_PositedBy],
[a].[AS_GEO_PositedAt],
[a].[AS_GEO_PositReliability],
[a].[AS_GEO_PositReliable]
FROM
[org].[AS_GEO_Assets_Location_Posit] [p]
INNER JOIN
[org].[AS_GEO_Assets_Location_Annex] [a]
ON [a].[AS_GEO_ID] = [p].[AS_GEO_ID];
GO
CREATE UNIQUE CLUSTERED INDEX [PK__AS_GEO_Assets_Location_SK]
ON [org].[AS_GEO_Assets_Location_SK]
[AS_GEO_AS_ID] ASC,
[AS_GEO_ChangedAt] DESC,
[AS_GEO_PositedAt] DESC,
[AS_GEO_PositedBy] ASC,
[AS_GEO_PositReliable] ASC
WITH (FILLFACTOR = 95);
GO
CREATE VIEW [org].[AS_Assets_Current]
WITH SCHEMABINDING
AS
SELECT
[AS].[AS_ID],
[AS].[AS_PositedBy],
[AS].[AS_PositedAt],
[AS].[AS_NME_ID],
[AS].[AS_NME_AS_ID],
[AS].[AS_NME_AssetTag],
[AS].[AS_NME_AssetName],
[AS].[AS_NME_AssetDetail],
[AS].[AS_NME_Checksum],
[AS].[AS_NME_ChangedAt],
[AS].[AS_NME_PositedBy],
[AS].[AS_NME_PositedAt],
[AS].[AS_NME_PositReliability],
[AS].[AS_NME_PositReliable],
[AS].[AS_GEO_ID],
[AS].[AS_GEO_AS_ID],
[AS].[AS_GEO_Longitude_Deg],
[AS].[AS_GEO_Latitude_Deg],
[AS].[AS_GEO_Wgs84],
[AS].[AS_GEO_Checksum],
[AS].[AS_GEO_ChangedAt],
[AS].[AS_GEO_PositedBy],
[AS].[AS_GEO_PositedAt],
[AS].[AS_GEO_PositReliability],
[AS].[AS_GEO_PositReliable]
FROM [org].[AS_Assets_Rewind](DEFAULT, DEFAULT, DEFAULT) [AS];
GO
CREATE TRIGGER [org].[AS_Assets_Current_Insert]
ON [org].[AS_Assets_Current]
INSTEAD OF INSERT
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
IF(EXISTS(SELECT [i].[AS_ID] FROM [inserted] [i] WHERE [i].[AS_ID] IS NOT NULL))
RAISERROR('INSERT into the anchor identity column ''AS_ID'' is not allowed.', 16, 1) WITH NOWAIT;
IF(EXISTS(SELECT [i].[AS_NME_ID] FROM [inserted] [i] WHERE [i].[AS_NME_ID] IS NOT NULL))
RAISERROR('INSERT into the identity column ''AS_NME_ID'' is not allowed.', 16, 1) WITH NOWAIT;
IF(EXISTS(SELECT [i].[AS_NME_AS_ID] FROM [inserted] [i] WHERE [i].[AS_NME_AS_ID] IS NOT NULL))
RAISERROR('INSERT into the foreign key identity column ''AS_NME_AS_ID'' is not allowed.', 16, 1) WITH NOWAIT;
IF(EXISTS(SELECT [i].[AS_NME_Checksum] FROM [inserted] [i] WHERE [i].[AS_NME_Checksum] IS NOT NULL))
RAISERROR('INSERT into the computed column ''AS_NME_Checksum'' is not allowed.', 16, 1) WITH NOWAIT;
IF(EXISTS(SELECT [i].[AS_NME_PositReliable] FROM [inserted] [i] WHERE [i].[AS_NME_PositReliable] IS NOT NULL))
RAISERROR('INSERT into the computed column ''AS_NME_PositReliable'' is not allowed.', 16, 1) WITH NOWAIT;
IF(EXISTS(SELECT [i].[AS_GEO_ID] FROM [inserted] [i] WHERE [i].[AS_GEO_ID] IS NOT NULL))
RAISERROR('INSERT into the identity column ''AS_GEO_ID'' is not allowed.', 16, 1) WITH NOWAIT;
IF(EXISTS(SELECT [i].[AS_GEO_AS_ID] FROM [inserted] [i] WHERE [i].[AS_GEO_AS_ID] IS NOT NULL))
RAISERROR('INSERT into the foreign key identity column ''AS_GEO_AS_ID'' is not allowed.', 16, 1) WITH NOWAIT;
IF(EXISTS(SELECT [i].[AS_GEO_Checksum] FROM [inserted] [i] WHERE [i].[AS_GEO_Checksum] IS NOT NULL))
RAISERROR('INSERT into the computed column ''AS_GEO_Checksum'' is not allowed.', 16, 1) WITH NOWAIT;
IF(EXISTS(SELECT [i].[AS_GEO_PositReliable] FROM [inserted] [i] WHERE [i].[AS_GEO_PositReliable] IS NOT NULL))
RAISERROR('INSERT into the computed column ''AS_GEO_PositReliable'' is not allowed.', 16, 1) WITH NOWAIT;
IF(EXISTS(SELECT [i].[AS_GEO_Wgs84] FROM [inserted] [i] WHERE [i].[AS_GEO_Wgs84] IS NOT NULL))
RAISERROR('INSERT into the computed column ''AS_GEO_Wgs84'' is not allowed.', 16, 1) WITH NOWAIT;
DECLARE @Reliability INT = 50;
DECLARE @Now DATETIMEOFFSET(7) = SYSDATETIMEOFFSET();
DECLARE @PositedBy INT;
EXECUTE @PositedBy = [posit].[Return_PositorId];
DECLARE @Inserted TABLE
[AS_PositedBy] INT NOT NULL,
[AS_PositedAt] DATETIMEOFFSET(7) NOT NULL,
[AS_NME_AssetTag] VARCHAR(12) NOT NULL CHECK([AS_NME_AssetTag] <> ''),
[AS_NME_AssetName] NVARCHAR(24) NOT NULL CHECK([AS_NME_AssetName] <> ''),
[AS_NME_AssetDetail] NVARCHAR(48) NOT NULL CHECK([AS_NME_AssetDetail] <> ''),
[AS_NME_Checksum] AS BINARY_CHECKSUM([AS_NME_AssetTag], [AS_NME_AssetName], [AS_NME_AssetDetail])
PERSISTED NOT NULL,
[AS_NME_ChangedAt] DATETIMEOFFSET(7) NOT NULL,
[AS_NME_PositedBy] INT NOT NULL,
[AS_NME_PositedAt] DATETIMEOFFSET(7) NOT NULL,
[AS_NME_PositReliability] TINYINT NOT NULL,
[AS_GEO_Longitude_Deg] DECIMAL(17, 14) NULL CHECK([AS_GEO_Longitude_Deg] >= -180.0), CHECK([AS_GEO_Longitude_Deg] <= 180.0),
[AS_GEO_Latitude_Deg] DECIMAL(17, 14) NULL CHECK([AS_GEO_Latitude_Deg] >= -90.0), CHECK([AS_GEO_Latitude_Deg] <= 90.0),
[AS_GEO_Checksum] AS BINARY_CHECKSUM([AS_GEO_Longitude_Deg], [AS_GEO_Latitude_Deg])
PERSISTED NOT NULL,
[AS_GEO_ChangedAt] DATETIMEOFFSET(7) NOT NULL,
[AS_GEO_PositedBy] INT NOT NULL,
[AS_GEO_PositedAt] DATETIMEOFFSET(7) NOT NULL,
[AS_GEO_PositReliability] TINYINT NOT NULL,
[ROW_ID] INT NOT NULL,
PRIMARY KEY([ROW_ID] ASC)
INSERT INTO @Inserted
[AS_PositedBy],
[AS_PositedAt],
[AS_NME_AssetTag],
[AS_NME_AssetName],
[AS_NME_AssetDetail],
[AS_NME_ChangedAt],
[AS_NME_PositedBy],
[AS_NME_PositedAt],
[AS_NME_PositReliability],
[AS_GEO_Longitude_Deg],
[AS_GEO_Latitude_Deg],
[AS_GEO_ChangedAt],
[AS_GEO_PositedBy],
[AS_GEO_PositedAt],
[AS_GEO_PositReliability],
[ROW_ID]
SELECT
COALESCE([i].[AS_PositedBy], @PositedBy),
COALESCE([i].[AS_PositedAt], @Now),
[i].[AS_NME_AssetTag],
[i].[AS_NME_AssetName],
[i].[AS_NME_AssetDetail],
COALESCE([i].[AS_NME_ChangedAt], @Now),
COALESCE([i].[AS_NME_PositedBy], @PositedBy),
COALESCE([i].[AS_NME_PositedAt], @Now),
COALESCE([i].[AS_NME_PositReliability], @Reliability),
[i].[AS_GEO_Longitude_Deg],
[i].[AS_GEO_Latitude_Deg],
COALESCE([i].[AS_GEO_ChangedAt], @Now),
COALESCE([i].[AS_GEO_PositedBy], @PositedBy),
COALESCE([i].[AS_GEO_PositedAt], @Now),
COALESCE([i].[AS_GEO_PositReliability], @Reliability),
ROW_NUMBER() OVER (PARTITION BY [i].[AS_ID] ORDER BY [i].[AS_ID])
FROM
[inserted] [i]
LEFT OUTER JOIN
[org].[AS_Assets_Current] [c]
ON [c].[AS_NME_Checksum] = BINARY_CHECKSUM([i].[AS_NME_AssetTag], [i].[AS_NME_AssetName], [i].[AS_NME_AssetDetail])
WHERE
[i].[AS_ID] IS NULL
AND [i].[AS_NME_ID] IS NULL
AND [i].[AS_NME_AS_ID] IS NULL
AND [i].[AS_GEO_ID] IS NULL
AND [i].[AS_GEO_AS_ID] IS NULL
AND [c].[AS_NME_AS_ID] IS NULL;
DECLARE @Anchor TABLE
[ROW_ID] INT NOT NULL IDENTITY(1, 1),
[AS_ID] INT NOT NULL,
PRIMARY KEY([ROW_ID] ASC),
UNIQUE CLUSTERED([AS_ID] ASC)
INSERT INTO [org].[AS_Assets]
[AS_PositedBy],
[AS_PositedAt]
OUTPUT
[inserted].[AS_ID]
INTO
@Anchor
[AS_ID]
SELECT
[i].[AS_PositedBy],
[i].[AS_PositedAt]
FROM
@Inserted [i]
ORDER BY
[i].[ROW_ID] ASC;
DECLARE @NME_Posit TABLE
[AS_NME_ID] INT NOT NULL,
[AS_NME_Checksum] INT NOT NULL,
PRIMARY KEY([AS_NME_ID] ASC),
UNIQUE CLUSTERED([AS_NME_Checksum] ASC)
INSERT INTO [org].[AS_NME_Assets_Name_Posit]
[AS_NME_AS_ID],
[AS_NME_AssetTag],
[AS_NME_AssetName],
[AS_NME_AssetDetail],
[AS_NME_ChangedAt]
OUTPUT
[inserted].[AS_NME_ID],
[inserted].[AS_NME_Checksum]
INTO
@NME_Posit
[AS_NME_ID],
[AS_NME_Checksum]
SELECT
[a].[AS_ID],
[i].[AS_NME_AssetTag],
[i].[AS_NME_AssetName],
[i].[AS_NME_AssetDetail],
[i].[AS_NME_ChangedAt]
FROM
@Inserted [i]
LEFT OUTER JOIN
@Anchor [a]
ON [a].[ROW_ID] = [i].[ROW_ID]
WHERE [a].[AS_ID] IS NOT NULL;
INSERT INTO [org].[AS_NME_Assets_Name_Annex]
[AS_NME_ID],
[AS_NME_PositedBy],
[AS_NME_PositedAt],
[AS_NME_PositReliability]
SELECT
[p].[AS_NME_ID],
[i].[AS_NME_PositedBy],
[i].[AS_NME_PositedAt],
[i].[AS_NME_PositReliability]
FROM
@Inserted [i]
INNER JOIN
@NME_Posit [p]
ON [p].[AS_NME_Checksum] = [i].[AS_NME_Checksum];
DECLARE @GEO_Posit TABLE
[AS_GEO_ID] INT NOT NULL,
[AS_GEO_Checksum] INT NOT NULL,
PRIMARY KEY([AS_GEO_ID] ASC),
UNIQUE CLUSTERED([AS_GEO_Checksum] ASC)
INSERT INTO [org].[AS_GEO_Assets_Location_Posit]
[AS_GEO_AS_ID],
[AS_GEO_Longitude_Deg],
[AS_GEO_Latitude_Deg],
[AS_GEO_ChangedAt]
OUTPUT
[inserted].[AS_GEO_ID],
[inserted].[AS_GEO_Checksum]
INTO
@GEO_Posit
[AS_GEO_ID],
[AS_GEO_Checksum]
SELECT
[a].[AS_ID],
[i].[AS_GEO_Longitude_Deg],
[i].[AS_GEO_Latitude_Deg],
[i].[AS_NME_ChangedAt]
FROM
@Inserted [i]
LEFT OUTER JOIN
@Anchor [a]
ON [a].[ROW_ID] = [i].[ROW_ID]
WHERE [a].[AS_ID] IS NOT NULL
AND [i].[AS_GEO_Longitude_Deg] IS NOT NULL
AND [i].[AS_GEO_Latitude_Deg] IS NOT NULL;
INSERT INTO [org].[AS_GEO_Assets_Location_Annex]
[AS_GEO_ID],
[AS_GEO_PositedBy],
[AS_GEO_PositedAt],
[AS_GEO_PositReliability]
SELECT
[p].[AS_GEO_ID],
[i].[AS_GEO_PositedBy],
[i].[AS_GEO_PositedAt],
[i].[AS_GEO_PositReliability]
FROM
@Inserted [i]
INNER JOIN
@GEO_Posit [p]
ON [p].[AS_GEO_Checksum] = [i].[AS_GEO_Checksum];
END;
GO
CREATE TRIGGER [org].[AS_Assets_Current_Update]
ON [org].[AS_Assets_Current]
INSTEAD OF UPDATE
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
IF(UPDATE([AS_ID]))
RAISERROR('Cannot update the anchor identity column ''AS_ID''.', 16, 1);
IF(UPDATE([AS_PositedBy]))
RAISERROR('Cannot update the anchor column ''AS_PositedBy''.', 16, 1);
IF(UPDATE([AS_PositedAt]))
RAISERROR('Cannot update the anchor column ''AS_PositedAt''.', 16, 1);
IF(UPDATE([AS_NME_ID]))
RAISERROR('Cannot update the identity column ''AS_NME_ID''.', 16, 1);
IF(UPDATE([AS_NME_AS_ID]))
RAISERROR('Cannot update the foreign key identity column ''AS_NME_AS_ID''.', 16, 1);
IF(UPDATE([AS_NME_Checksum]))
RAISERROR('Cannot update the computed column ''AS_NME_Checksum''.', 16, 1);
IF(UPDATE([AS_NME_PositReliable]))
RAISERROR('Cannot update the computed column ''AS_NME_PositReliable''.', 16, 1);
IF(UPDATE([AS_GEO_ID]))
RAISERROR('Cannot update the identity column ''AS_GEO_ID''.', 16, 1);
IF(UPDATE([AS_GEO_AS_ID]))
RAISERROR('Cannot update the foreign key identity column ''AS_GEO_AS_ID''.', 16, 1);
IF(UPDATE([AS_GEO_Checksum]))
RAISERROR('Cannot update the computed column ''AS_GEO_Checksum''.', 16, 1);
IF(UPDATE([AS_GEO_PositReliable]))
RAISERROR('Cannot update the computed column ''AS_GEO_PositReliable''.', 16, 1);
IF(UPDATE([AS_GEO_Wgs84]))
RAISERROR('Cannot update the computed column ''AS_GEO_Wgs84''.', 16, 1);
DECLARE @Now DATETIMEOFFSET(7) = SYSDATETIMEOFFSET();
DECLARE @PositedBy INT;
EXECUTE @PositedBy = [posit].[Return_PositorId];
DECLARE @Inserted TABLE
[AS_ID] INT NOT NULL,
[AS_PositedBy] INT NOT NULL,
[AS_PositedAt] DATETIMEOFFSET(7) NOT NULL,
[AS_NME_ID] INT NOT NULL,
[AS_NME_AS_ID] INT NOT NULL,
[AS_NME_AssetTag] VARCHAR(12) NULL CHECK([AS_NME_AssetTag] <> ''),
[AS_NME_AssetName] NVARCHAR(24) NULL CHECK([AS_NME_AssetName] <> ''),
[AS_NME_AssetDetail] NVARCHAR(48) NULL CHECK([AS_NME_AssetDetail] <> ''),
[AS_NME_Checksum] AS BINARY_CHECKSUM([AS_NME_AssetTag], [AS_NME_AssetName], [AS_NME_AssetDetail])
PERSISTED NOT NULL,
[AS_NME_ChangedAt] DATETIMEOFFSET(7) NOT NULL,
[AS_NME_PositedBy] INT NOT NULL,
[AS_NME_PositedAt] DATETIMEOFFSET(7) NOT NULL,
[AS_NME_PositReliability] TINYINT NOT NULL,
[AS_GEO_ID] INT NULL,
[AS_GEO_AS_ID] INT NULL,
[AS_GEO_Longitude_Deg] DECIMAL(17, 14) NULL CHECK([AS_GEO_Longitude_Deg] >= -180.0), CHECK([AS_GEO_Longitude_Deg] <= 180.0),
[AS_GEO_Latitude_Deg] DECIMAL(17, 14) NULL CHECK([AS_GEO_Latitude_Deg] >= -90.0), CHECK([AS_GEO_Latitude_Deg] <= 90.0),
[AS_GEO_Checksum] AS BINARY_CHECKSUM([AS_GEO_Longitude_Deg], [AS_GEO_Latitude_Deg])
PERSISTED NOT NULL,
[AS_GEO_ChangedAt] DATETIMEOFFSET(7) NULL,
[AS_GEO_PositedBy] INT NULL,
[AS_GEO_PositedAt] DATETIMEOFFSET(7) NULL,
[AS_GEO_PositReliability] TINYINT NULL,
[ROW_ID] INT NOT NULL,
PRIMARY KEY([ROW_ID] ASC)
INSERT INTO @Inserted
[AS_ID],
[AS_PositedBy],
[AS_PositedAt],
[AS_NME_ID],
[AS_NME_AS_ID],
[AS_NME_AssetTag],
[AS_NME_AssetName],
[AS_NME_AssetDetail],
[AS_NME_ChangedAt],
[AS_NME_PositedBy],
[AS_NME_PositedAt],
[AS_NME_PositReliability],
[AS_GEO_ID],
[AS_GEO_AS_ID],
[AS_GEO_Longitude_Deg],
[AS_GEO_Latitude_Deg],
[AS_GEO_ChangedAt],
[AS_GEO_PositedBy],
[AS_GEO_PositedAt],
[AS_GEO_PositReliability],
[ROW_ID]
SELECT
[i].[AS_ID],
CASE WHEN (UPDATE([AS_PositedBy])) THEN [i].[AS_PositedBy] ELSE @PositedBy END,
CASE WHEN (UPDATE([AS_PositedAt])) THEN [i].[AS_PositedAt] ELSE @Now END,
[i].[AS_NME_ID],
[i].[AS_NME_AS_ID],
[i].[AS_NME_AssetTag],
[i].[AS_NME_AssetName],
[i].[AS_NME_AssetDetail],
CASE WHEN (UPDATE([AS_NME_ChangedAt])) THEN [i].[AS_NME_ChangedAt] ELSE @Now END,
CASE WHEN (UPDATE([AS_NME_PositedBy])) THEN [i].[AS_NME_PositedBy] ELSE @PositedBy END,
CASE WHEN (UPDATE([AS_NME_PositedAt])) THEN [i].[AS_NME_PositedAt] ELSE @Now END,
[i].[AS_NME_PositReliability],
[i].[AS_GEO_ID],
[i].[AS_GEO_AS_ID],
[i].[AS_GEO_Longitude_Deg],
[i].[AS_GEO_Latitude_Deg],
CASE WHEN (UPDATE([AS_GEO_ChangedAt])) THEN [i].[AS_GEO_ChangedAt] ELSE @Now END,
CASE WHEN (UPDATE([AS_GEO_PositedBy])) THEN [i].[AS_GEO_PositedBy] ELSE @PositedBy END,
CASE WHEN (UPDATE([AS_GEO_PositedAt])) THEN [i].[AS_GEO_PositedAt] ELSE @Now END,
[i].[AS_GEO_PositReliability],
ROW_NUMBER() OVER (PARTITION BY [i].[AS_ID] ORDER BY [i].[AS_ID])
FROM
[inserted] [i]
LEFT OUTER JOIN
[org].[AS_Assets_Current] [c]
ON [c].[AS_NME_Checksum] = BINARY_CHECKSUM([i].[AS_NME_AssetTag], [i].[AS_NME_AssetName], [i].[AS_NME_AssetDetail])
LEFT OUTER JOIN
[org].[AS_Assets_Current] [g]
ON [g].[AS_GEO_Checksum] = BINARY_CHECKSUM([i].[AS_GEO_Longitude_Deg], [i].[AS_GEO_Latitude_Deg])
WHERE
[c].[AS_NME_AS_ID] IS NULL
OR [g].[AS_NME_AS_ID] IS NULL;
DECLARE @NME_Posit TABLE
[AS_NME_ID] INT NOT NULL,
[AS_NME_Checksum] INT NOT NULL,
PRIMARY KEY([AS_NME_ID] ASC),
UNIQUE CLUSTERED([AS_NME_Checksum] ASC)
INSERT INTO [org].[AS_NME_Assets_Name_Posit]
[AS_NME_AS_ID],
[AS_NME_AssetTag],
[AS_NME_AssetName],
[AS_NME_AssetDetail],
[AS_NME_ChangedAt]
OUTPUT
[inserted].[AS_NME_ID],
[inserted].[AS_NME_Checksum]
INTO
@NME_Posit
[AS_NME_ID],
[AS_NME_Checksum]
SELECT
[i].[AS_NME_AS_ID],
[i].[AS_NME_AssetTag],
[i].[AS_NME_AssetName],
[i].[AS_NME_AssetDetail],
[i].[AS_NME_ChangedAt]
FROM @Inserted [i];
INSERT INTO [org].[AS_NME_Assets_Name_Annex]
[AS_NME_ID],
[AS_NME_PositedBy],
[AS_NME_PositedAt],
[AS_NME_PositReliability]
SELECT
[p].[AS_NME_ID],
CASE WHEN (UPDATE([AS_NME_PositedBy])) THEN [i].[AS_NME_PositedBy] ELSE @PositedBy END,
CASE WHEN (UPDATE([AS_NME_PositedAt])) THEN [i].[AS_NME_PositedAt] ELSE @Now END,
[i].[AS_NME_PositReliability]
FROM @Inserted [i]
INNER JOIN
@NME_Posit [p]
ON [p].[AS_NME_Checksum] = [i].[AS_NME_Checksum];
INSERT INTO [org].[AS_NME_Assets_Name_Annex]
[AS_NME_ID],
[AS_NME_PositedBy],
[AS_NME_PositedAt],
[AS_NME_PositReliability]
SELECT
[i].[AS_NME_ID],
CASE WHEN (UPDATE([AS_NME_PositedBy])) THEN [i].[AS_NME_PositedBy] ELSE @PositedBy END,
CASE WHEN (UPDATE([AS_NME_PositedAt])) THEN [i].[AS_NME_PositedAt] ELSE @Now END,
[i].[AS_NME_PositReliability]
FROM [inserted] [i]
LEFT OUTER JOIN
@NME_Posit [p]
ON [p].[AS_NME_Checksum] = BINARY_CHECKSUM([i].[AS_NME_AssetTag])
WHERE
[p].[AS_NME_ID] IS NULL;
DECLARE @GEO_Posit TABLE
[AS_GEO_ID] INT NOT NULL,
[AS_GEO_Checksum] INT NOT NULL,
PRIMARY KEY([AS_GEO_ID] ASC),
UNIQUE CLUSTERED([AS_GEO_Checksum] ASC)
INSERT INTO [org].[AS_GEO_Assets_Location_Posit]
[AS_GEO_AS_ID],
[AS_GEO_Longitude_Deg],
[AS_GEO_Latitude_Deg],
[AS_GEO_ChangedAt]
OUTPUT
[inserted].[AS_GEO_ID],
[inserted].[AS_GEO_Checksum]
INTO
@GEO_Posit
[AS_GEO_ID],
[AS_GEO_Checksum]
SELECT
[i].[AS_GEO_AS_ID],
[i].[AS_GEO_Longitude_Deg],
[i].[AS_GEO_Latitude_Deg],
[i].[AS_GEO_ChangedAt]
FROM @Inserted [i];
INSERT INTO [org].[AS_GEO_Assets_Location_Annex]
[AS_GEO_ID],
[AS_GEO_PositedBy],
[AS_GEO_PositedAt],
[AS_GEO_PositReliability]
SELECT
[p].[AS_GEO_ID],
CASE WHEN (UPDATE([AS_GEO_PositedBy])) THEN [i].[AS_GEO_PositedBy] ELSE @PositedBy END,
CASE WHEN (UPDATE([AS_GEO_PositedAt])) THEN [i].[AS_GEO_PositedAt] ELSE @Now END,
[i].[AS_GEO_PositReliability]
FROM @Inserted [i]
INNER JOIN
@GEO_Posit [p]
ON [p].[AS_GEO_Checksum] = [i].[AS_GEO_Checksum];
INSERT INTO [org].[AS_GEO_Assets_Location_Annex]
[AS_GEO_ID],
[AS_GEO_PositedBy],
[AS_GEO_PositedAt],
[AS_GEO_PositReliability]
SELECT
[i].[AS_GEO_ID],
CASE WHEN (UPDATE([AS_GEO_PositedBy])) THEN [i].[AS_GEO_PositedBy] ELSE @PositedBy END,
CASE WHEN (UPDATE([AS_GEO_PositedAt])) THEN [i].[AS_GEO_PositedAt] ELSE @Now END,
[i].[AS_GEO_PositReliability]
FROM [inserted] [i]
LEFT OUTER JOIN
@GEO_Posit [p]
ON [p].[AS_GEO_Checksum] = BINARY_CHECKSUM([i].[AS_GEO_Longitude_Deg], [i].[AS_GEO_Latitude_Deg])
WHERE
[p].[AS_GEO_ID] IS NULL;
END;
GO
CREATE TRIGGER [org].[AS_Assets_Current_Delete]
ON [org].[AS_Assets_Current]
INSTEAD OF DELETE
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Now DATETIMEOFFSET(7) = SYSDATETIMEOFFSET();
DECLARE @PositedBy INT;
EXECUTE @PositedBy = [posit].[Return_PositorId];
INSERT INTO [org].[AS_NME_Assets_Name_Annex]
[AS_NME_ID],
[AS_NME_PositedBy],
[AS_NME_PositedAt],
[AS_NME_PositReliability]
SELECT
[d].[AS_NME_ID],
@PositedBy,
@Now,
0
FROM
[deleted] [d];
INSERT INTO [org].[AS_GEO_Assets_Location_Annex]
[AS_GEO_ID],
[AS_GEO_PositedBy],
[AS_GEO_PositedAt],
[AS_GEO_PositReliability]
SELECT
[d].[AS_GEO_ID],
@PositedBy,
@Now,
0
FROM
[deleted] [d];
END;
GO
INSERT INTO [org].[AS_Assets_Current]
[AS].[AS_NME_AssetTag],
[AS].[AS_NME_AssetName],
[AS].[AS_NME_AssetDetail],
[AS].[AS_GEO_Longitude_Deg],
[AS].[AS_GEO_Latitude_Deg]
SELECT
[AS].[AS_NME_AssetTag],
[AS].[AS_NME_AssetName],
[AS].[AS_NME_AssetDetail],
[AS].[AS_GEO_Longitude_Deg],
[AS].[AS_GEO_Latitude_Deg]
FROM (VALUES
('999', 'Dallas Test 3', 'Dallas Test 3', NULL, NULL, 'Plant', 'AUT', NULL)
) [AS]([AS_NME_AssetTag], [AS_NME_AssetName], [AS_NME_AssetDetail], [AS_GEO_Longitude_Deg], [AS_GEO_Latitude_Deg], [CN_ADD_Type_ID], [CN_ADD_Country_ID], [CN_ADD_State]);
GO

Similar Messages

  • ORA- 01461 : Can Bind a long value only for insert into a column error

    I was trying to create a new job using dbms_job.isubmit
    begin
    sys.dbms_job.isubmit(job => 1111,
    what => '',
    next_date => to_date('21-10-2011 03:00:00', 'dd-mm-yyyy hh24:mi:ss'),
    interval => 'TRUNC(SYSDATE+1)+3/24');
    commit;
    end;
    However, I am getting the error 'ORA- 01461 : Can Bind a long value only for insert into a column error'.
    I tried a lot but cant get rid of.
    Any help gurus ?

    You have an error in the code:
    1. you don't provide a value for 'what' - you have to tell Oracle what it should execute when it submits the job.
    And remember - with ISUBMIT the next_date parameter has datatype VARCHAR2 - SUBMIT uses datatype DATE. So make sure you provide a VARCHAR2 value and do not rely on implicit conversion.
    >
    PROCEDURE DBMS_JOB.ISUBMIT
    (job IN BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN VARCHAR2
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);
    PROCEDURE DBMS_JOB.SUBMIT
    (job OUT BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN DATE DEFAULT SYSDATE
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);

  • Split one column  value and insert into multiple columns

    hi
    am new to plsql .
    i want to split a characters from one column and insert into multiple columns
    i tried used substr function the symbol ',' vary his place dynamically ,so i can't apply substr function.
    for eg:  before split
    col1 :
    col2 :
    col3 :
    col4 :
    colu5: adsdf,fgrty,erfth,oiunth,okujt
    after split
    col1 :adsd
    col2 :fgrty
    col3 :erfth
    col4 :oiunth
    col5 : adsdf,fgrty,erfth,oiunth,okujt
    can anyone help me
    thanks
    Edited by: 800324 on Dec 23, 2010 8:28 AM
    Edited by: 800324 on Dec 23, 2010 8:36 AM

    How about:
    SQL> create table t
      2  (col1 varchar2(30)
      3  ,col2 varchar2(30)
      4  ,col3 varchar2(30)
      5  ,col4 varchar2(30)
      6  ,col5 varchar2(30)
      7  );
    Table created.
    SQL> insert into t (col5) values ('adsdf,fgrty,erfth,oiunth,okujt');
    1 row created.
    SQL> insert into t (col5) values ('x,y');
    1 row created.
    SQL> insert into t (col5) values ('a,b,c,d');
    1 row created.
    SQL> select * from t;
    COL1                           COL2                           COL3                           COL4                           COL5
                                                                                                                                adsdf,fgrty,erfth,oiunth,okujt
                                                                                                                                x,y
                                                                                                                                a,b,c,d
    3 rows selected.
    SQL>
    SQL> merge into t a
      2  using ( with t1 as ( select col5||',' col5
      3                       from   t
      4                     )
      5          select substr(col5, 1, instr(col5, ',', 1, 1)-1) col1
      6          ,      substr(col5, instr(col5, ',', 1, 1)+1, instr(col5, ',', 1, 2)- instr(col5, ',', 1, 1)-1) col2
      7          ,      substr(col5, instr(col5, ',', 1, 2)+1, instr(col5, ',', 1, 3)- instr(col5, ',', 1, 2)-1) col3
      8          ,      substr(col5, instr(col5, ',', 1, 3)+1, instr(col5, ',', 1, 4)- instr(col5, ',', 1, 3)-1) col4
      9          ,      rtrim(col5, ',') col5
    10          from   t1
    11        ) b
    12  on ( a.col5 = b.col5 )
    13  when matched then update set a.col1 = b.col1
    14                             , a.col2 = b.col2
    15                             , a.col3 = b.col3
    16                             , a.col4 = b.col4
    17  when not matched then insert (a.col1) values (null);
    3 rows merged.
    SQL> select * from t;
    COL1                           COL2                           COL3                           COL4                           COL5
    adsdf                          fgrty                          erfth                          oiunth                         adsdf,fgrty,erfth,oiunth,okujt
    x                              y                                                                                            x,y
    a                              b                              c                              d                              a,b,c,d
    3 rows selected.
    SQL> Assuming you're on 9i...

  • Insert into date column using EJB3.0 and toplink not working

    Hi All,
    I'm getting the following error whenever I attempt to insert a date value into my Oracle database.
    [TopLink Fine]: 2006.08.08 05:53:21.973--UnitOfWork(14806807)--Connection(14714759)--Thread(Thread[RMICallHand
    ler-0,5,RequestThreadGroup])--
    INSERT INTO EMP (EMPNO, ENAME, SAL, HIRE_DATE) VALUES (156, 'John', 2.0, {ts '2006-08-08 17:53:21.973'})
    [TopLink Warning]: 2006.08.08 05:53:22.036--UnitOfWork(14806807)--Thread(Thread[RMICallHandler-0,5,RequestThreadGroup])--
    Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)):
    oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00904: invalid column name
    The cause seems to be clear enough; from the sql above it seems that the timestamp syntax isn't being interpreted properly by either toplink or the JDBC driver , (I'm using whatever driver that comes with OC4J 10.1.3).
    I've seen somewhere that you can call setUseNativeSQL() in toplink but how do I get hold of the toplink session from an entity bean?
    That sounds like an awkward workaround anyway, what other workarounds are open to us?
    Thanks,
    C

    C,
    I don't use TopLink, but I suggest you set the "processEscapes" [Oracle database connection] property to "true", as described in the JDBC User's Guide and Reference.
    Oracle documentation can be accessed from here:
    http://www.oracle.com/technology/documentation/index.html
    Good Luck,
    Avi.

  • Insert into NVARCHAR2 columns(ORA_01461, ORA-01026)

    Hi,
    Oracle8i Client 8.1.5 (OCI8)
    Oracle9i Client 9.0.1 (OCI9)
    Oracle8i/9i DB
    I want to insert strings into a table with two NVARCHAR2 columns with OCI.
    NLS_NCHAR_CHARACTERSET is UTF8 (DB). The provided String is encoded in Windows-1252.
    The supplied buffers in the OCIBindByPos have a size of 200bytes each.
    ->With OCI8 I'm getting the message:
    "ORA-01026 multiple buffers of size > 4000 in the bind list"
    If only one NVARCHAR2 column is involved (or if I use normal
    VARCHAR2 instead) it works fine.
    ->With OCI9 I get the message:
    "ORA-01461 can bind a LONG value only for insert into a LONG column"
    But only, if I set the OCI_ATTR_MAXDATA_SIZE attribute.
    If I do not set the OCI_ATTR_MAXDATA_SIZE attribute, it works, but if
    I supply a buffer bigger than 1333 bytes in the OCIBindByPos for the second
    NVARCHAR2 column, then ORA_01461 happens. The buffer for the first NVARCHAR2
    column can be set to a higher values
    ->The same behaviour occurs with NCHAR, NCLOB (->national character types)
    These are the main steps:
    OCIBindByPos((OCIStmt *) pStmtInsert, (OCIBind **) &pBind,
    (OCIError *) pError, (ub4) i, (dvoid *)pData,
    (sb4) bufferSize, //200bytes
    (ub2) dataTypeSQLT, //SQLT_STR
    (dvoid *) pIndicator, (ub2 *) 0, (ub2 *) 0, (ub4) 0,
              (ub4 *) 0, (ub4) OCI_DEFAULT);
    OCIAttrSet((dvoid *) pBind, OCI_HTYPE_BIND,
    &Frm, //SQLCS_NCHAR
         0, OCI_ATTR_CHARSET_FORM, (OCIError *) pError);
    OCIAttrSet((dvoid *) pBind, OCI_HTYPE_BIND,
    (dvoid *) &charSet, //WE8MSWIN1252
         0, OCI_ATTR_CHARSET_ID, (OCIError *) pError);
    OCIAttrSet((dvoid *) pBind, OCI_HTYPE_BIND,
    (dvoid *) &maxDataSize, //->size of the column in bytes
    0, OCI_ATTR_MAXDATA_SIZE, (OCIError *) pError);
    OCIStmtExecute((OCISvcCtx *) pServiceContext, (OCIStmt *) pStmtInsert,(OCIError *) pError,
    (ub4) 1, (ub4) 0, (OCISnapshot *) 0, (OCISnapshot *) 0,
    OCI_COMMIT_ON_SUCCESS);
    Any ideas?
    Thanks,
    Axel

    I found this link referring to a similar problem that was apparently fixed in version 10.2.0.4 of the server: ORA-01461: can bind a LONG value only for insert into a LONG column Should I try to upgrade the server and see if that fixes things?

  • PHP create array/variable for two dropdowns and insert into one column

    Hello,
    I have been trying for days to get this to work. Any help would be very appreciated.
    The dropdown code:
    <?php //Dropdowns for hours and minutes
    $hour = array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
    $min = array (.00, .25, .50 ,.75);
    echo '<span class="red">Hours :</span><select name="hour">';
    foreach ($hour as $value1) {
    echo "<option value=\"$value1\">$value1</option>\n";
    echo '</select>';
    echo '<span class="red">Quarter Hours :</span><select name="min"';
    foreach ($min as $value2) {
    echo "<option value=\"$value2\">$value2</option>\n";
    echo '</select>';
    //Dropdowns for hours and minutes
    //Create variable to send to the time field using a hidden field
    function input_time($value1, $value2) {
    $time = count($value1 + $value2);
    return $input_time;
    ?>
    <input name="time" type="hidden" value="<?php echo "$input_time";?>" />
    The Schema:
    CREATE TABLE `ND_time_sheet` (
      `time_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `day` varchar(10) NOT NULL DEFAULT '',
      `date` varchar(8) NOT NULL DEFAULT '',
      `project_id` varchar(8) DEFAULT NULL,
      `non_bill` tinytext,
      `staff_id` varchar(5) NOT NULL DEFAULT '',
      `time` decimal(3,2) unsigned zerofill DEFAULT NULL,
      `type` varchar(30) NOT NULL DEFAULT '',
      PRIMARY KEY (`time_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1
    Thanks!

    9677670421 wrote:
    hi... i am trying to do the same but i am having the 2D array of data when first time if i clicked in table it should show the the first row values and if i again clicked same value should show in the second row and so on... but insted in my code if clicked (using insert into array ) at a time it is showing two rows of the data pl help me ..........
    This seems to be a different problem, so you should have started a new thread instead.
    Can you show us your code, tell us what you are clicking, tell us what you get and what you expect to get instead. Thanks.
    LabVIEW Champion . Do more with less code and in less time .

  • How to parse a delimited string and insert into different columns?

    Hi Experts,
    I need to parse a delimited string ':level1_value:level2_value:level3_value:...' to 'level1_value', 'level2_value', etc., and insert them into different columns of one table as one row:
    Table_Level (Level1, Level2, Level3, ...)
    I know I can use substr and instr to get level value one by one and insert into Table, but I'm wondering if there's better ways to do it?
    Thanks!

    user9954260 wrote:
    However, there is one tiny problem - the delimiter from the source system is a '|' When I replace your test query with | as delimiter instead of the : it fails. Interestingly, if I use ; it works. See below:
    with t as (
    select 'str1|str2|str3||str5|str6' x from dual union all
    select '|str2|str3|str4|str5|str6' from dual union all
    select 'str1|str2|str3|str4|str5|' from dual union all
    select 'str1|str2|||str5|str6' from dual)
    select x,
    regexp_replace(x,'^([^|]*).*$','\1') y1,
    regexp_replace(x,'^[^|]*|([^|]*).*$','\1') y2,
    regexp_replace(x,'^([^|]*|){2}([^|]*).*$','\2') y3,
    regexp_replace(x,'^([^|]*|){3}([^|]*).*$','\2') y4,
    regexp_replace(x,'^([^|]*|){4}([^|]*).*$','\2') y5,
    regexp_replace(x,'^([^|]*|){5}([^|]*).*$','\2') y6
    from t;
    The "bar" or "pipe" symbol is a special character, also called a metacharacter.
    If you want to use it as a literal in a regular expression, you will need to escape it with a backslash character (\).
    Here's the solution -
    test@ORA11G>
    test@ORA11G> --
    test@ORA11G> with t as (
      2    select 'str1|str2|str3||str5|str6' x from dual union all
      3    select '|str2|str3|str4|str5|str6' from dual union all
      4    select 'str1|str2|str3|str4|str5|' from dual union all
      5    select 'str1|str2|||str5|str6' from dual)
      6  --
      7  select x,
      8         regexp_replace(x,'^([^|]*).*$','\1') y1,
      9         regexp_replace(x,'^[^|]*\|([^|]*).*$','\1') y2,
    10         regexp_replace(x,'^([^|]*\|){2}([^|]*).*$','\2') y3,
    11         regexp_replace(x,'^([^|]*\|){3}([^|]*).*$','\2') y4,
    12         regexp_replace(x,'^([^|]*\|){4}([^|]*).*$','\2') y5,
    13         regexp_replace(x,'^([^|]*\|){5}([^|]*).*$','\2') y6
    14  from t;
    X                         Y1      Y2      Y3      Y4      Y5      Y6
    str1|str2|str3||str5|str6 str1    str2    str3            str5    str6
    |str2|str3|str4|str5|str6         str2    str3    str4    str5    str6
    str1|str2|str3|str4|str5| str1    str2    str3    str4    str5
    str1|str2|||str5|str6     str1    str2                    str5    str6
    4 rows selected.
    test@ORA11G>
    test@ORA11G>isotope
    PS - it works for semi-colon character ";" because it is not a metacharacter. So its literal value is considered by the regex engine for matching.
    Edited by: isotope on Feb 26, 2010 11:09 AM

  • ORA-07445 (solaris 9.0.) when inserting into LONG column

    i am getting a core-dump when inserting into a table w/ long column. running 9.0.1 on solaris.
    ORA-07445: exception encountered: core dump [kghtshrt()+68] [SIGSEGV] [Address not mapped to object] [0x387BBF0] [] []
    if anyone has ANY input - please provide it ... i am desperate at this point.
    i am trying to avoid upgrading to 9.2.0 to solve this problem.
    regards -
    jerome

    You should report this in a service request on http://metalink.oracle.com.
    It is a shame that you put all the effort here to describe your problem, but on the other hand you can now also copy & paste the question to Oracle Support.
    Because you are using 10.2.0.3; I am guessing that you have a valid service contract...

  • Need to insert into NVARCHAR2 column in a database table

    I need to insert into a table with column type NVARCHAR2(2000) in java.
    Cant use normal setString on that column. How can I do this using PreparedStatement in Java?

    The scenario is:
    I have to read a CSV file which contains a column in Urdu language, and show it on the JTable first.
    Then I have to import the JTable contents into a database table.
    Database Table structure is:
    CREATE TABLE IMPORT_TMP (
    ctype          VARCHAR2(3),
    urdu_name  NVARCHAR2(2000)
    );My java code which inserts into the database table is:
                    Vector dataVector = tableModel.getDataVector();
                    rowVector = (Vector) dataVector.get(row);
                  cType = "";
                    if (rowVector.get(INDEX_BANK) != null) {
                        cType = rowVector.get(INDEX_CTYPE).toString();
                    urduName = "";
                    if (rowVector.get(INDEX_URDU_NAME) != null) {
                        urduName = rowVector.get(INDEX_URDU_NAME).toString();
                    statementInsert.setString(1, cType);
                    statementInsert.setString(2, urduName);I also applied Renderer on the table column, my renderer class is:
    public class LangFontRenderer extends JLabel implements TableCellRenderer {
        private Font customFont;
        public LangFontRenderer(Font font) {
            super();
            customFont = font;
            System.out.println("font = " + font.getFontName());
            this.setFont(font);
        @Override
        public Component getTableCellRendererComponent(JTable table,
                Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            if (value != null) {
                if (value instanceof String) {
                    setText((String) value);
                    return this;
            return this;
        @Override
        public Font getFont() {
            return customFont;
        // overriding other methods for performance reasons only
        @Override
        public void invalidate() {
        @Override
        public boolean isOpaque() {
            return true;
        @Override
        public void repaint() {
        @Override
        public void revalidate() {
        @Override
        public void validate() {
    }I applied the renderer on the column as:
            TableColumn col = IATable.getColumnModel().getColumn(INDEX_URDU_NAME);
            LangFontRenderer langRenderer = new LangFontRenderer(new java.awt.Font("Urdu Naskh Asiatype", 0, 11));
            col.setCellRenderer(langRenderer);It does not give any error but when i query on the database table it does not show the column data in Urdu language.
    Also it does not show the correct value on JTable column, some un-identified symbols.
    Furthermore when I open the CSV file in notepad, it shows the correct language in that column, as I have installed the Urdu language and font on my system.

  • Error while inserting into blob column through PL/SQL

    Hi All,
    I am trying to insert into column having blob as datatype.
    INSERT INTO imagedb(image_name, content,description) VALUES ('logo.png',
    ?{file 'c:\logo.png'}, 'logo');
    it gives me error Unknown JDBC escape sequence:
    Is there anything wrong in above insert syntax for inserting into BLOB data type.
    Can any body please help me.
    Regards,
    Hiren

    It is not valid SQL as far as Oracle SQL is concerned. I assume that the file construct is suppose to replace that with the contents of the file?
    What happens when the file size exceeds the max length of the SQL command?
    And do you have any idea what will happen to the SQL Shared Pool on Oracle that needs to store the entire SQL command for every single SQL command passed to it? The whole purpose of the Shared Pool is for storing shared SQL. Not non-sharable SQL containing hardcoded values.
    Bind variable are to be used.. if you expect Oracle to perform like only Oracle can.
    And my bet is that you have not even bothered to read [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14249/toc.htm]Oracle® Database Application Developer's Guide - Large Objects guide....

  • Insert into blob column from form6i

    Dear all,
    I have a question....
    I need to develop an application with form6i which gets the filename and path from user and inserts the content of the file in a table with blob column...
    the files may be in any format...How can I do it in oracle form 6i..our database is 10g...
    If anybody has a sample please send me :[email protected]
    ThanX
    Farnaz

    If you want to insert a string and next convert to BLOB, you use the next SQL
    PreparedStatement ps = connectionObject.prepareStatement("INSERT INTO TEST_BLOB(NO,STR) VALUES(?,TO_BLOB(?))");and next
    ps.setInt(1, "1");
    ps.setString(2,"sample string here");

  • When I import a text file(comma separated )into a numbers spread sheet all the data goes into one column. Why does the text not go into separate columns based on the commas.

    When I import a text file(comma separated) into a numbers spreadsheet all the data goes into one column instead of individual columns based on the comma separators.  Excel allows you to do this during the import..  Is there a way to accomplish this in numbers without opening it in Excel and the importing into Numbers.

    Your user info says iPad. This is the OS X Numbers forum. Assuming you are using OS X… Be sure the file is named with a .csv suffix.
    (I don't have an iPad, so I don't know the iOS answer.)

  • How to insert into date column based on other columns?

    Hi
    I have four columns in a table called game named as
    R_Day - Type - Number
    R_Month - Type - Number
    R_Year - Type - Number
    R_Date - Type - Date
    I have around 1000 records and i want to fill R_Date column based on the data in the R_Day,R_Month,R_Year.
    How to write a query to fill the R_Date column based on other three columns.
    Thanks
    srinivas

    select
    to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
    dt from (select 23 R_Day,07 R_Month,2007 R_Year from
    dual);
    Hi,
    Update <Table Name> set R_Date=select
    to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
    from <Table Name>
    Regds.
    Nirmal
    SQL>  select * from test;
         R_DAY    R_MONTH     R_YEAR R_DATE
             1          1       2007
            21         11       2007
    SQL> update test
      2  set r_date = select to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
      3  from test;
    set r_date = select to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
    ERROR at line 2:
    ORA-00936: missing expression
    SQL> update test
      2  set r_date = to_date(r_day||'-'||r_month||'-'||r_year,'dd-mm-yyyy');
    2 rows updated.
    SQL> select * from test;
         R_DAY    R_MONTH     R_YEAR R_DATE
             1          1       2007 01-JAN-07
            21         11       2007 21-NOV-07
    NB:Please test before posting..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Insert into multiple tables; grab id from first

    I apologize if this has been answered elsewhere, but I tried
    searching and got no results.
    I'm trying to insert the contents of one form into two
    tables. After inserting some fields into one table, I want to grab
    the key/id from the first table into the second table with the
    other fields.
    I've tried a few different things, including trying to use
    SCOPE_IDENTITY(), but just kept getting lots of errors.
    The current version of my code works perfectly, *except for
    the fact that it doesn't insert the ID*!
    Can anyone tell me what I'm doing wrong? or offer another way
    of doing this?
    Thanks for your help, as usual.

    MarianneStone wrote:
    > The current version of my code works perfectly, *except
    for the fact that it doesn't insert > the ID*!
    > Can anyone tell me what I'm doing wrong?
    The EmployeeID is not inserted because the getMyID query
    cannot find the newly inserted record. When using a UUID to
    identify the new records ..
    <cfquery name="qAddDeptHead" datasource="#db#"
    result="result">
    INSERT INTO Employee(... , EmpUUID)
    VALUES ( ... , '#CreateUUID()#')
    </cfquery>
    You have to use that _same_ UUID to find the record, _not_
    create a new one.
    <cfquery name="getMyID" datasource="#db#">
    SELECT EmployeeID, EmpUUID
    FROM Employee
    WHERE Employee.EmpUUID='#UseTheSameUUIDFromTheFirstQuery#'
    </cfquery>
    As an aside, you could probably do this in two queries not
    three. Just drop the second SELECT query and use an INSERT
    INTO/SELECT .. FROM Table statement instead. Plus you should also
    consider using cfqueryparam for your query parameters. It has many
    benefits.
    http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_p-q_18.html#1102474
    > Can anyone ... offer another way of doing this?
    There are a few options. For ColdFusion 8, you could use the
    result attribute. After running the INSERT you can grab the new
    EmployeeID by using #yourResult.IDENTITYCOL#
    <cfquery name="qAddDeptHead" datasource="#db#"
    result="yourResult">
    INSERT INTO Employee ( Columns here )
    VALUES (... values here ...)
    </cfquery>
    For earlier versions, you can either use SCOPE_IDENTITY() or
    a UUID value - as you are currently doing now.
    > I've tried a few different things, including trying to
    use SCOPE_IDENTITY(),
    > but just kept getting lots of errors.
    If you use SCOPE_IDENTITY() turn off the rowcount, or the
    query variable "qAddDeptHead" may be undefined when you try and use
    it.
    <cfquery name="qAddDeptHead" datasource="#db#"
    result="yourResult">
    SET NOCOUNT ON;
    INSERT INTO Employee ( Columns here )
    VALUES (... values here ...)
    SELECT EmployeeID AS NewEmployeeID
    SET NOCOUNT OFF;
    </cfquery>
    <cfquery name="qNewEmpPosition" datasource="#db#">
    INSERT INTO EmployeePositions(EmployeeID, .... )
    VALUES ( #qAddDeptHead.NewEmployeeID#, ....)
    </cfquery>

  • INSERTING INTO A TABLE FROM ANOTHER TABLE

    Hi,
    I am having a table called emp in which 5 columns are there, I want to insert some rows from another table called employees, only into three columns of emp table through a sub query.
    Is this scenario is possible, I tried so many queries but it is not working out.
    Can any body help me out.
    The columns in emp table is
    empno, ename, doj, designation, salary, deptno, mgrid
    The columns in employees table is
    empno, name, hiredate, post, salary, commission, deptno, mgr
    I want to insert into empno, ename, doj, designation columns of emp table from the employees table empno, name, hiredate, post columns.
    Ramesh.

    It looks like your EMP table has 7 columns, not 5, and you want to insert into 4 columns, not 3.
    insert into emp
      (empno, ename, doj, designation)
      select empno, name, hiredate, post
        from employees;

Maybe you are looking for

  • XI  problem file to file scenario

    Trying to send vendor from Java application to R/3.  Now the  process is source xml file is place in one directory of FTP  and XI picks the file to transform the data After mapping the data to the target structure , XI is supposed to place the file b

  • Error code 2324 when trying to download iTunes for windows 8.

    I started by trying to update my iTunes, and was given an error message and was unable to open it. I've deleted/uninstalled it, each time I try to reinstall it or download it again, I get the error code 2324. I have no idea how to proceed or what I a

  • Error while closing an Internal Order

    Hello, I received an error while closing an order saying . +"There is still a purchase order commitment for Order 'XYZ' ". Error no. K0447. The order has been completely settled. I don't see any error on PO side What could be causing this and how can

  • Can't ReOpen PP CC after it "quit unexpectedly"

    When I try to open Premiere Pro CC, it begins to load but immediately goes to an Apple Problem Report page saying "Adobe Premiere Pro CC quit unexpectedly".  It says to click the reopen button to start Premiere again, but when I do this, it goes stra

  • Site Put button greyed out in CS4

    i am attempting to migrate from MS front page to dreamweaver. as i try to publish one of my sites using the Site>Put command, i'm finding that it is greyed out, along with many other menu items. the ftp settings/server connection seem to be testing j