• Save
Oracle: Programs
Upcoming SlideShare
Loading in...5
×
 

Oracle: Programs

on

  • 3,843 views

Oracle: Programs

Oracle: Programs

Statistics

Views

Total Views
3,843
Views on SlideShare
3,832
Embed Views
11

Actions

Likes
0
Downloads
0
Comments
0

2 Embeds 11

http://www.dataminingtools.net 6
http://dataminingtools.net 5

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Oracle: Programs Oracle: Programs Presentation Transcript

  • 1
    Using ORACLE®
    MANIPULATING DATA using PL/SQL
  • 2
    COMMENTING CODE
    We can add comments to the PL/SQL .There are two types of comments:
    EXAMPLE:
    DECLARE
    eage NUMBER ; --This is a single line comment . number variable defined.
    BEGIN
    SELECT age INTO eage FROM InfoTable WHERE name = ‘bill’; /* A multiline command .Here the select command is defined */
    END
  • 3
    FUNCTIONS
    The functions available in SQL can be used in PL/SQL code. Not all SQL function can be used in PL/SQL statements .The SQL functions unavailable in Pl/SQL statements are:
    DECODE function.
    All GROUP functions except the LEAST and GREATEST.
    EXAMPLE1:
    ename VARCHAR2(20) := INITCAP(‘bill’); --stores Bill in the variable ename.
    We can use data type conversion function in PL/SQL statements.
    EXAMPLE 2:
    mainphone NUMBER(10) := 9000000000;
    ename VARCHAR2(20);
    BEGIN
    SELECT name INTO ename FROM InfoTable WHERE phone = TO_NUMBER(mainphone);
    END
  • 4
    Operators in PL/SQL
  • 5
    Operators
    EXAMPLES:
    profit BOOL; sp NUMBER; cp NUMBER;
    BEGIN
    cp:= 1000;
    sp:= 1200;
    profit := ((sp – cp) > 100); -- finding if profit was above 100 or not
    END
  • 6
    RETRIEVING DATA
    We can retrieve data using the SELECT command. Variables are used to store the values returned from the SELECT statement and hence have to be of the same datatype and be declared before use.
    SYNTAX:
    SELECT column, […column]
    INTO variable_name,[…variable_name]
    FROM table_name
    WHERE { expression….};
    EXAMPLE:
    DECLARE
    eage NUMBER;
    BEGIN
    SELECT age INTO eage FROM InfoTable WHERE name = ‘bill’;
    DBMS_OUTPUT.PUT_LINE(‘ Age of bill is : ‘ || eage);
    END
  • 7
    INSERT command
    We can insert data into tables using the PL/SQL INSERT command.
    SYNTAX:
    INSERT INTO table_name
    (column , (…..column))
    VALUES
    (value , (…..value));
    EXAMPLE:
    BEGIN
    INSERT INTO InfoTable
    (name,age,phone)
    VALUES
    (‘micheal’,45,9666002203);
    END
  • 8
    UPDATE command
    We can update data in tables using the PL/SQL UPDATE comand.
    SYNTAX:
    UPDATE table_name
    SET column = value,
    (…column = value);
    WHERE {expression };
    EXAMPLE: DECLARE
    eage NUMBER(5):=40;
    BEGIN
    UPDATE InfoTable SET age = eage
    WHERE name = ‘micheal’;
    END
  • 9
    DELETE command
    We can delete data from tables using the PL/SQL DELETE comand.
    SYNTAX:
    DELETE FROM table_name
    WHERE { expression };
    EXAMPLE:
    BEGIN
    DELETE FROM InfoTable
    WHERE age = 45 ;
    END
  • 10
    MERGE COMMAND
    The MERGE comand is use to merge the data of one table into the data of another table.The merge command updates or inserts rows in order to make data in both rows similar.
    DECLARE
    ename INFOTABLE.NAME%TYPE := ‘bill';
    BEGIN
    MERGE INTO addtable a
    USING infotable I Infotable
    ON (i.name =ename)
    WHEN MATCHED THEN
    UPDATE SET
    a.phone = i.phoneADDtable
    WHEN NOT MATCHED THEN
    INSERT VALUES(i.name,NULL,i.phone);
    END;
    ADDtable after MERGE
  • THANK YOU
    11
    THANK YOU FOR VIEWING THIS PRESENTATION
    FOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING ,
    please visit:
    www.dataminingtools.net