Skip to content
Advertisement

Work Around for PL/SQL to do column validation

I need to create a procedure to validate number of digits between 2 columns. I have some reason that this handling won’t do in Java so it needs to be a stored procedure.

It first will get the template(result_format) from one of my table and itself contain data like

then the argument P_RESULT will have input like

then I need to compare and count the first data from first result [16768] to the result_format [5] to see whether it contains 5 digits as per the result_format, then continue till end of the result. if it detect different in the length of the result to the result format it will throw exception.

My procedure is below, it has compilation errors, it’s because of it can’t search my temporary table when i trying to put them into a temporary table and start my validation. [line 28]

is there any workaround that i can do something like this. or maybe not by the method of temporary table?

Advertisement

Answer

You can achieve it using the following query directly:

Testing with values that fails. see first value in template, I have set it to 1 but its related value in dataa is 16768 (length: 5). So it must fail.

Note: This solution assumes that the number of values in both the strings is same.

Cheers!!

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement