IEEE Day 2013 Oracle Database 12c: new features for developers
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

IEEE Day 2013 Oracle Database 12c: new features for developers

  • 1,458 views
Uploaded on

IEEE Day 2013 Baku ...

IEEE Day 2013 Baku
Oracle Database 12c: new features PL/SQL and Java developers.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,458
On Slideshare
1,456
From Embeds
2
Number of Embeds
1

Actions

Shares
Downloads
22
Comments
0
Likes
0

Embeds 2

https://twitter.com 2

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. IEEE Day 2013 Ramin Orujov ICT/Internal Applications Team Head Azercell Telecom SCJP 6, OCE Java EE 6 WCD www.linkedin.com/in/raminorujov 01 October 2013, Qafqaz University Oracle database 12c: New features for developers
  • 2. About me Senior software developer Internal Applications Team Head@Azercell Teacher @ Qafqaz University CE dept. Co-manager of AZEROUG Founder and manager of AZERJUG October 1, 20132
  • 3. Oracle database platforms Oracle 9i – internet Oracle 10g/11g – grid Oracle 12c - cloud http://www.oracle.com/us/products/databas http://www.oracle.com/technetwork/databas October 1, 20133
  • 4. SQL new features  SEQUENCE as default column value  IDENTITY column  VARCHAR2, NVARCHAR2 32K limit  LIMIT, OFFSET support for paging  Invisible column support  Inline PL/SQL function within SQL WITH expression October 1, 20134
  • 5. SEQUENCE as default col value 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 SQLRF54458 October 1, 20135
  • 6. IDENTITY column 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/ DRDAA109 October 1, 20136
  • 7. VARCHAR2,NVARCHAR2 32K limit 32767 character support VARCHAR2, NVARCHAR2, RAW Initialization param MAX_STRING_SIZE = EXTENDED http://docs.oracle.com/cd/E16655_01/server October 1, 20137
  • 8. LIMIT, OFFSET support select * from ( select rownum rn, id, e.* from employees e ) where rn between 1 AND 10 order by 1; October 1, 20138
  • 9. LIMIT, OFFSET support October 1, 20139
  • 10. LIMIT, OFFSET support October 1, 201310 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;
  • 11. LIMIT, OFFSET support October 1, 201311 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
  • 12. Invisible column October 1, 201312 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
  • 13. Inline PL/SQL function WITH October 1, 201313 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 performance improvement http://docs.oracle.com/cd/E16655_01/server.121/e17
  • 14. PL/SQL new features October 1, 201314  New way for returning cursor  Modularity with ACCESSIBLE BY  New UTL_CALL_STACK package  Using PL/SQL types in SQL context  Result cache support for functions with invoker’s right
  • 15. New way for returning cursor October 1, 201315 create procedure get_customer_order_list as cur_customer sys_refcursor; cur_order sys_refcursor; begin open cur_customer for select * from customer; open cur_order for select * from order; dbms_sql.return_result(cur_customer); dbms_sql.return_result(cur_order); end;
  • 16. New way for returning cursor October 1, 201316 // sample JDBC code String sql = “begin get_customer_order_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 } }
  • 17. Modularity with ACCESSIBLE BY October 1, 201317 package pkg_api; package pkg_api_utility; pkg_api_utility is considered to be used only by pkg_api ACCESSİBLE BY
  • 18. Modularity with ACCESSIBLE BY October 1, 201318 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;
  • 19. Modularity with ACCESSIBLE BY October 1, 201319 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
  • 20. UTL_CALLSTACK package October 1, 201320 DBMS_UTILITY functions related to call/error stack: –FORMAT_CALL_STACK –FORMAT_ERROR_STACK –FORMAT_ERROR_BACKTRACE New package: UTL_CALLSTACK http://docs.oracle.com/cd/E16655_01/appdev.121/e17602/
  • 21. Result cache support for functions with invoker’s right October 1, 201321 In Oracle Database 11g Release 2 (11.2), only definer's rights PL/SQL functions could be result cached. Now, invoker's rights PL/SQL functions can also be result cached. (The identity of the invoking user is implicitly added to the key of the result.) http://docs.oracle.com/cd/E16655_01/appde v.121/e17622/release_changes.htm#LNPLS1 10
  • 22. Java new features October 1, 201322  PL/SQL boolean support in JDBC driver  PL/SQL package level collection support
  • 23. Package level collection support October 1, 201323 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; /
  • 24. Package level collection support October 1, 201324 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;
  • 25. JDBC code October 1, 201325 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(); }
  • 26. JDBC code October 1, 201326 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(); }
  • 27. JDBC code October 1, 201327 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);
  • 28. References October 1, 201328  http://docs.oracle.com/cd/E16655_01/appdev.121 /e17622/release_changes.htm  http://www.toadworld.com/platforms/oracle/b/we blog/archive/2013/07/01/oracle-database-12c- new-pl-sql-features.aspx  http://docs.oracle.com/cd/E16655_01/java.121/e1 7657/apxref.htm#CHEIIJCC  http://www.oracle-base.com/articles/12c/with- clause-enhancements-12cr1.php
  • 29. Q&A ?