SlideShare a Scribd company logo
1 of 28
Oracle 12c VBİS-də proqramçılar üçün yeniliklər
Ramin Orucov http://raminorucov.wordpress.com
SCJP 6, OCE Java EE 6 Web Component Developer
http://www.azeroug.org
http://www.azeroug.org
2/
Özüm haqda
Şənbə, 14 Sentyabr 2013
Azercell Telekom
İKT/Daxili proqramların yaradılması
qrupunun rəhbəri
Qafqaz Universiteti
Java, Java web, Android
proqramlaşdırma üzrə müəllim
Ramin Orucov
http://www.azeroug.org
3/
Oracle 12c VBİS
Şənbə, 14 Sentyabr 2013
Oracle 9i – internet
Oracle 10g/11g – grid
Oracle 12c - cloud
http://www.oracle.com/us/products/database
/overview/index.html
http://www.oracle.com/technetwork/database
/plug-into-cloud-wp-12c-1896100.pdf
Ramin Orucov
http://www.azeroug.org
4/
SQL yenilikləri
Şənbə, 14 Sentyabr 2013
 Sütun default value üçün SEQUENCE qiyməti
 İDENTİTY sütunu
 VARCHAR2, NVARCHAR2 32K limit
 SQL sorğularında LİMİT, OFFSET dəstəyi
 Görünməz(invisible) sütun dəstəyi
 SQL WITH ifadəsindən PL/SQL funksiya
imkanı
Ramin Orucov
http://www.azeroug.org
5/
Sütun default value sequence
Şənbə, 14 Sentyabr 2013
create sequence test_seq
start with 1
increment by 1;
create table test_table(
id number default test_seq.nextval primary key
);
http://docs.oracle.com/cd/E16655_01/server.121/
e17209/statements_7002.htm#SQLRF54458
Ramin Orucov
http://www.azeroug.org
6/
IDENTITY sütunu
Şənbə, 14 Sentyabr 2013
MySQL,MS SQL Server auto increment/identity
create table test_table(
id number generated by default on null as identity,
name varchar2(10)
)
insert into test_table(name) values(‘ramin’)
insert into test_table(id,name) values(null, ‘ramin’)
http://docs.oracle.com/cd/E16655_01/gateways.121/e
22508/migr_tools_feat.htm#DRDAA109
Ramin Orucov
http://www.azeroug.org
7/
VARCHAR2, NVARCHAR2 32K limit
Şənbə, 14 Sentyabr 2013
32767 simvol dəstəyi
VARCHAR2, NVARCHAR2, RAW
Initialization param
MAX_STRING_SIZE = EXTENDED
http://docs.oracle.com/cd/E16655_01/server.121/
e17209/sql_elements001.htm#SQLRF55623
Ramin Orucov
http://www.azeroug.org
8/
SQL sorğularında Limit, Offset dəstəyi
Şənbə, 14 Sentyabr 2013 Ramin Orucov
select *
from (
select rownum rn, id, e.*
from employees e
)
where rn between 1 AND 10
order by 1;
http://www.azeroug.org
9/
SQL sorğularında Limit, Offset dəstəyi
Şənbə, 14 Sentyabr 2013 Ramin Orucov
http://www.azeroug.org
10/
SQL sorğularında Limit, Offset dəstəyi
Şənbə, 14 Sentyabr 2013
SELECT employee_id, last_name
FROM employees
ORDER BY salary
FETCH FIRST 10 ROWS ONLY;
SELECT employee_id, last_name
FROM employees
ORDER BY salary
OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY;
Ramin Orucov
http://www.azeroug.org
11/
SQL sorğularında Limit, Offset dəstəyi
Şənbə, 14 Sentyabr 2013
Min maaş alan işçilərin 5% + sonuncu sətirdəkinə
bərabər maaş alan bütün işçilər
SELECT employee_id, last_name, salary
FROM employees
ORDER BY salary
FETCH FIRST 5 PERCENT ROWS WITH TIES;
http://docs.oracle.com/cd/E16655_01/server.121/
e17209/statements_10002.htm#SQLRF55636
Ramin Orucov
http://www.azeroug.org
12/
Görünməz(invisible) sütun dəstəyi
Şənbə, 14 Sentyabr 2013
create table app_user(
id number generated by default on null as
identity,
username varchar2(100) not null,
passwd varchar(100) invisible
);
select * from app_user;
http://docs.oracle.com/cd/E16655_01/server.121/
e17636/tables.htm#ADMIN13866
Ramin Orucov
http://www.azeroug.org
13/
SQL WITH ifadəsi PL/SQL funksiya
Şənbə, 14 Sentyabr 2013
with
function sqr(p_num in number)
return number
is
begin
return p_num * p_num;
end;
select u.user_id, sqr(u.user_id) from all_users
where rownum <= 10;
2.5-3x dəfə performanslı
http://docs.oracle.com/cd/E16655_01/server.121/e17209/sRamin Orucov
http://www.azeroug.org
14/
PL/SQL yenilikləri
Şənbə, 14 Sentyabr 2013
 Prosedurdan cursor qaytarmaq
 ACCESSIBLE BY ilə paket qadağası
 Yeni UTL_CALL_STACK paketi
 JDBC üçün PL/SQL boolean və s. tip dəstəyi
 SQL kontekstdə PL/SQL tiplərinin istifadəsi
 Invoker right funksiyasına result cache dəstəyi
Ramin Orucov
http://www.azeroug.org
15/
PL/SQL prosedurdan cursor qaytarmaq
Şənbə, 14 Sentyabr 2013
create procedure get_customer_list
as
cur_customer sys_refcursor;
begin
open cur_customer for
select * from customer;
dbms_sql.return_result(cur_customer);
end get_customer_list;
http://docs.oracle.com/cd/E16655_01/java.121/e1
7657/getsta.htm#JJDBC29004
Ramin Orucov
http://www.azeroug.org
16/
PL/SQL prosedurdan cursor qaytarmaq
Şənbə, 14 Sentyabr 2013
String sql = “begin get_customer_list; end;”;
Connection con = datasource.getConnection();
PreparedStatement ps = con.prepareStatement();
ps.executeQuery(sql);
while(ps.getMoreResults()) {
ResultSet rs = ps.getResultSet();
while(rs.next()) {
… read columns
}
} Ramin Orucov
http://www.azeroug.org
17/
ACCESSİBLE BY ilə paket qadağası
Şənbə, 14 Sentyabr 2013
package pkg_api;
package pkg_api_utility;
pkg_api_utility paketi yalnız pkg_api daxilində
istifadə üçün nəzərdə tutulub, ayrılıqda istifadə
olunmamalıdır.
ACCESSİBLE BY
Ramin Orucov
http://www.azeroug.org
18/
ACCESSİBLE BY ilə paket qadağası
Şənbə, 14 Sentyabr 2013
CREATE OR REPLACE PACKAGE pkg_api_utility
ACCESSIBLE BY (pkg_api)
IS
PROCEDURE h1;
PROCEDURE h2;
END pkg_api_utility;
CREATE OR REPLACE PACKAGE BODY pkg_api_utility
IS
PROCEDURE h1 IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Helper procedure h1');
END;
PROCEDURE h2 IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Helper procedure h2');
END;
END pkg_api_utility;
Ramin Orucov
http://www.azeroug.org
19/
ACCESSİBLE BY ilə paket qadağası
Şənbə, 14 Sentyabr 2013
begin
pkg_api.p1;
pkg_api.p2;
end;
/
begin
pkg_api_utility.h1;
pkg_api_utility.h2;
end;
/
ORA-06550
PLS-00904: insufficient privilege to access object PKG_API_UTILITY
Ramin Orucov
http://www.azeroug.org
20/
UTL_CALL_STACK paketi
Şənbə, 14 Sentyabr 2013
DBMS_UTILITY paketindəki funksiyalar:
– FORMAT_CALL_STACK
– FORMAT_ERROR_STACK
– FORMAT_ERROR_BACKTRACE
UTL_CALLSTACK paketi
http://docs.oracle.com/cd/E16655_01/appdev.121/e17602/u_call_stac
k.htm#ARPLS74078
Ramin Orucov
http://www.azeroug.org
21/
JDBC daha yaxşı PL/SQL tip dəstəyi
Şənbə, 14 Sentyabr 2013
create or replace package TEST_PKG is
type V_TYP is varray(10) of varchar2(200);
type R_TYP is record(c1 pls_integer, c2 varchar2(100));
procedure VARR_PROC(p1 in V_TYP, p2 OUT V_TYP);
procedure REC_PROC(p1 in R_TYP, p2 OUT R_TYP);
end;
/
Ramin Orucov
http://www.azeroug.org
22/
JDBC daha yaxşı PL/SQL tip dəstəyi
Şənbə, 14 Sentyabr 2013
create or replace package body TEST_PKG is
procedure VARR_PROC(p1 in V_TYP, p2 OUT V_TYP) is
begin
p2 := p1;
end;
procedure REC_PROC(p1 in R_TYP, p2 OUT R_TYP) is
begin
p2 := p1;
end;
end;
Ramin Orucov
http://www.azeroug.org
23/
JDBC daha yaxşı PL/SQL tip dəstəyi
Şənbə, 14 Sentyabr 2013
CallableStatement cstmt = null;
try {
cstmt = conn.prepareCall("{ call TEST_PKG.VARR_PROC(?,?) }");
Array arr = ((OracleConnection)conn).createArray("TEST_PKG.V_TYP",
new String[]{"A", "B"});
cstmt.setArray(1, arr);
cstmt.registerOutParameter(2, Types.ARRAY, "TEST_PKG.V_TYP");
cstmt.execute();
//get PLSQL VARRAY type out parameter value
Array outArr = cstmt.getArray(2);
} catch( Exception e) {
e.printStackTrace();
}
Ramin Orucov
http://www.azeroug.org
24/
JDBC daha yaxşı PL/SQL tip dəstəyi
Şənbə, 14 Sentyabr 2013
try {
cstmt = conn.prepareCall("{ call TEST_PKG.REC_PROC(?,?) }");
//PLSQL RECORD type binding
Struct struct = conn.createStruct("TEST_PKG.R_TYP", new
Object[]{12345, "B"});
cstmt.setObject(1, struct);
cstmt.registerOutParameter(2, Types.STRUCT, "TEST_PKG.R_TYP");
cstmt.execute();
//get PLSQL RECORD type out parameter value
Struct outStruct = (Struct)cstmt.getObject(2);
} catch( Exception e) {
e.printStackTrace();
}
Ramin Orucov
http://www.azeroug.org
25/
JDBC daha yaxşı PL/SQL tip dəstəyi
Şənbə, 14 Sentyabr 2013
CREATE OR REPLACE PACKAGE PACK1 AS
TYPE EMPLOYEE_ROWTYPE_ARRAY IS TABLE OF
EMPLOYEES%ROWTYPE;
END PACK1;
CallableStatement cstmt = conn.prepareCall("BEGIN SELECT
* BULK COLLECT INTO :1 FROM EMPLOYEE; END;");
cstmt.registerOutParameter(1,OracleTypes.ARRAY,
"PACK1.EMPLOYEE_ROWTYPE_ARRAY");
cstmt.execute();
Array a = cstmt.getArray(1);
Ramin Orucov
http://www.azeroug.org
26/
Qaynaqlar
Şənbə, 14 Sentyabr 2013
 http://docs.oracle.com/cd/E16655_01/appde
v.121/e17622/release_changes.htm
 http://www.toadworld.com/platforms/oracle
/b/weblog/archive/2013/07/01/oracle-
database-12c-new-pl-sql-features.aspx
 http://docs.oracle.com/cd/E16655_01/java.1
21/e17657/apxref.htm#CHEIIJCC
 http://www.oracle-
base.com/articles/12c/with-clause-
enhancements-12cr1.php
Ramin Orucov
http://www.azeroug.org
27/
Sizin suallarınız
Şənbə, 14 Sentyabr 2013 Ramin Orucov
http://www.azeroug.org
28/
Son
Şənbə, 14 Sentyabr 2013 Ramin Orucov
Ramin Orucov
raminorujov@gmail.com
Mobil: 050 231 01 09
https://www.facebook.com/ramin.orucov
https://www.linkedin.com/in/raminorujov

More Related Content

Viewers also liked

056 - Vinde Senhor Vinde em Meu Auxilio - a cartageno (E)
056 - Vinde Senhor Vinde em Meu Auxilio - a cartageno (E)056 - Vinde Senhor Vinde em Meu Auxilio - a cartageno (E)
056 - Vinde Senhor Vinde em Meu Auxilio - a cartageno (E)João Rosa
 
Security managers july 2015 (1)
Security managers july 2015 (1)Security managers july 2015 (1)
Security managers july 2015 (1)Arthur Schmunk
 
Get Your Gamestorming On! Shift the Paradigm of Requirements Gathering
Get Your Gamestorming On! Shift the Paradigm of Requirements GatheringGet Your Gamestorming On! Shift the Paradigm of Requirements Gathering
Get Your Gamestorming On! Shift the Paradigm of Requirements GatheringMichelle Caldwell, PSM, SSGB
 
thermo fisher ED886123-7163-46F5-8387-5F57485F786B_FINAL09SHOW_III
thermo fisher ED886123-7163-46F5-8387-5F57485F786B_FINAL09SHOW_IIIthermo fisher ED886123-7163-46F5-8387-5F57485F786B_FINAL09SHOW_III
thermo fisher ED886123-7163-46F5-8387-5F57485F786B_FINAL09SHOW_IIIfinance40
 
History Of The Internet[1]
History Of The Internet[1]History Of The Internet[1]
History Of The Internet[1]jsoni2
 
Learn about a Live WebShow Video Channel and Video email
Learn about a Live WebShow Video Channel and Video emailLearn about a Live WebShow Video Channel and Video email
Learn about a Live WebShow Video Channel and Video emailBusiness Growth Coach
 
Arizona alec-2011-lesko-1
Arizona alec-2011-lesko-1Arizona alec-2011-lesko-1
Arizona alec-2011-lesko-1DeepDude
 
Project planning form
Project planning formProject planning form
Project planning formltilem
 
Bypass Immo Tool Instruction
Bypass Immo Tool InstructionBypass Immo Tool Instruction
Bypass Immo Tool Instructionobddeal
 
Bambole Fatte A Mano
Bambole Fatte A ManoBambole Fatte A Mano
Bambole Fatte A ManoCinzia Racca
 
ECOGAS améliore sa relation fournisseurs grâce à la dématérialisation de ses ...
ECOGAS améliore sa relation fournisseurs grâce à la dématérialisation de ses ...ECOGAS améliore sa relation fournisseurs grâce à la dématérialisation de ses ...
ECOGAS améliore sa relation fournisseurs grâce à la dématérialisation de ses ...ESKER
 
imagebrochure_schauenburg_2016
imagebrochure_schauenburg_2016imagebrochure_schauenburg_2016
imagebrochure_schauenburg_2016Daleen Postma
 
Nuestro día D...NI OLVIDO NI PERDÓN
Nuestro día D...NI OLVIDO NI PERDÓNNuestro día D...NI OLVIDO NI PERDÓN
Nuestro día D...NI OLVIDO NI PERDÓNinsn
 

Viewers also liked (16)

056 - Vinde Senhor Vinde em Meu Auxilio - a cartageno (E)
056 - Vinde Senhor Vinde em Meu Auxilio - a cartageno (E)056 - Vinde Senhor Vinde em Meu Auxilio - a cartageno (E)
056 - Vinde Senhor Vinde em Meu Auxilio - a cartageno (E)
 
Security managers july 2015 (1)
Security managers july 2015 (1)Security managers july 2015 (1)
Security managers july 2015 (1)
 
Get Your Gamestorming On! Shift the Paradigm of Requirements Gathering
Get Your Gamestorming On! Shift the Paradigm of Requirements GatheringGet Your Gamestorming On! Shift the Paradigm of Requirements Gathering
Get Your Gamestorming On! Shift the Paradigm of Requirements Gathering
 
Muri che parlano
Muri che parlano Muri che parlano
Muri che parlano
 
thermo fisher ED886123-7163-46F5-8387-5F57485F786B_FINAL09SHOW_III
thermo fisher ED886123-7163-46F5-8387-5F57485F786B_FINAL09SHOW_IIIthermo fisher ED886123-7163-46F5-8387-5F57485F786B_FINAL09SHOW_III
thermo fisher ED886123-7163-46F5-8387-5F57485F786B_FINAL09SHOW_III
 
Imagenes chistosas
Imagenes chistosasImagenes chistosas
Imagenes chistosas
 
History Of The Internet[1]
History Of The Internet[1]History Of The Internet[1]
History Of The Internet[1]
 
Learn about a Live WebShow Video Channel and Video email
Learn about a Live WebShow Video Channel and Video emailLearn about a Live WebShow Video Channel and Video email
Learn about a Live WebShow Video Channel and Video email
 
Arizona alec-2011-lesko-1
Arizona alec-2011-lesko-1Arizona alec-2011-lesko-1
Arizona alec-2011-lesko-1
 
Project planning form
Project planning formProject planning form
Project planning form
 
Bypass Immo Tool Instruction
Bypass Immo Tool InstructionBypass Immo Tool Instruction
Bypass Immo Tool Instruction
 
Bambole Fatte A Mano
Bambole Fatte A ManoBambole Fatte A Mano
Bambole Fatte A Mano
 
ECOGAS améliore sa relation fournisseurs grâce à la dématérialisation de ses ...
ECOGAS améliore sa relation fournisseurs grâce à la dématérialisation de ses ...ECOGAS améliore sa relation fournisseurs grâce à la dématérialisation de ses ...
ECOGAS améliore sa relation fournisseurs grâce à la dématérialisation de ses ...
 
imagebrochure_schauenburg_2016
imagebrochure_schauenburg_2016imagebrochure_schauenburg_2016
imagebrochure_schauenburg_2016
 
Nuestro día D...NI OLVIDO NI PERDÓN
Nuestro día D...NI OLVIDO NI PERDÓNNuestro día D...NI OLVIDO NI PERDÓN
Nuestro día D...NI OLVIDO NI PERDÓN
 
Elmasfuerte
ElmasfuerteElmasfuerte
Elmasfuerte
 

More from Ramin Orujov

Best practices for RESTful web service design
Best practices for RESTful web service designBest practices for RESTful web service design
Best practices for RESTful web service designRamin Orujov
 
Android Platform Overview - Azercell Barama
Android Platform Overview - Azercell BaramaAndroid Platform Overview - Azercell Barama
Android Platform Overview - Azercell BaramaRamin Orujov
 
Hackathon Azerbaijan Android API Overview and Repository
Hackathon Azerbaijan Android API Overview and RepositoryHackathon Azerbaijan Android API Overview and Repository
Hackathon Azerbaijan Android API Overview and RepositoryRamin Orujov
 
Hackathon Azerbaijan Android Age - Next Step
Hackathon Azerbaijan Android Age - Next StepHackathon Azerbaijan Android Age - Next Step
Hackathon Azerbaijan Android Age - Next StepRamin Orujov
 
Ikt sahəsində əsas istiqamətlər və iş imkanları
Ikt sahəsində əsas istiqamətlər və iş imkanlarıIkt sahəsində əsas istiqamətlər və iş imkanları
Ikt sahəsində əsas istiqamətlər və iş imkanlarıRamin Orujov
 

More from Ramin Orujov (6)

Best practices for RESTful web service design
Best practices for RESTful web service designBest practices for RESTful web service design
Best practices for RESTful web service design
 
Android Platform Overview - Azercell Barama
Android Platform Overview - Azercell BaramaAndroid Platform Overview - Azercell Barama
Android Platform Overview - Azercell Barama
 
Hackathon Azerbaijan Android API Overview and Repository
Hackathon Azerbaijan Android API Overview and RepositoryHackathon Azerbaijan Android API Overview and Repository
Hackathon Azerbaijan Android API Overview and Repository
 
Hackathon Azerbaijan Android Age - Next Step
Hackathon Azerbaijan Android Age - Next StepHackathon Azerbaijan Android Age - Next Step
Hackathon Azerbaijan Android Age - Next Step
 
Ikt sahəsində əsas istiqamətlər və iş imkanları
Ikt sahəsində əsas istiqamətlər və iş imkanlarıIkt sahəsində əsas istiqamətlər və iş imkanları
Ikt sahəsində əsas istiqamətlər və iş imkanları
 
Android platform
Android platformAndroid platform
Android platform
 

Oracle Database 12c new features for the developers.

  • 1. Oracle 12c VBİS-də proqramçılar üçün yeniliklər Ramin Orucov http://raminorucov.wordpress.com SCJP 6, OCE Java EE 6 Web Component Developer http://www.azeroug.org
  • 2. http://www.azeroug.org 2/ Özüm haqda Şənbə, 14 Sentyabr 2013 Azercell Telekom İKT/Daxili proqramların yaradılması qrupunun rəhbəri Qafqaz Universiteti Java, Java web, Android proqramlaşdırma üzrə müəllim Ramin Orucov
  • 3. http://www.azeroug.org 3/ Oracle 12c VBİS Şənbə, 14 Sentyabr 2013 Oracle 9i – internet Oracle 10g/11g – grid Oracle 12c - cloud http://www.oracle.com/us/products/database /overview/index.html http://www.oracle.com/technetwork/database /plug-into-cloud-wp-12c-1896100.pdf Ramin Orucov
  • 4. http://www.azeroug.org 4/ SQL yenilikləri Şənbə, 14 Sentyabr 2013  Sütun default value üçün SEQUENCE qiyməti  İDENTİTY sütunu  VARCHAR2, NVARCHAR2 32K limit  SQL sorğularında LİMİT, OFFSET dəstəyi  Görünməz(invisible) sütun dəstəyi  SQL WITH ifadəsindən PL/SQL funksiya imkanı Ramin Orucov
  • 5. http://www.azeroug.org 5/ Sütun default value sequence Şənbə, 14 Sentyabr 2013 create sequence test_seq start with 1 increment by 1; create table test_table( id number default test_seq.nextval primary key ); http://docs.oracle.com/cd/E16655_01/server.121/ e17209/statements_7002.htm#SQLRF54458 Ramin Orucov
  • 6. http://www.azeroug.org 6/ IDENTITY sütunu Şənbə, 14 Sentyabr 2013 MySQL,MS SQL Server auto increment/identity create table test_table( id number generated by default on null as identity, name varchar2(10) ) insert into test_table(name) values(‘ramin’) insert into test_table(id,name) values(null, ‘ramin’) http://docs.oracle.com/cd/E16655_01/gateways.121/e 22508/migr_tools_feat.htm#DRDAA109 Ramin Orucov
  • 7. http://www.azeroug.org 7/ VARCHAR2, NVARCHAR2 32K limit Şənbə, 14 Sentyabr 2013 32767 simvol dəstəyi VARCHAR2, NVARCHAR2, RAW Initialization param MAX_STRING_SIZE = EXTENDED http://docs.oracle.com/cd/E16655_01/server.121/ e17209/sql_elements001.htm#SQLRF55623 Ramin Orucov
  • 8. http://www.azeroug.org 8/ SQL sorğularında Limit, Offset dəstəyi Şənbə, 14 Sentyabr 2013 Ramin Orucov select * from ( select rownum rn, id, e.* from employees e ) where rn between 1 AND 10 order by 1;
  • 9. http://www.azeroug.org 9/ SQL sorğularında Limit, Offset dəstəyi Şənbə, 14 Sentyabr 2013 Ramin Orucov
  • 10. http://www.azeroug.org 10/ SQL sorğularında Limit, Offset dəstəyi Şənbə, 14 Sentyabr 2013 SELECT employee_id, last_name FROM employees ORDER BY salary FETCH FIRST 10 ROWS ONLY; SELECT employee_id, last_name FROM employees ORDER BY salary OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY; Ramin Orucov
  • 11. http://www.azeroug.org 11/ SQL sorğularında Limit, Offset dəstəyi Şənbə, 14 Sentyabr 2013 Min maaş alan işçilərin 5% + sonuncu sətirdəkinə bərabər maaş alan bütün işçilər SELECT employee_id, last_name, salary FROM employees ORDER BY salary FETCH FIRST 5 PERCENT ROWS WITH TIES; http://docs.oracle.com/cd/E16655_01/server.121/ e17209/statements_10002.htm#SQLRF55636 Ramin Orucov
  • 12. http://www.azeroug.org 12/ Görünməz(invisible) sütun dəstəyi Şənbə, 14 Sentyabr 2013 create table app_user( id number generated by default on null as identity, username varchar2(100) not null, passwd varchar(100) invisible ); select * from app_user; http://docs.oracle.com/cd/E16655_01/server.121/ e17636/tables.htm#ADMIN13866 Ramin Orucov
  • 13. http://www.azeroug.org 13/ SQL WITH ifadəsi PL/SQL funksiya Şənbə, 14 Sentyabr 2013 with function sqr(p_num in number) return number is begin return p_num * p_num; end; select u.user_id, sqr(u.user_id) from all_users where rownum <= 10; 2.5-3x dəfə performanslı http://docs.oracle.com/cd/E16655_01/server.121/e17209/sRamin Orucov
  • 14. http://www.azeroug.org 14/ PL/SQL yenilikləri Şənbə, 14 Sentyabr 2013  Prosedurdan cursor qaytarmaq  ACCESSIBLE BY ilə paket qadağası  Yeni UTL_CALL_STACK paketi  JDBC üçün PL/SQL boolean və s. tip dəstəyi  SQL kontekstdə PL/SQL tiplərinin istifadəsi  Invoker right funksiyasına result cache dəstəyi Ramin Orucov
  • 15. http://www.azeroug.org 15/ PL/SQL prosedurdan cursor qaytarmaq Şənbə, 14 Sentyabr 2013 create procedure get_customer_list as cur_customer sys_refcursor; begin open cur_customer for select * from customer; dbms_sql.return_result(cur_customer); end get_customer_list; http://docs.oracle.com/cd/E16655_01/java.121/e1 7657/getsta.htm#JJDBC29004 Ramin Orucov
  • 16. http://www.azeroug.org 16/ PL/SQL prosedurdan cursor qaytarmaq Şənbə, 14 Sentyabr 2013 String sql = “begin get_customer_list; end;”; Connection con = datasource.getConnection(); PreparedStatement ps = con.prepareStatement(); ps.executeQuery(sql); while(ps.getMoreResults()) { ResultSet rs = ps.getResultSet(); while(rs.next()) { … read columns } } Ramin Orucov
  • 17. http://www.azeroug.org 17/ ACCESSİBLE BY ilə paket qadağası Şənbə, 14 Sentyabr 2013 package pkg_api; package pkg_api_utility; pkg_api_utility paketi yalnız pkg_api daxilində istifadə üçün nəzərdə tutulub, ayrılıqda istifadə olunmamalıdır. ACCESSİBLE BY Ramin Orucov
  • 18. http://www.azeroug.org 18/ ACCESSİBLE BY ilə paket qadağası Şənbə, 14 Sentyabr 2013 CREATE OR REPLACE PACKAGE pkg_api_utility ACCESSIBLE BY (pkg_api) IS PROCEDURE h1; PROCEDURE h2; END pkg_api_utility; CREATE OR REPLACE PACKAGE BODY pkg_api_utility IS PROCEDURE h1 IS BEGIN DBMS_OUTPUT.PUT_LINE('Helper procedure h1'); END; PROCEDURE h2 IS BEGIN DBMS_OUTPUT.PUT_LINE('Helper procedure h2'); END; END pkg_api_utility; Ramin Orucov
  • 19. http://www.azeroug.org 19/ ACCESSİBLE BY ilə paket qadağası Şənbə, 14 Sentyabr 2013 begin pkg_api.p1; pkg_api.p2; end; / begin pkg_api_utility.h1; pkg_api_utility.h2; end; / ORA-06550 PLS-00904: insufficient privilege to access object PKG_API_UTILITY Ramin Orucov
  • 20. http://www.azeroug.org 20/ UTL_CALL_STACK paketi Şənbə, 14 Sentyabr 2013 DBMS_UTILITY paketindəki funksiyalar: – FORMAT_CALL_STACK – FORMAT_ERROR_STACK – FORMAT_ERROR_BACKTRACE UTL_CALLSTACK paketi http://docs.oracle.com/cd/E16655_01/appdev.121/e17602/u_call_stac k.htm#ARPLS74078 Ramin Orucov
  • 21. http://www.azeroug.org 21/ JDBC daha yaxşı PL/SQL tip dəstəyi Şənbə, 14 Sentyabr 2013 create or replace package TEST_PKG is type V_TYP is varray(10) of varchar2(200); type R_TYP is record(c1 pls_integer, c2 varchar2(100)); procedure VARR_PROC(p1 in V_TYP, p2 OUT V_TYP); procedure REC_PROC(p1 in R_TYP, p2 OUT R_TYP); end; / Ramin Orucov
  • 22. http://www.azeroug.org 22/ JDBC daha yaxşı PL/SQL tip dəstəyi Şənbə, 14 Sentyabr 2013 create or replace package body TEST_PKG is procedure VARR_PROC(p1 in V_TYP, p2 OUT V_TYP) is begin p2 := p1; end; procedure REC_PROC(p1 in R_TYP, p2 OUT R_TYP) is begin p2 := p1; end; end; Ramin Orucov
  • 23. http://www.azeroug.org 23/ JDBC daha yaxşı PL/SQL tip dəstəyi Şənbə, 14 Sentyabr 2013 CallableStatement cstmt = null; try { cstmt = conn.prepareCall("{ call TEST_PKG.VARR_PROC(?,?) }"); Array arr = ((OracleConnection)conn).createArray("TEST_PKG.V_TYP", new String[]{"A", "B"}); cstmt.setArray(1, arr); cstmt.registerOutParameter(2, Types.ARRAY, "TEST_PKG.V_TYP"); cstmt.execute(); //get PLSQL VARRAY type out parameter value Array outArr = cstmt.getArray(2); } catch( Exception e) { e.printStackTrace(); } Ramin Orucov
  • 24. http://www.azeroug.org 24/ JDBC daha yaxşı PL/SQL tip dəstəyi Şənbə, 14 Sentyabr 2013 try { cstmt = conn.prepareCall("{ call TEST_PKG.REC_PROC(?,?) }"); //PLSQL RECORD type binding Struct struct = conn.createStruct("TEST_PKG.R_TYP", new Object[]{12345, "B"}); cstmt.setObject(1, struct); cstmt.registerOutParameter(2, Types.STRUCT, "TEST_PKG.R_TYP"); cstmt.execute(); //get PLSQL RECORD type out parameter value Struct outStruct = (Struct)cstmt.getObject(2); } catch( Exception e) { e.printStackTrace(); } Ramin Orucov
  • 25. http://www.azeroug.org 25/ JDBC daha yaxşı PL/SQL tip dəstəyi Şənbə, 14 Sentyabr 2013 CREATE OR REPLACE PACKAGE PACK1 AS TYPE EMPLOYEE_ROWTYPE_ARRAY IS TABLE OF EMPLOYEES%ROWTYPE; END PACK1; CallableStatement cstmt = conn.prepareCall("BEGIN SELECT * BULK COLLECT INTO :1 FROM EMPLOYEE; END;"); cstmt.registerOutParameter(1,OracleTypes.ARRAY, "PACK1.EMPLOYEE_ROWTYPE_ARRAY"); cstmt.execute(); Array a = cstmt.getArray(1); Ramin Orucov
  • 26. http://www.azeroug.org 26/ Qaynaqlar Şənbə, 14 Sentyabr 2013  http://docs.oracle.com/cd/E16655_01/appde v.121/e17622/release_changes.htm  http://www.toadworld.com/platforms/oracle /b/weblog/archive/2013/07/01/oracle- database-12c-new-pl-sql-features.aspx  http://docs.oracle.com/cd/E16655_01/java.1 21/e17657/apxref.htm#CHEIIJCC  http://www.oracle- base.com/articles/12c/with-clause- enhancements-12cr1.php Ramin Orucov
  • 28. http://www.azeroug.org 28/ Son Şənbə, 14 Sentyabr 2013 Ramin Orucov Ramin Orucov raminorujov@gmail.com Mobil: 050 231 01 09 https://www.facebook.com/ramin.orucov https://www.linkedin.com/in/raminorujov

Editor's Notes

  1. Sizin suallarınız
  2. Təşəkkürlər AZEROUG