I have SQL scripts like below. I want to convert all the text in these files to lower case except the strings enclosed within single quotes .
Any idea how I can achieve this ?
Sample text:
$ cat sample.txt
SELECT A.LOGIN_ID,A.password,NVL(A.TEMP_PASS_EXPIRY_DT,SYSTIMESTAMP),NVL(UPPER(A.STATUS), ' ')
INTO V_LOGIN_ID, V_PASSWORD , V_TEMP_PASS_EXPIRY_DT,V_STATUS
FROM W_DEALER_MASTER A, W_DEALER_USER_MAP B
WHERE A.LOGIN_ID = I_LOGINID AND B.LOGIN_ID=A.LOGIN_ID AND B.ROLE_ID in ('sysAdmSupervisorR2','sysAdmSalesRepR2');
IF V_PASSWORD = v_entered_password AND V_STATUS = 'ACTIVE' THEN
O_STATUS := 'SUCCESS';
O_MESSAGE := null;
ELSE
O_STATUS := 'FAIL';
Expected output:
select a.login_id,a.password,nvl(a.temp_pass_expiry_dt,systimestamp),nvl(upper(a.status), ' ')
into v_login_id, v_password , v_temp_pass_expiry_dt,v_status
from w_dealer_master a, w_dealer_user_map b
where a.login_id = i_loginid and b.login_id=a.login_id and b.role_id in ('sysAdmSupervisorR2','sysAdmSalesRepR2');
if v_password = v_entered_password and v_status = 'ACTIVE' then
o_status := 'SUCCESS';
o_message := null;
else
o_status := 'FAIL';
Unless there is something additional here (or that I missed), this appears to fail if the quoted string is not bounded by whitespace ... cheers, drl
Results:
select a.login_id,a.password,nvl(a.temp_pass_expiry_dt,systimestamp),nvl(upper(a.status), ' ')
into v_login_id, v_password , v_temp_pass_expiry_dt,v_status
from w_dealer_master a, w_dealer_user_map b
where a.login_id = i_loginid and b.login_id=a.login_id and b.role_id in ('sysadmsupervisorr2','sysadmsalesrepr2');
if v_password = v_entered_password and v_status = 'ACTIVE' then
o_status := 'success';
o_message := null;
else
o_status := 'fail';
On a system like:
OS, ker|rel, machine: Linux, 3.16.0-4-amd64, x86_64
Distribution : Debian 8.7 (jessie)
awk GNU Awk 4.1.1, API: 1.1 (GNU MPFR 3.1.2-p3, GNU MP 6.0.0)
select a.login_id,a.password,nvl(a.temp_pass_expiry_dt,systimestamp),nvl(upper(a.status),
' ')
into v_login_id, v_password , v_temp_pass_expiry_dt,v_status
from w_dealer_master a, w_dealer_user_map b
where a.login_id = i_loginid and b.login_id=a.login_id and b.role_id
in ('sysAdmSupervisorR2','sysAdmSalesRepR2');
if v_password = v_entered_password and v_status = 'ACTIVE' then
o_status := 'SUCCESS';
o_message := null;
else
o_status := 'FAIL';