1. create Table
Create a table for inserting data.
CREATE TABLE Userdata(
USER_ID NUMBER (5) NOT NULL,
USERNAME VARCHAR2 (20) NOT NULL,
PASSWORD VARCHAR2 (20) NOT NULL,
CREATED_DATE DATE NOT NULL,
PRIMARY KEY ( USER_ID )
)
2. Write Stored Procedure
Write the stored procedure, accept four input parameters and insert it into table “Userdata”.
CREATE OR REPLACE PROCEDURE insertUserdata( p_userid IN DBUSER.USER_ID%TYPE, p_username IN DBUSER.USERNAME%TYPE, p_Pass IN DBUSER.PASSWORD %TYPE, p_date IN DBUSER.CREATED_DATE%TYPE) IS BEGIN INSERT INTO Userdata("USER_ID", "USERNAME", "PASSWORD", "CREATED_DATE") VALUES (p_userid, p_username,p_Pass , p_date); COMMIT; END; /
3.Execute from pl/sql like this :
BEGIN insertUserdata(123,'nju123','system',SYSDATE); END;