PL/SQL Shortcut Function

Shortcut functions are PL/SQL functions usually returning a certain field of an object, given the object_id. All of these functions could be replaced by a simple "join" as part of an SQL query, so these functions are not really necessary. However, using these functions allows to keep SQL queries more compact and readable.

 

Let's look take a typical example with "im_category_from_id" (the most frequently used shortcut function):

 

select
       project_id,
       project_name,
       im_category_from_id(project_status_id) as project_status
from
       im_projects
;

This SQL returns a list of all project_id's, together with the name of the project and a human readable project_status such as "Open" or "Closed". Without the shortcut function, the SQL would have to look like this:


select
       p.project_id,
       p.project_name,
       c.category as project_status
from
       im_projects p,
       im_categories c
where
       p.project_status_id = c.category_id
;

 

 

Admittedly, the difference is small in this example. However, many real-live SQLs in ]po[ include multiple categories, so that the shortcut functions provides a real benefit.


  Contact Us
  Project Open Business Solutions S.L.

Calle Aprestadora 19, 12o-2a

E-08907 Hospitalet de Llobregat (Barcelona)

 Tel Europe: +34 932 202 088
 Tel US: +1 415 429 5995
 Mail: info@project-open.com