DEV Community

Query Filter
Query Filter

Posted on

sql7

SET VERIFY OFF
SET FEEDBACK OFF
SET HEADING OFF
SET ECHO OFF

-- Check the parameter and set a flag
DEFINE p_flag = "&1"

-- Use a temp table or variable to control flow
CREATE GLOBAL TEMPORARY TABLE run_control (should_run CHAR(1)) ON COMMIT DELETE ROWS;

BEGIN
  IF UPPER(NVL('&p_flag', 'N')) = 'Y' THEN
    INSERT INTO run_control VALUES ('Y');
  END IF;
END;
/

-- Check if we should continue
DECLARE
  v_count NUMBER;
BEGIN
  SELECT COUNT(*) INTO v_count FROM run_control;
  IF v_count = 0 THEN
    -- Exit the script cleanly
    RETURN;
  END IF;
END;
/

-- Main script continues
PROMPT Running utils.sql...
-- Rest of your script here...

-- Cleanup
DROP TABLE run_control;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)