SET SERVEROUT ON SIZE 10000
DECLARE
DBNAME VARCHAR2(32):=null;
BEGIN
SELECT name
INTO DBNAME
FROM v$database;
DBMS_OUTPUT.ENABLE;
DBMS_OUTPUT.PUT_LINE('DATABASE NAME = ' || DBNAME);
END;
/
This is the basic code to get the db name - it displays it. For a trigger you would not want a display.