Goldengate 列轉換樣例
Goldengate提供的Column Conversion Functions中包括對應的num轉str,str轉num等函式,如下:
如果OGG提供的函式不能滿足需求,我的想法是還能利用oracle本身的函式寫對應的query語句來完成轉換,比如
jy_date date
jy_date_str varchar2
MAP sales.account, TARGET sales.account, SQLEXEC (ID lookup, QUERY "select to_char(jy_date, 'yyyy-dd-mm') into target_col from account",
COLMAP (newacct_id = account_id, jy_date_str = lookup.target_col);
NUMSTR
Use the @NUMSTR function to convert a string (character) column or value into a number.
Use @NUMSTR to do either of the following:
● Map a string (character) to a number.
● Use a string column that contains only numbers in an arithmetic expression.
Syntax @NUMSTR ()
Example PAGE_NUM = @NUMSTR (ALPHA_PAGE_NO)
STRNUM
Use the @STRNUM function to convert a number into a string and specify the output format
and padding.
Syntax @STRNUM (
Argument Description
within quotes.
Argument Description
Argument Description
LEFT Left justify, without padding.
LEFTSPACE Left justify, fill the rest of the target column with spaces.
RIGHT Right justify, fill the rest of the target column with spaces. If the value of a column
is a negative value, the spaces are added before the minus sign. For example,
strnum(Col1, right) used for a column value of -1.27 becomes ###-1.27, assuming the
target column allows 7 digits. The minus sign is not counted as a digit, but the
decimal is.
RIGHTZERO Right justify, fill the rest of the target column with zeros. If the value of a column
is a negative value, the zeros are added after the minus sign and before the
numbers. For example, strnum(Col1, rightzero) used for a column value of -1.27
becomes -0001.27, assuming the target column allows 7 digits. The minus sign is
not counted as a digit, but the decimal is.
(all but LEFT). For example:
◆ strnum(Col1, right, 6) used for a column value of -1.27 becomes ##-1.27. The minus
sign is not counted as a digit, but the decimal is.
◆ strnum(Col1, rightzero, 6) used for a column value of -1.27 becomes -001.27. The
minus sign is not counted as a digit, but the decimal is.
Example Assuming a source column named NUM has a value of 15 and the target column’s maximum
length is 5 characters, the following examples show the different types of results obtained
with formatting options.
Function statement Result (# denotes a space)
CHAR1 = @STRNUM (NUM, LEFT) 15
CHAR1 = @STRNUM (NUM, LEFTSPACE) 15###
CHAR1 = @STRNUM (NUM, RIGHTZERO) 00015
CHAR1 = @STRNUM (NUM, RIGHT) ###15
Function statement Result (# denotes a space)
CHAR1 = @STRNUM (NUM, LEFTSPACE, 4) 15##
CHAR1 = @STRNUM (NUM, RIGHTZERO, 4) 0015
CHAR1 = @STRNUM (NUM, RIGHT, 4) ##15
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7199859/viewspace-719849/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- javascript將類陣列轉換為陣列程式碼例項JavaScript陣列
- javascript將字串轉換為陣列程式碼例項JavaScript字串陣列
- js將陣列元素轉換為字串程式碼例項JS陣列字串
- 行列轉換,列行轉換統計
- oracle行列轉換-字串轉換成多列Oracle字串
- oracle行列轉換-多列轉換成字串Oracle字串
- SQL 列行轉換SQL
- oracle行列轉換-行轉列Oracle
- oracle行列轉換-列轉行Oracle
- excel日期格式轉換中,怎樣將“/”轉換成“-”Excel
- 陣列型別轉換陣列型別
- c#列舉轉換C#
- PHP陣列轉換為js陣列PHP陣列JS
- echarts圖表樣式轉換Echarts
- 抽樣之逆轉換方法
- GoldenGate中使用strcat和strext進行資料轉換Go
- PHP 物件轉換成陣列PHP物件陣列
- JavaScript 字串轉換為陣列JavaScript字串陣列
- 陣列轉換成List集合陣列
- javascript字串和陣列轉換JavaScript字串陣列
- List 和 陣列 的轉換陣列
- jQuery將類陣列物件轉換為陣列jQuery陣列物件
- 【Java】int[] 陣列 和 Integer陣列的轉換Java陣列
- 【轉】css樣式自動換行(強制換行)CSS
- json字串 轉換為陣列JSON字串陣列
- Java 中陣列轉換為 ListJava陣列
- Java 集合與陣列互相轉換Java陣列
- JavaScript將陣列轉換為字串JavaScript陣列字串
- 陣列和集合的相互轉換陣列
- 字串和陣列的相互轉換字串陣列
- char(16)列的資料轉換
- linux命令列大小寫轉換Linux命令列
- 字串:怎樣轉換字串為數字型別? (轉)字串型別
- 將字串陣列轉換為浮點數陣列字串陣列
- js將偽陣列或者集合轉換為陣列JS陣列
- JavaScript二維陣列轉換成一維陣列JavaScript陣列
- 怎麼樣轉換pdf格式為Word?
- 【CDB】怎樣轉換non-CDB to CDB