Saturday, November 25, 2017

SQL vs PL/SQL


SQL
PL/SQL
Used to access data within Oracle database
Used to access data within oracle databases
Not include all normal programming language features.
Includes all normal programing language features, e.g. loops, IF…THEN…ELSE statements
Tells the database what to do (declarative)
Tells the database how to do things (procedural)
Is used to code queries, DML and DDL statements
Used to code program blocks, triggers, functions, procedures and packages
Is executed one statement at a time
Executed as a block of codes
Can be embedded in a PL/SQL program
Can’t be embedded in a SQL statement

PL/SQL has the ability to easily integrate with SQL
Eg 1:
SET SERVEROUTPUT ON SIZE 4000;
DECLARE
todays_date DATE;
BEGIN
todays_date := SYSDATE;
DBMS_OUTPUT.PUT_LINE('Today''s date is ' || todays_date);
END;

Eg 2:
SET SERVEROUTPUT ON SIZE 4000;
DECLARE
todays_date DATE;
BEGIN
todays_date := SYSDATE;
DBMS_OUTPUT.PUT_LINE('Today''s date is ' || TO_CHAR(todays_date, 'Month DD, YYYY'));
END

No comments:

Post a Comment

GEN AI

  Stay Tuned....