code2pg
is a tool that help migrating application code that contains SQL queries from Oracle to PostgreSQL standard.
It can:
code2pg
is a standalone script. It requires Perl >= 5.20 and the File::Slurp
, File::Find::Rule
, List::MoreUtils
, Getopt::Long
and Config::General
Perl modules. They can be obtained either from a CPAN client or from your distribution.
On a Centos 7(+) box, it can be installed this way:
sudo yum install perl-File-Slurp perl-File-Find-Rule perl-Config-General perl-List-MoreUtils perl-Getopt-Long
On a Debian box, the packages could be installed with:
sudo apt-get install libfile-slurp-perl libfile-find-rule-perl libconfig-general-perl liblist-moreutils-perl libgetopt-mixed-perl
With the cpan minus client, the prerequisites can be installed this way:
cpanm File::Slurp File::Find::Rule List::MoreUtils Getopt::Long Config::General
The script has been tested very lightly on Windows with Strawberry Perl (v5.24.3) with the proper modules installed (the CPAN client can be used for this). A warning is issued though as wc
is usually not recognized.
git clone https://github.com/societe-generale/code2pg
The script should then be made executable:
chmod +x code2pg
Please refer to the complete generated documentation for more details. Here are a few examples:
./code2pg --help
./code2pg --help COMMIT
./code2pg --help ALL_INSTRUCTIONS | pandoc -f markdown -o myfile.pdf
./code2pg -e java -l comma-strings
./code2pg -e java -e jsp -l comma-strings -o myproject_java.html
./code2pg -e properties -l plain -o myproject_properties.html
./code2pg -e properties -l plain -d /tmp/project1 -d /tmp/project2 -o project_estimate.html
./code2pg -D svn -d https://mysvnrepo/project/trunk -l comma-strings -e java -f txt
./code2pg -c code2pg.conf
Done !
Estimation: 0.19 man-days
Settings
========
- Version code2pg: 0.13.0
- Analysis date: 29/04/2019
- Source code directory: /home/user/migration-project/
- Number of .java files: 76
- Language: comma-strings
- Number of analyzed LOC: 0
- Log file:
- orafce usage: No
Estimates
=========
| | Number of instructions | Time/instruction | Estimated time (minutes) | Man-days |
|------------|------------------------|------------------|--------------------------|----------|
| Level 1 | 265 | 1 | 265 | 0.7 |
| Level 2 | 27 | 4 | 108 | 0.3 |
| Level 3 | 26 | 8 | 208 | 0.6 |
| Level 4 | 140 | 20 | 2800 | 7.8 |
| estimation | 458 | 7.4 | 3381 | 9.4 |
Instructions
============
| Level | Instruction | Number |
|-------|----------------------|--------|
| 1 | ASCII | 60 |
| 1 | COUNT | 11 |
| 1 | LOWER | 178 |
| 1 | MAX | 4 |
| 1 | MIN | 9 |
| 1 | UPPER | 3 |
| 2 | NVL | 8 |
| 2 | SUM | 17 |
| 2 | TO_NUMBER | 2 |
| 3 | CAST | 1 |
| 3 | DECODE | 20 |
| 3 | HINTS | 4 |
| 3 | ROWNUM | 1 |
| 4 | CONVERT | 140 |
ADD_MONTHS
==========
A function can be created. For example:
CREATE OR REPLACE FUNCTION public.add_months(date date, months integer)
RETURNS date
LANGUAGE plpgsql
AS $function$
BEGIN
RETURN (date + (months * '1 month' :: interval)) :: date;
END;
$function$
How to contribute?
------------------
See [CONTRIBUTING.md](CONTRIBUTING.md)
License
--------
License is under the 2-Clause BSD License.
[![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](LICENSE.md)