Abstract: Oracle released a feature in 10g Release 2 they thought worthy of facilitating in previous versions via patch sets - so I thought it was worthy enough for a closer look.
Conditional compilation isn't a foreign concept in the programming world, and for the developer aficionado it's a wonderful paradigm to explore.
Conditional compilation was designed with the main intention of being able to create database version specific code. With the recent advent of 11g, developers can actually start adding 11g features to their 10g code today!
However it provides the savvy PL/SQL developer to enhance their code in more ways than just gearing up for the next release… Dust of your software engineering hats and discover how to utilise conditional compilation to explore concepts such as latent self tracing code; latent assertions; and enhanced prototyping for your unit tests.
This seminar will illustrate several examples of conditional compilation that will open your mind; ultimately benefit your users; and can be implemented as far back as 9.2!
Adding Dependency Injection to Legacy ApplicationsSam Hennessy
Dependency Injection (DI) is a fantastic technique, but what if you what to use dependency injection in your legacy application. Fear not! As someone who as done this very thing, I will show how you can successful and incrementally add DI to any application. I will present a number of recipes and solutions to common problems and give a tour of the various PHP DI projects and how they can help.
Back in the ’40s, Samuel Eilenberg and Saunders Mac Lane started developing an entire new branch of mathematics: Category Theory. This was 10 years after Lambda calculus and 10 years before Lisp. Mathematics offers a powerful and concise language; we can represent a lot of complexity with short equations like E=mc2.
This session will explore how programming can harness maths’ capacity for conciseness and expression, borrowing from Category Theory. We’ll discover algebraic data types that can impact the way we code tremendously. You’ll also learn about functors, monads, applicatives, semigroups and monoids and how they can be used in a PHP context.
November Camp - Spec BDD with PHPSpec 2Kacper Gunia
My slides on PHPSpec 2 from Symfony November Camp Stockholm.
www.symfony.se/november-camp/
More Domain-Driven Design related content at: https://domaincentric.net/
Adding Dependency Injection to Legacy ApplicationsSam Hennessy
Dependency Injection (DI) is a fantastic technique, but what if you what to use dependency injection in your legacy application. Fear not! As someone who as done this very thing, I will show how you can successful and incrementally add DI to any application. I will present a number of recipes and solutions to common problems and give a tour of the various PHP DI projects and how they can help.
Back in the ’40s, Samuel Eilenberg and Saunders Mac Lane started developing an entire new branch of mathematics: Category Theory. This was 10 years after Lambda calculus and 10 years before Lisp. Mathematics offers a powerful and concise language; we can represent a lot of complexity with short equations like E=mc2.
This session will explore how programming can harness maths’ capacity for conciseness and expression, borrowing from Category Theory. We’ll discover algebraic data types that can impact the way we code tremendously. You’ll also learn about functors, monads, applicatives, semigroups and monoids and how they can be used in a PHP context.
November Camp - Spec BDD with PHPSpec 2Kacper Gunia
My slides on PHPSpec 2 from Symfony November Camp Stockholm.
www.symfony.se/november-camp/
More Domain-Driven Design related content at: https://domaincentric.net/
You must’ve heard of Unit testing… If not, then this talk is definitely for you! If you do know Unit testing, you probably ran at some point into a hurdle: “Where do I start?” And despite your best efforts, you end up not having enough tests for your application – Then that change request comes in, requiring you to change that very same complex piece of code for which you are lacking tests! How do you going refactor while maintaining all those ‘undocumented’ business rules? This talk will show how Codeception can be leveraged to refactor the visuals aspects of an application, maintaining backwards compatibility on API changes and even assist in moving to a whole different server infrastructure.
Clear PHP is a coding reference for all of us. It tracks recommendations to write clear code, avoiding the classic traps, keeping options opened for the future and preventing decayed code. Those recommendations are above coding conventions, that focuses on code writing, and code architecture, with its design patterns and conceptions. This is the first time in history where an effort was made to collect all those rules, so every project can choose among them, and define exactly his own coding standard.
Slides from my presentation at DunDDD, 17th Nov 2012.
Most of this session was spent discussing unit test examples harvested from github. If anyone would like to see them, just ask.
So you are thinking of unit-testing the applications you work on a daily basis or already started to do so? Congratulations, but the really hard part is maintaining your test quality on such a high level so that you don't give up on testing down the road. In this talk I discuss unit-testing bad practices and test-smells, how to avoid them and show examples from open-source projects.
Symfony World - Symfony components and design patternsŁukasz Chruściel
There are so many Symfony components already, and they have some pretty neat perks. But have you seen them in action?
Design patterns are not a silver bullet. They will never resolve your problem on their own. On the other hand, design patterns provide a common ground for developers without going into details and could be used as building bricks to solve some more advanced problems.
During my presentation, I will take a closer look and explain the appliance of selected design patterns. What is more, I will take advantage of the Symfony ecosystem to implement them with ease.
I will do the presentation on sample code that developers will understand at all levels of expertise.
PHP7 brings a tremendous number of new features. Tonight, we will take a look at the null coalesce operator, new execution order (uniform variable syntax), new exceptions and more.
Entities lifecycle is usually something more than create and delete. Models with which we are working on day to day basis change their state under some business circumstances. State machine patterns can be a powerful allay when solving this kind of problem. How does it look like? What are the pros and cons of state machine usage? What are the things that we should be beware of? I will answer these questions during my talk, together with practical differences between the most popular implementation.
PHP 8.1 brings Enums, one of the most requested features in PHP.
Enums, or Enumerations, allow creating strict and type-safe structures for fixed values. An Enum structure can hold a number of values that can also be backed with integer or string values.
In this comprehensive session, we will discover what Enums are, why they are useful, how to apply them on our applications including Drupal, and things to watch out for when using Enums.
Audience
This session is for those who are familiar with modern PHP practices such as Object Oriented Programming, and principles such as Liskov Substitution principle. A quick introduction will be given to catch up to speed, but familiarity with such concepts can help a lot.
What you will learn
What are Enums.
Why Enums are useful.
How to use Enums
Migrating from magic constants/values to Enums.
Backed Enums and storing/fetching Enum values with a database.
Using Enums in a Drupal context.
Caveats when using Enums.
Author
Ayesh Karunaratne is the author of PHP.Watch (https://php.watch), where he provides in-depth articles and documents on PHP and latest changes to the language.
PHP 8.0: https://php.watch/versions/8.0
PHP 8.1: https://php.watch/versions/8.1
Enums: https://php.watch/versions/8.1/enums
Slides from my talk at the GTA-PHP Meetup Group about getting mixed HTML / PHP code into objects using SOLID principles.
Meetup page: http://www.meetup.com/GTA-PHP-User-Group-Toronto/events/230656470/
Code is on github: https://github.com/zymsys/solid
Building a Pyramid: Symfony Testing StrategiesCiaranMcNulty
The last few years have seen a huge adoption of testing practices, and an explosion of different testing tools, in the PHP space. The difficulties come when we have to choose which tools to use, in what combinations, and how to apply them to existing codebases.
In this talk we will look at what tools are available, what their strengths are, how to decide which set of tools to use for new or legacy projects, and when to prioritise decoupling and testability over the convenience we get from our frameworks.
Writing readable code is one of the most important aspects of web development. A developer should write code which another human is able to understand without the help of too many comments.
This talk will show you how to tidy up your code and write readable PHP.
You must’ve heard of Unit testing… If not, then this talk is definitely for you! If you do know Unit testing, you probably ran at some point into a hurdle: “Where do I start?” And despite your best efforts, you end up not having enough tests for your application – Then that change request comes in, requiring you to change that very same complex piece of code for which you are lacking tests! How do you going refactor while maintaining all those ‘undocumented’ business rules? This talk will show how Codeception can be leveraged to refactor the visuals aspects of an application, maintaining backwards compatibility on API changes and even assist in moving to a whole different server infrastructure.
Clear PHP is a coding reference for all of us. It tracks recommendations to write clear code, avoiding the classic traps, keeping options opened for the future and preventing decayed code. Those recommendations are above coding conventions, that focuses on code writing, and code architecture, with its design patterns and conceptions. This is the first time in history where an effort was made to collect all those rules, so every project can choose among them, and define exactly his own coding standard.
Slides from my presentation at DunDDD, 17th Nov 2012.
Most of this session was spent discussing unit test examples harvested from github. If anyone would like to see them, just ask.
So you are thinking of unit-testing the applications you work on a daily basis or already started to do so? Congratulations, but the really hard part is maintaining your test quality on such a high level so that you don't give up on testing down the road. In this talk I discuss unit-testing bad practices and test-smells, how to avoid them and show examples from open-source projects.
Symfony World - Symfony components and design patternsŁukasz Chruściel
There are so many Symfony components already, and they have some pretty neat perks. But have you seen them in action?
Design patterns are not a silver bullet. They will never resolve your problem on their own. On the other hand, design patterns provide a common ground for developers without going into details and could be used as building bricks to solve some more advanced problems.
During my presentation, I will take a closer look and explain the appliance of selected design patterns. What is more, I will take advantage of the Symfony ecosystem to implement them with ease.
I will do the presentation on sample code that developers will understand at all levels of expertise.
PHP7 brings a tremendous number of new features. Tonight, we will take a look at the null coalesce operator, new execution order (uniform variable syntax), new exceptions and more.
Entities lifecycle is usually something more than create and delete. Models with which we are working on day to day basis change their state under some business circumstances. State machine patterns can be a powerful allay when solving this kind of problem. How does it look like? What are the pros and cons of state machine usage? What are the things that we should be beware of? I will answer these questions during my talk, together with practical differences between the most popular implementation.
PHP 8.1 brings Enums, one of the most requested features in PHP.
Enums, or Enumerations, allow creating strict and type-safe structures for fixed values. An Enum structure can hold a number of values that can also be backed with integer or string values.
In this comprehensive session, we will discover what Enums are, why they are useful, how to apply them on our applications including Drupal, and things to watch out for when using Enums.
Audience
This session is for those who are familiar with modern PHP practices such as Object Oriented Programming, and principles such as Liskov Substitution principle. A quick introduction will be given to catch up to speed, but familiarity with such concepts can help a lot.
What you will learn
What are Enums.
Why Enums are useful.
How to use Enums
Migrating from magic constants/values to Enums.
Backed Enums and storing/fetching Enum values with a database.
Using Enums in a Drupal context.
Caveats when using Enums.
Author
Ayesh Karunaratne is the author of PHP.Watch (https://php.watch), where he provides in-depth articles and documents on PHP and latest changes to the language.
PHP 8.0: https://php.watch/versions/8.0
PHP 8.1: https://php.watch/versions/8.1
Enums: https://php.watch/versions/8.1/enums
Slides from my talk at the GTA-PHP Meetup Group about getting mixed HTML / PHP code into objects using SOLID principles.
Meetup page: http://www.meetup.com/GTA-PHP-User-Group-Toronto/events/230656470/
Code is on github: https://github.com/zymsys/solid
Building a Pyramid: Symfony Testing StrategiesCiaranMcNulty
The last few years have seen a huge adoption of testing practices, and an explosion of different testing tools, in the PHP space. The difficulties come when we have to choose which tools to use, in what combinations, and how to apply them to existing codebases.
In this talk we will look at what tools are available, what their strengths are, how to decide which set of tools to use for new or legacy projects, and when to prioritise decoupling and testability over the convenience we get from our frameworks.
Writing readable code is one of the most important aspects of web development. A developer should write code which another human is able to understand without the help of too many comments.
This talk will show you how to tidy up your code and write readable PHP.
Too many of us have been taught that views are nothing more than stored SQL statements. The goal of this presentation is to challenge this notion. Or, to be precise, to take you one step further, from technicalities to the huge role that well-designed views can play in contemporary database solutions.
Current views are very advanced. They can be built on top of user-defined functions; they can utilize extremely complex INSTEAD-OF triggers (including composite ones), and they can even have indexes! As a result, with all of this added functionality views can serve as an isolation level between UI-driven data representation (heavily denormalized and customized) and DBA-driven data representation (normalized with referential integrity constraints and foreign keys).
Contemporary IT solutions often take this transformation completely out of the database, usually moving it to the middle-tier. This presentation will show that keeping business logic IN the database provides you with much greater flexibility, manageability, and performance. Of course, there are some traps and pitfalls, but these are also avoidable. Real-world examples will be provided to show that the role of views is seriously underestimated.
Some companies have to process data volumes that by far exceed the capacity of “small” database clusters and they definitely have a valid use case for one of the modern parallelizing / streaming / big data processing technologies. For all others, expressing transformations in plain SQL is just fine and PostgreSQL is the perfect workhorse for that purpose.
In this talk, I will go through some of our best practices for building fast, robust, and tested data integration pipelines inside PostgreSQL. I will explain many of our technical patterns, for example for schema management or for splitting large computations by chunking and table partitioning. And I will show how to apply standard software engineering techniques to maintain agility, consistency, and correctness.
Video: http://www.ustream.tv/recorded/109227465
Xenogenetics for PL/SQL - infusing with Java best practicesLucas Jellema
Xenogenetics for PL/SQL- Infusing with Java Best Practices and Design Patterns - PL/SQL is a venerable programming language that is both vital and very much alive. This session will discuss how we further rejuvenate and enhance the way we create PL/SQL programs. We'll tap into the world of .NET, Java, and other modern programming language to do some cherry picking: what are the very best practices, concepts, and design patterns and how can we apply them to PL/SQL? We'll explain and demonstrate dependency injection, the observer pattern based on listeners, aspect-oriented programming (AOP), the decorator and template pattern, use of user-defined nested types, and collections.
Watch Erik's presentation on PHP Unit Testing to gain familiarity with unit tests and unit testing here at Tagged, with the testing framework currently in place and also learn how to write (better) unit tests. Download his slides here or email him at ejohannessen@tagged.com.
With Extbase - a new framework for extension development introduced in TYPO3 4.3 - you are able to develop with the paradigms of FLOW3 today. During this talk, you get in touch with the features of the framework to understand how it supports your development process to develop clean code cost efficient in less time. Extbase is one cornerstone for a smooth transition to TYPO3 v5, another is reusable business domain knowledge in form of Generic Domain Models available in 4.x and 5.x. The Generic Domain Models will enable you to add a Semantic Web topping.
Replacing dependents with doubles is a central part of testing that every developer has to master. This talk goes over the different types of doubles and explains their place in testing, how to implement them in a mainstream mocking framework, and which strategies or doubles to use in different message exchange scenarios between objects. After this talk you will have moved a step forward in your understanding of testing in the context of object oriented programming.
PHP Data Objects (PDO) provides a clear, simple (but powerful), unified API for working with all our favorite databases. Features include prepared statements with bound parameters (for all databases, even those that don’t natively support them), transactions, cursors, LOBs, and flexible error handling.
Oracle Text is a facility within the database that provides more advanced indexing & search techniques - including the ability to index documents stored in your database; on your server; or even the web!
Now you can incorporate this functionality into your web application using Oracle Application Express.
This presentation will demonstrate how easy it is to combine the two, and give you a platform for further expansion and exploration within a very powerful product.
This paper was presented by Tim Daniell, Systems Architect, Fresh Computer Systems at the Brisbane conference. We liked it so much we have obtained Tim's permission to present it at AUSOUG Perth 2013.
Does anyone have too much time and not enough to do in it? I thought not. We all try to cram as much as possible into each day and then struggle to achieve it. In this session, we will look at ways to achieve more but also manage our own expectations of what is achievable. To do this, we want to understand how our brain works to make better use of it. We need to understand our tools and how they can help us. We'll look at ways to better manage what time we have and focus on the things that actually matter. We'll also explore many other ways to be more productive and achieve more inside the 8-hour-burn we call "work".
Over the years there have been countless technical and social presentations doting on 5, 10, 12 ways to improve this, that and the other.
I will go through various performance tweaks (not tweets) for Oracle Application Express without limiting myself to a golden number.
These improvements will vary from simple PL/SQL refactoring; to monitoring for bottlenecks in your application; to cutting down maintenance time - which relates to the performance of you as an Oracle developer with only 24 hours in a day.
We may even visit a little APEX instrumentation on the way.
Oracle Text is a facility within the database that provides more advanced indexing & search techniques - including the ability to index documents stored in your database; on your server; or even the web!
Now you can incorporate this functionality into your web application using Oracle Application Express.
This presentation will demonstrate how easy it is to combine the two, and give you a platform for further expansion and exploration within a very powerful product.
Abstract: If you're a database developer, regardless of whether you have 6 months or 6 years experience, you need a good reference manual.
By good, I mean one that you can locate what you need within seconds. I know you know what I mean...
I'd like to show you how easy the free Oracle supplied documentation really is to use. And if for some reason it still doesn't cater to your needs, I'll show you some other methods and destinations that might save you a few headaches.
In this short presentation, I'll show you how to find most day to day documentation requirements in 2 clicks, maybe 3 if you're unlucky - without connecting to the net.
You might also hear some other new words such as Ubiquity & Bookmarklets.
Oracle 11g new features for developersScott Wesley
Abstract: There are a wealth of new features available in the 11g database release. This presentation touches on SQL & PL/SQL features I found of interest, and concentrates particularly on virtual columns.
Relevant scripts found at my blog
http://grassroots-oracle.com/2009/07/presentations.html#11gNewFeatures
Abstract: Developers - If you are not using Bulk Binds you are not writing PL/SQL efficiently!
Bulk binding has been around for a long time, yet there are sites out there that don't utilise this feature to its full extent, if at all. Every release of Oracle improves on this functionality so obviously it's a topic worthy of consistent awareness.
In PL/SQL and SQL, there are a few nifty features related to bulk binding you may not have seen - it's not all about BULK COLLECT. Whether you're on 8i, 11g or anything in between, you'll benefit from the concepts described in this seminar and become a Bulk Binding Baron!
Abstract: The session will breakdown the Model clause into its fundamental components and provides some basic real-world examples to demonstrate its greater potential.
Though most developers have heard of the SQL Model clause in 10g, many may baulk at the idea of using it - daunted by seemingly foreign syntax that might well have come out of a FORTRAN program.
Look a little closer and you'll find it's just like building a spreadsheet. Concise, easy to read syntax that provides the functionality for demanding calculations that would normally require elaborate joins, unions, analytics or PL/SQL. In addition to the development and maintenance burden, we are also faced with the all too familiar problem of business customers duplicating data to an Excel spreadsheet that is shared and erroneously modified around the workplace.
This session uses the Model clause as a high performance tool that can simplify approaches to every day problems. It demonstrates that Model is an extension to SQL that forms multi-dimensional arrays with inter-row & inter-array calculations that automatically resolves formula dependencies.
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...2023240532
Quantitative data Analysis
Overview
Reliability Analysis (Cronbach Alpha)
Common Method Bias (Harman Single Factor Test)
Frequency Analysis (Demographic)
Descriptive Analysis
Adjusting OpenMP PageRank : SHORT REPORT / NOTESSubhajit Sahu
For massive graphs that fit in RAM, but not in GPU memory, it is possible to take
advantage of a shared memory system with multiple CPUs, each with multiple cores, to
accelerate pagerank computation. If the NUMA architecture of the system is properly taken
into account with good vertex partitioning, the speedup can be significant. To take steps in
this direction, experiments are conducted to implement pagerank in OpenMP using two
different approaches, uniform and hybrid. The uniform approach runs all primitives required
for pagerank in OpenMP mode (with multiple threads). On the other hand, the hybrid
approach runs certain primitives in sequential mode (i.e., sumAt, multiply).
Techniques to optimize the pagerank algorithm usually fall in two categories. One is to try reducing the work per iteration, and the other is to try reducing the number of iterations. These goals are often at odds with one another. Skipping computation on vertices which have already converged has the potential to save iteration time. Skipping in-identical vertices, with the same in-links, helps reduce duplicate computations and thus could help reduce iteration time. Road networks often have chains which can be short-circuited before pagerank computation to improve performance. Final ranks of chain nodes can be easily calculated. This could reduce both the iteration time, and the number of iterations. If a graph has no dangling nodes, pagerank of each strongly connected component can be computed in topological order. This could help reduce the iteration time, no. of iterations, and also enable multi-iteration concurrency in pagerank computation. The combination of all of the above methods is the STICD algorithm. [sticd] For dynamic graphs, unchanged components whose ranks are unaffected can be skipped altogether.
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Data and AI
Discussion on Vector Databases, Unstructured Data and AI
https://www.meetup.com/unstructured-data-meetup-new-york/
This meetup is for people working in unstructured data. Speakers will come present about related topics such as vector databases, LLMs, and managing data at scale. The intended audience of this group includes roles like machine learning engineers, data scientists, data engineers, software engineers, and PMs.This meetup was formerly Milvus Meetup, and is sponsored by Zilliz maintainers of Milvus.
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...pchutichetpong
M Capital Group (“MCG”) expects to see demand and the changing evolution of supply, facilitated through institutional investment rotation out of offices and into work from home (“WFH”), while the ever-expanding need for data storage as global internet usage expands, with experts predicting 5.3 billion users by 2023. These market factors will be underpinned by technological changes, such as progressing cloud services and edge sites, allowing the industry to see strong expected annual growth of 13% over the next 4 years.
Whilst competitive headwinds remain, represented through the recent second bankruptcy filing of Sungard, which blames “COVID-19 and other macroeconomic trends including delayed customer spending decisions, insourcing and reductions in IT spending, energy inflation and reduction in demand for certain services”, the industry has seen key adjustments, where MCG believes that engineering cost management and technological innovation will be paramount to success.
MCG reports that the more favorable market conditions expected over the next few years, helped by the winding down of pandemic restrictions and a hybrid working environment will be driving market momentum forward. The continuous injection of capital by alternative investment firms, as well as the growing infrastructural investment from cloud service providers and social media companies, whose revenues are expected to grow over 3.6x larger by value in 2026, will likely help propel center provision and innovation. These factors paint a promising picture for the industry players that offset rising input costs and adapt to new technologies.
According to M Capital Group: “Specifically, the long-term cost-saving opportunities available from the rise of remote managing will likely aid value growth for the industry. Through margin optimization and further availability of capital for reinvestment, strong players will maintain their competitive foothold, while weaker players exit the market to balance supply and demand.”
Machine learning and optimization techniques for electrical drives.pptx
Oracle PL/SQL - Creative Conditional Compilation
1. SAGE Computing Services
Customised Oracle Training Workshops and Consulting
Creative Conditional Compilation
… and “raising the bar” with yourPL/SQL
Sco tt We sle y
Systems Consultant
2.
3. The example everybody’s seen…
FUNCTION qty_booked(p_resource IN VARCHAR2
,p_date IN DATE)
RETURN NUMBER
$IF dbms_db_version.ver_le_10 $THEN
$ELSE RESULT_CACHE $END
IS
li_total PLS_INTEGER := 0;
BEGIN
SELECT SUM(b.qty)
INTO li_total
FROM bookings b, events e
WHERE p_date BETWEEN e.start_date AND e.end_date
AND b.resource = p_resource;
RETURN li_total
END qty_booked;
4. The example everybody’s seen…
FUNCTION qty_booked(p_resource IN VARCHAR2FUNCTION qty_booked(p_resource IN VARCHAR2
,p_date IN DATE),p_date IN DATE)
RETURN NUMBERRETURN NUMBER
$IF dbms_db_version.ver_le_10 $THEN
$ELSE RESULT_CACHE $END
ISIS
li_total PLS_INTEGER := 0;li_total PLS_INTEGER := 0;
BEGINBEGIN
SELECT SUM(b.qty)SELECT SUM(b.qty)
INTO li_totalINTO li_total
FROM bookings b, events eFROM bookings b, events e
WHERE p_date BETWEEN e.start_date AND e.end_dateWHERE p_date BETWEEN e.start_date AND e.end_date
AND b.resource = p_resource;AND b.resource = p_resource;
RETURN li_totalRETURN li_total
END qty_booked;END qty_booked;
5. • PL/SQL User’s Guide & Reference
10g Release 2
– Fundamentals of the PL/SQL Language
• Conditional Compilation
6. Availability
• 11g
• 10g Release 2
– Enabled out of the box
• 10.1.0.4 – Once patched, enabled by default
– Disable using “_parameter”
• 9.2.0.6 – Once patched, disabled by default
– Enable using “_parameter”
9. Facilitates removal of unnecessary code at compile time
Performance
Readability
Accuracy Testing
It's cool!
10. Selection Directives
$IF boolean_static_expression $THEN text
[ $ELSIF boolean_static_expression $THEN text ]
[ $ELSE text ]
$END
Inquiry Directives
DBMS_OUTPUT.PUT_LINE($$PLSQL_LINE);
ALTER SESSION SET PLSQL_CCFLAGS='max_sentence:100';
IF sentence > $$max_sentence THEN
Error Directives
$IF $$PLSQL_OPTIMIZE_LEVEL != 2
$THEN
$ERROR 'intensive_program must be compiled with
maximum optimisation'
$END
$END
Semantics
14. > CREATE OR REPLACE PROCEDURE sw_test IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Unit:'||$$PLSQL_UNIT);
DBMS_OUTPUT.PUT_LINE('Line:'||$$PLSQL_LINE);
END sw_test;
/
Procedure created.
> exec sw_test
Unit:SW_TEST
Line:4
15. ALTER SESSION SET PLSQL_CCFLAGS = 'max_sentence:100';
Session altered.
16. > BEGIN
IF p_sentence > $$max_sentence THEN
DBMS_OUTPUT.PUT_LINE('Parole Available');
ELSE
DBMS_OUTPUT.PUT_LINE('Life');
END IF;
END;
/
Life
17. ALTER SYSTEM SET PLSQL_CCFLAGS =
'VARCHAR2_SIZE:100, DEF_APP_ERR:-20001';
DECLARE
lc_variable_chr VARCHAR2($$VARCHAR2_SIZE);
e_def_app_err EXCEPTION;
PRAGMA EXCEPTION_INIT (e_def_app_err, $$DEF_APP_ERR);
BEGIN
--> rest of your code
END anon;
/
19. ALTER SESSION SET PLSQL_CCFLAGS = 'MY_PI:314';
CREATE OR REPLACE PROCEDURE universe_alpha IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Alpha pi = '||$$my_pi/100);
END;
CREATE OR REPLACE PROCEDURE universe_gamma IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Gamma pi = '||$$my_pi/100);
END;
CREATE OR REPLACE PROCEDURE universe_oz IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Oz pi = '||$$my_pi/100);
END;ALTER PROCEDURE universe_alpha COMPILE
PLSQL_CCFLAGS = 'MY_PI:289'
REUSE SETTINGS; ALTER PROCEDURE universe_gamma COMPILE
PLSQL_CCFLAGS = 'MY_PI:423'
REUSE SETTINGS;
> BEGIN
universe_alpha;
universe_gamma;
universe_oz;
END;
/
Alpha pi = 2.89
Gamma pi = 4.23
Oz pi = 3.14
21. Using new version code today
$IF dbms_db_version.ver_le_10 $THEN
-- version 10 and earlier code
$ELSIF dbms_db_version.ver_le_11 $THEN
-- version 11 code
$ELSE
-- version 12 and later code
$END
23. CREATE OR REPLACE PROCEDURE sw_debug (p_text IN
VARCHAR2) IS
$IF $$sw_debug_on $THEN
l_text VARCHAR2(32767);
$END
BEGIN
$IF $$sw_debug_on $THEN
-- Let’s provide debugging info
$IF dbms_db_version.ver_le_10_1 $THEN
-- We have to truncate for <= 10.1
l_text := SUBSTR(p_text, 1 ,200);
$ELSE
l_text := p_text;
$END
DBMS_OUTPUT.PUT_LINE(p_text);
$ELSE
-- No debugging
NULL;
$END
END sw_debug;
24. CREATE OR REPLACE PROCEDURE sw_debug (p_text INCREATE OR REPLACE PROCEDURE sw_debug (p_text IN
VARCHAR2) ISVARCHAR2) IS
$IF $$sw_debug_on $THEN
l_text VARCHAR2(32767);
$END
BEGINBEGIN
$IF $$sw_debug_on $THEN
-- Let’s provide debugging info
$IF dbms_db_version.ver_le_10_1 $THEN
-- We have to truncate for <= 10.1
l_text := SUBSTR(p_text, 1 ,200);
$ELSE
l_text := p_text;
$END
DBMS_OUTPUT.PUT_LINE(p_text);
$ELSE$ELSE
-- No debugging-- No debugging
NULL;NULL;
$END$END
END sw_debug;END sw_debug;
25. CREATE OR REPLACE PROCEDURE sw_debug (p_text INCREATE OR REPLACE PROCEDURE sw_debug (p_text IN
VARCHAR2) ISVARCHAR2) IS
$IF $$sw_debug_on $THEN$IF $$sw_debug_on $THEN
l_text VARCHAR2(32767);l_text VARCHAR2(32767);
$END$END
BEGINBEGIN
$IF $$sw_debug_on $THEN$IF $$sw_debug_on $THEN
-- Let’s provide debugging info-- Let’s provide debugging info
$IF dbms_db_version.ver_le_10_1 $THEN
-- We have to truncate for <= 10.1
l_text := SUBSTR(p_text, 1 ,255);
$ELSE$ELSE
l_text := p_text;l_text := p_text;
$END$END
DBMS_OUTPUT.PUT_LINE(p_text);DBMS_OUTPUT.PUT_LINE(p_text);
$ELSE$ELSE
-- No debugging-- No debugging
NULL;NULL;
$END$END
END sw_debug;END sw_debug;
26. 10g vs 11g result_cache
FUNCTION quantity_ordered
(p_item_id IN items.item_id%TYPE)
RETURN NUMBER
$IF dbms_version.ver_le_10 $THEN
-- nothing
$ELSE
RESULT_CACHE
$END
IS
BEGIN
...
28. CREATE OR REPLACE PACKAGE BODY sw_bulk_insert IS
PROCEDURE sw_insert (sw_tab IN t_sw_tab) IS
BEGIN
$IF dbms_db_version.ver_le_9 $THEN
DECLARE
l_dense t_sw_tab;
ln_index PLS_INTEGER := sw_tab.FIRST;
BEGIN
<< dense_loop >>
WHILE (l_index IS NOT NULL) LOOP
l_dense(l_dense.COUNT + 1) := sw_tab(l_index);
l_index := sw_tab.NEXT(l_index);
END LOOP dense_loop;
FORALL i IN 1..l_dense.COUNT
INSERT INTO sw_table VALUES l_dense(i);
END;
$ELSE
FORALL i IN INDICES OF sw_tab
INSERT INTO sw_table
VALUES sw_tab(i);
$END
END sw_insert;
END sw_bulk_insert;
29. CREATE OR REPLACE PACKAGE BODY sw_bulk_insert IS
PROCEDURE sw_insert (sw_tab IN t_sw_tab) IS
BEGIN
$IF dbms_db_version.ver_le_9 $THEN
DECLARE
l_dense t_sw_tab;
ln_index PLS_INTEGER := sw_tab.FIRST;
BEGIN
<< dense_loop >>
WHILE (l_index IS NOT NULL) LOOP
l_dense(l_dense.COUNT + 1) := sw_tab(l_index);
l_index := sw_tab.NEXT(l_index);
END LOOP dense_loop;
FORALL i IN 1..l_dense.COUNT
INSERT INTO sw_table VALUES l_dense(i);
END;
$ELSE$ELSE
FORALL i IN INDICES OF sw_tabFORALL i IN INDICES OF sw_tab
INSERT INTO sw_tableINSERT INTO sw_table
VALUES sw_tab(i);VALUES sw_tab(i);
$END$END
END sw_insert;
END sw_bulk_insert;
30. CREATE OR REPLACE PACKAGE BODY sw_bulk_insert IS
PROCEDURE sw_insert (sw_tab IN t_sw_tab) IS
BEGIN
$IF dbms_db_version.ver_le_9 $THEN$IF dbms_db_version.ver_le_9 $THEN
DECLAREDECLARE
l_dense t_sw_tab;l_dense t_sw_tab;
ln_index PLS_INTEGER := sw_tab.FIRST;ln_index PLS_INTEGER := sw_tab.FIRST;
BEGINBEGIN
<< dense_loop >><< dense_loop >>
WHILE (l_index IS NOT NULL) LOOPWHILE (l_index IS NOT NULL) LOOP
l_dense(l_dense.COUNT + 1) := sw_tab(l_index);l_dense(l_dense.COUNT + 1) := sw_tab(l_index);
l_index := sw_tab.NEXT(l_index);l_index := sw_tab.NEXT(l_index);
END LOOP dense_loop;END LOOP dense_loop;
FORALL i IN 1..l_dense.COUNTFORALL i IN 1..l_dense.COUNT
INSERT INTO sw_table VALUES l_dense(i);INSERT INTO sw_table VALUES l_dense(i);
END;END;
$ELSE
FORALL i IN INDICES OF sw_tab
INSERT INTO sw_table
VALUES sw_tab(i);
$END
END sw_insert;
END sw_bulk_insert;
33. CREATE OR REPLACE PACKAGE pkg_debug IS
debug_flag CONSTANT BOOLEAN := FALSE;
END pkg_debug;
/
CREATE OR REPLACE PROCEDURE sw_proc IS
BEGIN
$IF pkg_debug.debug_flag $THEN
dbms_output.put_line ('Debug=T');
$ELSE
dbms_output.put_line ('Debug=F');
$END
END sw_proc;
/
35. “Assertions should be used to document
logically impossible situations —
Development tool
Testing Aid
In-line Documentation
if the ‘impossible’ occurs,
then something fundamental is clearly wrong.
This is distinct from error handling.”
Run-time Cost
40. CREATE PACKAGE universe IS
PROCEDURE create_sun;
PROCEDURE create_planets;
-- CC test procedure
PROCEDURE test_orbit;
END universe;
CREATE PACKAGE BODY universe IS
-- Private
PROCEDURE orbit IS .. END;
-- Public
PROCEDURE create_sun IS .. END;
PROCEDURE create_planets IS .. END;
-- Testers
PROCEDURE test_orbit IS
BEGIN
$IF $$testing $THEN
orbit;
$ELSE
RAISE program_error;
$END
END test_orbit;
END universe;
41. CREATE PACKAGE universe IS
PROCEDURE create_sun;
PROCEDURE create_planets;
-- CC test sequence
PROCEDURE test_run;
END universe;
CREATE PACKAGE BODY universe IS
-- Private
PROCEDURE orbit IS .. END;
-- Public
PROCEDURE create_sun IS .. END;
PROCEDURE create_planets IS .. END;
-- Test sequence
PROCEDURE test_run IS
BEGIN
$IF $$testing $THEN
create_sun;
create_planets;
orbit;
$ELSE
RAISE program_error;
$END
END test_run;
END universe;
43. FUNCTION get_emp(p_emp_id IN emp.emp_id%TYPE)
RETURN t_emp IS
l_emp t_emp;
BEGIN
$IF $$mock_emp $THEN
l_emp.emp_name := 'Scott';
..
RETURN l_emp;
$ELSE
SELECT *
FROM emp
INTO l_emp
WHERE emp_id = p_emp_id;
RETURN l_emp;
$END
END get_emp;
47. PACKAGE BODY core IS
PROCEDURE execute_component(p_choice IN VARCHAR2) IS
BEGIN
CASE p_choice -- Base is always installed.
WHEN 'base' THEN base.main();
$IF CC_licence.cheap_installed $THEN
WHEN 'cheap' THEN cheap.main();
$END
...
$IF CC_licence.pricey_installed $THEN
WHEN 'pricey' THEN pricey.main();
$END
END CASE;
EXCEPTION WHEN case_not_found THEN
dbms_output.put_line('Component '||p_choice||' is
not installed.');
END execute_component;
END core;
52. 1 CREATE PROCEDURE process_court_outcome IS
2 BEGIN
3 IF lr_victim.age > 18 THEN
4 send_to_prison(lr_victim);
5 ELSE
6 $ERROR
7 'Waiting for business to advise '||
8 $$PLSQL_UNIT||' line: '||$$PLSQL_LINE
9 $END
10 END IF;
11 END process_court_outcome;
12 /
Warning: Procedure created with compilation errors.
SQL> sho err
LINE/COL ERROR
-------- ----------------------------------------
6/6 PLS-00179: $ERROR: Waiting for business to
advise PROCESS_COURT_OUTCOME line: 8
60. SAGE Computing Services
Customised Oracle Training Workshops and Consulting
Questions and Answers?
Presentations are available from our website:
http: //www. sag e co m puting . co m . au
e nq uirie s@ sag e co m puting . co m . au
sco tt. we sle y@ sag e co m puting . co m . au
http: //triang le -circle -sq uare . blo g spo t. co m
Editor's Notes
Some powerpoint pezzaz straight off the bat, let’s get into an example you’ve probably seen before so you all know what I’m talking about
And one that Penny even details later in the conference. I’m going to talk in depth about the concept behind conditional compilation and delve into a few more uses for you.
This funky bit of code here is the concept where going to talk about. As usual, I’ll fly through the semantics because that’s all available in the doco
You don’t need to look far to find it.
What I really want to concentrate on with you is more diverse applications of this concept, using programming principles that have been around for a while.
Feature of 10gr2, but made available to previous releases via patchsets.
Historians of Oracle Database might be interested to know that the introduction
of PL/SQL conditional compilation was motivated by a request from Oracle’s
Applications Division for a solution to the problem of code spanning multiple releases.
Catch22 - So you must patch your previous db to make conditional compilation available to prepare for new release
Catch22 - So you must patch your previous db to make conditional compilation available to prepare for new release
I&apos;ll basically go through all of these points in the seminar
Note the lack of semicolon, end ‘if’;
This demo really needs to highlight the difference between enquiry directive usage. Diff between $$x and static constant. Usage behind both examples can differ depending on what you are trying to accomplish. Example shown later in competing soln.
Designers should choose carefully with their names,
to minimise collision
Accidental discovery
Reserved words
Even more valuable, I can use inquiry directives in places in my code where a variable is not allowed. Here are two examples
Also note it’s system or session specific
A quick word for developers to ensure the same compiler directives are used when functions recompiled later
Let’s have a quick look at was this feature was made for
A quick word for developers to ensure the same compiler directives are used when functions recompiled later
Don’t forget the whole poor software engineering premise to this funky technology though -
never recommend putting untested code in production.
When you upgrade to 11g obviously you’d test the upgrade in a non-production environment as
part of search for side effects or compilation issues.
Just means you haven’t forgotten this new feature. We won’t flick switch to 11g on prod anyway.
OK, you don&apos;t upgrade often. How about these paradigms
We saw this one in the demo…
Ok, who’se heard of assertions?
Ok, who’se heard of LATENT assertions?
“In tests, a mock object behaves exactly like a real object with one crucial
difference: the programmer will hard-code return values for its methods...”
REALLY basic example here, the white paper example I saw was on it&apos;s way
towards some sophisticated testing, but there is so much potential here.
for embedding test plans, particular for subprograms in packages
Highlight not so much the code, but the concept behind this. Making sure code doesn’t get lost, competing examples don’t get lost and confused as commented code. Life may only be days/weeks, not production code. But the concept does lead on to the idea of component based installation for licensed software.
Inquiry directives allow quite flexible playing around with other triggers or events elsewhere in your app that you can control your testing with.
Much of a segue from the previous solution, but too deep a topic to go to any more detail today than a quick conceptual example
Pick up any textbook that talks about conditional compilation.