Using Persistent Global Objects

Intellezy Trainers
A free video tutorial from Intellezy Trainers
Computer Training Specialists
4.4 instructor rating • 198 courses • 152,792 students

Learn more from the full course

Oracle PL/SQL Fundamentals vol. I & II

A complete introduction to PL/SQL database programming language

19:59:18 of on-demand video • Updated May 2020

  • Over 90 lectures and 20 hours of content
  • Prepare your enviornment
  • Introducing Database Program Units
  • Creating and Maintaining Packages
  • Using System-Supplied Packages
  • Creating and Maintaining Database Triggers
  • Implementing System Event Triggers
  • Work with Oracle database tools
  • Understand and work work language features
  • Work with DECLARE, BEGIN & EXCEPTION clause
  • Understand and use nested blocks
  • Use explicit cursors
English [Auto] Our next topic is going to deal with persistent global objects. And that term always cracks me up because persistent global object sounds very technical and really all you're doing is creating a global variable. So for any of you who programmed in any other programming language Java C-Sharp C VB VBA VB dot net. Whatever the case may be you've already worked with global variables. Well this is the same thing. But again these are the global variables are only available to us within a package. So when we start talking about our pro package specification not only will it include or not only can it include our public procedures whether those are procedures or functions. You can also include a global variable and we just consider that to be a persistent global object. So a global variable can't consist of a variable constants. Exceptions explicit cursors cursor variables basically any object that you've already worked with. You can put inside of that public specification. The moment you do this you are now exposing that if you put this inside of the specification you're exposing that not only to the world but you're also exposing it to every procedure or function found with in your package which is extremely cool. So it is now considered a global object. But what's even cooler about this is that you can also create global objects within the body or the implementation. When you do that now those variables are available throughout the entire package not just the public procedures or functions. So it's very very powerful. This is extremely cool. Now this is what it looks like. You have your create or replace package personnel as and then the one thing that I always do is I always create my public or my global variables at the top and in some program changes you have to do that. So this is just following that rule. And here we just say I just put in a comment saying to find my global variables or my global objects and you have current employee SSN so employees that SSN you identify its type and it's no different than any other variable declaration that we've done from the beginning of this course but now what makes this variable unique is that it is now available to the higher employees. The fire employees transfer employees and any other procedures or functions that we have in there. That is the key feature of working with a global variable. So now this gives us a lot of flexibility because instead of trying to put in a new parameter so we can transfer things back and forth. Now we can use a global variable and you can just use it as if it were your own. Please keep in mind however the moment you start manipulating your code to use a global variable that means that it can no longer be a standalone application you can't just pull it out and use it as standalone because this feature is only available to us in a package so keep that in mind when you start working with global variables in that key.