Sep-06-2022, 09:36 PM
Hello!
I'm hoping you guys can help me with a thorny issue I'm having.
I'm a beginner, not having touched Python since University 12 years ago :-)
I think this may be extremely easy for you guys, any tips you can provide would help greatly!
At a high level- I have a set of Oracle SQL DDL scripts that are generating errors because they have statements setting fields to be 'Not Null' because they are already not null...
Here's what the error looks like:
Error starting at line : 159 File 'XXX.sql'
In command -
ALTER TABLE "TABLE" MODIFY ("PK" NOT NULL ENABLE)
Error report -
ORA-01442: column to be modified to NOT NULL is already NOT NULL
01442. 00000 - "column to be modified to NOT NULL is already NOT NULL"
*Cause:
*Action:
What I want to do is write a simple script with two parts- one has a regular expression search that takes 'TABLE' and 'PK' from this error log and writes to a separate file using a regular expression search- perhaps using re.split(). Since this is an error log, a regular expression search for the active 'ALTER TABLE' line would suffice.
Then, I want to read this file and add line comments.. '--' to the beginning if each line in the original DDL script (A different file) that adds the erroneous constraints:
ALTER TABLE "TABLE" MODIFY ("PK" NOT NULL ENABLE)
~becomes~
-- ALTER TABLE "TABLE" MODIFY ("PK" NOT NULL ENABLE)
The things I don't understand:
How to load the key terms into variables with the regular expression search
How to add a comment before a line containing a regular expression search using terms parsed from the original file.
Anything that can help would be greatly appreciated.
Thanks Everyone!
I'm hoping you guys can help me with a thorny issue I'm having.
I'm a beginner, not having touched Python since University 12 years ago :-)
I think this may be extremely easy for you guys, any tips you can provide would help greatly!
At a high level- I have a set of Oracle SQL DDL scripts that are generating errors because they have statements setting fields to be 'Not Null' because they are already not null...
Here's what the error looks like:
Error starting at line : 159 File 'XXX.sql'
In command -
ALTER TABLE "TABLE" MODIFY ("PK" NOT NULL ENABLE)
Error report -
ORA-01442: column to be modified to NOT NULL is already NOT NULL
01442. 00000 - "column to be modified to NOT NULL is already NOT NULL"
*Cause:
*Action:
What I want to do is write a simple script with two parts- one has a regular expression search that takes 'TABLE' and 'PK' from this error log and writes to a separate file using a regular expression search- perhaps using re.split(). Since this is an error log, a regular expression search for the active 'ALTER TABLE' line would suffice.
Then, I want to read this file and add line comments.. '--' to the beginning if each line in the original DDL script (A different file) that adds the erroneous constraints:
ALTER TABLE "TABLE" MODIFY ("PK" NOT NULL ENABLE)
~becomes~
-- ALTER TABLE "TABLE" MODIFY ("PK" NOT NULL ENABLE)
The things I don't understand:
How to load the key terms into variables with the regular expression search
How to add a comment before a line containing a regular expression search using terms parsed from the original file.
Anything that can help would be greatly appreciated.
Thanks Everyone!