GoldenGate @STRCAT亂碼

abstractcyj發表於2013-07-22
今天在測試GoldeGate Oracle到MSSQL的資料同步時,發現GoldenGate的對列的計算會出現亂碼:

GGSCI (chenyj-WorkPC) 37> view param msrep1
REPLICAT MSREP1
setenv(NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
targetdb ggs_nc
GETTRUNCATES
APPLYNOOPUPDATES
SOURCEDEFS dirdef/source.def
--MAP scott.customer, TARGET dbo.customer;
map scott.myemps, target dbo.myemps,
COLMAP (USEDEFAULTS,
WAGES = @COMPUTE(SALARY * 12)
FULL_NAME = @STRCAT(LAST_NAME,",",FIRST_NAME));


first_name與last_name都可以正確的從oracle複製到MSSQL,但是當涉及到字串的拼接時,結果就出現了問題。可以檢視圖片

可以採用觸發器的方式解決問題
附MSSQL觸發器:

-- ================================================
-- Template generated from Template Explorer using:
-- Create Trigger (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- See additional Create Trigger templates for more
-- examples of different Trigger statements.
--
-- This block of comments will not be included in
-- the definition of the function.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:
-- Create date:
-- Description:
-- =============================================
alter TRIGGER my_trig
   ON  dbo.myemps
   after  INSERT
AS 
  declare @first_name varchar(200), @last_name varchar(200), @id numeric;
BEGIN


update myemps set full_name = inserted.first_name + inserted.last_name from inserted where inserted.id = myemps.id

    -- Insert statements for trigger here

END
GO



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8520577/viewspace-766843/,如需轉載,請註明出處,否則將追究法律責任。

相關文章