SlideShare une entreprise Scribd logo
1  sur  5
Anar Godjaev
http://anargodjaev.wordpress.com/

PL/SQL Blocks
declare
--<Variables, Cursors, user defined exception>
begin
--<Sql statements>
--<PL/SQL statements>
exception
When <exception name> then
--<Actions to perform when errors, occur>
end;

EX:
declare
v_variablevarchar2(15);
begin
selectcolumn_name
intov_variable
fromtable_name;
exception
whenothers then
null;
end;

create or replace procedure <procedure_name> as
--<declare any variables here>
begin
null;
end;

create or replace function <function_name> return <datatype> as
--<declare any veriables here>
begin
return<value>;
end;

Variable Types:
scalar (single value) -- varchar2, number, date, subtype
composite (records) -- record, plsql table
reference (pointer) -- ref cursor
LOB (large objects) -- BLOB, CLOB, LOB
Bind variables -- variables defined outside plsql block, ex: .NET, Java, sqlplus
Scalar data types:
Anar Godjaev
http://anargodjaev.wordpress.com/

Char, varchar2, long, number, binary_integer, boolean, date, timestamp, timestamp
withtimezone, timestamp with local time zone
declare
str_jobvarchar2(15);
int_countbinary_integer := 0;
n_tot_salnumber(9,2);
cons_numconstant number(3,2) := 8.25;
b_validboolean not null default true;
_name employees.last_name%TYPE;
date_dtdate := sysdate+7;
subtypetype_my_varchar varchar2(100);
type_my_charmy_varchar;

EX:
declare
n_deptnonumber(4); --departments.department_no%TYPE
n_location_idnumber(4); --departments.locations_id%TYPE
begin
selectdepartment_id, location_id
intov_deptno, v_location_id
fromdepartments where department_name= 'Sales';
end;

Composite data types:
Records:
rec_tbl_based is table_name%ROWTYPE;
rec_cur_based is cur_name%ROWTYPE;
typetype_rec_var_based is (field1 datatype1, field2 datatype2, .. )
rec_my_recordtype_rec_var_based
selectcol_name into rec_my_record.col_name from table_name;
selectrec_my_record.col_name from dual;
EX:
declare
rec_empemployees%ROWTYPE;
n_employee_numbernumber := 1024;
begin
select* into emp_recfrom employees
whereemployee_id= n_employee_number;
insert into retired_emps
(emp_no, ename, job, mng, hire_date, leave_date, sql, comm, rept_no)
values
(emp_rec.employee_id, emprec.lastname,...);
commit;
end;
Anar Godjaev
http://anargodjaev.wordpress.com/
EX:
declare
typeemp_record_typeis record
(
last_namevarchar2(25),
job_idvarchar2(10),
salarynumber(8,2)
);
emp_recordemp_record_type;
begin
emp_record.last_name:= 'ERGEM';
dbms_output.put_line(emp_record.last_name);
end;

Plsql Tables:
typetype_tbl_city_codes is table of varchar2(50);
typetype_tbl_city_codes is table of t_city.code%TYPE;
typetype_tbl_based_on_cur is table of type_rec_var_based
[index by binary integer];
tbl_city_codestype_tbl_city_codes;
select code into tbl_city_codes(15) from t_city where city_id=15;
selecttbl_city_codes(15) from dual;
typeename_table_type is table of employees.lastname%TYPE
index by binary_integer;
ename_tableename_table_type;

EX:
declare
-- declare the table type
typeename_table_typeis table of
varchar2(100);--employees.last_name%TYPE index by binary integer;
typehiredate_table_typeis table of
dateindex by binary_integer;
-- declare the table type variable
ename_tableename_table_type;
hiredate_tablehiredate_table_type;
begin
-- initialize the table by a call to the constructor
ename_table:= ename_table_type();
-- extend the table
ename_table.extend(1);
-- assign a value
ename_table(1) := 'cameron';
-- indexed tables do not need initializing and extending
Anar Godjaev
http://anargodjaev.wordpress.com/
-- hiredate_table := hiredate_table_type();
-- hiredate_table.extend(10);
hiredate_table(8) := sysdate + 7;
ifename_table.exists(1) then
--insert into ...
dbms_output.put_line(ename_table(1));
dbms_output.put_line(hiredate_table(8));
end if;
end;

Pl/SQL table attributes:
Exists [(n)]
Count
First
Last
Prior [(n)]
Next [(n)]
Trim [(n)] -- rename one element from end table
Delete [(n)] -- remove elements

EX:
declare
typeemp_table_typeis table of employees%ROWTYPE
index by binary_integer;
my_emp_tableemp_table_type;
v_countnumber(3) := 104;
begin
fori in 10.. v_countloop
select* into my_emp_table(i) from employees
whereemployee_id= i;
end loop;
fori in my_emp_table.first .. my_emp_table.last loop
dbms_output.put_line(my_emp_table.lastname(i));
end loop;
end;

Variables in nested blocks:
declare
d_birth_date date;
begin
declare
d_birth_date date;
begin
...
Outer.d_birth_date:=to_Date(’03-NOV-2013’,’DD-MON-YYYY’);
end;
Anar Godjaev
http://anargodjaev.wordpress.com/
...
end;
EX:
<<outer>>-- label the outer block
Declare
n_sum_salnumber(10,2);
n_dept_nonumber not null := 60;
--n_employee_idemployees.employee_id%TYPE;
Begin
declare
n_sum_salnumber(10,2) := 1111;
begin
/*
select sum(salary) into outer.n_sum_sal
from employees
wheredepartment_id = n_dept_no;
*/
-- call to outer block variable
outer.n_sum_sal:= 2532.22;
end;
dbms_output.put_line('The outer sum salary is: ' ||
to_char(n_sum_sal));
/*
selecthire_date from employees
whereemployee_id = n_employee_id;
*/
end;

Contenu connexe

Tendances

Александр Трищенко: PHP 7 Evolution
Александр Трищенко: PHP 7 EvolutionАлександр Трищенко: PHP 7 Evolution
Александр Трищенко: PHP 7 EvolutionOleg Poludnenko
 
The Truth About Lambdas in PHP
The Truth About Lambdas in PHPThe Truth About Lambdas in PHP
The Truth About Lambdas in PHPSharon Levy
 
Data structure circular list
Data structure circular listData structure circular list
Data structure circular listiCreateWorld
 
(Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++ (Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++ Eli Diaz
 
(Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++ (Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++ Eli Diaz
 
Single linked list
Single linked listSingle linked list
Single linked listSayantan Sur
 
Circular linked list
Circular linked listCircular linked list
Circular linked listSayantan Sur
 
Conditional Control
Conditional ControlConditional Control
Conditional ControlAnar Godjaev
 
Double linked list
Double linked listDouble linked list
Double linked listSayantan Sur
 
2 3. standard io
2 3. standard io2 3. standard io
2 3. standard io웅식 전
 
Михаил Крайнюк. Form api: ajax-commands
Михаил Крайнюк. Form api: ajax-commandsМихаил Крайнюк. Form api: ajax-commands
Михаил Крайнюк. Form api: ajax-commandsKsenia Rogachenko
 
Chaincode Development 區塊鏈鏈碼開發
Chaincode Development 區塊鏈鏈碼開發Chaincode Development 區塊鏈鏈碼開發
Chaincode Development 區塊鏈鏈碼開發HO-HSUN LIN
 
Perl gui
Perl guiPerl gui
Perl guiumnix
 
TestFest - Respect\Validation 1.0
TestFest - Respect\Validation 1.0TestFest - Respect\Validation 1.0
TestFest - Respect\Validation 1.0Henrique Moody
 

Tendances (20)

Александр Трищенко: PHP 7 Evolution
Александр Трищенко: PHP 7 EvolutionАлександр Трищенко: PHP 7 Evolution
Александр Трищенко: PHP 7 Evolution
 
The Truth About Lambdas in PHP
The Truth About Lambdas in PHPThe Truth About Lambdas in PHP
The Truth About Lambdas in PHP
 
Data structure circular list
Data structure circular listData structure circular list
Data structure circular list
 
(Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++ (Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++
 
(Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++ (Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++
 
Clauses
ClausesClauses
Clauses
 
Single linked list
Single linked listSingle linked list
Single linked list
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
Conditional Control
Conditional ControlConditional Control
Conditional Control
 
Final ds record
Final ds recordFinal ds record
Final ds record
 
Double linked list
Double linked listDouble linked list
Double linked list
 
2 3. standard io
2 3. standard io2 3. standard io
2 3. standard io
 
Password.php
Password.phpPassword.php
Password.php
 
week-14x
week-14xweek-14x
week-14x
 
C program to implement linked list using array abstract data type
C program to implement linked list using array abstract data typeC program to implement linked list using array abstract data type
C program to implement linked list using array abstract data type
 
Array menu
Array menuArray menu
Array menu
 
Михаил Крайнюк. Form api: ajax-commands
Михаил Крайнюк. Form api: ajax-commandsМихаил Крайнюк. Form api: ajax-commands
Михаил Крайнюк. Form api: ajax-commands
 
Chaincode Development 區塊鏈鏈碼開發
Chaincode Development 區塊鏈鏈碼開發Chaincode Development 區塊鏈鏈碼開發
Chaincode Development 區塊鏈鏈碼開發
 
Perl gui
Perl guiPerl gui
Perl gui
 
TestFest - Respect\Validation 1.0
TestFest - Respect\Validation 1.0TestFest - Respect\Validation 1.0
TestFest - Respect\Validation 1.0
 

Similaire à PL/SQL Blocks

The Story About The Migration
 The Story About The Migration The Story About The Migration
The Story About The MigrationEDB
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1Swapnali Pawar
 
Lecture 3 sql {basics ddl commands}
Lecture 3 sql {basics  ddl commands}Lecture 3 sql {basics  ddl commands}
Lecture 3 sql {basics ddl commands}Shubham Shukla
 
Exploring collections with example
Exploring collections with exampleExploring collections with example
Exploring collections with examplepranav kumar verma
 
Where's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsWhere's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsEleanor McHugh
 
Oracle - Program with PL/SQL - Lession 01
Oracle - Program with PL/SQL - Lession 01Oracle - Program with PL/SQL - Lession 01
Oracle - Program with PL/SQL - Lession 01Thuan Nguyen
 
Web Developer make the most out of your Database !
Web Developer make the most out of your Database !Web Developer make the most out of your Database !
Web Developer make the most out of your Database !Jean-Marc Desvaux
 
Programming in Oracle with PL/SQL
Programming in Oracle with PL/SQLProgramming in Oracle with PL/SQL
Programming in Oracle with PL/SQLlubna19
 
Databricks Sql cheatseet for professional exam
Databricks Sql cheatseet for professional examDatabricks Sql cheatseet for professional exam
Databricks Sql cheatseet for professional examRupiniSarguru
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Achmad Solichin
 
Function Procedure Trigger Partition.pdf
Function Procedure Trigger Partition.pdfFunction Procedure Trigger Partition.pdf
Function Procedure Trigger Partition.pdfSanam Maharjan
 
Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05Thuan Nguyen
 

Similaire à PL/SQL Blocks (20)

DOODB_LAB.pptx
DOODB_LAB.pptxDOODB_LAB.pptx
DOODB_LAB.pptx
 
The Story About The Migration
 The Story About The Migration The Story About The Migration
The Story About The Migration
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 
Lecture 3 sql {basics ddl commands}
Lecture 3 sql {basics  ddl commands}Lecture 3 sql {basics  ddl commands}
Lecture 3 sql {basics ddl commands}
 
Trig
TrigTrig
Trig
 
Exploring collections with example
Exploring collections with exampleExploring collections with example
Exploring collections with example
 
Where's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsWhere's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord Migrations
 
Sql
SqlSql
Sql
 
Oracle - Program with PL/SQL - Lession 01
Oracle - Program with PL/SQL - Lession 01Oracle - Program with PL/SQL - Lession 01
Oracle - Program with PL/SQL - Lession 01
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
Taller
TallerTaller
Taller
 
Web Developer make the most out of your Database !
Web Developer make the most out of your Database !Web Developer make the most out of your Database !
Web Developer make the most out of your Database !
 
Programming in Oracle with PL/SQL
Programming in Oracle with PL/SQLProgramming in Oracle with PL/SQL
Programming in Oracle with PL/SQL
 
Databricks Sql cheatseet for professional exam
Databricks Sql cheatseet for professional examDatabricks Sql cheatseet for professional exam
Databricks Sql cheatseet for professional exam
 
Query
QueryQuery
Query
 
Les09
Les09Les09
Les09
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
 
Function Procedure Trigger Partition.pdf
Function Procedure Trigger Partition.pdfFunction Procedure Trigger Partition.pdf
Function Procedure Trigger Partition.pdf
 
PLSQL.pptx
PLSQL.pptxPLSQL.pptx
PLSQL.pptx
 
Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05
 

Plus de Anar Godjaev

Asm disk group migration from
Asm disk group migration from Asm disk group migration from
Asm disk group migration from Anar Godjaev
 
How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...Anar Godjaev
 
how to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaulthow to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaultAnar Godjaev
 
Database Vault / Verinin Güvenliği
Database Vault /  Verinin GüvenliğiDatabase Vault /  Verinin Güvenliği
Database Vault / Verinin GüvenliğiAnar Godjaev
 
Oracle Golden Gate
Oracle Golden GateOracle Golden Gate
Oracle Golden GateAnar Godjaev
 
Oracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumOracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumAnar Godjaev
 
DataPump ile Single Parititon Export
DataPump ile Single Parititon ExportDataPump ile Single Parititon Export
DataPump ile Single Parititon ExportAnar Godjaev
 
Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Anar Godjaev
 
Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Anar Godjaev
 
Instance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeInstance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeAnar Godjaev
 
Audit Mekani̇zmasi
Audit Mekani̇zmasiAudit Mekani̇zmasi
Audit Mekani̇zmasiAnar Godjaev
 
Backup and Recovery
Backup and RecoveryBackup and Recovery
Backup and RecoveryAnar Godjaev
 

Plus de Anar Godjaev (20)

Oracle GoldenGate
Oracle GoldenGateOracle GoldenGate
Oracle GoldenGate
 
Asm disk group migration from
Asm disk group migration from Asm disk group migration from
Asm disk group migration from
 
How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...How to protect your sensitive data using oracle database vault / Creating and...
How to protect your sensitive data using oracle database vault / Creating and...
 
how to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vaulthow to protect your sensitive data using oracle database vault
how to protect your sensitive data using oracle database vault
 
Database Vault / Verinin Güvenliği
Database Vault /  Verinin GüvenliğiDatabase Vault /  Verinin Güvenliği
Database Vault / Verinin Güvenliği
 
Oracle Golden Gate
Oracle Golden GateOracle Golden Gate
Oracle Golden Gate
 
Oracle 10g Database Server Kurulum
Oracle 10g Database Server KurulumOracle 10g Database Server Kurulum
Oracle 10g Database Server Kurulum
 
DataPump ile Single Parititon Export
DataPump ile Single Parititon ExportDataPump ile Single Parititon Export
DataPump ile Single Parititon Export
 
Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇Redologlar ve Yöneti̇mi̇
Redologlar ve Yöneti̇mi̇
 
Contraints
ContraintsContraints
Contraints
 
Oracle SQL
Oracle SQLOracle SQL
Oracle SQL
 
Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇Veri̇tabani ve Kullanici Yöneti̇mi̇
Veri̇tabani ve Kullanici Yöneti̇mi̇
 
Instance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını IncelemeInstance ve Media Bozukluklarını Inceleme
Instance ve Media Bozukluklarını Inceleme
 
Wait Interface
Wait InterfaceWait Interface
Wait Interface
 
Audit Mekani̇zmasi
Audit Mekani̇zmasiAudit Mekani̇zmasi
Audit Mekani̇zmasi
 
Tuning SGA
Tuning SGATuning SGA
Tuning SGA
 
Parallel Server
Parallel ServerParallel Server
Parallel Server
 
Table Partitions
Table PartitionsTable Partitions
Table Partitions
 
Backup and Recovery
Backup and RecoveryBackup and Recovery
Backup and Recovery
 
Memory Management
Memory ManagementMemory Management
Memory Management
 

Dernier

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Dernier (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

PL/SQL Blocks

  • 1. Anar Godjaev http://anargodjaev.wordpress.com/ PL/SQL Blocks declare --<Variables, Cursors, user defined exception> begin --<Sql statements> --<PL/SQL statements> exception When <exception name> then --<Actions to perform when errors, occur> end; EX: declare v_variablevarchar2(15); begin selectcolumn_name intov_variable fromtable_name; exception whenothers then null; end; create or replace procedure <procedure_name> as --<declare any variables here> begin null; end; create or replace function <function_name> return <datatype> as --<declare any veriables here> begin return<value>; end; Variable Types: scalar (single value) -- varchar2, number, date, subtype composite (records) -- record, plsql table reference (pointer) -- ref cursor LOB (large objects) -- BLOB, CLOB, LOB Bind variables -- variables defined outside plsql block, ex: .NET, Java, sqlplus Scalar data types:
  • 2. Anar Godjaev http://anargodjaev.wordpress.com/ Char, varchar2, long, number, binary_integer, boolean, date, timestamp, timestamp withtimezone, timestamp with local time zone declare str_jobvarchar2(15); int_countbinary_integer := 0; n_tot_salnumber(9,2); cons_numconstant number(3,2) := 8.25; b_validboolean not null default true; _name employees.last_name%TYPE; date_dtdate := sysdate+7; subtypetype_my_varchar varchar2(100); type_my_charmy_varchar; EX: declare n_deptnonumber(4); --departments.department_no%TYPE n_location_idnumber(4); --departments.locations_id%TYPE begin selectdepartment_id, location_id intov_deptno, v_location_id fromdepartments where department_name= 'Sales'; end; Composite data types: Records: rec_tbl_based is table_name%ROWTYPE; rec_cur_based is cur_name%ROWTYPE; typetype_rec_var_based is (field1 datatype1, field2 datatype2, .. ) rec_my_recordtype_rec_var_based selectcol_name into rec_my_record.col_name from table_name; selectrec_my_record.col_name from dual; EX: declare rec_empemployees%ROWTYPE; n_employee_numbernumber := 1024; begin select* into emp_recfrom employees whereemployee_id= n_employee_number; insert into retired_emps (emp_no, ename, job, mng, hire_date, leave_date, sql, comm, rept_no) values (emp_rec.employee_id, emprec.lastname,...); commit; end;
  • 3. Anar Godjaev http://anargodjaev.wordpress.com/ EX: declare typeemp_record_typeis record ( last_namevarchar2(25), job_idvarchar2(10), salarynumber(8,2) ); emp_recordemp_record_type; begin emp_record.last_name:= 'ERGEM'; dbms_output.put_line(emp_record.last_name); end; Plsql Tables: typetype_tbl_city_codes is table of varchar2(50); typetype_tbl_city_codes is table of t_city.code%TYPE; typetype_tbl_based_on_cur is table of type_rec_var_based [index by binary integer]; tbl_city_codestype_tbl_city_codes; select code into tbl_city_codes(15) from t_city where city_id=15; selecttbl_city_codes(15) from dual; typeename_table_type is table of employees.lastname%TYPE index by binary_integer; ename_tableename_table_type; EX: declare -- declare the table type typeename_table_typeis table of varchar2(100);--employees.last_name%TYPE index by binary integer; typehiredate_table_typeis table of dateindex by binary_integer; -- declare the table type variable ename_tableename_table_type; hiredate_tablehiredate_table_type; begin -- initialize the table by a call to the constructor ename_table:= ename_table_type(); -- extend the table ename_table.extend(1); -- assign a value ename_table(1) := 'cameron'; -- indexed tables do not need initializing and extending
  • 4. Anar Godjaev http://anargodjaev.wordpress.com/ -- hiredate_table := hiredate_table_type(); -- hiredate_table.extend(10); hiredate_table(8) := sysdate + 7; ifename_table.exists(1) then --insert into ... dbms_output.put_line(ename_table(1)); dbms_output.put_line(hiredate_table(8)); end if; end; Pl/SQL table attributes: Exists [(n)] Count First Last Prior [(n)] Next [(n)] Trim [(n)] -- rename one element from end table Delete [(n)] -- remove elements EX: declare typeemp_table_typeis table of employees%ROWTYPE index by binary_integer; my_emp_tableemp_table_type; v_countnumber(3) := 104; begin fori in 10.. v_countloop select* into my_emp_table(i) from employees whereemployee_id= i; end loop; fori in my_emp_table.first .. my_emp_table.last loop dbms_output.put_line(my_emp_table.lastname(i)); end loop; end; Variables in nested blocks: declare d_birth_date date; begin declare d_birth_date date; begin ... Outer.d_birth_date:=to_Date(’03-NOV-2013’,’DD-MON-YYYY’); end;
  • 5. Anar Godjaev http://anargodjaev.wordpress.com/ ... end; EX: <<outer>>-- label the outer block Declare n_sum_salnumber(10,2); n_dept_nonumber not null := 60; --n_employee_idemployees.employee_id%TYPE; Begin declare n_sum_salnumber(10,2) := 1111; begin /* select sum(salary) into outer.n_sum_sal from employees wheredepartment_id = n_dept_no; */ -- call to outer block variable outer.n_sum_sal:= 2532.22; end; dbms_output.put_line('The outer sum salary is: ' || to_char(n_sum_sal)); /* selecthire_date from employees whereemployee_id = n_employee_id; */ end;