upper_cursor

PHOTO EMBED

Sun May 26 2024 17:45:54 GMT+0000 (Coordinated Universal Time)

Saved by @exam123

DECLARE
    
    v_ename VARCHAR2(100);

    -- Implicit cursor
    CURSOR c_employee IS SELECT ename FROM employee; -- Replace your_table with the actual table name

BEGIN
    OPEN c_employee;

    -- Fetch and process each row
    LOOP
        -- Fetching data from the cursor into v_ename
        FETCH c_employee INTO v_ename;

         EXIT WHEN c_employee%NOTFOUND;

        -- Update the ename column to uppercase
        UPDATE employee SET ename = UPPER(v_ename);
    END LOOP;

    -- Close the cursor
    CLOSE c_employee;

    -- Output message
    DBMS_OUTPUT.PUT_LINE('All ename values updated to uppercase.');
END;
/
content_copyCOPY