SlideShare a Scribd company logo
Dynamic Websites
PHP with Oracle DB   By Belal Arfa
Section 3
In this section will discuss
1- Quiz 1 Notes
2- Quiz 2
3- Install Oracle 11g ex
4- SqlDev
5- PL/SQL
6- Stored Procedure
7- Function
8- Triggers
9- HTML
Quiz (2)
Relations:
Classes(class, type, country, numGuns, bore, displacement)
Ships(name, class, launched)
Battles(name, date)
Outcomes(ship, battle, result)

Queries:
a) Find the countries whose ships had the largest number of guns.
b) Find the classes of ships at least one of which was sunk in a battle.
c) Find the names of the ships with a 16-inch bore.
d) Find the battles in which ships of the Kongo class participated.
Quiz (2) Answer
a) SELECT country FROM classes
   WHERE numGuns = (SELECT MAX(numGuns) from classes);

b) SELECT DISTINCT class FROM Ships
   WHERE name IN (SELECT ship FROM Outcomes WHERE result = ‘sunk’);

c) SELECT name FROM ships
   WHERE class IN (SELECT class from classes where bore = 16);
  - SELECT name FROM ships, classes
    WHERE ships.class = classes.class AND bore = 16;

d) SELECT DISTINCT battle FROM ships, outcomes
   WHERE class = ‘Kongo’;
Install Oracle 11g ex
Be aware of OS type, Processor type and Oracle version type.
Download it from Oracle
●   Start Setup
●   Next.....
●   Enter Password be aware of this password
    because it will the system password
●   Next....
●   Install....
●   Finish
Sql Developer


    How to connect to your Database
PL/SQL
What is PL/SQL?
PL/SQL stands for Procedural Language extension of SQL.
PL/SQL is a combination of SQL along with the procedural features of programming languages.
It was developed by Oracle Corporation in the early 90’s to enhance the capabilities of SQL.
Advantages
 ●   Block Structures: PL SQL consists of blocks of code, which can be nested within each other.
     Each block forms a unit of a task or a logical module. PL/SQL Blocks can be stored in the
     database and reused.
 ●    Procedural Language Capability: PL SQL consists of procedural language constructs such as
     conditional statements (if else statements) and loops like (FOR loops).
 ●    Better Performance: PL SQL engine processes multiple SQL statements simultaneously as a
     single block, thereby reducing network traffic.
 ●   Error Handling: PL/SQL handles errors or exceptions effectively during the execution of a
     PL/SQL program. Once an exception is caught, specific actions can be taken depending upon
     the type of the exception or it can be displayed to the user with a message.
Stored Procedures
A stored procedure is a named PL/SQL block which performs one or more
specific task. This is similar to a procedure in other programming languages.


We can pass parameters to procedures in three ways.
1) IN-parameters
2) OUT-parameters
3) IN OUT-parameters
A procedure may or may not return any value.
Stored Procedure
Syntax
CREATE [OR REPLACE] PROCEDURE proc_name [list of parameters]
IS
 Declaration section
BEGIN
 Execution section
EXCEPTION
 Exception section
END;
IS - marks the beginning of the body of the procedure and is similar to DECLARE in
anonymous PL/SQL Blocks.
The code between IS and BEGIN forms the Declaration section.
The syntax within the brackets [ ] indicate they are optional. By using CREATE OR
REPLACE together the procedure is created if no other procedure with the same name
exists or the existing procedure is replaced with the current code.
Stored Procedure
Example
CREATE OR REPLACE PROCEDURE insertDBUSER
IS
BEGIN
  INSERT INTO DBUSER ('USER_ID', 'USERNAME', 'PASSWORD', 'CREATED_DATE')
  VALUES (1, 'Belal','123', SYSDATE);
  COMMIT;
END;
/
How to execute a Stored Procedure?
There are two ways to execute a procedure.
1) From the SQL prompt: EXECUTE [or EXEC] procedure_name;
2) Within another procedure – simply use the procedure name: procedure_name;
NOTE: In the examples given above, we are using backward slash ‘/’ at the end of the program. This
indicates the oracle engine that the PL/SQL program has ended and it can begin processing the
statements.
Function
What is a Function in PL/SQL?
A function is a named PL/SQL Block which is similar to a procedure. The major difference
between a procedure and a function is, a function must always return a value, but a
procedure may or may not return a value.
Syntax
CREATE [OR REPLACE] FUNCTION function_name [parameters]
RETURN return_datatype;
IS
Declaration_section
BEGIN
Execution_section
Return return_variable;
EXCEPTION
exception section
Return return_variable;
END;
Function
1) Return Type: The header section defines the return type of the function. The return
datatype can be any of the oracle datatypes like varchar, number etc.
2) The execution and exception section both should return a value which is of the data
type defined in the header section.
For example, let’s create a function called ''employer_details_func'
CREATE OR REPLACE FUNCTION employer_details_func
   RETURN VARCHAR(20);
 IS
   emp_name VARCHAR(20);
 BEGIN
     SELECT first_name INTO emp_name
     FROM emp_tbl WHERE empID = '100';
     RETURN emp_name;
 END;
 /
Function
How to execute a PL/SQL Function?
A function can be executed in the following ways.
1) Since a function returns a value we can assign it to a variable.
employee_name := employer_details_func;
If ‘employee_name’ is of datatype varchar we can store the name of the employee
by assigning the return type of the function to it.

2) As a part of a SELECT statement
SELECT employer_details_func FROM dual;

3) In a PL/SQL Statements like,
dbms_output.put_line(employer_details_func);
This line displays the value returned by the function.
Triggers

A trigger is a pl/sql block structure which is fired when a DML
statements like Insert, Delete, Update is executed on a
database table.
A trigger is triggered automatically when an associated DML
statement is executed.
Triggers
Syntax:
   CREATE [OR REPLACE ] TRIGGER trigger_name
   {BEFORE | AFTER }
   {INSERT [OR] | UPDATE [OR] | DELETE}
   [OF col_name] ON table_name
   [REFERENCING OLD AS old NEW AS new]
   [FOR EACH ROW]
   WHEN (condition)
   BEGIN
     --- sql statements
   END;
Triggers
● CREATE [OR REPLACE ] TRIGGER trigger_name - This clause
  creates a trigger with the given name or overwrites an existing trigger
  with the same name.
● {BEFORE | AFTER } - This clause indicates at what time should the
  trigger get fired. i.e for example: before or after updating a table.
● {INSERT [OR] | UPDATE [OR] | DELETE} - This clause determines the
  triggering event. More than one triggering events can be used together
  separated by OR keyword. The trigger gets fired at all the specified
  triggering event.
● [OF col_name] - This clause is used with update triggers. This clause
  is used when you want to trigger an event only when a specific column
  is updated.
Triggers
● [ON table_name] - This clause identifies the name of the table to which
  the trigger is associated.
● [REFERENCING OLD AS old NEW AS new] - This clause is used to
  reference the old and new values of the data being changed. By
  default, you reference the values as :old.column_name or :new.
  column_name. The reference names can also be changed from old (or
  new) to any other user-defined name. You cannot reference old values
  when inserting a record, or new values when deleting a record,
  because they do not exist.
● [FOR EACH ROW] - This clause is used to determine whether a trigger
  must fire when each row gets affected ( i.e. a Row Level Trigger) or
  just once when the entire sql statement is executed(i.e.statement level
  Trigger).
● WHEN (condition) - This clause is valid only for row level triggers. The
  trigger is fired only for rows that satisfy the condition specified.
Triggers
For Example: The price of a product changes constantly. It is important to maintain the
history of the prices of the products.
We can create a trigger to update the 'product_price_history' table when the price of the
product is updated in the 'product' table.
1) Create the 'product' table and 'product_price_history' table
CREATE TABLE product_price_history
(product_id number(5),
product_name varchar2(32),
supplier_name varchar2(32),
unit_price number(7,2) );
CREATE TABLE product
(product_id number(5),
product_name varchar2(32),
supplier_name varchar2(32),
unit_price number(7,2) );
Triggers
2) Create the price_history_trigger and execute it.
CREATE or REPLACE TRIGGER price_history_trigger
BEFORE UPDATE OF unit_price
ON product
FOR EACH ROW
BEGIN
INSERT INTO product_price_history
VALUES
(:old.product_id,
:old.product_name,
:old.supplier_name,
:old.unit_price);
END;
/
Triggers

3) Lets update the price of a product.
UPDATE PRODUCT SET unit_price = 800 WHERE product_id = 100
Once the above update query is executed, the trigger fires and updates the
'product_price_history' table.

4)If you ROLLBACK the transaction before committing to the database, the data inserted
to the table is also rolled back.
HTML
HTML or Hypertext Markup Language
 is the most widely used language on Web.
Technically, HTML is not a programming language, but rather a markup
language.
Before beginning:
it's important that you know Windows. A working knowledge of Windows
makes it much easier to learn HTML.
You should be familiar with:
Basic word processing using any text editor..
Basic understanding on internet browsing using a browser like Google Chrome
or Firefox etc.
HTML
Creating HTML Document:
  - Open Notepad or another text editor and type:
        <html>
             <head>
                  <title>This is document title</title>
             </head>
             <body>
                  <h1>This is a heading</h1>
                   <p>Document description goes here.....</p>
             </body>
        </html>
  - Name the file template.html.
  - Click Save.
HTML
Now you have created one HTML page and you can use a Web Browser to
open this HTML file to see the result.

Hope you understood that Web Pages are nothing but they are simple HTML
files with some content which can be rendered using Web Browsers.

Here <html>, <head>,...<p>, <h1> etc. are called HTML tags.
HTML tags are building blocks of an HTML document.

NOTE: One HTML file can have extension as .htm or .html. So you can use
either of them based on your comfort.
HTML
HTML Document Structure:
An HTML document starts and ends with <html> and >/html> tags. These tags
tell the browser that the entire document is composed in HTML. Inside these
two tags, the document is split into two sections:
The <head>...</head> elements, which contain information about the
document such as title of the document, author of the document etc.
The <body>...</body> elements, which contain the real content of the
document that you see on your screen.
HTML Tags and Elements:
HTML language is a markup language and we use many tags to markup text. You
have seen <html> etc. are called HTML tags or HTML elements.
Every tag consists of a tag name, sometimes followed by an optional list of tag
attributes , all placed between opening and closing brackets (< and >).
According to the HTML standard, tag and attribute names are not case-sensitive.
There's no difference in effect between <HEAD> and <HeaD>;
HTML
HTML Attributes:
An attribute is used to define the characteristics of an element and is placed inside the
element's opening tag.
All attributes are made up of two parts: a name and a value:
The name is the property you want to set.
The value is what you want the value of the property to be.
The value of the attribute should be put in double quotation marks, and is separated from
the name by the equals sign. <font face="arial" color="#CC0000">
The four core attributes that can be used on the majority of HTML elements
(although not all) are:
      id
      title
      class
      style
<p style="font-family:arial; color:#FF0000;">Some text...</p>
HTML
Create Headings - The <hn> Elements:
Any documents starts with a heading. You use different sizes for your
headings. HTML also have six levels of headings, which use the elements
<h1>, <h2>, <h3>, <h4>, <h5>, and <h6>. While displaying any heading,
browser adds one line before and after that heading.
Example:
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
HTML
Line Breaks
Hello<br />
You come most carefully upon your hour.<br />
Thanks<br />
 Mahnaz
Center Content
<p>This is not in the center.</p>
<center> <p>This is in the center.</p> </center>
Bold Text
<p>The following word uses a <b>bold</b> typeface.</p>
Italic Text
<p>The following word uses a <i>italicized</i> typeface.</p>
HTML
Style Tag
The HTML <style> tag is used for declaring style sheets within the head of your HTML
document.
<head>
<style type="text/css">
 h1 { color:#F1F1F1 }
</style>
</head>

<html>
     <body style="background-color:yellow;">
         <h2 style="background-color:red;">This is a heading</h2>
         <p style="background-color:green;">This is a paragraph.</p>
     </body>
</html>

More Related Content

What's hot (20)

Programming in Oracle with PL/SQL
Programming in Oracle with PL/SQLProgramming in Oracle with PL/SQL
Programming in Oracle with PL/SQL
lubna19
 
Commands of DML in SQL
Commands of DML in SQLCommands of DML in SQL
Commands of DML in SQL
Ashish Gaurkhede
 
Stored procedure
Stored procedureStored procedure
Stored procedure
baabtra.com - No. 1 supplier of quality freshers
 
Plsql
PlsqlPlsql
Plsql
fika sweety
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
Vaibhav Kathuria
 
Basic cursors in oracle
Basic cursors in oracleBasic cursors in oracle
Basic cursors in oracle
Suhel Firdus
 
Oracle: Cursors
Oracle: CursorsOracle: Cursors
Oracle: Cursors
DataminingTools Inc
 
PL-SQL DIFFERENT PROGRAMS
PL-SQL DIFFERENT PROGRAMSPL-SQL DIFFERENT PROGRAMS
PL-SQL DIFFERENT PROGRAMS
raj upadhyay
 
Plsql
PlsqlPlsql
Plsql
Mandeep Singh
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
Nick Buytaert
 
Plsql
PlsqlPlsql
Plsql
Shohan Ahmed
 
Oracle: Procedures
Oracle: ProceduresOracle: Procedures
Oracle: Procedures
DataminingTools Inc
 
Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL
Abdul Rehman
 
Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sql
naveen
 
Oracle: DML
Oracle: DMLOracle: DML
Oracle: DML
DataminingTools Inc
 
STRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGESTRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGE
SarithaDhanapal
 
Michael Colon Portfolio
Michael Colon PortfolioMichael Colon Portfolio
Michael Colon Portfolio
michael_colon
 
PostgreSQL- An Introduction
PostgreSQL- An IntroductionPostgreSQL- An Introduction
PostgreSQL- An Introduction
Smita Prasad
 
Sqlapi0.1
Sqlapi0.1Sqlapi0.1
Sqlapi0.1
jitendral
 
SQL
SQLSQL
SQL
Surendra Shukla
 

Viewers also liked (13)

Powerpoint tugas filsafat UNNES
Powerpoint tugas filsafat UNNESPowerpoint tugas filsafat UNNES
Powerpoint tugas filsafat UNNES
200409190711
 
Paradigma baru (kepengawasan)
Paradigma baru (kepengawasan)Paradigma baru (kepengawasan)
Paradigma baru (kepengawasan)
200409190711
 
Model manajemen pendidikan
Model manajemen pendidikanModel manajemen pendidikan
Model manajemen pendidikan
200409190711
 
Pendidikan Integral Transformatif
Pendidikan Integral TransformatifPendidikan Integral Transformatif
Pendidikan Integral Transformatif
200409190711
 
Fadli UNNES
Fadli UNNESFadli UNNES
Fadli UNNES
200409190711
 
Dynamic websites lec5
Dynamic websites lec5Dynamic websites lec5
Dynamic websites lec5
Belal Arfa
 
Tugas landasan educational psychology terbaru
Tugas landasan educational psychology  terbaruTugas landasan educational psychology  terbaru
Tugas landasan educational psychology terbaru
200409190711
 
Dynamic websites(lec1)
Dynamic websites(lec1)Dynamic websites(lec1)
Dynamic websites(lec1)
Belal Arfa
 
Presentation1
Presentation1Presentation1
Presentation1
Yohan Torres
 
English presentation g3 rombel 1
English presentation g3 rombel 1English presentation g3 rombel 1
English presentation g3 rombel 1
200409190711
 
Dynamic websites lec4
Dynamic websites lec4Dynamic websites lec4
Dynamic websites lec4
Belal Arfa
 
Dynamic websites lec2
Dynamic websites lec2Dynamic websites lec2
Dynamic websites lec2
Belal Arfa
 
Physiology of sense organ EYE
Physiology of sense organ EYEPhysiology of sense organ EYE
Physiology of sense organ EYE
Sudipta Himel
 
Powerpoint tugas filsafat UNNES
Powerpoint tugas filsafat UNNESPowerpoint tugas filsafat UNNES
Powerpoint tugas filsafat UNNES
200409190711
 
Paradigma baru (kepengawasan)
Paradigma baru (kepengawasan)Paradigma baru (kepengawasan)
Paradigma baru (kepengawasan)
200409190711
 
Model manajemen pendidikan
Model manajemen pendidikanModel manajemen pendidikan
Model manajemen pendidikan
200409190711
 
Pendidikan Integral Transformatif
Pendidikan Integral TransformatifPendidikan Integral Transformatif
Pendidikan Integral Transformatif
200409190711
 
Dynamic websites lec5
Dynamic websites lec5Dynamic websites lec5
Dynamic websites lec5
Belal Arfa
 
Tugas landasan educational psychology terbaru
Tugas landasan educational psychology  terbaruTugas landasan educational psychology  terbaru
Tugas landasan educational psychology terbaru
200409190711
 
Dynamic websites(lec1)
Dynamic websites(lec1)Dynamic websites(lec1)
Dynamic websites(lec1)
Belal Arfa
 
English presentation g3 rombel 1
English presentation g3 rombel 1English presentation g3 rombel 1
English presentation g3 rombel 1
200409190711
 
Dynamic websites lec4
Dynamic websites lec4Dynamic websites lec4
Dynamic websites lec4
Belal Arfa
 
Dynamic websites lec2
Dynamic websites lec2Dynamic websites lec2
Dynamic websites lec2
Belal Arfa
 
Physiology of sense organ EYE
Physiology of sense organ EYEPhysiology of sense organ EYE
Physiology of sense organ EYE
Sudipta Himel
 

Similar to Dynamic websites lec3 (20)

SQL / PL
SQL / PLSQL / PL
SQL / PL
srijanani2030
 
PLSQL.pptxokokokoo9oooodjdjfjfjfjrjejrjrrjrj
PLSQL.pptxokokokoo9oooodjdjfjfjfjrjejrjrrjrjPLSQL.pptxokokokoo9oooodjdjfjfjfjrjejrjrrjrj
PLSQL.pptxokokokoo9oooodjdjfjfjfjrjejrjrrjrj
KathanPatel49
 
Lecture Notes Unit5 chapter 15 PL/SQL Programming
Lecture Notes Unit5 chapter 15 PL/SQL ProgrammingLecture Notes Unit5 chapter 15 PL/SQL Programming
Lecture Notes Unit5 chapter 15 PL/SQL Programming
Murugan146644
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Alex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Alex Zaballa
 
Assignment#08
Assignment#08Assignment#08
Assignment#08
Sunita Milind Dol
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
Alex Zaballa
 
Module04
Module04Module04
Module04
Sridhar P
 
PLSQL
PLSQLPLSQL
PLSQL
Shubham Bammi
 
PL SQL.pptx in computer language in database
PL SQL.pptx in computer language in databasePL SQL.pptx in computer language in database
PL SQL.pptx in computer language in database
ironman82715
 
Lecture Notes Unit5 chapter17 Stored procedures and functions
Lecture Notes Unit5 chapter17 Stored procedures and functionsLecture Notes Unit5 chapter17 Stored procedures and functions
Lecture Notes Unit5 chapter17 Stored procedures and functions
Murugan146644
 
Java 17
Java 17Java 17
Java 17
Mutlu Okuducu
 
SQL Procedures & Functions
SQL Procedures & FunctionsSQL Procedures & Functions
SQL Procedures & Functions
JeevananthamArumugam
 
Unit 3
Unit 3Unit 3
Unit 3
Abha Damani
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
Reka
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
InSync Conference
 
Chapter8 pl sql
Chapter8 pl sqlChapter8 pl sql
Chapter8 pl sql
Jafar Nesargi
 
plsql.ppt
plsql.pptplsql.ppt
plsql.ppt
faizan992426
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
metsarin
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
Jay Patel
 
PLSQL.pptxokokokoo9oooodjdjfjfjfjrjejrjrrjrj
PLSQL.pptxokokokoo9oooodjdjfjfjfjrjejrjrrjrjPLSQL.pptxokokokoo9oooodjdjfjfjfjrjejrjrrjrj
PLSQL.pptxokokokoo9oooodjdjfjfjfjrjejrjrrjrj
KathanPatel49
 
Lecture Notes Unit5 chapter 15 PL/SQL Programming
Lecture Notes Unit5 chapter 15 PL/SQL ProgrammingLecture Notes Unit5 chapter 15 PL/SQL Programming
Lecture Notes Unit5 chapter 15 PL/SQL Programming
Murugan146644
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Alex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Alex Zaballa
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
Alex Zaballa
 
PL SQL.pptx in computer language in database
PL SQL.pptx in computer language in databasePL SQL.pptx in computer language in database
PL SQL.pptx in computer language in database
ironman82715
 
Lecture Notes Unit5 chapter17 Stored procedures and functions
Lecture Notes Unit5 chapter17 Stored procedures and functionsLecture Notes Unit5 chapter17 Stored procedures and functions
Lecture Notes Unit5 chapter17 Stored procedures and functions
Murugan146644
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
Reka
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
InSync Conference
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
metsarin
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
Jay Patel
 

Recently uploaded (20)

Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 

Dynamic websites lec3

  • 1. Dynamic Websites PHP with Oracle DB By Belal Arfa
  • 2. Section 3 In this section will discuss 1- Quiz 1 Notes 2- Quiz 2 3- Install Oracle 11g ex 4- SqlDev 5- PL/SQL 6- Stored Procedure 7- Function 8- Triggers 9- HTML
  • 3. Quiz (2) Relations: Classes(class, type, country, numGuns, bore, displacement) Ships(name, class, launched) Battles(name, date) Outcomes(ship, battle, result) Queries: a) Find the countries whose ships had the largest number of guns. b) Find the classes of ships at least one of which was sunk in a battle. c) Find the names of the ships with a 16-inch bore. d) Find the battles in which ships of the Kongo class participated.
  • 4. Quiz (2) Answer a) SELECT country FROM classes WHERE numGuns = (SELECT MAX(numGuns) from classes); b) SELECT DISTINCT class FROM Ships WHERE name IN (SELECT ship FROM Outcomes WHERE result = ‘sunk’); c) SELECT name FROM ships WHERE class IN (SELECT class from classes where bore = 16); - SELECT name FROM ships, classes WHERE ships.class = classes.class AND bore = 16; d) SELECT DISTINCT battle FROM ships, outcomes WHERE class = ‘Kongo’;
  • 5. Install Oracle 11g ex Be aware of OS type, Processor type and Oracle version type. Download it from Oracle ● Start Setup ● Next..... ● Enter Password be aware of this password because it will the system password ● Next.... ● Install.... ● Finish
  • 6. Sql Developer How to connect to your Database
  • 7. PL/SQL What is PL/SQL? PL/SQL stands for Procedural Language extension of SQL. PL/SQL is a combination of SQL along with the procedural features of programming languages. It was developed by Oracle Corporation in the early 90’s to enhance the capabilities of SQL. Advantages ● Block Structures: PL SQL consists of blocks of code, which can be nested within each other. Each block forms a unit of a task or a logical module. PL/SQL Blocks can be stored in the database and reused. ● Procedural Language Capability: PL SQL consists of procedural language constructs such as conditional statements (if else statements) and loops like (FOR loops). ● Better Performance: PL SQL engine processes multiple SQL statements simultaneously as a single block, thereby reducing network traffic. ● Error Handling: PL/SQL handles errors or exceptions effectively during the execution of a PL/SQL program. Once an exception is caught, specific actions can be taken depending upon the type of the exception or it can be displayed to the user with a message.
  • 8. Stored Procedures A stored procedure is a named PL/SQL block which performs one or more specific task. This is similar to a procedure in other programming languages. We can pass parameters to procedures in three ways. 1) IN-parameters 2) OUT-parameters 3) IN OUT-parameters A procedure may or may not return any value.
  • 9. Stored Procedure Syntax CREATE [OR REPLACE] PROCEDURE proc_name [list of parameters] IS Declaration section BEGIN Execution section EXCEPTION Exception section END; IS - marks the beginning of the body of the procedure and is similar to DECLARE in anonymous PL/SQL Blocks. The code between IS and BEGIN forms the Declaration section. The syntax within the brackets [ ] indicate they are optional. By using CREATE OR REPLACE together the procedure is created if no other procedure with the same name exists or the existing procedure is replaced with the current code.
  • 10. Stored Procedure Example CREATE OR REPLACE PROCEDURE insertDBUSER IS BEGIN INSERT INTO DBUSER ('USER_ID', 'USERNAME', 'PASSWORD', 'CREATED_DATE') VALUES (1, 'Belal','123', SYSDATE); COMMIT; END; / How to execute a Stored Procedure? There are two ways to execute a procedure. 1) From the SQL prompt: EXECUTE [or EXEC] procedure_name; 2) Within another procedure – simply use the procedure name: procedure_name; NOTE: In the examples given above, we are using backward slash ‘/’ at the end of the program. This indicates the oracle engine that the PL/SQL program has ended and it can begin processing the statements.
  • 11. Function What is a Function in PL/SQL? A function is a named PL/SQL Block which is similar to a procedure. The major difference between a procedure and a function is, a function must always return a value, but a procedure may or may not return a value. Syntax CREATE [OR REPLACE] FUNCTION function_name [parameters] RETURN return_datatype; IS Declaration_section BEGIN Execution_section Return return_variable; EXCEPTION exception section Return return_variable; END;
  • 12. Function 1) Return Type: The header section defines the return type of the function. The return datatype can be any of the oracle datatypes like varchar, number etc. 2) The execution and exception section both should return a value which is of the data type defined in the header section. For example, let’s create a function called ''employer_details_func' CREATE OR REPLACE FUNCTION employer_details_func RETURN VARCHAR(20); IS emp_name VARCHAR(20); BEGIN SELECT first_name INTO emp_name FROM emp_tbl WHERE empID = '100'; RETURN emp_name; END; /
  • 13. Function How to execute a PL/SQL Function? A function can be executed in the following ways. 1) Since a function returns a value we can assign it to a variable. employee_name := employer_details_func; If ‘employee_name’ is of datatype varchar we can store the name of the employee by assigning the return type of the function to it. 2) As a part of a SELECT statement SELECT employer_details_func FROM dual; 3) In a PL/SQL Statements like, dbms_output.put_line(employer_details_func); This line displays the value returned by the function.
  • 14. Triggers A trigger is a pl/sql block structure which is fired when a DML statements like Insert, Delete, Update is executed on a database table. A trigger is triggered automatically when an associated DML statement is executed.
  • 15. Triggers Syntax: CREATE [OR REPLACE ] TRIGGER trigger_name {BEFORE | AFTER } {INSERT [OR] | UPDATE [OR] | DELETE} [OF col_name] ON table_name [REFERENCING OLD AS old NEW AS new] [FOR EACH ROW] WHEN (condition) BEGIN --- sql statements END;
  • 16. Triggers ● CREATE [OR REPLACE ] TRIGGER trigger_name - This clause creates a trigger with the given name or overwrites an existing trigger with the same name. ● {BEFORE | AFTER } - This clause indicates at what time should the trigger get fired. i.e for example: before or after updating a table. ● {INSERT [OR] | UPDATE [OR] | DELETE} - This clause determines the triggering event. More than one triggering events can be used together separated by OR keyword. The trigger gets fired at all the specified triggering event. ● [OF col_name] - This clause is used with update triggers. This clause is used when you want to trigger an event only when a specific column is updated.
  • 17. Triggers ● [ON table_name] - This clause identifies the name of the table to which the trigger is associated. ● [REFERENCING OLD AS old NEW AS new] - This clause is used to reference the old and new values of the data being changed. By default, you reference the values as :old.column_name or :new. column_name. The reference names can also be changed from old (or new) to any other user-defined name. You cannot reference old values when inserting a record, or new values when deleting a record, because they do not exist. ● [FOR EACH ROW] - This clause is used to determine whether a trigger must fire when each row gets affected ( i.e. a Row Level Trigger) or just once when the entire sql statement is executed(i.e.statement level Trigger). ● WHEN (condition) - This clause is valid only for row level triggers. The trigger is fired only for rows that satisfy the condition specified.
  • 18. Triggers For Example: The price of a product changes constantly. It is important to maintain the history of the prices of the products. We can create a trigger to update the 'product_price_history' table when the price of the product is updated in the 'product' table. 1) Create the 'product' table and 'product_price_history' table CREATE TABLE product_price_history (product_id number(5), product_name varchar2(32), supplier_name varchar2(32), unit_price number(7,2) ); CREATE TABLE product (product_id number(5), product_name varchar2(32), supplier_name varchar2(32), unit_price number(7,2) );
  • 19. Triggers 2) Create the price_history_trigger and execute it. CREATE or REPLACE TRIGGER price_history_trigger BEFORE UPDATE OF unit_price ON product FOR EACH ROW BEGIN INSERT INTO product_price_history VALUES (:old.product_id, :old.product_name, :old.supplier_name, :old.unit_price); END; /
  • 20. Triggers 3) Lets update the price of a product. UPDATE PRODUCT SET unit_price = 800 WHERE product_id = 100 Once the above update query is executed, the trigger fires and updates the 'product_price_history' table. 4)If you ROLLBACK the transaction before committing to the database, the data inserted to the table is also rolled back.
  • 21. HTML HTML or Hypertext Markup Language is the most widely used language on Web. Technically, HTML is not a programming language, but rather a markup language. Before beginning: it's important that you know Windows. A working knowledge of Windows makes it much easier to learn HTML. You should be familiar with: Basic word processing using any text editor.. Basic understanding on internet browsing using a browser like Google Chrome or Firefox etc.
  • 22. HTML Creating HTML Document: - Open Notepad or another text editor and type: <html> <head> <title>This is document title</title> </head> <body> <h1>This is a heading</h1> <p>Document description goes here.....</p> </body> </html> - Name the file template.html. - Click Save.
  • 23. HTML Now you have created one HTML page and you can use a Web Browser to open this HTML file to see the result. Hope you understood that Web Pages are nothing but they are simple HTML files with some content which can be rendered using Web Browsers. Here <html>, <head>,...<p>, <h1> etc. are called HTML tags. HTML tags are building blocks of an HTML document. NOTE: One HTML file can have extension as .htm or .html. So you can use either of them based on your comfort.
  • 24. HTML HTML Document Structure: An HTML document starts and ends with <html> and >/html> tags. These tags tell the browser that the entire document is composed in HTML. Inside these two tags, the document is split into two sections: The <head>...</head> elements, which contain information about the document such as title of the document, author of the document etc. The <body>...</body> elements, which contain the real content of the document that you see on your screen. HTML Tags and Elements: HTML language is a markup language and we use many tags to markup text. You have seen <html> etc. are called HTML tags or HTML elements. Every tag consists of a tag name, sometimes followed by an optional list of tag attributes , all placed between opening and closing brackets (< and >). According to the HTML standard, tag and attribute names are not case-sensitive. There's no difference in effect between <HEAD> and <HeaD>;
  • 25. HTML HTML Attributes: An attribute is used to define the characteristics of an element and is placed inside the element's opening tag. All attributes are made up of two parts: a name and a value: The name is the property you want to set. The value is what you want the value of the property to be. The value of the attribute should be put in double quotation marks, and is separated from the name by the equals sign. <font face="arial" color="#CC0000"> The four core attributes that can be used on the majority of HTML elements (although not all) are: id title class style <p style="font-family:arial; color:#FF0000;">Some text...</p>
  • 26. HTML Create Headings - The <hn> Elements: Any documents starts with a heading. You use different sizes for your headings. HTML also have six levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>, <h5>, and <h6>. While displaying any heading, browser adds one line before and after that heading. Example: <h1>This is heading 1</h1> <h2>This is heading 2</h2> <h3>This is heading 3</h3> <h4>This is heading 4</h4> <h5>This is heading 5</h5> <h6>This is heading 6</h6>
  • 27. HTML Line Breaks Hello<br /> You come most carefully upon your hour.<br /> Thanks<br /> Mahnaz Center Content <p>This is not in the center.</p> <center> <p>This is in the center.</p> </center> Bold Text <p>The following word uses a <b>bold</b> typeface.</p> Italic Text <p>The following word uses a <i>italicized</i> typeface.</p>
  • 28. HTML Style Tag The HTML <style> tag is used for declaring style sheets within the head of your HTML document. <head> <style type="text/css"> h1 { color:#F1F1F1 } </style> </head> <html> <body style="background-color:yellow;"> <h2 style="background-color:red;">This is a heading</h2> <p style="background-color:green;">This is a paragraph.</p> </body> </html>