從挑夫古道遠眺望龍埤
望龍埤
基隆外木山
Total Pageviews
2014/05/31
2014/05/27
[iReport] Exported Excel Report But Has Missing Data
Problem
I am using iReport 5.5 in my project, the requirement is to use iReport to design report template, and export the report with pdf and xls format.
The problem is as I export pdf format, I can see complete data
but as I export xls format, the xls report has lost data in page header band.
Solution
The missing data problem results from the overlapping elements (even 1 pixel).
After I fixed the overlapping problems (add one more space between elements)
I can see complete data in xls report.
I am using iReport 5.5 in my project, the requirement is to use iReport to design report template, and export the report with pdf and xls format.
The problem is as I export pdf format, I can see complete data
but as I export xls format, the xls report has lost data in page header band.
Solution
The missing data problem results from the overlapping elements (even 1 pixel).
After I fixed the overlapping problems (add one more space between elements)
I can see complete data in xls report.
Labels:
iReport
2014/05/23
How do I sort an array of files according to their last modified dates?
Apache commons IO provide LastModifiedFileComparator to do file sorting based on its last modified date/time.
It provide two instance:
1. LASTMODIFIED_COMPARATOR: Last modified comparator instance
2. LASTMODIFIED_REVERSE: Reverse last modified comparator instance
Example
1. Read files from old to new
The console will print
2. Read files from new to old
The console will print
Reference
[1] http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/comparator/LastModifiedFileComparator.html
It provide two instance:
1. LASTMODIFIED_COMPARATOR: Last modified comparator instance
2. LASTMODIFIED_REVERSE: Reverse last modified comparator instance
Example
1. Read files from old to new
/**
* The main method.
*
* @param args
* the arguments
*/
public static void main(String args[]) {
Collection files =
FileUtils.listFiles(new File(FmsBatchConfig.INPUT_FOLDER_PATH), // assign file path
FileFilterUtils.prefixFileFilter("COP0407"), // assign file name
FalseFileFilter.FALSE);// include subdirectories
File[] fileArr = files.toArray(new File[files.size()]);
Arrays.sort(fileArr, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR);//from old to new
// print file name
for (File file : fileArr) {
System.out.println(file.getName()+"["+new Date(file.lastModified())+"]");
}
}
The console will print
COP0407_01_1030501.txt[Thu May 08 16:45:01 CST 2014]
COP0407_01_1030502.txt[Fri May 23 10:31:45 CST 2014]
2. Read files from new to old
/**
* The main method.
*
* @param args
* the arguments
*/
public static void main(String args[]) {
Collection files =
FileUtils.listFiles(new File(FmsBatchConfig.INPUT_FOLDER_PATH), // assign file path
FileFilterUtils.prefixFileFilter("COP0407"), // assign file name
FalseFileFilter.FALSE);// include subdirectories
File[] fileArr = files.toArray(new File[files.size()]);
Arrays.sort(fileArr, LastModifiedFileComparator.LASTMODIFIED_REVERSE);//from new to old
// print file name
for (File file : fileArr) {
System.out.println(file.getName()+"["+new Date(file.lastModified())+"]");
}
}
The console will print
COP0407_01_1030502.txt[Fri May 23 10:31:45 CST 2014]
COP0407_01_1030501.txt[Thu May 08 16:45:01 CST 2014]
Reference
[1] http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/comparator/LastModifiedFileComparator.html
Labels:
Apache Project
How to get all files with specific name in a directory(including subdirectories) using Commons IO
Requirement
1. Search specific directory called "COP0407"
2. Search through all directories called "COP0407"
Solution
Apache commons IO package provide FileUtils for general file manipulation, here has two sample code
1. Search specific directory called "COP0407" (exclude subdirectory)
The console will print
2. Search through all directories called "COP0407"
The console will print
Reference
[1] http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html#listFiles(java.io.File, org.apache.commons.io.filefilter.IOFileFilter, org.apache.commons.io.filefilter.IOFileFilter)
1. Search specific directory called "COP0407"
2. Search through all directories called "COP0407"
Supposed the directory is D:\psrdata\transfer\ftp\tofms, and has one subdirectory D:\psrdata\transfer\ftp\tofms\done
Solution
Apache commons IO package provide FileUtils for general file manipulation, here has two sample code
1. Search specific directory called "COP0407" (exclude subdirectory)
public static void main(String args[]) {
Collection files=
FileUtils.listFiles(new File(FmsBatchConfig.INPUT_FOLDER_PATH), //assign file path
FileFilterUtils.prefixFileFilter("COP0407"), //assign file name
FalseFileFilter.FALSE);//exclude subdirectories
//print file name
for(File file : files) {
System.out.println(file.getName());
}
}
The console will print
COP0407_01_1030501.txt
COP0407_01_1030502.txt
2. Search through all directories called "COP0407"
public static void main(String args[]) {
Collection files=
FileUtils.listFiles(new File(FmsBatchConfig.INPUT_FOLDER_PATH), //assign file path
FileFilterUtils.prefixFileFilter("COP0407"), //assign file name
TrueFileFilter.TRUE);//include subdirectories
//print file name
for(File file : files) {
System.out.println(file.getName());
}
}
The console will print
COP0407_01_1030501.txt
COP0407_01_1030502.txt
COP0407_01_1030501 (2).txt
Reference
[1] http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html#listFiles(java.io.File, org.apache.commons.io.filefilter.IOFileFilter, org.apache.commons.io.filefilter.IOFileFilter)
Labels:
Apache Project
2014/05/22
Create custom display filter in AngularJS
Requirement
Assume we have a drop down list which used to control the currency unit display.
It has two options, the first one is dollar. You can see the amount had been used dollar as its currency unit display.
The second option is a hundred million. You can see the amount had been used hundred million as its currency unit display.
Custom display filter
AngularJS provide some build-in filter, ex. number filter can used to determine If the input is not a number an empty string is returned.
In order to create a new filter, you are going to create a fms421rCurrency module and register your custom filter with this module:
//根據資料單位下拉單的選項,決定顯示於前端的金額單位是元或億
app.filter('fms421rCurrency', ['$filter', function ($filter, $scope) {
var fun = function(input, id) {
try{
input = BigDecimalROUND_HALF_UP(input, id);
return input;
}catch (e) {
return "";
}
};
return fun;
}]);
//根據資料單位下拉單的選項,決定金額是否要除以100000000
var BigDecimalROUND_HALF_UP = function(input, id){
if(input == 0){
return new BigDecimal("0");
}
var numb = new BigDecimal(input.toString());
var bil = new BigDecimal("100000000");
if ("02"==id) {//01:元, 02:億
numb = numb.divide(bil,0, BigDecimal.prototype.ROUND_HALF_UP);
}
return numb;
};
The syntax for using filters in Angular templates is as follows:
{{ expression | filter }}
We can apply the filter in the fms421r tempate page:
<td class="text-right border-right">
{{fms421rDto.dayRslt1|fms421rCurrency:model.dataunit.id|fms421rnative|number}}
</td>
Reference
Labels:
AngularJS
2014/05/21
虛擬股市交易系統
如果手上資金不夠,可以利用這個虛擬交易網站做股票進出、練功
順便觀察、參考其他人的進出 http://www.cmoney.tw/
[1] http://www.cmoney.tw/notes/note-detail.aspx?cid=22814&nid=11548&utm_source=Facebook&utm_medium=Timeline&utm_term=Notes&utm_content=nid%3D11548&utm_campaign=nid%3D11548
Labels:
Investment
2014/05/12
[Oracle] LISTAGG function
Requirement
The following SQL statement will retrieve multiple row of data
Reference
[1] http://docs.oracle.com/cd/E11882_01/server.112/e10592/functions089.htm#SQLRF55593
[2] http://www.oracle-developer.net/display.php?id=515
The following SQL statement will retrieve multiple row of data
SELECT PDATE, ACC || F_SYS_FIND_ACC_NM(:SCODE, :FYR, ACC, '000') AS ACC_NM FROM CF0006 WHERE ACC LIKE '24%' AND LENGTH(TRIM(ACC))=11
But my requirement is to turn these multiple row of data into a single row per group.
Solution
Oracle provided LISTAGG function to fulfill this kind of requirement.
LISTAGG is an aggregate function that can optionally be used as an analytic (i.e. the optional OVER() clause). The following elements are mandatory:
- the column or expression to be aggregated;
- the WITHIN GROUP keywords;
- the ORDER BY clause within the grouping.
The arguments to the function are subject to the following rules:
- The
measure_expr
can be any expression. Null values in the measure column are ignored. - The
delimiter_expr
designates the string that is to separate the measure values. This clause is optional and defaults toNULL
. - The
order_by_clause
determines the order in which the concatenated values are returned. The function is deterministic only if theORDER
BY
column list achieved unique ordering.
For example. The following group-set aggregate example lists, for each pdate in the CF0006 table, the ACC_NM in that CF0006 in order of their pdate (separate with comma):
SELECT PDATE, LISTAGG(ACC || F_SYS_FIND_ACC_NM(:SCODE, :FYR, ACC, '000'), ', ') WITHIN GROUP (ORDER BY PDATE) "ACC_NM_LIST" FROM CF0006 WHERE ACC LIKE '24%' AND LENGTH(TRIM(ACC))=11 GROUP BY PDATE;
Reference
[1] http://docs.oracle.com/cd/E11882_01/server.112/e10592/functions089.htm#SQLRF55593
[2] http://www.oracle-developer.net/display.php?id=515
Labels:
Oracle
2014/05/09
java.lang.NullPointerException: Cannot find parameter "json" from request.
Problem
I found out I fail to execute print functions in every function in my system.
And the console throw this exception message:
java.lang.NullPointerException: Cannot find parameter "json" from request.
at java.util.Objects.requireNonNull(Objects.java:226) ~[na:1.7.0_25]
at com.cht.commons.web.resolver.JsonParamResolver.resolveArgument(JsonParamResolver.java:34) ~[cht-commons-web-0.1.0-SNAPSHOT.jar:0.1.0-SNAPSHOT]
Root Cause
As I check its request header, it submit nothing
It result from my request had been blocked by AdBlock (Chrome Plug-in), which I installed yesterday. That's why I failed to execute every print function today.
As I disabled this Chrome plug-in, AdBlock, and check its request header again. We can see request header had submitted data.
Finally, my report function had recovered.
Labels:
JavaScript
2014/05/02
ORA-01422 Error From Oracle Function
Problem
I wrote an Oracle function on my own as bellows:
After I test it, it show this error message as bellows:
But this select SQL statement must return one record, if I provide all search criteria
Root cause
This error result from the parameter name cannot be equal to database column name. If yes, Oracle will not know what I am doing and ignore this search criteria. That's why it will have ORA-01422 error.
Solution
Just rename input parameter name from ASP to INPUT_ASP, then this problem can be resolved.
I wrote an Oracle function on my own as bellows:
CREATE OR REPLACE FUNCTION F_FMS420R_GET_ACCUM_AMTA (S_YYY_MM IN VARCHAR2 --起始年月 ,E_YYY_MM IN VARCHAR2 --結束年月 ,ASP IN VARCHAR2 --性質別 ) RETURN NUMBER IS AMT_A NUMBER(20, 2) := 0; BEGIN SELECT AMT_A INTO AMT_A FROM (SELECT YEAR, ASP, SUM(AMT_A) AS AMT_A FROM FMS420FA WHERE (YYY_MM BETWEEN S_YYY_MM AND E_YYY_MM) AND ASP = ASP GROUP BY YEAR, ASP); RETURN (AMT_A); END F_FMS420R_GET_ACCUM_AMTA;
After I test it, it show this error message as bellows:
ORA-01422: exact fetch returns more than requested number of rows (精確擷取傳回的列數超過所要求的列數)
ORA-06512: 在 "AP_PSR.F_FMS420R_GET_ACCUM_AMTA", line 9
ORA-06512: 在 line 11
But this select SQL statement must return one record, if I provide all search criteria
SELECT YEAR, ASP, SUM(B.AMT_A) AS AMT_A FROM FMS420FA B WHERE B.YYY_MM BETWEEN :S_YYY_MM AND :E_YYY_MM AND B.ASP = :ASP GROUP BY YEAR, ASP
Root cause
This error result from the parameter name cannot be equal to database column name. If yes, Oracle will not know what I am doing and ignore this search criteria. That's why it will have ORA-01422 error.
Solution
Just rename input parameter name from ASP to INPUT_ASP, then this problem can be resolved.
CREATE OR REPLACE FUNCTION F_FMS420R_GET_ACCUM_AMTA (S_YYY_MM IN VARCHAR2 --起始年月 ,E_YYY_MM IN VARCHAR2 --結束年月 ,INPUT_ASP IN VARCHAR2 --性質別 ) RETURN NUMBER IS AMT_A NUMBER(20, 2) := 0; BEGIN SELECT AMT_A INTO AMT_A FROM (SELECT YEAR, ASP, SUM(AMT_A) AS AMT_A FROM FMS420FA WHERE (YYY_MM BETWEEN S_YYY_MM AND E_YYY_MM) AND ASP = INPUT_ASP GROUP BY YEAR, ASP); RETURN (AMT_A); END F_FMS420R_GET_ACCUM_AMTA;
Labels:
Oracle
2014/04/29
[Apache Maven Problem] org/apache/maven/shared/ filtering/MavenFilteringException
Problem
As I build my JavaEE project with Apache Maven in Eclipse, it show this error message in my Eclipse
I try to do mvn clean install again, again, and again. But still in vain.
Solution
This problem may result from you have broken jar files. Try to retrieve jar files again. The steps are as follows:
Step1. Go to you .m2 folder, and delete everything.
As I build my JavaEE project with Apache Maven in Eclipse, it show this error message in my Eclipse
Multiple annotations found at this line:
Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed: A required class was missing while executing org.apache.maven.plugins:maven-resources-plugin:2.6:resources: org/apache/maven/shared/filtering/MavenFilteringException
-----------------------------------------------------
realm = plugin>org.apache.maven.plugins:maven-resources-plugin:2.6
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/javis-msi/.m2/repository/org/apache/maven/ plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.jar
urls[1] = file:/C:/Users/javis-msi/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar
urls[2] = file:/C:/Users/javis-msi/.m2/ repository/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.jar
urls[3] = file:/C:/Users/javis- msi/.m2/repository/commons-cli/commons-cli/1.0/commons-cli-1.0.jar
urls[4] = file:/C:/Users/javis-msi/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
urls[5] = file:/C:/Users/javis-msi/.m2/ repository/junit/junit/3.8.1/junit-3.8.1.jar
urls[6] = file:/C:/Users/javis-msi/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.5/plexus-utils-2.0.5.jar
urls[7] = file:/C:/Users/javis-msi/.m2/repository/org/apache/maven/shared/maven-filtering/1.1/maven- filtering-1.1.jar
urls[8] = file:/C:/Users/javis-msi/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.13/plexus-interpolation-1.13.jar
Number of foreign imports: 4
I try to do mvn clean install again, again, and again. But still in vain.
Solution
This problem may result from you have broken jar files. Try to retrieve jar files again. The steps are as follows:
Step1. Go to you .m2 folder, and delete everything.
Step2. Retrieve all jar files again.
Labels:
Maven
2014/04/27
2014/04/25
2014/04/16
CronMaker - a utility which helps you to build cron expressions
It's a good utility to build cron expression as I use Quartz to write batch program.
http://www.cronmaker.com/
http://www.cronmaker.com/
2014/04/02
SVN error on Eclipse: org.tigris.subversion.javahl.ClientException: Attempted to lock an already-locked dir
Problem
As I commit my source code to SVN in eclipse, but Eclipse shut down unexpectedly. After I launch Eclipse again, and try to commit again, it show this error message:
Solution
Right click on the offending project, click Team and then select Refresh/Cleanup. SVN gets the offending .lock files and deletes them.
After Refresh/Cleanup, I can commit source code successfully
As I commit my source code to SVN in eclipse, but Eclipse shut down unexpectedly. After I launch Eclipse again, and try to commit again, it show this error message:
org.apache.subversion.javahl.ClientException: Attempted to lock an already-locked dir
svn: Commit failed (details follow):
svn: Working copy 'D:\workspace\fms\fms-webapp\src\main\java\gov\nta\fms\web\controller' locked.
svn: 'D:\workspace\fms\fms-webapp\src\main\java\gov\nta\fms\web\controller' is already locked.
Solution
Right click on the offending project, click Team and then select Refresh/Cleanup. SVN gets the offending .lock files and deletes them.
cleanup D:/workspace/fms/fms-webapp/src/main/java
After Refresh/Cleanup, I can commit source code successfully
commit -m "add 4 spaces for rptInfo parameter" D:/workspace/fms/fms-webapp/src/main/java/gov/nta/fms/web/controller/Fms406rReportController.java
Sending D:/workspace/fms/fms-webapp/src/main/java/gov/nta/fms/web/controller/Fms406rReportController.java
Transmitting file data ...
Committed revision 1264.
Reference
2014/03/31
How to set Static IP Address from command line
Requirement
Owing I need to move workplace from office to customer site lately, I need to change my laptop's IP address as I change workplace. So I edit a batch file to set my static IP address automatically.
Syntax
Let’s say I want to give my Windows 7 system an IP address of 10.144.38.195, a subnet mask of 255.255.255.0, a default gateway of 10.144.38.254. Type the following command and save as a batch file with encoding with ANSI
The address will be found via netsh interface ipv4 show interfaces command.
In this case, I would like to configure 區域連線. So the address name="區域連線"
Step by step
Step1. open command prompt.
Step2. execute the batch script file, i.e.SetIP4Office.bat
Well Done!
So you can edit different batch files to set different IP address for different workplace.
Reference
[1] http://www.windowsreference.com/networking/how-to-set-staticdhcp-ip-address-from-command-line/
Owing I need to move workplace from office to customer site lately, I need to change my laptop's IP address as I change workplace. So I edit a batch file to set my static IP address automatically.
Syntax
Let’s say I want to give my Windows 7 system an IP address of 10.144.38.195, a subnet mask of 255.255.255.0, a default gateway of 10.144.38.254. Type the following command and save as a batch file with encoding with ANSI
netsh interface ipv4 set address name="區域連線" source=static address=10.144.38.195 mask=255.255.255.0 gateway=10.144.38.254
The address will be found via netsh interface ipv4 show interfaces command.
Idx Met MTU 狀態 名稱
--- ---------- ---------- ------------ ---------------------------
1 50 4294967295 connected Loopback Pseudo-Interface 1
13 50 1500 disconnected 無線網路連線
12 1 1500 disconnected 區域連線
19 30 1500 disconnected 區域連線 2
16 40 1500 disconnected Bluetooth 網路連線
20 20 1500 connected 區域連線 3
In this case, I would like to configure 區域連線. So the address name="區域連線"
Step by step
Step1. open command prompt.
Step2. execute the batch script file, i.e.SetIP4Office.bat
C:\Users\albert\Desktop>SetIP4Office.bat
C:\Users\albert\Desktop>netsh interface ipv4 set address name="區域連線" source=static address=10.14
4.38.195 mask=255.255.255.0 gateway=10.144.38.254
Well Done!
So you can edit different batch files to set different IP address for different workplace.
Reference
[1] http://www.windowsreference.com/networking/how-to-set-staticdhcp-ip-address-from-command-line/
Labels:
MicrosoftWindows
Bat(Batch) script 執行出現出現中文亂碼問題
Problem
I edit a batch script which be used to set IP address
But when I execute this batch script in command prompt, it seems that the Traditional Chinese characters are broken.
Solution
This problem results from the encoding of the batch script file. You need to change its encoding from UTF-8 to ANSI.
Reference
[1] http://www.bathome.net/viewthread.php?tid=24088
I edit a batch script which be used to set IP address
netsh interface ipv4 set address name="區域連線" source=static address=10.144.38.195 mask=255.255.255.0 gateway=10.144.38.254
But when I execute this batch script in command prompt, it seems that the Traditional Chinese characters are broken.
C:\Users\albert\Desktop>netsh interface ipv4 set address name="????" source=static address=10.14
4.38.195 mask=255.255.255.0 gateway=10.144.38.254
檔案名稱、目錄名稱或磁碟區標籤語法錯誤。
Solution
This problem results from the encoding of the batch script file. You need to change its encoding from UTF-8 to ANSI.
Reference
[1] http://www.bathome.net/viewthread.php?tid=24088
Labels:
MicrosoftWindows
2014/03/27
投資的最高境界是「不交易」!
這篇文章不錯
[quote 1]「掌握波段,比殺進殺出要賺得多。」
[quote 2]大盤K值從高處滑落到20附近,就開始買,一路往下買,回彈到80以上,就一路往上賣。
[quote 3]「停損」當然是最重要的一招。只要持股跌了10%到15%,就該執行停損,認賠出場。
[quote 5]股市還有一句名言:「會買股票不稀奇,會賣股票才是師父。」就算是手上的股票處於獲利狀態,也要懂得「停利」。KD值都來到95以上,這時你若還奢望持股會繼續漲不停,就很可能只是一場「紙上富貴」
http://www.businesstoday.com.tw/article-content-80494-106484?page=1
[quote 2]大盤K值從高處滑落到20附近,就開始買,一路往下買,回彈到80以上,就一路往上賣。
[quote 3]「停損」當然是最重要的一招。只要持股跌了10%到15%,就該執行停損,認賠出場。
[quote 4]如果你忘了當初買進的價格,或許你在面對它反彈到相對高價時,你會捨得去賣它。什麼叫「相對高價」?就是技術指標呈現過熱訊號,或是股價來到重要壓力區。
http://www.businesstoday.com.tw/article-content-80494-106484?page=1
Labels:
Investment
2014/03/25
How do I insert a record if it does not exist in Oracle?
Requirement
Each year has its own report items, ex. 102年度--未滿一年之短期融資, 103年度--未滿一年之短期融資, 102年度--公債及賒借收入, 103年度--公債及賒借收入, etc.
Our requirement is to generate the two report items automatically next year.
Solution
We can use merge statement to accomplish this requirement.
Step1: Find record(s) in FMS405FA based on our defined search criteria
Step2: Result
2.1: If does not find any record, then insert data into FMS405FA
2.2: If found record(s), then skip it.
MERGE INTO FMS405FA T1 USING DUAL ON(T1.ACCYR = (SELECT TRIM(TO_CHAR(EXTRACT(YEAR FROM SYSDATE)-1911, '000')) FROM DUAL) AND T1.RPT_TYPE='FMS434R' AND T1.RPT_NO='0001') WHEN NOT MATCHED THEN INSERT(T1.ACCYR, T1.RPT_TYPE, T1.RPT_NO, T1.RPT_NM) VALUES( (SELECT TRIM(TO_CHAR(EXTRACT(YEAR FROM SYSDATE)-1911, '000')) FROM DUAL), 'FMS434R', '0001', (SELECT TRIM(TO_CHAR(EXTRACT(YEAR FROM SYSDATE)-1911, '000')) FROM DUAL)||'年度--未滿一年之短期融資')
MERGE INTO FMS405FA T1 USING DUAL ON(T1.ACCYR = (SELECT TRIM(TO_CHAR(EXTRACT(YEAR FROM SYSDATE)-1911, '000')) FROM DUAL) AND T1.RPT_TYPE='FMS434R' AND T1.RPT_NO='0002') WHEN NOT MATCHED THEN INSERT(T1.ACCYR, T1.RPT_TYPE, T1.RPT_NO, T1.RPT_NM) VALUES( (SELECT TRIM(TO_CHAR(EXTRACT(YEAR FROM SYSDATE)-1911, '000')) FROM DUAL), 'FMS434R', '0002', (SELECT TRIM(TO_CHAR(EXTRACT(YEAR FROM SYSDATE)-1911, '000')) FROM DUAL)||'年度--公債及賒借收入')
Reference
[1] http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm#SQLRF01606
Labels:
Oracle
2014/03/20
How to create a Boolean field in Oracle
Problem
If we would like to create a field, it will store the information if this datum had create by external system or be added by manual.
Originally, I would like to crate a field with Boolean data type. But it seems that Oracle does not support Boolean data type.
Solution
We can use the check constraint to limit its value, i.e. 'Y' means adding by manual, 'N' means adding by external system.
ex.
Reference
[1] http://www.techonthenet.com/oracle/check.php
If we would like to create a field, it will store the information if this datum had create by external system or be added by manual.
Originally, I would like to crate a field with Boolean data type. But it seems that Oracle does not support Boolean data type.
Solution
We can use the check constraint to limit its value, i.e. 'Y' means adding by manual, 'N' means adding by external system.
ex.
ALTER TABLE FMS435FB ADD CONSTRAINT SELF_ADDED_CHECK CHECK (SELF_ADDED IN ('N', 'Y'));
Reference
[1] http://www.techonthenet.com/oracle/check.php
Labels:
Oracle
Subscribe to:
Posts (Atom)