Recently encountered a test demand, the use of online analytical processing (OLAP), is summarized in the record, but also hope to help people with related problems.1. The test environment is DB2, through ETL (data extraction, data transformation, data loading) technology to load the data source data into the target data warehouse.2. Requirements approximate meaning: Verify that the order containing the product encoding is loaded from the data source i
The previous article mentioned in the DB2, can through Sysibm.sysdummy1, SYSIBM. Dual gets the value in the register, or you can get the value in the register by using the VALUES keyword. In this article, we'll look at these functions directly using the VALUES keyword.1.CURRENT Date Gets the current date, the current time gets the timestamp, current time stamp (including year, month, day, hour, minute, second), year () gets years; month () Gets the da
In oracle, INSERT corresponds to the LOCATE function usage in db2. The SQL code www.2cto.com eg: SELECT CONCAT (FIRST_NAME, LAST_NAME) FROM T1 eg: SELECT CONCAT (FIRST_NAME, LAST_NAME) FROM T1 INSERT function Syntax: the INSERT (ARG1, POS, SIZE, ARG2) function returns a string, which deletes the SIZE of ARG1 from the P
:00:00 ')
DATE (' 2002-10-20 ')
DATE (' 10/20/2002 ')
Time (' 12:00:00 ')
Time (' 12.00.00 ')
The TIMESTAMP (), DATE (), and time () functions accept more than one format. The above formats are just examples, and I'll take it as an exercise for readers to discover other formats themselves.
Sometimes, you need to know the difference between two time stamps. To do this, DB2 provides a built-in function name
The usage of the DB2 DECODE function generally uses CASE when data is queried and conditional judgment is required... WHEN the condition is equal, in addition to the CASE... you can also use the DECODE function. If you want to use like,>,
In the ETL project often encounter such a situation:A column in the target table originates from a different source data table A,b,c. If no valid data in A is taken from B, if none in B is taken from C, then set to null if none is in C.In situations like this, sometimes the first thought is the case and then else end, which can solve the problem, but it's still more complicated and error-prone, especially when someone looks at the SQL you're writing.So is there a better way?That's the COALESCE f
DB2 time function statement [SQL] Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/-- > -- Get the current date: select current date from sysibm. sysdummy1; values current date; -- Obtain the current date select current time from sysibm. sysdummy1; values current time; -- Obtain the current timestamp select current timestamp from sysibm. sysdummy1; values curre
current date+1 year;Values current date+3 years+2 months +15 days;Values current time +5 hours-3 minutes +10 seconds;--Calculates the number of days between two datesValues days (current date) – Days (date (' 2010-02-20 '));--Change time and date to stringValues char (current date);Values char (current time);--to convert a string to a date or time valueValues timestamp (' 2010-03-09-22.43.00.000000 ');Values timestamp (' 2010-03-09 22:44:36 ');Values date (' 2010-03-09 ');Values date (' 03/09/2
Values char (' ABCD ', ' A ', ' OPMN ') returns the result of OPMNBCDUpdate EMP Set Name=replace (name, ' D ', ' W ') where empno=70The key to the use of this function is case-sensitive, there can be no space between the strings, otherwise it cannot be replaced.Update test111 set A=replace[object Object] (A,CHR (13) | | Chr (10), ' 1 ') This is a substitution statement, Chr (13) | | CHR (10) wraps the carriage return. The experiment was successful on
DB2 time function is one of our most common functions, the following is to introduce you some DB2 time functions, for your reference, I hope you can have more understanding of the DB2 time function.1 --get the current date:2 3 Select CurrentDate fromsysibm.sysdummy1; 4 Val
DB2 Create function (a), which describes the use of function content as a field value, or as a where condition.DB2 creates function (ii), which describes the creation of the returned content as a table collection. A call example is shown below?
1
select * fromtable(GET_EFFECTIVE_USER_ID(21))--GET_E
string expression.
SELECT DOUBLE (' 5678 ') from Bsempms;
EXP ()
Returns the exponential function of the parameter.
SELECT EXP (2) from Bsempms;
FLOAT ()
Returns a floating-point representation of a number.
SELECT FLOAT (789) from Bsempms;
Floor ()
Returns the largest integer less than or equal to the parameter.
SELECT Floor (88.93) from Bsempms;
Oracle,sql server, and DB2 should also have its reverse function, because there is a certain application scenario.
CREATE OR REPLACE FUNCTION REVERSE
(
p1 varchar)
RETURNS varchar (m) Specific
"REVERSE"
LANGUAGE SQL
Deterministic
NO EXTERNAL ACTION
reads SQL DATA
BEGIN
declare v_str varchar (m) default ';
DECLARE V_index INTEGER; --Define subs
There are times when we need to index a set of data using letters from A to Z. If the data format is all half-width English is easy to achieve, but if the index of a group of Chinese data will cause a little trouble, data input database may not have specified an index letter, This requires the application to automatically generate information for indexing.
In general, the index of Chinese data uses the first letter of the Chinese pinyin of the phrase, for example:
Phrase Index letter
--- ----
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.