Code Monkey home page Code Monkey logo

ex-no-4-creating-procedures-using-pl-sql's Introduction

Ex. No: 4 Creating Procedures using PL/SQL

DATE:25.9.2023

AIM: To create a procedure using PL/SQL.

Steps:

  1. Create employee table with following attributes (empid NUMBER, empname VARCHAR(10), dept VARCHAR(10),salary NUMBER);
  2. Create a procedure named as insert_employee data.
  3. Inside the procdure block, write the query for inserting the values into the employee table.
  4. End the procedure.
  5. Call the insert_employee data procedure to insert the values into the employee table.
  6. Display the employee table

Program:

SQL> CREATE TABLE empl(
  2       empid NUMBER,
  3       empname VARCHAR(10),
  4       dept VARCHAR(10),
  5       salary NUMBER
  6      );

SQL> CREATE OR REPLACE PROCEDURE emp_data AS
  2      BEGIN
  3      INSERT INTO empl(empid,empname,dept,salary)
  4      values(1,'SHRIRAM','MD',10000000);
  5      INSERT INTO empl(empid,empname,dept,salary)
  6      values(2,'KANISHKAR','HR',500000);
  7      INSERT INTO empl(empid,empname,dept,salary)
  8      values(3,'PRAVEEN','IT',200000);
  9      COMMIT;
 10     FOR emp_rec IN (SELECT * FROM empl)LOOP
 11     DBMS_OUTPUT.PUT_LINE('EMPLOYEE ID:'||emp_rec.empid||',EMPLOYEE NAME:'|| emp_rec.empname||
 12     ',DEPARTMENT:'||emp_rec.dept||',SALARY:'||emp_rec.salary);
 13     END LOOP;
 14     END;
 15    /

Output:

DBMS Lab_1 op

Result:

THE PROGRAM HAS BEEN IMPLEMENTED SUCCESSFULLY.

ex-no-4-creating-procedures-using-pl-sql's People

Contributors

dineshgl avatar psrivarshan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.