Wednesday, July 1, 2026

Hide password getting printed in log during batch file execution for code migration

 Hi,

To avoid the password getting printed in the log during code migrations using batch file, we need to mask the password when DBA enters the password during file execution. Below is a sample code which helps to achieve the requirement. 

Note : To ensure whether the received password is correct I have reprinted in the script which you can comment.


@echo off
setlocal enabledelayedexpansion

echo Enter Password:
:: Call PowerShell to securely prompt, mask characters, and return plain text
for /f "delims=" %%A in ('powershell -Command "$secret = Read-Host -AsSecureString; $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($secret); [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"') do (
    set "PASSWORD=%%A"
)

echo Password: !PASSWORD!

pause




Thursday, May 1, 2025

Converting Comma separated string to Rows using SQL


WITH rws AS (SELECT ',Bala,Mithu,Achu,Comma,' str FROM DUAL)
    SELECT REGEXP_SUBSTR (str, '[^,]+', 1, LEVEL) VALUE
      FROM rws
CONNECT BY LEVEL <= LENGTH (TRIM (BOTH ',' FROM str)) - LENGTH (REPLACE (str, ',')) + 1;

Script Output

VALUE
---------------
Bala
Mithu
Achu
Comma