DB2 SQL to Denodo VQL Quick Reference

Applies to: Denodo 8.0 BETA , Denodo 7.0
Last modified on: 12 May 2020
Tags: DB2 JDBC data sources

Download document

You can translate the document:

Goal

This document is a quick reference for migrating DB2 SQL to Denodo VQL. The document is aimed at administrators and developers that want to efficiently migrate their existing DB2 queries to Denodo VQL queries.

Content

The Knowledge Base article VDP Conformance with Standard SQL contains a reference of the Virtual DataPort conformance with the SQL 92 standard. The document is focused on query capabilities and contains information about: Data Types, SQL Predicates Support and SQL Functions Support. The Query Expressions section lists the expressions defined by the standard SQL and their equivalent in Virtual DataPort, explaining the differences with the standard when appropriate.

Following, a group of tables where the correspondence between DB2 functions and the Denodo equivalents is presented. This list is just a reference since more functions can be included in future Denodo versions.

Functions mapping

Denodo function

DB2 function

cast(data_type, value)

cast(value as data_type)

coalesce(arg0 [, argi]*)

  • coalesce(arg0[, $argi]{1, n}, null)
  • nvl(arg0[, $argi]{1, n}, null)

concat(arg0, arg1, arg2)

concat(arg0,concat(arg1, arg2))

textcat(arg0, arg1, arg2)

concat(arg0,concat(arg1, arg2))

formatdate(date_pattern, datetimevalue [, localename])

VARCHAR_FORMAT(date,date_pattern[, localename)

getday(daterelatedvalue)

DAY(date)

gethour(timerelatedvalue)

hour(date)

getminute(timerelatedvalue)

minute(date)

getsecond(timerelatedvalue)

second(date)

gettimeinmillis(daterelatedvalue)

BIGINT(86400000)*(DAYS(TIMESTAMP(date)-DAYS(TIMESTAMP('1970-01-01-00:00:00')))+

MIDNIGHT_SECONDS(timestamp(date))

getmonth(daterelatedvalue)

month(date)

getyear(daterelatedvalue)

year(date)

getmillisecond(daterelatedvalue)

trunc(microsecond(date)/1000, 0)

getdaysbetween(daterelatedvalue1, daterelatedvalue2)

days(date2) - days(date1)

getmonthsbetween(daterelatedvalue1, daterelatedvalue2)

int(months_between(date2, date1))

getdayofweek(daterelatedvalue)

dayofweek(date)

getdayofyear(daterelatedvalue)

dayofyear(date)

instr(arg0, arg1)

LOCATE(arg1, arg0)-1

degrees(arg0)

degrees(arg0)

radians(arg0)

radians(arg0)

log(arg0)

log10(arg0)

ltrim(arg0)

ltrim(arg0)

now()

CURRENT_TIMESTAMP

max(arg0 [,argi]*)

max(arg0 [,argi]*)

min(arg0 [,argi]*)

min(arg0 [,argi]*)

removeaccents(arg0)

replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(replace( replace(replace(replace(arg0, 'Ý', 'Y'), 'Û', 'U'), 'Ô', 'O'), 'Î', 'I'), 'Ê', 'E'), ' ', 'A'), 'Ü', 'U'), 'Ö', 'O'), 'Ï', 'I'), 'Ë', 'E'), 'Ä', 'A'), 'Ù', 'U'), 'Ò', 'O'), 'Ì', 'I'), 'È', 'E'), 'À', 'A'), 'Ú', 'U'), 'Ó', 'O'), 'Í', 'I'), 'É', 'E'), 'Á', 'A'), 'ý', 'y'), 'ÿ', 'y'), 'û', 'u'), 'ô', 'o'), 'î', 'i'), 'ê', 'e'), 'â', 'a'), 'ü', 'u'), 'ö', 'o'), 'ï', 'i'), 'ë', 'e'), 'ä', 'a'), 'ù', 'u'), 'ò', 'o'), 'ì', 'i'), 'è', 'e'), 'à', 'a'), 'ú', 'u'), 'ó', 'o'), 'í', 'i'), 'é', 'e'), 'á', 'a')

repeat(arg0, count)

repeat(arg0, count)

round(arg0 [, arg1])

round(arg0 [, arg1])

rtrim(arg0)

rtrim(arg0)

substr(arg0, arg1)

SUBSTR(arg0,arg1)

substr(arg0, arg1,arg2)

SUBSTR(arg0,arg1,arg2)

to_date(date_pattern, value)

to_date(value, date_pattern)

addday(daterelatedvalue,inc)

DATE + inc DAY

addhour(timerelatedvalue,inc)

DATE + inc HOUR

addminute(timerelatedvalue,inc)

DATE +inc MINUTE

addsecond(timerelatedvalue,inc)

DATE + inc SECOND

addmonth(daterelatedvalue,inc)

  • DATE + inc MONTH
  • add_months(DATE,inc)

addweek(daterelatedvalue,inc)

DATE +(inc*7) DAY

addyear(daterelatedvalue,inc)

DATE + inc YEAR

firstdayofmonth(daterelatedvalue)

add_months(last_day(date),-1)+1

firstdayofweek(daterelatedvalue)

NEXT_DAY(date-7,<first weekday abbreviation depending on locale, example 'SUN' for sunday>)

lastdayofmonth(daterelatedvalue)

last_day(date)

lastdayofweek(daterelatedvalue)

next_day(date-1, <first weekday abbreviation depending on locale, example 'SAT' for saturday>)

nextweekday(daterelatedvalue,weekDay)

next_day(date,weekDay)

previousweekday(daterelatedvalue,weekDay)

next_day(date-8,weekDay)

trunc(daterelatedvalue[,pattern])

trunc(date[,pattern])

current_date

current_date

len(arg0)

LENGTH(arg0)

CASE WHEN arg0 THEN arg1 [WHEN argi THEN argj] [ELSE argk]

CASE WHEN arg0 THEN arg1 [WHEN argi THEN argj] [ELSE argk]

ceil(arg0)

ceiling(arg0)

In the above list, there are different types of data and time functions:

  • Functions that are related with datetime types that includes dates (date, localdate, timestamp, timestamptz), will be referred as daterelatedvalue.
  • Functions that are related with datetime types that includes times (date, time, timestamp, timestamptz), will be referred as timerelatedvalue.
  • Functions that receive any datetime values, except intervals, will be referred as datetimevalue.

Aggregation functions

Denodo Function

DB2 function

stdevp(arg0)

STDDEV(arg0)

varp(arg0)

VARIANCE(arg0)

count(arg0)

count_big(arg0)

Questions

Ask a question
You must sign in to ask a question. If you do not have an account, you can register here

Featured content

DENODO TRAINING

Ready for more? Great! We offer a comprehensive set of training courses, taught by our technical instructors in small, private groups for getting a full, in-depth guided training in the usage of the Denodo Platform. Check out our training courses.

Training