The document discusses Oracle PL/SQL programming concepts including triggers, stored procedures, packages, functions, and cursors. It provides examples of creating triggers for insert, update and delete operations on a student table to log changes to an audit table. Stored procedures are demonstrated for inserting, updating, and deleting records in a cities table. A stored procedure is also created to select data from the student table and return values using output parameters.
AHA is an upcoming tuition-free TK-8 public charter school (pending approval) with an emphasis in STEAM, Trilingual Learning, and Peacebuilding.
This is a brief overview of AHA and our program. For questions, contact info@adrianhandsacademy.org
Михайлова Е.В. Особенности PR-сопровождения вывода на рынок ТИКОprasu1995
Опубликовано в сборнике: PR и реклама в изменяющемся мире: Региональный аспект [Текст] : сборник статей/ под ред. М.В. Гундарина, А. Г. Сидоровой, Ю. В. Явинской. – Вып. 10. – Барнаул: Изд-во Алт. ун-та, 2012.
AHA is an upcoming tuition-free TK-8 public charter school (pending approval) with an emphasis in STEAM, Trilingual Learning, and Peacebuilding.
This is a brief overview of AHA and our program. For questions, contact info@adrianhandsacademy.org
Михайлова Е.В. Особенности PR-сопровождения вывода на рынок ТИКОprasu1995
Опубликовано в сборнике: PR и реклама в изменяющемся мире: Региональный аспект [Текст] : сборник статей/ под ред. М.В. Гундарина, А. Г. Сидоровой, Ю. В. Явинской. – Вып. 10. – Барнаул: Изд-во Алт. ун-та, 2012.
Плахин В.Т. Имя как «очаг» рекламного семиозисаprasu1995
Опубликовано в сборнике: PR и реклама в изменяющемся мире: Региональный аспект [Текст] : сборник статей/ под ред. М.В. Гундарина, А. Г. Сидоровой, Ю. В. Явинской. – Вып. 10. – Барнаул: Изд-во Алт. ун-та, 2012.
Tatjana Brzulović Stanisavljević held a presentation "Digital rights management" at the Serbian Library Association’s 10th International conference "The World and European Horizons of Librarianship in Digital Age", October 2011
Soy Ingeniero de Obras Públicas con 10 años de experiencia como jefe de obra civil. He realizado obras significativas tanto en Guipúzcoa como en Vizcaya. Mi experiencia va de obras de largo plazo y grandes recursos/presupuesto a realizar hasta 3 obras pequeñas simultáneamente. También he realizado obras de edificación como rehabilitaciones de oficinas, así como viviendas de nueva construcción.
En los últimos años he compatibilizado el trabajo como jefe de obra con el de realización de presupuestos para licitación con Promotores públicos y privados, también en UTE con grandes compañías, teniendo bajo mi responsabilidad a dos ingenieros para la redacción de las ofertas.
Soy un apasionado de la tecnología, siempre al día y dispuesto a aplicar los últimos avances a nuestro trabajo, tanto en los procedimientos y materiales de construcción como con las últimas herramientas de gestión y diseño.
An overview of the Business confidence monitor produced by the ICAEW in association with Grant Thornton UK LLP. Read more about business confidence by sector in this quarter here: http://www.grant-thornton.co.uk/en/Thinking/UK-business-confidence-mapped-by-sector/
Slides from Openworl 2019. A look at how to safely (and unsafely) kill sessions in the Oracle database, and how to perhaps avoid killing them altogether.
Slides from OpenWorld. Flashback has been around for long time yet people assume it should entirely within the realm of the DBA. But with modern development techniques such as continuous integration/continuous deployment, flashback actually is a perfect for *developers*
Плахин В.Т. Имя как «очаг» рекламного семиозисаprasu1995
Опубликовано в сборнике: PR и реклама в изменяющемся мире: Региональный аспект [Текст] : сборник статей/ под ред. М.В. Гундарина, А. Г. Сидоровой, Ю. В. Явинской. – Вып. 10. – Барнаул: Изд-во Алт. ун-та, 2012.
Tatjana Brzulović Stanisavljević held a presentation "Digital rights management" at the Serbian Library Association’s 10th International conference "The World and European Horizons of Librarianship in Digital Age", October 2011
Soy Ingeniero de Obras Públicas con 10 años de experiencia como jefe de obra civil. He realizado obras significativas tanto en Guipúzcoa como en Vizcaya. Mi experiencia va de obras de largo plazo y grandes recursos/presupuesto a realizar hasta 3 obras pequeñas simultáneamente. También he realizado obras de edificación como rehabilitaciones de oficinas, así como viviendas de nueva construcción.
En los últimos años he compatibilizado el trabajo como jefe de obra con el de realización de presupuestos para licitación con Promotores públicos y privados, también en UTE con grandes compañías, teniendo bajo mi responsabilidad a dos ingenieros para la redacción de las ofertas.
Soy un apasionado de la tecnología, siempre al día y dispuesto a aplicar los últimos avances a nuestro trabajo, tanto en los procedimientos y materiales de construcción como con las últimas herramientas de gestión y diseño.
An overview of the Business confidence monitor produced by the ICAEW in association with Grant Thornton UK LLP. Read more about business confidence by sector in this quarter here: http://www.grant-thornton.co.uk/en/Thinking/UK-business-confidence-mapped-by-sector/
Slides from Openworl 2019. A look at how to safely (and unsafely) kill sessions in the Oracle database, and how to perhaps avoid killing them altogether.
Slides from OpenWorld. Flashback has been around for long time yet people assume it should entirely within the realm of the DBA. But with modern development techniques such as continuous integration/continuous deployment, flashback actually is a perfect for *developers*
If you want ensure that sensitive data is masked when presented to the end user, you could change every single application and report ... or you could just do it in one place in the database.
Do you want to get up to speed with the most current release of Oracle Database? If so, this session is for you. You will learn about the most exciting and useful new features of Oracle Database 12c that can make your work as a database developer a lot easier. There is more to Oracle Database 12c than just pluggable databases.
Do you want to get up to speed with the most current release of Oracle Database? If so, this session is for you. You will learn about the most exciting and useful new features of Oracle Database 12c that can make your work as a database developer a lot easier. There is more to Oracle Database 12c than just pluggable databases.
Slides from the APAC Groundbreakers Tour from Perth and Melbourne legs. This session covered the features in 18c, 19c and 20c, along with the new free database offerings from Oracle from OpenWorld 2019
Slides from the ITOUG events in Rome and Milan 2020.
Most people think of the Flashback features in Oracle as the "In Case of Emergency" switch, to only be used when some catastrophe has occurred on your database. And while it is true that Flashback will definitely help you 3 seconds after you press the Commit button and you realise that you probably needed to have a WHERE clause on that "delete all rows from the SALES table" SQL statement. Or for when you run "drop table" on the Production database, when you were just so sure that you were logged onto the Test system. But Flashback is not only for those "Oh No!" moments. It enables benefits for developers ranging from data consistency to continuous integration and data auditing. Tucked away in Enterprise Edition are six independent and powerful technologies that might just save your career—they will also open up a myriad of other benefits of well.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
7. 6
Triggers
Connected to:
Personal Oracle Database 11g Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table student_aduit
2 (student_id Number(8,0),
3 salutation varchar2(5),
4 first_name varchar2(25),
5 last_name varchar2(25),
6 street_address varchar2(50),
7 zip varchar2(5),
8 phone varchar2(15),
9 record_id number,
10 modified_by varchar2(30)
11 );
Table created.
SQL> create sequence studentrecord_aduit_seq
2 start with 09081
3 increment by 45
4 nocycle
5 nocache;
Sequence created.
8. 7
SQL> create or replace trigger student_aduit_RD
2 before insert on student_aduit
3 for each row
4 begin
5 /* fill in the record_id with the primary key values created by sequence*/
6 select studentrecord_aduit_seq.nextval
7 into :NEW.record_id
8 from dual;
9 end student_aduit_RD;
10 /
Trigger created.
SQL> Alter table student_aduit
2 add modified_date date;
Table altered.
SQL> Alter table student_aduit
2 add EMPLOYER varchar2(50);
Table altered.
SQL> Alter table student_aduit
2 add REGISTRATION_DATE date;
Table altered.
SQL> Alter table student_aduit
2 add created_by varchar2(50);
Table altered.
SQL>
SQL> Alter table student_aduit
2 add CREATED_DATE date;
Table altered.
9. 8
SQL>descstudent_aduit;
Name Null? Type
----------------------------------------- -------- ----------------------------
STUDENT_ID NUMBER(8)
SALUTATION VARCHAR2(5)
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
STREET_ADDRESS VARCHAR2(50)
ZIP VARCHAR2(5)
PHONE VARCHAR2(15)
RECORD_ID NUMBER
MODIFIED_BY VARCHAR2(30)
MODIFIED_DATE DATE
EMPLOYER VARCHAR2(50)
REGISTRATION_DATE DATE
CREATED_BY VARCHAR2(50)
CREATED_DATE DATE
SQL> Alter table student_aduit
2 add action_typechar(12);
Table altered.
SQL> Create or replace trigger studentrecd_inst_trgg
2 after insert on student
3 for each row
4 begin
5 insert into student_aduit(student_id,salutation,first_name, last_name,
6 street_address, zip, phone, employer, registration_date, created_by, created_date)
7 select :New.student_id,:New.salutation, :New.first_name. :New.last_name,
8 :NEW.street_address, :New.zip, :New.phone, :New.employer, :New.registration_date,
9 :NEW.created_by, :NEW.created_date FROM DUAL;
10 ENDstudentrecd_inst_trgg;
11 /
10. 9
Warning: Trigger created with compilation errors.
SQL> SHOW ERRORS;
Errors for TRIGGER STUDENTRECD_INST_TRGG:
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/4 PL/SQL: SQL Statement ignored
4/60 PL/SQL: ORA-00919: invalid function
SQL> Create or replace trigger studentrecd_4
2 after insert on STUDENT
3 for each row
4 begin
5 insert into student_aduit(student_id,salutation,first_name, last_name, street_address, zip, phone, employer, registration_date, created_by, created_date)
6 select :New.student_id,:New.salutation, :New.first_name, :New.last_name,
7 :NEW.street_address, :New.zip, :New.phone, :New.employer, :New.registration_date,
8 :NEW.created_by, :NEW.created_date FROM DUAL;
9 END studentrecd_4;
10 /
Trigger created.
SQL> Create or replace trigger studentrecd_updt_trg
2 after update on student
3 for each row
11. 10
4 begin
5 insert into student_aduit(student_id,salutation,first_name, last_name, street_address, zip, phone, employer, registration_date, modified_by,
modified_date)
6 select :New.student_id,:New.salutation, :New.first_name, :New.last_name,
7 :NEW.street_address, :New.zip, :New.phone, :New.employer, :New.registration_date,
8 :NEW.modified_by, :NEW.modified_date FROM DUAL;
9 ENDstudentrecd_updt_trg;
10 /
Trigger created.
Create or replace trigger studentrecd_delt_trg
after delete on student
for each row
begin
insert into student_aduit(student_id,salutation,first_name, last_name, street_address, zip, phone, employer, registration_date, modified_by, modified_date)
select :old.student_id,:old.salutation, :old.first_name, :old.last_name,
:old.street_address, :old.zip, :old.phone, :old.employer, :old.registration_date,
:old.modified_by, :old.modified_date FROM DUAL;
END studentrecd_delt_trg;
/
Trigger created.
insert into student(salutation, first_name, last_name, street_address,
zip,phone,employer,registration_date, created_by, created_date, student_id, modified_by ,MODIFIED_DATE)
values('Mr', 'Jackson','Philp','1900 E Bellview Apt 341D','07055',
'7089809812','County Foods',(select sysdate from dual),'Jackson',(select sysdate from dual), 805678, 'NA',
(selectsysdate from dual));
1 row created.
select * from student where student_id = 805678
12. 11
STUDENT_ID SALUTATION FIRST_NAME LAST_NAME STREET_ADDRESS ZIP PHONE EMPLOYER
REGISTRATION_DATE CREATED_BY CREATED_DATE MODIFIED_BY MODIFIED_DATE
---------------------- ---------- ------------------------- ------------------------- -------------------------------------------------- ----- --------------- -------------------------------------------------- -----
-------------------- ------------------------------ ------------------------- ------------------------------ -------------------------
805678 Mr Jackson Philp 1900 E Bellview Apt 341D 07055 7089809812 County Foods
15-MAR-13 Jackson 15-MAR-13 NA 15-MAR-13
update student
set last_name ='Mark',
modified_by='Jackson',
Modified_date = (select sysdate from dual)
wherestudent_id = 805678;
select * from student_aduit;
STUDE
NT_ID
SALUT
ATION
FIRST_
NAME
LAST_
NAME
STREET_ADD
RESS
ZIP PHON
E
RECO
RD_I
D
MODIF
IED_BY
MODIFIE
D_DATE
EMPL
OYER
REGISTRATIO
N_DATE
CREAT
ED_BY
CREATED_D
ATE
ACTION_T
YPE
80567
8
Mr Jackso
n
Philp 1900 E
Bellview Apt
341D
705
5
70898
09812
9171 Coun
ty
Foods
3/15/2013 Jackso
n
3/15/2013
80567
8
Mr Jackso
n
Philp 1900 E
Bellview Apt
341D
705
5
70898
09812
9216 Coun
ty
Foods
3/15/2013 Jackso
n
3/15/2013
80567
8
Mr Jackso
n
Mark 1900 E
Bellview Apt
341D
705
5
70898
09812
9261 Jackso
n
3/15/201
3
Coun
ty
Foods
3/15/2013
13. 12
SQL> delete student where student_id = 805678;
1 row deleted.
SQL> commit;
select * from student_aduit;
STUDE
NT_ID
SALUT
ATION
FIRST_
NAME
LAST_
NAME
STREET_ADDR
ESS
ZI
P
PHON
E
RECOR
D_ID
MODIFI
ED_BY
MODIFIE
D_DATE
EMPLO
YER
REGISTRATI
ON_DATE
CREAT
ED_BY
CREATED
_DATE
ACTION
_TYPE
805678 Mr Jackson Philp 1900 E
Bellview Apt
341D
70
55
70898
09812
9171 County
Foods
3/15/2013 Jackson 3/15/20
13
805678 Mr Jackson Philp 1900 E
Bellview Apt
341D
70
55
70898
09812
9216 County
Foods
3/15/2013 Jackson 3/15/20
13
805678 Mr Jackson Mark 1900 E
Bellview Apt
341D
70
55
70898
09812
9261 Jackson 3/15/201
3
County
Foods
3/15/2013
805678 Mr Jackson Mark 1900 E
Bellview Apt
341D
70
55
70898
09812
9306 Jackson 3/15/201
3
County
Foods
3/15/2013
14. 13
selecttrigger_name, trigger_type, triggering_event, table_name,
column_name, action_type, trigger_body,REFERENCING_NAMES ,CROSSEDITION
fromuser_triggers
TRIGGER_NAM
E
TRIGGE
R_TYPE
TRIGGERIN
G_EVENT
TABLE_
NAME
COLUMN
_NAME
ACTION
_TYPE
TRIGGER_BODY REFERENCI
NG_NAMES
CROSSE
DITION
STUDENTRECD
_INST_TRGG
AFTER
EACH
ROW
INSERT STUDENT PL/SQL begin
insert into
student_aduit(student_id,s
alutation,first_name,
last_name,
street_address,
REFERENCIN
G NEW AS
NEW OLD AS
OLD
NO
STUDENTRECD
_UPDT_TRG
AFTER
EACH
ROW
UPDATE STUDENT PL/SQL begin
insert into
student_aduit(student_id,s
alutation,first_name,
last_name, street_address,
zip,
REFERENCIN
G NEW AS
NEW OLD AS
OLD
NO
STUDENT_ADUI
T_RD
BEFORE
EACH
ROW
INSERT STUDENT
_ADUIT
PL/SQL begin
/* fill in the record_id
with the primary key
values created by
sequence*/
select studentrec
REFERENCIN
G NEW AS
NEW OLD AS
OLD
NO
STUDENTRECD
_4
AFTER
EACH
ROW
INSERT STUDENT PL/SQL begin
insert into
student_aduit(student_id,s
alutation,first_name,
last_name, street_address,
zip,
REFERENCIN
G NEW AS
NEW OLD AS
OLD
NO
STUDENTRECD
_DELT_TRG
AFTER
EACH
ROW
DELETE STUDENT PL/SQL begin
insert into
student_aduit(student_id,s
alutation,first_name,
REFERENCIN
G NEW AS
NEW OLD AS
OLD
NO
16. 15
Stored Procedures
SQL> Create table cities
2 (city_namechar(45),
3 Location_Statechar(45),
4 country char(45)
5 );
Table created.
SQL>
SQL> create or replace procedure city
2 (city_namecity.city_name%TYPE,
3 Location_statecity.Location_State%TYPE,
4 country city.country%TYPE
5 )
6 AS BEGIN
7 INSERT INTO city(city_name, location_state, country)
8 values(city_name, location_state, country);
9 End city;
10 /
Warning: Procedure created with compilation errors.
SQL> show errors;
Errors for PROCEDURE CITY:
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
2/13 PLS-00225: subprogram or cursor 'CITY' reference is out of scope
SQL> create or replace procedure city
2 (city_namecities.city_name%TYPE,
3 Location_statecities.Location_State%TYPE,
17. 16
4 country cities.country%TYPE
5 )
6 AS BEGIN
7 INSERT INTO city(city_name, location_state, country)
8 values(city_name, location_state, country);
9 End city;
10 /
Warning: Procedure created with compilation errors.
SQL> show errors;
Errors for PROCEDURE CITY:
LINE/COL ERROR
-------- -----------------------------------------------------------------
7/7 PL/SQL: SQL Statement ignored
7/19 PL/SQL: ORA-04044: procedure, function, package, or type is not
allowed here
create or replace procedure city_insert
(city_namecities.city_name%TYPE,
Location_statecities.Location_State%TYPE,
countrycities.country%TYPE
)
AS BEGIN
INSERT INTO cities(city_name, location_state, country)
values(city_name, location_state, country);
End city_insert;
/
Procedure created.
SQL> Begin
2 city_insert('Washington','DC','USA');
18. 17
3 city_insert('Chicago','IL','USA');
4 End;
5 /
PL/SQL procedure successfully completed.
Select * from cities;
CITY_NAME LOCATION_STATE COUNTRY
Washington DC USA
Chicago IL USA
/
Begin
city_insert('Portland','Or','USA');
city_insert('Portland','ME','USA');
city_insert('New York','NY', 'USA');
End;
/
Select * from cities;
CITY_NAME LOCATION_STATE COUNTRY
Washington DC USA
Chicago IL USA
Portland Or USA
Portland ME USA
New York NY USA
20. 19
AS BEGIN
INSERT INTO cities(city_name,city_id, location_state, country)
values(city_name, city_id, location_state, country);
End city_insert;
/
SQL> Begin
2 city_insert('Portland',909,'Or','USA');
3 city_insert('Portland',890,'ME','USA');
4 city_insert('New York',788,'NY', 'USA');
5 city_insert('chicago',789,'IL', 'USA');
6 city_insert('Washington',787,'DC', 'USA');
7 End;
8 /
PL/SQL procedure successfully completed.
Select * from cities
CITY_NAME LOCATION_STATE COUNTRY CITY_ID
Portland Or USA 909
Portland ME USA 890
New York NY USA 788
chicago IL USA 789
Washington DC USA 787
21. 20
SQL> begin
2 city_update('IL','787');
3 end;
4 /
Select * from cities
CITY_NAME LOCATION_STATE COUNTRY CITY_ID
Portland Or USA 909
Portland ME USA 890
New York NY USA 788
chicago IL USA 789
Washington IL USA 787
SQL> create or replace procedure city_delete
2 (
3 c_idcities.city_id%TYPE
4 )AS Begin
5 delete cities
6 where city_id = c_id;
7 endcity_delete;
8 /
Procedure created.
22. 21
Select * from cities
CITY_NAME LOCATION_STATE COUNTRY CITY_ID
Portland Or USA 909
Portland ME USA 890
New York NY USA 788
chicago IL USA 789
SQL>
SQL> create or replace procedure studentselect
2 (stud_id in student.student_id%TYPE,
3 salut OUT student.salutation%TYPE,
4 F_name OUT student.first_name%TYPE,
5 L_Name OUT student.Last_name%TYPE,
6 S_Add OUTstudent.Street_Address%TYPE,
7 ZIP OUTstudent.ZIP%TYPE,
8 Phone OUT student.phone%TYPE,
9 EMP OUT student.Employer%Type,
10 RegdateOUT student.Registration_Date%TYPE,
11 Crdate OUT student.Created_date%TYPE,
12 CBY OUT student.created_by%TYPE,
13 MBY OUTstudent.Modified_by%TYPE,
14 MdateOUT student.Modified_date%Type)
15 IS
16 BEGIN
17 SELECT
18 initcap( SALUTATION)as SALUTATION, initcap (FIRST_NAME)as First_Name
nitcap (LAST_NAME)as Last_Name,
19 initcap(STREET_ADDRESS)as Street_Address,
30. 29
35 /
Name :Mr.Asian,Chirichella
STUDENT_ADDRESS : 134-25 Franklin Ave. #512
CITY : Flushing
R_STATE : NY
ZIP: 11355
PHONE: 718-555-5555
EMPLOYER :Peo Capital Corp.
REGISTRATION_DATE : February -23-2007
CREATED_DATE: February -23-2007
CREATED_BY: BROSENZWEIG
MODIFIED_BY: BROSENZW
MODIFIED_DATE: February -26-2007
PL/SQL procedure successfully completed.
SQL>
SELECT * FROM USER_PROCEDURES WHERE OBJECT_TYPE = 'PROCEDURE' ;
31. 30
SELECT * FROM USER_PROCEDURES WHERE OBJECT_TYPE ='PACKAGE';
OBJECT_NAME PROCEDURE_NAME OBJECT_ID SUBPROGRAM_ID OBJECT_TYPE AGGREGATE PIPELINED PARALLEL INTERFACE DETERMINISTIC AUTHID
STUDENTSELECT 72969 1 PROCEDURE NO NO NO NO NO DEFINER
CITY_DELETE 72966 1 PROCEDURE NO NO NO NO NO DEFINER
CITY_INSERT 72964 1 PROCEDURE NO NO NO NO NO DEFINER
CITY_UPDATE 72965 1 PROCEDURE NO NO NO NO NO DEFINER
CITY 72963 1 PROCEDURE NO NO NO NO NO DEFINER
STUDENT_SELECT 72968 1 PROCEDURE NO NO NO NO NO DEFINER
OBJECT_NAME PROCEDURE_NAME OBJECT_ID SUBPROGRAM_ID OBJECT_TYPE AGGREGATE PIPELINED PARALLEL INTERFACE DETERMINISTIC AUTHID
CITIESDB UPDATECITY 73066 1 PACKAGE NO NO NO NO NO DEFINER
CITIESDB DELETECITY 73066 2 PACKAGE NO NO NO NO NO DEFINER
CITIESDB 73066 0 PACKAGE NO NO NO NO NO DEFINER
32. 31
Packages
SQL> CREATE OR REPLACE PACKAGE CitiesDB as
2 PROCEDURE updatecity(CID IN CITIES.CITY_ID%TYPE,
3 CSTATE IN CITIES.LOCATION_STATE%TYPE,
4 CCITY IN CITIES.CITY_NAME%TYPE );
5 PROCEDURE DELETECITY(CID IN CITIES.CITY_ID%TYPE);
6
7 END CitiesDB;
8 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY CitiesDB as
2 PROCEDURE updatecity(CID IN CITIES.CITY_ID%TYPE,
3 CSTATE IN CITIES.LOCATION_STATE%TYPE,
4 CCITY IN CITIES.CITY_NAME%TYPE ) IS
5 BEGIN
6 UPDATE CITIES
7 SET CITY_NAME = CCITY, LOCATION_STATE = CSTATE
8 WHERE CITY_ID = CID;
9 END updatecity;
10
11 PROCEDURE DELETECITY(CID IN CITIES.CITY_ID%TYPE) IS
12 BEGIN
13 DELETE FROM CITIES
14 WHERE CITY_ID = CID;
15 END DELETECITY;
16
17 END CitiesDB;
18 /
Package body created.
33. 32
SQL> BEGIN
2 CitiesDB.updatecity(789,'PA', 'CHICAGO');
3 END;
4 /
PL/SQL procedure successfully completed.
SELECT * FROM CITIES;
CITY_NAME LOCATION_STATE COUNTRY CITY_ID
Portland Or USA 909
Portland ME USA 890
New York NY USA 788
CHICAGO PA USA 789
SQL>
SQL> BEGIN
2 CitiesDB.updatecity(909, 'WA','PORTLAND' );
3 CitiesDB.DELETECITY(890);
4 END;
5 /
PL/SQL procedure successfully completed.
CITY_NAME LOCATION_STATE COUNTRY CITY_ID
PORTLAND WA USA 909
New York NY USA 788
CHICAGO PA USA 789
34. 33
Functions
SQL> CREATE OR REPLACE FUNCTION STUDENTNAME
2 (studid in student.student_id%TYPE
3 )
4 RETURN
5 VARCHAR2 IS
6
7 STUDENT_NAME VARCHAR2(50);
8 BEGIN
9
10 SELECT INITCAP (S.FIRST_NAME||','||S.LAST_NAME)AS NAME
11 INTO
12 STUDENT_NAME
13 FROM STUDENT S
14 WHERE S.STUDENT_ID = studid;
15
16 RETURN STUDENT_NAME;
17
18 END STUDENTNAME;
19 /
Function created.
SQL> COMMIT;
Commit complete.
35. 34
SQL>
SQL> SELECT STUDENTNAME(STUDENT_ID)STUDENT_NAME
2 FROM STUDENT
3 WHERE STUDENT_ID =120;
STUDENT_NAME
---------------------------------------------------
Ralph,Alexander
SQL>
SQL> SELECT STUDENTNAME(S.STUDENT_ID)STUDENT_NAME
2 ,S.STUDENT_ID, SUM(G.NUMERIC_GRADE)AS GRADE,
3 G.SECTION_ID
4 FROM STUDENT S
5 INNER JOIN GRADE G
6 ON
7 S.STUDENT_ID = G.STUDENT_ID
8 WHERE S.STUDENT_ID = 120
9 AND
10 G.SECTION_ID = 103
11 GROUP BY STUDENTNAME(S.STUDENT_ID), S.STUDENT_ID, G.SECTION_ID;
STUDENT_NAME
--------------------------------------------------------------------------
STUDENT_ID GRADE SECTION_ID
---------- ---------- ----------
Ralph,Alexander
120 751 103
36. 35
SQL> GROUP BY STUDENTNAME(S.STUDENT_ID), S.STUDENT_ID, G.SECTION_ID;
SP2-0734: unknown command beginning "GROUP BY S..." - rest of line ignored.
SQL>SELECT STUDENTNAME(S.STUDENT_ID)STUDENT_NAME
2 ,S.STUDENT_ID, SUM(G.NUMERIC_GRADE)AS GRADE,
3 G.SECTION_ID
4 FROM STUDENT S
5 INNER JOIN GRADE G
6 ON
7 S.STUDENT_ID = G.STUDENT_ID
8 WHERE S.STUDENT_ID IN( 120,211)
9 GROUP BY STUDENTNAME(S.STUDENT_ID), S.STUDENT_ID, G.SECTION_ID;
STUDENT_NAME
--------------------------------------------------------------------------------
STUDENT_ID GRADE SECTION_ID
---------- ---------- ----------
Jenny,Goldsmith
211 798 141
Jenny,Goldsmith
211 943 86
Ralph,Alexander
120 751 103
create OR REPLACE view S_GRADES
(STUDENT_NAME, STUDENT_ID, GRADE, INSTRUCTOR_NAME, SECTION_ID, DESCRIPTION)
as
SELECT S.salutation||''||S.first_name ||','||S.last_name as Student_Name
,S.STUDENT_ID, SUM(G.NUMERIC_GRADE)AS GRADE, I.salutation||''||I.first_name ||','||I.last_name as Instructor_Name,
G.SECTION_ID, C.DESCRIPTION as DESCRIPTION
37. 36
FROM STUDENT S
INNER JOIN GRADE G
ON
S.STUDENT_ID = G.STUDENT_ID
INNER JOIN SECTION T
ON
G.SECTION_ID = T.SECTION_ID
INNER JOIN COURSE C
ON
C.COURSE_NO = T.COURSE_NO
INNER JOIN INSTRUCTOR I
ON
T.INSTRUCTOR_ID = I.INSTRUCTOR_ID
group by S.salutation||''||S.first_name ||','||S.last_name, S.STUDENT_ID, I.salutation||''||I.first_name ||','||I.last_name,
G.SECTION_ID, C.DESCRIPTION;
38. 37
Cursors
Explicit Cursors
SQL> show user;
USER is "SUNNY"
SQL>
SQL> set serveroutput on
SQL> declare
2 salustudent.salutation%type;
3 fnamestudent.first_name%type;
4 lnamestudent.last_name%type;
5 saddressstudent.street_address%TyPE;
6 scityzipcode.city%Type;
7 sstatezipcode.state%Type;
8 szipzipcode.zip%type;
9 sphonestudent.phone%type;
10 sregdatevarchar2(80) :=0;
11 rowcount PLS_INTEGER :=0;
12
13 cursorstudrec
14 is
15 SELECT S.SALUTATION ,S.FIRST_NAME, S.LAST_NAME,
16 S.STREET_ADDRESS,Z.CITY,Z.STATE,Z.ZIP,S.PHONE, TO_CHAR(S.REGISTRATION_DATE,'MON-DD-RRRR') AS REGISTRATION_DATE
17 FROM STUDENT S INNER JOIN ZIPCODE Z
18 ON
19 S.ZIP = Z.ZIP;
20
21 begin
22
23 openstudrec;
24 loop
25 fetchstudrec into salu,fname, lname, saddress,scity,sstate,szip, sphone,sregdate;
26 EXIT when studrec%NOTFOUND;
27 rowcount :=studrec%ROWCOUNT;
28
29 DBMS_OUTPUT.PUT_LINE(rowcount ||' ' ||'is the number of rows processed ');
30 DBMS_OUTPUT.PUT_LINE('Student Name:'||' '||salu||' '||fname||' '||lname);
31 DBMS_OUTPUT.PUT_LINE('Address:'||saddress);
32 DBMS_OUTPUT.PUT_LINE('City:'||scity);
39. 38
33 DBMS_OUTPUT.PUT_LINE('State:'||sstate);
34 DBMS_OUTPUT.PUT_LINE('Phone:'||sphone);
35 DBMS_OUTPUT.PUT_LINE('REGISTRATION DATE:'||sregdate);
36 END LOOP;
37 CLOSEstudrec;
38
39 IFstudrec%ISOPEN = FALSE
40 THEN
41 DBMS_OUTPUT.PUT_LINE('Cursor is closed');
42 ELSE
43 DBMS_OUTPUT.PUT_LINE('Cursor is open');
44 END IF;
45 EXCEPTION
46 WHEN OTHERS
47 THEN
48 DBMS_OUTPUT.PUT_LINE(SQLERRM);
49 END;
50 /
1 is the number of rows processed
Student Name: Mr. Jim Joas
Address:53-33 192nd St.
City:Fresh Meadows
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
2 is the number of rows processed
Student Name: Ms. Sally Naso
Address:812 79th St.
City:North Bergen
State:NJ
Phone:201-555-5555
REGISTRATION DATE:FEB-02-2007
3 is the number of rows processed
Student Name: Mr. Frantz McLean
Address:23-08 Newtown Ave.
City:Astoria
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
40. 39
4 is the number of rows processed
Student Name: Ms. P. Balterzar
Address:30 Carriage Rd.
City:Roslyn
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
Results Abridged
SQL> set serveroutput on
SQL> declare
2 studidstudent.student_id%type;
3 salustudent.salutation%type;
4 fnamestudent.first_name%type;
5 lnamestudent.last_name%type;
6 saddressstudent.street_address%TyPE;
7 scityzipcode.city%Type;
8 sstatezipcode.state%Type;
9 szipzipcode.zip%type;
10 sphonestudent.phone%type;
11 sregdatevarchar2(80) :=0;
12 rowcount PLS_INTEGER :=0;
13
14 cursorstudrec(studidint)
15 is
16 SELECT S.SALUTATION ,S.FIRST_NAME, S.LAST_NAME,
17 S.STREET_ADDRESS,Z.CITY,Z.STATE,Z.ZIP,S.PHONE, TO_CHAR(S.REGISTRATION_DATE,'MON-DD-RRRR') AS REGISTRATION_DATE,
18 S.STUDENT_ID
19 FROM STUDENT S INNER JOIN ZIPCODE Z
20 ON
21 S.ZIP = Z.ZIP
22 wherestudent_id<studid ;
23
24 begin
25
26 openstudrec(375);
27 loop
28 fetch studrec into salu,fname, lname, saddress,scity,sstate,szip, sphone,sregdate,studid ;
29 EXIT when studrec%NOTFOUND;
41. 40
30 rowcount :=studrec%ROWCOUNT;
31
32 DBMS_OUTPUT.PUT_LINE(rowcount ||' ' ||'is the number of rows processed ');
33 DBMS_OUTPUT.PUT_LINE('Student ID:'||' '||studid);
34 DBMS_OUTPUT.PUT_LINE('Student Name:'||' '||salu||' '||fname||' '||lname);
35 DBMS_OUTPUT.PUT_LINE('Address:'||saddress);
36 DBMS_OUTPUT.PUT_LINE('City:'||scity);
37 DBMS_OUTPUT.PUT_LINE('State:'||sstate);
38 DBMS_OUTPUT.PUT_LINE('Phone:'||sphone);
39 DBMS_OUTPUT.PUT_LINE('REGISTRATION DATE:'||sregdate);
40 END LOOP;
41 CLOSEstudrec;
42
43 IFstudrec%ISOPEN = FALSE
44 THEN
45 DBMS_OUTPUT.PUT_LINE('Cursor is closed');
46 ELSE
47 DBMS_OUTPUT.PUT_LINE('Cursor is open');
48 END IF;
49 EXCEPTION
50 WHEN OTHERS
51 THEN
52 DBMS_OUTPUT.PUT_LINE(SQLERRM);
53 END;
54 /
1 is the number of rows processed
Student ID: 167
Student Name: Mr. Jim Joas
Address:53-33 192nd St.
City:Fresh Meadows
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
2 is the number of rows processed
Student ID: 168
Student Name: Ms. Sally Naso
Address:812 79th St.
City:North Bergen
State:NJ
42. 41
Phone:201-555-5555
REGISTRATION DATE:FEB-02-2007
3 is the number of rows processed
Student ID: 169
Student Name: Mr. Frantz McLean
Address:23-08 Newtown Ave.
City:Astoria
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
4 is the number of rows processed
Student ID: 170
Student Name: Ms. P. Balterzar
Address:30 Carriage Rd.
City:Roslyn
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
Results Abridged
SQL> set serveroutput on
SQL> declare
2 studidstudent.student_id%type;
3 salustudent.salutation%type;
4 fnamestudent.first_name%type;
5 lnamestudent.last_name%type;
6 saddressstudent.street_address%TyPE;
7 scityzipcode.city%Type;
8 sstatezipcode.state%Type;
9 szipzipcode.zip%type;
10 sphonestudent.phone%type;
11 sregdatevarchar2(80) :=0;
12 rowcount PLS_INTEGER :=0;
13
14 cursorstudrec(studidint)
15 is
16 SELECT S.SALUTATION ,S.FIRST_NAME, S.LAST_NAME,
17 S.STREET_ADDRESS,Z.CITY,Z.STATE,Z.ZIP,S.PHONE, TO_CHAR(S.REGISTRATION_DATE,'MON-DD-RRRR') AS REGISTRATION_DATE,
18 S.STUDENT_ID
43. 42
19 FROM STUDENT S INNER JOIN ZIPCODE Z
20 ON
21 S.ZIP = Z.ZIP
22 wherestudent_id != studid;
23
24 begin
25
26 openstudrec(375);
27 loop
28 fetch studrec into salu,fname, lname, saddress,scity,sstate,szip, sphone,sregdate,studid ;
29 EXIT when studrec%NOTFOUND;
30 rowcount :=studrec%ROWCOUNT;
31
32 DBMS_OUTPUT.PUT_LINE(rowcount ||' ' ||'is the number of rows processed ');
33 DBMS_OUTPUT.PUT_LINE('Student ID:'||' '||studid);
34 DBMS_OUTPUT.PUT_LINE('Student Name:'||' '||salu||' '||fname||' '||lname);
35 DBMS_OUTPUT.PUT_LINE('Address:'||saddress);
36 DBMS_OUTPUT.PUT_LINE('City:'||scity);
37 DBMS_OUTPUT.PUT_LINE('State:'||sstate);
38 DBMS_OUTPUT.PUT_LINE('Phone:'||sphone);
39 DBMS_OUTPUT.PUT_LINE('REGISTRATION DATE:'||sregdate);
40 END LOOP;
41 CLOSEstudrec;
42
43 IFstudrec%ISOPEN = FALSE
44 THEN
45 DBMS_OUTPUT.PUT_LINE('Cursor is closed');
46 ELSE
47 DBMS_OUTPUT.PUT_LINE('Cursor is open');
48 END IF;
49 EXCEPTION
50 WHEN OTHERS
51 THEN
52 DBMS_OUTPUT.PUT_LINE(SQLERRM);
53 END;
54 /
1 is the number of rows processed
Student ID: 167
Student Name: Mr. Jim Joas
44. 43
Address:53-33 192nd St.
City:Fresh Meadows
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
2 is the number of rows processed
Student ID: 168
Student Name: Ms. Sally Naso
Address:812 79th St.
City:North Bergen
State:NJ
Phone:201-555-5555
REGISTRATION DATE:FEB-02-2007
3 is the number of rows processed
Student ID: 169
Student Name: Mr. Frantz McLean
Address:23-08 Newtown Ave.
City:Astoria
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
4 is the number of rows processed
Student ID: 170
Student Name: Ms. P. Balterzar
Address:30 Carriage Rd.
City:Roslyn
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
5 is the number of rows processed
Student ID: 171
Student Name: Ms. Denise Brownstein
Address:104-36 196th St.
City:Hollis
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
6 is the number of rows processed
Student ID: 172
45. 44
Student Name: Ms. Maria Arias
Address:Box 216
City:Bellrose
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
7 is the number of rows processed
Student ID: 173
Student Name: Mr. Oscar McGill
Address:578 E 40th ST.
City:Brooklyn
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
8 is the number of rows processed
Student ID: 174
Student Name: Mr. Michael Brown
Address:265 Hawthorne St #2D
City:Brooklyn
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
9 is the number of rows processed
Student ID: 175
Student Name: Ms. Debra Boyce
Address:294 East 98 St.
City:Brooklyn
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
10 is the number of rows processed
Student ID: 176
Student Name: Ms. Beth Satterfield
Address:140 Amity St
City:Brooklyn
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-02-2007
Results Abridged
46. 45
SQL>
SQL> set serveroutput on
SQL> declare
2 studidstudent.student_id%type;
3 salustudent.salutation%type;
4 fnamestudent.first_name%type;
5 lnamestudent.last_name%type;
6 saddressstudent.street_address%TyPE;
7 scityzipcode.city%Type;
8 sstatezipcode.state%Type;
9 szipzipcode.zip%type;
10 sphonestudent.phone%type;
11 sregdatevarchar2(80) :=0;
12 rowcount PLS_INTEGER :=0;
13
14 cursorstudrec(studidint)
15 is
16 SELECT S.SALUTATION ,S.FIRST_NAME, S.LAST_NAME,
17 S.STREET_ADDRESS,Z.CITY,Z.STATE,Z.ZIP,S.PHONE, TO_CHAR(S.REGISTRATION_DATE,'MON-DD-RRRR') AS REGISTRATION_DATE,
18 S.STUDENT_ID
19 FROM STUDENT S INNER JOIN ZIPCODE Z
20 ON
21 S.ZIP = Z.ZIP
22 wherestudent_id = studid;
23
24 begin
25
26 openstudrec(375);
27 loop
28 fetch studrec into salu,fname, lname, saddress,scity,sstate,szip, sphone,sregdate,studid ;
29 EXIT when studrec%NOTFOUND;
30 rowcount :=studrec%ROWCOUNT;
31
32 DBMS_OUTPUT.PUT_LINE(rowcount ||' ' ||'is the number of rows processed ');
33 DBMS_OUTPUT.PUT_LINE('Student ID:'||' '||studid);
34 DBMS_OUTPUT.PUT_LINE('Student Name:'||' '||salu||' '||fname||' '||lname);
35 DBMS_OUTPUT.PUT_LINE('Address:'||saddress);
47. 46
36 DBMS_OUTPUT.PUT_LINE('City:'||scity);
37 DBMS_OUTPUT.PUT_LINE('State:'||sstate);
38 DBMS_OUTPUT.PUT_LINE('Phone:'||sphone);
39 DBMS_OUTPUT.PUT_LINE('REGISTRATION DATE:'||sregdate);
40 END LOOP;
41
42
43 IFstudrec%ISOPEN = FALSE
44 THEN
45 DBMS_OUTPUT.PUT_LINE('Cursor is closed');
46 ELSE
47 DBMS_OUTPUT.PUT_LINE('Cursor is open');
48 END IF;
49 EXCEPTION
50 WHEN OTHERS
51 THEN
52 DBMS_OUTPUT.PUT_LINE(SQLERRM);
53 END;
54 /
1 is the number of rows processed
Student ID: 375
Student Name: Mr. Jack Kasperovich
Address:98-17 162nd Ave.
City:Howard Bank
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-21-2007
Cursor is open
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL> set serveroutput on
SQL> declare
2 studidstudent.student_id%type;
3 salustudent.salutation%type;
4 fnamestudent.first_name%type;
5 lnamestudent.last_name%type;
48. 47
6 saddressstudent.street_address%TyPE;
7 scityzipcode.city%Type;
8 sstatezipcode.state%Type;
9 szipzipcode.zip%type;
10 sphonestudent.phone%type;
11 sregdatevarchar2(80) :=0;
12 rowcount PLS_INTEGER :=0;
13
14 cursorstudrec(studidint)
15 is
16 SELECT S.SALUTATION ,S.FIRST_NAME, S.LAST_NAME,
17 S.STREET_ADDRESS,Z.CITY,Z.STATE,Z.ZIP,S.PHONE, TO_CHAR(S.REGISTRATION_DATE,'MON-DD-RRRR') AS REGISTRATION_DATE,
18 S.STUDENT_ID
19 FROM STUDENT S INNER JOIN ZIPCODE Z
20 ON
21 S.ZIP = Z.ZIP
22 wherestudent_id = studid;
23
24 begin
25
26 openstudrec(375);
27 loop
28 fetch studrec into salu,fname, lname, saddress,scity,sstate,szip, sphone,sregdate,studid ;
29 EXIT when studrec%NOTFOUND;
30 rowcount :=studrec%ROWCOUNT;
31
32 DBMS_OUTPUT.PUT_LINE(rowcount ||' ' ||'is the number of rows processed ');
33 DBMS_OUTPUT.PUT_LINE('Student ID:'||' '||studid);
34 DBMS_OUTPUT.PUT_LINE('Student Name:'||' '||salu||' '||fname||' '||lname);
35 DBMS_OUTPUT.PUT_LINE('Address:'||saddress);
36 DBMS_OUTPUT.PUT_LINE('City:'||scity);
37 DBMS_OUTPUT.PUT_LINE('State:'||sstate);
38 DBMS_OUTPUT.PUT_LINE('Phone:'||sphone);
39 DBMS_OUTPUT.PUT_LINE('REGISTRATION DATE:'||sregdate);
40 END LOOP;
41 CLOSEstudrec;
42
43 IFstudrec%ISOPEN = FALSE
44 THEN
49. 48
45 DBMS_OUTPUT.PUT_LINE('Cursor is closed');
46 ELSE
47 DBMS_OUTPUT.PUT_LINE('Cursor is open');
48 END IF;
49 EXCEPTION
50 WHEN OTHERS
51 THEN
52 DBMS_OUTPUT.PUT_LINE(SQLERRM);
53 END;
54 /
1 is the number of rows processed
Student ID: 375
Student Name: Mr. Jack Kasperovich
Address:98-17 162nd Ave.
City:Howard Bank
State:NY
Phone:718-555-5555
REGISTRATION DATE:FEB-21-2007
Cursor is closed
PL/SQL procedure successfully completed.
SQL>
SQL> SET ECHO OFF;
SQL> SPOOL OFF;
Implicit Cursors
SET SERVEROUTPUT ON
BEGIN
DBMS_OUTPUT.ENABLE(1000000);
UPDATE STUDENT
SET FIRST_NAME = 'JACKSON'
WHERE STUDENT_ID = 375;
DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT||'rows updated');
50. 49
IF SQL%NOTFOUND
THEN
DBMS_OUTPUT.PUT_LINE('CHECK THE STUDENT ID ENTERED BECAUSE IS NOT FOUND IN DATABASE');
END IF;
COMMIT;
EXCEPTION
WHEN OTHERS
THEN DBMS_OUTPUT.PUT_lINE(SQLERRM);
END;
/
anonymous block completed
1rows updated
select first_name ,last_name, student_id from student where student_id = 375
FIRST_NAME LAST_NAME STUDENT_ID
JACKSON Kasperovich 375
SET SERVEROUTPUT ON
BEGIN
DBMS_OUTPUT.ENABLE(1000000);
UPDATE STUDENT
SET FIRST_NAME = 'JACKSON'
WHERE STUDENT_ID = 500;
DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT||'rows updated');
IF SQL%NOTFOUND
THEN
DBMS_OUTPUT.PUT_LINE('CHECK THE STUDENT ID ENTERED BECAUSE IS NOT FOUND IN DATABASE');
END IF;
COMMIT;
51. 50
EXCEPTION
WHEN OTHERS
THEN DBMS_OUTPUT.PUT_lINE(SQLERRM);
END;
anonymous block completed
0rows updated
CHECK THE STUDENT ID ENTERED BECAUSE IS NOT FOUND IN DATABASE
Records
SQL> DECLARE
2
3 Studentsstudent%rowtype;
4
5 begin
6
7 Students.student_id :=400;
8 Students.first_name :='joe';
9 Students.last_name :='Joe';
10 Students.street_address := '5909 Wood Lane Drv';
11 Students.zip := '48104';
12 Students.phone := '709-908-9876';
13 Students.Employer :='ABC NEWS';
14 Students.Registration_date := '30-jan-09';
52. 51
15 Students.Created_date := '30-jan-09';
16 Students.modified_date := '30-jan-09';
17 Students.created_by := 'sunny';
18 Students.modified_by :='sunny';
19
20
21 insert into student(student_id, first_name, last_name,street_address,zip,phone,
22 employer, registration_date, created_date, modified_date, created_by,modified_by)
23 values(Students.student_id,Students.first_name ,Students.last_name , Students.street_address,
24 Students.zip,Students.phone,Students.Employer, Students.Registration_date ,
25 Students.Created_date ,Students.modified_date, Students.created_by,
26 Students.modified_by
27 );
28
29 end;
30 /
PL/SQL procedure successfully completed.
SQL> commit;
Commit complete.
select first_name,last_name,student_id from student where student_id =400;
DECLARE
TYPE studentsR is record
( student_idstudent.student_id%TYPE,
first_namestudent.first_name%TYPE,
last_namestudent.last_name%TYPE,
street_addressstudent.street_address%TYPE,
phonestudent.phone%TYPE,
zip student.zip%TYPE,
FIRST_NAME LAST_NAME STUDENT_ID
joe Joe 400
54. 53
select first_name,last_name,student_id from student where student_id =600;
FIRST_NAME LAST_NAME STUDENT_ID
Michael Joesph 600
Oracle Label Security
DBA
SQL> create user secmanidentified by s;
User created.
SQL> create user bank identified by b;
User created.
SQL> grant dba to secman;
Grant succeeded.
SQL> grant create session , resources to bank;
grant create session , resources to bank
*
ERROR at line 1:
ORA-01919: role 'RESOURCES' does not exist
SQL> grant create session , resource to bank;
55. 54
Grant succeeded.
SQL> spool off
grant execute on dbms_rls to secman;
grant execute succeeded.
grant execute on dbms_rls to system;
grant execute succeeded.
SQL> create user lara identified by l;
User created.
SQL> create user scott identified by s;
User created.
SQL> grant create session to scott, lara;
Grant succeeded.
SQL> set echo off
SQL> spool off;
USER Secman
SQL> create table access_policy
2 (AM_NAME VARCHAR2(20) NOT NULL,
3 CUST_ID NUMBER NOT NULL,
4 ACCESS_TYPE CHAR(1) NOT NULL);
Table created.
SQL>
SQL> INSERT INTO ACCESS_POLICY(AM_NAME, CUST_ID, ACCESS_TYPE)
2 VALUES('SCOTT', 123, 'S');