]project-open[ : @This Wiki
Portrait

Welcome, Unregistered Visitor

 · · · Index · Login/Register

Contents





6 registered users
 in last 24 hours

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.


Please take a moment to complete this form to help us improve our service.

Did this page help you to achieve your goal?

 Yes  No  Don't know

Please provide us with comments to improve this page:

How useful is the information?

 1  2  3  4  5
Not
useful
      Extremely
useful
 
Privacy Policy