迟到了,慢慢享用吧 CREATE OR REPLACE PROCEDURE UpdateClasses(
p_Department IN classes.department%TYPE, p_NewCredits IN classes.num_credits%TYPE, p_RowsUpdated OUT INTEGER) AS v_CursorID INTEGER; v_UpdateStmt VARCHAR2(100); BEGIN -- Open the cursor for processing. v_CursorID := DBMS_SQL.OPEN_CURSOR; -- Determine the SQL string. v_UpdateStmt := 'UPDATE classes SET num_credits = :nc WHERE department = :dept'; -- Parse the statement. DBMS_SQL.PARSE(v_CursorID, v_UpdateStmt, DBMS_SQL.NATIVE); DBMS_SQL.BIND_VARIABLE(v_CursorID, ':nc', p_NewCredits); DBMS_SQL.BIND_VARIABLE_CHAR(v_CursorID, ':dept', p_Department); -- Execute the statement. p_RowsUpdated := DBMS_SQL.EXECUTE(v_CursorID); -- Close the cursor. DBMS_SQL.CLOSE_CURSOR(v_CursorID); EXCEPTION WHEN OTHERS THEN -- Close the cursor, then raise the error again. DBMS_SQL.CLOSE_CURSOR(v_CursorID); RAISE; END UpdateClasses; /
CREATE OR REPLACE PROCEDURE UpdateClasses(
p_Department IN classes.department%TYPE,
p_NewCredits IN classes.num_credits%TYPE,
p_RowsUpdated OUT INTEGER) AS v_CursorID INTEGER;
v_UpdateStmt VARCHAR2(100);
BEGIN
-- Open the cursor for processing.
v_CursorID := DBMS_SQL.OPEN_CURSOR; -- Determine the SQL string.
v_UpdateStmt :=
'UPDATE classes
SET num_credits = :nc
WHERE department = :dept'; -- Parse the statement.
DBMS_SQL.PARSE(v_CursorID, v_UpdateStmt, DBMS_SQL.NATIVE);
DBMS_SQL.BIND_VARIABLE(v_CursorID, ':nc', p_NewCredits);
DBMS_SQL.BIND_VARIABLE_CHAR(v_CursorID, ':dept', p_Department); -- Execute the statement.
p_RowsUpdated := DBMS_SQL.EXECUTE(v_CursorID); -- Close the cursor.
DBMS_SQL.CLOSE_CURSOR(v_CursorID);
EXCEPTION
WHEN OTHERS THEN
-- Close the cursor, then raise the error again.
DBMS_SQL.CLOSE_CURSOR(v_CursorID);
RAISE;
END UpdateClasses;
/