SlideShare a Scribd company logo
1 of 19
Advanced
Oracle PL/SQL
A CASE STUDY
BY ZIEMOWIT JANKOWSKI, DATABASE ARCHITECT
Purpose of this presentation
To show the power of PL/SQL as general programming
system embedded into a database:
● Calling built-in java in Oracle database from PL/SQL
● Performing tasks outside of database with PL/SQL
● Consolidation of different data sources into one single
SQL query
The original task
An Oracle-based system receives data from different
external systems. Task: for management and error
tracking purposes present a SQL query that will query
many different systems for a specific item. That query can
be mapped into a web page or used directly from TOAD.
Some other pre-conditions exist:
● Two of the external systems are accessible via web
pages only.
● A few of the external systems can be offline at times.
● The usage of the query should be logged and logging
should be hard to bypass.
Limitations and assumptions
● Architectural limitation:
● Do not introduce new inter-database dependencies if no
absolutely necessary
● Accessibility limitation:
● The external systems that expose HTTP interface cannot
be accessed in any other way
● The external systems that expose database access may
be online or offline. (Timeout issues)
● Assumptions:
● All involved systems run some flavour of Unix/Linux
● The delivered amount of data is small enough to reside
in memory
Solution outline
● Only well-known technologies used
● “Everything” implemented in PL/SQL
● Database queries
● HTTP queries
● Queries to other databases
● Using embedded java to execute O/S commands
● Running O/S commands to access remote databases
via SQL Plus
● Using pipelined functions to build a dataset for all data
Pipelined functions
● Gather data from data sources into an internal dataset
in PL/SQL package
● Table of record
● Traverse table and for every row execute PIPE ROW
● Caller needs to execute statement:
SELECT <…>
from TABLE(<pipelined-function>(<params>))
<where clause, order by clause etc>
Pros and cons
● Pros:
● Full control over returned data
● Data acquisition totally obfuscated for caller
● Data can be returned from several disparate sources
with one SQL statement
● Cons:
● Some (small) overhead
● TABLE (…) is not very common construct
Example
Code:
Function SelectAll (
itemID IN varchar2
)
return ItemSearchListTab pipelined as
<…some code…>
retidx := returnTab.first;
while retidx is not null loop
pipe row(returnTab(retidx));
retidx := returnTab.next(retidx);
end loop;
SELECT statement:
Select * from table(packageName.SelectAll(’someID’)) order by 1;
Using embedded java
● Execute O/S commands:
● Runs as user Oracle in O/S
● Harvest the results into varchar2 variables in code
● Can be used to:
● List contents of directories
● Move and remove files
● Send strings to applications or other systems and
harvest results, in particular:
● Send HTTP queries over network
● Run SQL*Plus and execute SQL scripts on external systems
Pros and Cons
● Pros:
● The impossible becomes possible
● Vast opportunities of extending SQL functionality
● Cons:
● Can be misused if left unprotected
Example
HTTP Queries
● Use standard Oracle package UTL_HTTP
● Harvest result as string
● Linefeed as line delimiter
● Limitations of result to varchar2 size
● Analyze HTTP output string and fill a PL/SQL table with
results
● Return resulting PL/SQL table as function value
Example
HTMLArray := UTL_HTTP.REQUEST_PIECES (searchURL, 20000);
if HTMLArray.count > 0 then
for HTMLLine in HTMLArray.first .. HTMLArray.last loop
tempString := tempString || HTMLArray(HTMLLine);
end loop;
<…some code…>
return returnTab;
Queries to other databases
● No inter-database dependencies allowed:
● No database links
● Use external Unix/Linux command to run SQL*Plus with
script
● No changes in local TNSNAMES.ORA
● Use full connection strings
● Harvest output strings into PL/SQL tables
● Unknown connectivity of remote database at given
time:
● Risk for hanging SQL queries
● Use native Unix/Linux function to probe remote node
Example – check
connectivity
-- status 0 means port OK, status 1 means port not
available
out_text := os_cmd.run_cmd('nc -w 1
'||connections(cidx).IPAddress||' '||connections(cidx).port||' ;
echo $?');
Example – run SQL
command
● Connect string:
'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<IP>)(PORT=<P>)))(CON
NECT_DATA=(SERVICE_NAME=<SVC>)))‘
● Executed code:
connectString := Replace(connectString,'<IP>',connections(cidx).IPAddress);
connectString := Replace(connectString,'<P>',connections(cidx).port);
connectString := Replace(connectString,'<SVC>',connections(cidx).serviceName);
<…some code…>
out_text := os_cmd.run_cmd('$ORACLE_HOME/bin/sqlplus -S -L '||
connections(cidx).userNme||'/'||connections(cidx).passwrd||
'@"'||connections(cidx).connectString||
'“ @'||gblTempDir||gblFilePrefix||fileNamePart2||'.sql');
Log queries
● Use Oracle autonomous transactions
● Does not interfere with ”ordinary” operations
Wrapping it up
● SQL results, remote dataase queries (not necessarily
Oracle), HTTP calls – all combined into one SQL
statement
● All searches logged
● Not to mention additional functionality:
● Passwords, entered in plain text, stored coded in
dataase
● Passwords retrieved in plain text or verifyed, but only
through code with logging enabled
Demonstration

More Related Content

What's hot

What's hot (20)

Introduction to PL/SQL
Introduction to PL/SQLIntroduction to PL/SQL
Introduction to PL/SQL
 
PLSQL Advanced
PLSQL AdvancedPLSQL Advanced
PLSQL Advanced
 
Data pump-export-examples
Data pump-export-examplesData pump-export-examples
Data pump-export-examples
 
Architecture of Native XML Database Sedna
Architecture of Native XML Database SednaArchitecture of Native XML Database Sedna
Architecture of Native XML Database Sedna
 
Sedna XML Database System: Internal Representation
Sedna XML Database System: Internal RepresentationSedna XML Database System: Internal Representation
Sedna XML Database System: Internal Representation
 
Udemy talend notes
Udemy talend notesUdemy talend notes
Udemy talend notes
 
Sqlmap
SqlmapSqlmap
Sqlmap
 
ORACLE PL SQL FOR BEGINNERS
ORACLE PL SQL FOR BEGINNERSORACLE PL SQL FOR BEGINNERS
ORACLE PL SQL FOR BEGINNERS
 
SQL
SQLSQL
SQL
 
Oracle: Procedures
Oracle: ProceduresOracle: Procedures
Oracle: Procedures
 
Changing platforms of Oracle database
Changing platforms of Oracle databaseChanging platforms of Oracle database
Changing platforms of Oracle database
 
3963066 pl-sql-notes-only
3963066 pl-sql-notes-only3963066 pl-sql-notes-only
3963066 pl-sql-notes-only
 
PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
Oracle: PLSQL Introduction
Oracle: PLSQL IntroductionOracle: PLSQL Introduction
Oracle: PLSQL Introduction
 
Improving the Performance of PL/SQL function calls from SQL
Improving the Performance of PL/SQL function calls from SQLImproving the Performance of PL/SQL function calls from SQL
Improving the Performance of PL/SQL function calls from SQL
 
ORACLE PL SQL
ORACLE PL SQLORACLE PL SQL
ORACLE PL SQL
 
Etl2
Etl2Etl2
Etl2
 
XQuery Triggers in Native XML Database Sedna
XQuery Triggers in Native XML Database SednaXQuery Triggers in Native XML Database Sedna
XQuery Triggers in Native XML Database Sedna
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
 
4. plsql
4. plsql4. plsql
4. plsql
 

Viewers also liked

How Email as a Service Can Remove Your Operation Pain
How Email as a Service Can Remove Your Operation PainHow Email as a Service Can Remove Your Operation Pain
How Email as a Service Can Remove Your Operation PainPT Datacomm Diangraha
 
mengapa peran guru tidak tergantikan oleh teknologi
 mengapa peran guru tidak tergantikan oleh teknologi mengapa peran guru tidak tergantikan oleh teknologi
mengapa peran guru tidak tergantikan oleh teknologiyurvista sari
 
Generalidades de tic_y_la_formacion_docente
Generalidades de tic_y_la_formacion_docenteGeneralidades de tic_y_la_formacion_docente
Generalidades de tic_y_la_formacion_docenteluisax123
 
DN11_U3_A5_PYNR
DN11_U3_A5_PYNRDN11_U3_A5_PYNR
DN11_U3_A5_PYNRdenizota
 
Telehealth Accreditation: Adding Value to Your Organization Through Independe...
Telehealth Accreditation: Adding Value to Your Organization Through Independe...Telehealth Accreditation: Adding Value to Your Organization Through Independe...
Telehealth Accreditation: Adding Value to Your Organization Through Independe...Epstein Becker Green
 
Digital Researcher at Higher Education
Digital Researcher at Higher EducationDigital Researcher at Higher Education
Digital Researcher at Higher EducationAjmalSultany
 
theories of communication
theories of communicationtheories of communication
theories of communicationMahmuda Islam
 
Las TIC y la Formación Docente
Las TIC y la Formación DocenteLas TIC y la Formación Docente
Las TIC y la Formación Docentehilda2000
 
Bla Bla Car
Bla Bla CarBla Bla Car
Bla Bla CarESG B3A
 
JADE Intrapreneurship Conference, Romania
JADE Intrapreneurship Conference, RomaniaJADE Intrapreneurship Conference, Romania
JADE Intrapreneurship Conference, RomaniaINNOVATION COPILOTS
 
Rebirth of the Eagle - Story of Eagle Photo Presentation
Rebirth of the Eagle - Story of Eagle Photo PresentationRebirth of the Eagle - Story of Eagle Photo Presentation
Rebirth of the Eagle - Story of Eagle Photo PresentationTargetseo.com
 
Core java concepts
Core java  conceptsCore java  concepts
Core java conceptsRam132
 
Generalidades acerca de las tics y la formacion docente
Generalidades acerca de las tics y la formacion docenteGeneralidades acerca de las tics y la formacion docente
Generalidades acerca de las tics y la formacion docenteMESCyT
 

Viewers also liked (19)

book escape room nashville
book escape room nashvillebook escape room nashville
book escape room nashville
 
Regent Knowledge Centre
Regent Knowledge CentreRegent Knowledge Centre
Regent Knowledge Centre
 
How Email as a Service Can Remove Your Operation Pain
How Email as a Service Can Remove Your Operation PainHow Email as a Service Can Remove Your Operation Pain
How Email as a Service Can Remove Your Operation Pain
 
mengapa peran guru tidak tergantikan oleh teknologi
 mengapa peran guru tidak tergantikan oleh teknologi mengapa peran guru tidak tergantikan oleh teknologi
mengapa peran guru tidak tergantikan oleh teknologi
 
new world
new worldnew world
new world
 
Herman Henselmann
Herman HenselmannHerman Henselmann
Herman Henselmann
 
Generalidades de tic_y_la_formacion_docente
Generalidades de tic_y_la_formacion_docenteGeneralidades de tic_y_la_formacion_docente
Generalidades de tic_y_la_formacion_docente
 
DN11_U3_A5_PYNR
DN11_U3_A5_PYNRDN11_U3_A5_PYNR
DN11_U3_A5_PYNR
 
Telehealth Accreditation: Adding Value to Your Organization Through Independe...
Telehealth Accreditation: Adding Value to Your Organization Through Independe...Telehealth Accreditation: Adding Value to Your Organization Through Independe...
Telehealth Accreditation: Adding Value to Your Organization Through Independe...
 
Digital Researcher at Higher Education
Digital Researcher at Higher EducationDigital Researcher at Higher Education
Digital Researcher at Higher Education
 
theories of communication
theories of communicationtheories of communication
theories of communication
 
Las TIC y la Formación Docente
Las TIC y la Formación DocenteLas TIC y la Formación Docente
Las TIC y la Formación Docente
 
Bla Bla Car
Bla Bla CarBla Bla Car
Bla Bla Car
 
TSRT Crashes
TSRT CrashesTSRT Crashes
TSRT Crashes
 
JADE Intrapreneurship Conference, Romania
JADE Intrapreneurship Conference, RomaniaJADE Intrapreneurship Conference, Romania
JADE Intrapreneurship Conference, Romania
 
Rebirth of the Eagle - Story of Eagle Photo Presentation
Rebirth of the Eagle - Story of Eagle Photo PresentationRebirth of the Eagle - Story of Eagle Photo Presentation
Rebirth of the Eagle - Story of Eagle Photo Presentation
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
Core java slides
Core java slidesCore java slides
Core java slides
 
Generalidades acerca de las tics y la formacion docente
Generalidades acerca de las tics y la formacion docenteGeneralidades acerca de las tics y la formacion docente
Generalidades acerca de las tics y la formacion docente
 

Similar to Case_Study_-_Advanced_Oracle_PLSQL

Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Zohar Elkayam
 
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Alex Zaballa
 
Properly Use Parallel DML for ETL
Properly Use Parallel DML for ETLProperly Use Parallel DML for ETL
Properly Use Parallel DML for ETLAndrej Pashchenko
 
Optimizing your Database Import!
Optimizing your Database Import! Optimizing your Database Import!
Optimizing your Database Import! Nabil Nawaz
 
Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...
Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...
Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...Srikanth Reddy Pallerla
 
SQLcl the next generation of SQLPlus?
SQLcl the next generation of SQLPlus?SQLcl the next generation of SQLPlus?
SQLcl the next generation of SQLPlus?Zohar Elkayam
 
Perl Stored Procedures for MySQL (2009)
Perl Stored Procedures for MySQL (2009)Perl Stored Procedures for MySQL (2009)
Perl Stored Procedures for MySQL (2009)Antony T Curtis
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
Introduction to PLSQL.PPT
Introduction to PLSQL.PPTIntroduction to PLSQL.PPT
Introduction to PLSQL.PPTSujayaBiju
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 
[Altibase] 9 replication part2 (methods and controls)
[Altibase] 9 replication part2 (methods and controls)[Altibase] 9 replication part2 (methods and controls)
[Altibase] 9 replication part2 (methods and controls)altistory
 
Introduction to Threading in .Net
Introduction to Threading in .NetIntroduction to Threading in .Net
Introduction to Threading in .Netwebhostingguy
 
Procedures/functions of rdbms
Procedures/functions of rdbmsProcedures/functions of rdbms
Procedures/functions of rdbmsjain.pralabh
 
New features of SQL in Firebird
New features of SQL in FirebirdNew features of SQL in Firebird
New features of SQL in FirebirdMind The Firebird
 

Similar to Case_Study_-_Advanced_Oracle_PLSQL (20)

Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?
 
Store programs
Store programsStore programs
Store programs
 
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
 
Properly Use Parallel DML for ETL
Properly Use Parallel DML for ETLProperly Use Parallel DML for ETL
Properly Use Parallel DML for ETL
 
Optimizing your Database Import!
Optimizing your Database Import! Optimizing your Database Import!
Optimizing your Database Import!
 
Apache airflow
Apache airflowApache airflow
Apache airflow
 
Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...
Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...
Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...
 
SQLcl the next generation of SQLPlus?
SQLcl the next generation of SQLPlus?SQLcl the next generation of SQLPlus?
SQLcl the next generation of SQLPlus?
 
Perl Stored Procedures for MySQL (2009)
Perl Stored Procedures for MySQL (2009)Perl Stored Procedures for MySQL (2009)
Perl Stored Procedures for MySQL (2009)
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
Introduction to PLSQL.PPT
Introduction to PLSQL.PPTIntroduction to PLSQL.PPT
Introduction to PLSQL.PPT
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
Java 8 streams
Java 8 streams Java 8 streams
Java 8 streams
 
[Altibase] 9 replication part2 (methods and controls)
[Altibase] 9 replication part2 (methods and controls)[Altibase] 9 replication part2 (methods and controls)
[Altibase] 9 replication part2 (methods and controls)
 
Introduction to Threading in .Net
Introduction to Threading in .NetIntroduction to Threading in .Net
Introduction to Threading in .Net
 
Procedures/functions of rdbms
Procedures/functions of rdbmsProcedures/functions of rdbms
Procedures/functions of rdbms
 
New features of SQL in Firebird
New features of SQL in FirebirdNew features of SQL in Firebird
New features of SQL in Firebird
 

Case_Study_-_Advanced_Oracle_PLSQL

  • 1. Advanced Oracle PL/SQL A CASE STUDY BY ZIEMOWIT JANKOWSKI, DATABASE ARCHITECT
  • 2. Purpose of this presentation To show the power of PL/SQL as general programming system embedded into a database: ● Calling built-in java in Oracle database from PL/SQL ● Performing tasks outside of database with PL/SQL ● Consolidation of different data sources into one single SQL query
  • 3. The original task An Oracle-based system receives data from different external systems. Task: for management and error tracking purposes present a SQL query that will query many different systems for a specific item. That query can be mapped into a web page or used directly from TOAD. Some other pre-conditions exist: ● Two of the external systems are accessible via web pages only. ● A few of the external systems can be offline at times. ● The usage of the query should be logged and logging should be hard to bypass.
  • 4. Limitations and assumptions ● Architectural limitation: ● Do not introduce new inter-database dependencies if no absolutely necessary ● Accessibility limitation: ● The external systems that expose HTTP interface cannot be accessed in any other way ● The external systems that expose database access may be online or offline. (Timeout issues) ● Assumptions: ● All involved systems run some flavour of Unix/Linux ● The delivered amount of data is small enough to reside in memory
  • 5. Solution outline ● Only well-known technologies used ● “Everything” implemented in PL/SQL ● Database queries ● HTTP queries ● Queries to other databases ● Using embedded java to execute O/S commands ● Running O/S commands to access remote databases via SQL Plus ● Using pipelined functions to build a dataset for all data
  • 6. Pipelined functions ● Gather data from data sources into an internal dataset in PL/SQL package ● Table of record ● Traverse table and for every row execute PIPE ROW ● Caller needs to execute statement: SELECT <…> from TABLE(<pipelined-function>(<params>)) <where clause, order by clause etc>
  • 7. Pros and cons ● Pros: ● Full control over returned data ● Data acquisition totally obfuscated for caller ● Data can be returned from several disparate sources with one SQL statement ● Cons: ● Some (small) overhead ● TABLE (…) is not very common construct
  • 8. Example Code: Function SelectAll ( itemID IN varchar2 ) return ItemSearchListTab pipelined as <…some code…> retidx := returnTab.first; while retidx is not null loop pipe row(returnTab(retidx)); retidx := returnTab.next(retidx); end loop; SELECT statement: Select * from table(packageName.SelectAll(’someID’)) order by 1;
  • 9. Using embedded java ● Execute O/S commands: ● Runs as user Oracle in O/S ● Harvest the results into varchar2 variables in code ● Can be used to: ● List contents of directories ● Move and remove files ● Send strings to applications or other systems and harvest results, in particular: ● Send HTTP queries over network ● Run SQL*Plus and execute SQL scripts on external systems
  • 10. Pros and Cons ● Pros: ● The impossible becomes possible ● Vast opportunities of extending SQL functionality ● Cons: ● Can be misused if left unprotected
  • 12. HTTP Queries ● Use standard Oracle package UTL_HTTP ● Harvest result as string ● Linefeed as line delimiter ● Limitations of result to varchar2 size ● Analyze HTTP output string and fill a PL/SQL table with results ● Return resulting PL/SQL table as function value
  • 13. Example HTMLArray := UTL_HTTP.REQUEST_PIECES (searchURL, 20000); if HTMLArray.count > 0 then for HTMLLine in HTMLArray.first .. HTMLArray.last loop tempString := tempString || HTMLArray(HTMLLine); end loop; <…some code…> return returnTab;
  • 14. Queries to other databases ● No inter-database dependencies allowed: ● No database links ● Use external Unix/Linux command to run SQL*Plus with script ● No changes in local TNSNAMES.ORA ● Use full connection strings ● Harvest output strings into PL/SQL tables ● Unknown connectivity of remote database at given time: ● Risk for hanging SQL queries ● Use native Unix/Linux function to probe remote node
  • 15. Example – check connectivity -- status 0 means port OK, status 1 means port not available out_text := os_cmd.run_cmd('nc -w 1 '||connections(cidx).IPAddress||' '||connections(cidx).port||' ; echo $?');
  • 16. Example – run SQL command ● Connect string: '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<IP>)(PORT=<P>)))(CON NECT_DATA=(SERVICE_NAME=<SVC>)))‘ ● Executed code: connectString := Replace(connectString,'<IP>',connections(cidx).IPAddress); connectString := Replace(connectString,'<P>',connections(cidx).port); connectString := Replace(connectString,'<SVC>',connections(cidx).serviceName); <…some code…> out_text := os_cmd.run_cmd('$ORACLE_HOME/bin/sqlplus -S -L '|| connections(cidx).userNme||'/'||connections(cidx).passwrd|| '@"'||connections(cidx).connectString|| '“ @'||gblTempDir||gblFilePrefix||fileNamePart2||'.sql');
  • 17. Log queries ● Use Oracle autonomous transactions ● Does not interfere with ”ordinary” operations
  • 18. Wrapping it up ● SQL results, remote dataase queries (not necessarily Oracle), HTTP calls – all combined into one SQL statement ● All searches logged ● Not to mention additional functionality: ● Passwords, entered in plain text, stored coded in dataase ● Passwords retrieved in plain text or verifyed, but only through code with logging enabled