How to Update a Statement in PL/SQL Developer
- 1). Connect to Oracle SQL*Plus by clicking "Start," "All Programs" and "SQLPlus."
- 2). Once the Oracle SQL*Plus dialog box appears, enter your username and password, then click "OK."
- 3). Use the describe command to identify the columns contained in the employee's table. For example, to begin the process of updating a statement in PL/SQL, using the describe command will indicate that a "NOT NULL" is assigned to all the columns in the employee's table. The employee_id, manager_id, first_name, last_name, title, and salary will require a value. At the SQL prompt, enter the code:
SQL>
"DESCRIBE employees;"
Name
--------
EMPLOYEE_ID
MANAGER_ID
FIRST_NAME
LAST_NAME
TITLE
SALARY
Null?
-------
NOT NULL
NOT NULL
NOT NULL
NOT NULL
NOT NULL
NOT NULL
Type
-------
NUMBER(38)
NUMBER(38)
VARCHAR2(10)
VARCHAR2(10)
VARCHAR2(20)
NUMBER(6) - 4). Create an Update statement in a PL/SQL program. When updating an employee's record that is stored in the author's table, the UPDATE statement, the SET and the WHERE clause are used. For example, Update the salary for an employee with an employee_id of 2. At the SQL prompt, enter the code:
SQL >
"SET SERVEROUTPUT ON
DECLARE
BEGIN
UPDATE employees
SET salary = 75000
WHERE employee_id = 2;
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE(sqlerrm);
ROLLBACK;
END;
/ "
PL/SQL procedure successfully completed. - 5). Create a select statement to query the employee's records. The results will ensure that the Update statement did successfully execute and updated the salary of Fred Jones. At the SQL prompt, type the code to select all the data stored in the author's table:
SQL> SELECT * FROM employees;
EMPLOYEE_ID
----------------------
1
2
MANAGER_ID
---------------------
1
2
FIRST_NAME
--------------------
James
Fred
LAST_NAME
-------------------
Smith
Jones
TITLE
---------
CEO
Sales Manager
SALARY
-------------
80000
75000
Source...