markmulligansr
MIS
If anyone has the time to read this problem statement and can tell me how to use Perl to read the input records, write them as is and then read those to then format the output as shown below, I would really appreciate it. We have a lot of business users spending a lot of time trying to solve syntax errors and if I could figure out how to read this log file and process it using Perl, I know how to take the output and email to our business users shortly after they have a syntax error and this may save a lot of people a lot of time. Thanks in advance.
Our company bought an appliance from IBM called PureData for our data warehouse. PureData used to be known as Netezza and it appears that the software was originally PostgreSQL. I guess IBM named it PureData so it would sound like Teradata. It may sound like it but that's about it.
When people at our company run SQL (Structured Query Language) using this relational database and get a syntax error, this software returns a message like this.
error found "A" (at char 195) expecting a keyword
The problem is that this error does not display enough of the SQL statement to quickly find the syntax error and so people are manually counting the character offset to find where the problem is. Imagine if this char 195 was char 1,202 ??? Needless to say this is taking people a lot of time.
I found some PostgreSQL log files and the records below show an example of an SQL stateuemtn that has an ERROR.
How do I read and format records like this into lines like the example I show below that will have 99 characters per line with numbered lines above each SQL line so we can quickly fine the character offset into our SQL and see where the syntax error is located ???
Here are the input records that I would like to read and write into a file and then the additional formatted output records with the character offset count above each line.
Input Records to Read and Write
2014-11-23 13:39:16.171213 EST [62534] ERROR: 'select distinct
a.plcy_nb,
b.vhcl_ky
from
edwp06.edw.plcy_trm as a,
edwp06.edw.vhcl as b
where
a.plcy_ky = b.plcy_ky and
a.plcy_evnt_ky = b.plcy_evnt_ky and
a.rtd_st_cd = 'SD'
a.plcy_efctv_typ_cd = 'N' and
date(a.isu_actvty_ts) between '2014-10-01' and '2014-10-31''
error ^ found "A" (at char 195) expecting a keyword
Additional output records that I would like to write with the SQL statement formatted with 99 characters per output line. The example below has to work for SQL statements that have thousands of characters if not tens of thousands because we have some business users who come up with pages and pages of complex analytical SQL that joins many tables and is quite complex at times. Solving syntax errors in long SQL statements is taking a very long time with this database and the type of ERROR information it returns. (Warning, when I entered this there are 9 spaces between the numbers on the 3 lines above the 4th number line and the SQL appears below the correct numbers but when I previewed this everything is pushed back to the left so some sort of font or something must be doing this. Hopefully, you can understand what my idea is to try to solve this problem.)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 1 2 3 4 5 6 7 8 9
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
EST 62534 ERROR 'select distinct a.plcy_nb, b.vhcl_ky from edwp06.edw.plcy_trm as a, edwp06.edw.vh
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
cl as b where a.plcy_ky = b.plcy_ky and a.plcy_evnt_ky = b.plcy_evnt_ky and a.rtd_st_cd = 'SD' a.plc
0 0 0 0 0 0 0 0 0 0
2 2 2 2 2 2 2 2 2 2
0 1 2 3 4 5 6 7 8 9
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
y_efctv_typ_cd = 'N' and date(a.isu_actvty_ts) between '2014-10-01' and '2014-10-31''
Thanks again.
Our company bought an appliance from IBM called PureData for our data warehouse. PureData used to be known as Netezza and it appears that the software was originally PostgreSQL. I guess IBM named it PureData so it would sound like Teradata. It may sound like it but that's about it.
When people at our company run SQL (Structured Query Language) using this relational database and get a syntax error, this software returns a message like this.
error found "A" (at char 195) expecting a keyword
The problem is that this error does not display enough of the SQL statement to quickly find the syntax error and so people are manually counting the character offset to find where the problem is. Imagine if this char 195 was char 1,202 ??? Needless to say this is taking people a lot of time.
I found some PostgreSQL log files and the records below show an example of an SQL stateuemtn that has an ERROR.
How do I read and format records like this into lines like the example I show below that will have 99 characters per line with numbered lines above each SQL line so we can quickly fine the character offset into our SQL and see where the syntax error is located ???
Here are the input records that I would like to read and write into a file and then the additional formatted output records with the character offset count above each line.
Input Records to Read and Write
2014-11-23 13:39:16.171213 EST [62534] ERROR: 'select distinct
a.plcy_nb,
b.vhcl_ky
from
edwp06.edw.plcy_trm as a,
edwp06.edw.vhcl as b
where
a.plcy_ky = b.plcy_ky and
a.plcy_evnt_ky = b.plcy_evnt_ky and
a.rtd_st_cd = 'SD'
a.plcy_efctv_typ_cd = 'N' and
date(a.isu_actvty_ts) between '2014-10-01' and '2014-10-31''
error ^ found "A" (at char 195) expecting a keyword
Additional output records that I would like to write with the SQL statement formatted with 99 characters per output line. The example below has to work for SQL statements that have thousands of characters if not tens of thousands because we have some business users who come up with pages and pages of complex analytical SQL that joins many tables and is quite complex at times. Solving syntax errors in long SQL statements is taking a very long time with this database and the type of ERROR information it returns. (Warning, when I entered this there are 9 spaces between the numbers on the 3 lines above the 4th number line and the SQL appears below the correct numbers but when I previewed this everything is pushed back to the left so some sort of font or something must be doing this. Hopefully, you can understand what my idea is to try to solve this problem.)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 1 2 3 4 5 6 7 8 9
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
EST 62534 ERROR 'select distinct a.plcy_nb, b.vhcl_ky from edwp06.edw.plcy_trm as a, edwp06.edw.vh
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
cl as b where a.plcy_ky = b.plcy_ky and a.plcy_evnt_ky = b.plcy_evnt_ky and a.rtd_st_cd = 'SD' a.plc
0 0 0 0 0 0 0 0 0 0
2 2 2 2 2 2 2 2 2 2
0 1 2 3 4 5 6 7 8 9
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
y_efctv_typ_cd = 'N' and date(a.isu_actvty_ts) between '2014-10-01' and '2014-10-31''
Thanks again.