PL/SQL Constructor

A "constructor" is a PL/SQL routine  to create a new ]po[ object. As a convention, constructor names consist of the object_type, followed by "__new" (double underscore).

Constructors construct ]po[ objects starting with the top element of the ]po[ "class" hierarchy, which is acs_object followed by other super-classes. For this reason ]po[ constructors require you to specify all required parameters of all super-classes.


Let's look take a typical example (creating a new project):

 

select im_project__new (
        :object_id,
        :object_type,
        :creation_date,
        :creation_user,
        :creation_ip,
        :context_id,

        :project_name,
        :project_nr,
        :project_path,
        :parent_id,
        :company_id,
        :project_type_id,
        :project_status_id
);

 

The first 6 parameters are the parameters required by the [acs_object__new] constructor and are passed on directly:

  • object_id - NULL:
    The object_id for the new object. This parameter should usually be NULL, indicating that the next object_id should be taken.

  • object_type - 'im_project':
    The object_type for the new object. This should usually be the object type itself.
    The constructors of a sub-type (for example: im_ticket is a sub-class of im_project) will specify the object_type of the sub-type here.

  • creation_date - now():
    The date of creation, for audit purposes.
    In most cases it's save to put the PL/SQL function "now()" here, to use the current time.

  • creation_user - 0:
    The ID of the user creating the object, for audit purposes.
    External applications can use the value "0" to refer to the pre-defined "anonymous user", or use the following SQL to determine the SysAdmin user: "select min(user_id) from users where user_id > 0".

  • creation _id - "0.0.0.0":
    The IP-address of the user creating the object.
    You can use '0.0.0.0' to indicate that there is no valid IP address (for example in case of an external application creating the user).

  • context_id - NULL:
    The ID of a "context" or "container" object, such as a package.
    The object will inherit permissions from the context_id, if it is not NULL.

The following parameters are specific to each object type and cover required database fields. Here are the parameters for creating a new projects:

  • project_name - "Sample Project":
    A human readable name for the project. The field is unique, within the object's hierarchy level.

  • project_nr - "2009_0001":
    A current number for the project. The default ]po[ number circuit consists of 4 digits for the year, followed by an underscore and 4 digits for the current number of the project within the year.

  • project_path - "2009_0001":
    The path for projec files in the file storage. Restriction: This field should be identical to the project_nr at the moment.

  • parent_id - NULL:
    The ID of the project's super-project. This field allows creating project hierarchies.

  • company_id - company_id:
    Who is the customer of the project (=paying for the project?). You need to specify a valid company.
    For testing or for "internal" projects (i.e. projects without an external customer) you can specify the "internal company" with the ID: "select company_id from im_companies where company_path = 'internal'".

  • project_type_id - 2501:
    A valid ID from the Intranet Project Type category or the "im_project_types" view. The 2501 sample value is a constant and refers to a "Consulting Project".

  • project_status_id - 76:
    A valid ID from the Intranet Project Status category or the "im_project_status" view. The 76 sample value is a constant and refers to the status "Open".

  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