Back to home page

OSCL-LXR

 
 

    


0001 --
0002 --   Licensed to the Apache Software Foundation (ASF) under one or more
0003 --   contributor license agreements.  See the NOTICE file distributed with
0004 --   this work for additional information regarding copyright ownership.
0005 --   The ASF licenses this file to You under the Apache License, Version 2.0
0006 --   (the "License"); you may not use this file except in compliance with
0007 --   the License.  You may obtain a copy of the License at
0008 --
0009 --      http://www.apache.org/licenses/LICENSE-2.0
0010 --
0011 --   Unless required by applicable law or agreed to in writing, software
0012 --   distributed under the License is distributed on an "AS IS" BASIS,
0013 --   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014 --   See the License for the specific language governing permissions and
0015 --   limitations under the License.
0016 --
0017 
0018 -- ImplicitTypeCasts
0019 
0020 CREATE TEMPORARY VIEW t AS SELECT 1;
0021 
0022 SELECT 1 + '2' FROM t;
0023 SELECT 1 - '2' FROM t;
0024 SELECT 1 * '2' FROM t;
0025 SELECT 4 / '2' FROM t;
0026 SELECT 1.1 + '2' FROM t;
0027 SELECT 1.1 - '2' FROM t;
0028 SELECT 1.1 * '2' FROM t;
0029 SELECT 4.4 / '2' FROM t;
0030 SELECT 1.1 + '2.2' FROM t;
0031 SELECT 1.1 - '2.2' FROM t;
0032 SELECT 1.1 * '2.2' FROM t;
0033 SELECT 4.4 / '2.2' FROM t;
0034 
0035 -- concatenation
0036 SELECT '$' || cast(1 as smallint) || '$' FROM t;
0037 SELECT '$' || 1 || '$' FROM t;
0038 SELECT '$' || cast(1 as bigint) || '$' FROM t;
0039 SELECT '$' || cast(1.1 as float) || '$' FROM t;
0040 SELECT '$' || cast(1.1 as double) || '$' FROM t;
0041 SELECT '$' || 1.1 || '$' FROM t;
0042 SELECT '$' || cast(1.1 as decimal(8,3)) || '$' FROM t;
0043 SELECT '$' || 'abcd' || '$' FROM t;
0044 SELECT '$' || date('1996-09-09') || '$' FROM t;
0045 SELECT '$' || timestamp('1996-09-09 10:11:12.4' )|| '$' FROM t;
0046 
0047 -- length functions
0048 SELECT length(cast(1 as smallint)) FROM t;
0049 SELECT length(cast(1 as int)) FROM t;
0050 SELECT length(cast(1 as bigint)) FROM t;
0051 SELECT length(cast(1.1 as float)) FROM t;
0052 SELECT length(cast(1.1 as double)) FROM t;
0053 SELECT length(1.1) FROM t;
0054 SELECT length(cast(1.1 as decimal(8,3))) FROM t;
0055 SELECT length('four') FROM t;
0056 SELECT length(date('1996-09-10')) FROM t;
0057 SELECT length(timestamp('1996-09-10 10:11:12.4')) FROM t;
0058 
0059 -- extract
0060 SELECT year( '1996-01-10') FROM t;
0061 SELECT month( '1996-01-10') FROM t;
0062 SELECT day( '1996-01-10') FROM t;
0063 SELECT hour( '10:11:12') FROM t;
0064 SELECT minute( '10:11:12') FROM t;
0065 SELECT second( '10:11:12') FROM t;
0066 
0067 -- like
0068 select 1 like '%' FROM t;
0069 select date('1996-09-10') like '19%' FROM t;
0070 select '1' like 1 FROM t;
0071 select '1 ' like 1 FROM t;
0072 select '1996-09-10' like date('1996-09-10') FROM t;