shlogg · Early preview
Judy @esproc_spl

Converting SQL Queries For MySQL With EsProc

Need to execute SQL with WEEKOFYEAR function in MySQL without rewriting. Use esProc script p1.dfx to translate and query database, then close connection.

Problem description & analysis
There is a data table CLUE in MySQL database, as shown below:

We have a SQL statement SELECT ID, WEEKOFYEAR(DATES) AS WOF, CUSTOMER, AREA FROM CLUE, where the standard function WEEKOFYEAR(d) is used to find which week where d falls in the current year.
But the counterpart function in MySQL is WEEK(d).
Our need is to execute the above SQL without in MySQL without rewriting it. Below is the desired result:

Solution
Write the following script p1.dfx in esProc:

Explanation
A1   Translate the SQL statement according to the specific database type. Both sql and dbtyp...