C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
PL/SQL ProcedureThe PL/SQL stored procedure or simply a procedure is a PL/SQL block which performs one or more specific tasks. It is just like procedures in other programming languages. The procedure contains a header and a body.
How to pass parameters in procedure:When you want to create a procedure or function, you have to define parameters .There is three ways to pass parameters in procedure:
A procedure may or may not return any value.PL/SQL Create ProcedureSyntax for creating procedure: CREATE [OR REPLACE] PROCEDURE procedure_name [ (parameter [,parameter]) ] IS [declaration_section] BEGIN executable_section [EXCEPTION exception_section] END [procedure_name]; Create procedure exampleIn this example, we are going to insert record in user table. So you need to create user table first. Table creation: create table user(id number(10) primary key,name varchar2(100)); Now write the procedure code to insert record in user table. Procedure Code: create or replace procedure "INSERTUSER" (id IN NUMBER, name IN VARCHAR2) is begin insert into user values(id,name); end; / Output: Procedure created. PL/SQL program to call procedureLet's see the code to call above created procedure. BEGIN insertuser(101,'Rahul'); dbms_output.put_line('record inserted successfully'); END; / Now, see the "USER" table, you will see one record is inserted.
PL/SQL Drop ProcedureSyntax for drop procedure DROP PROCEDURE procedure_name; Example of drop procedureDROP PROCEDURE pro1;
Next TopicPL/SQL Function
|