Performing some final housekeeping – PB Docs 125

Performing some final housekeeping

When your application has finished processing pipelines, you
need to make sure it takes care of a few cleanup chores. These chores
basically involve releasing the resources you obtained at the beginning
to support pipeline execution.

note.png Garbage collection

You should avoid using the DESTROY statement
to clean up resources unless you are sure that the objects you are
destroying are not used elsewhere. PowerBuilder’s garbage
collection mechanism automatically removes unreferenced objects.
For more information, see “Garbage collection and memory
management”
.

proc.png To clean up when you have finished using pipelines:

  1. Destroy the instance that you created of
    your supporting user object.

    To do this, code the DESTROY statement
    in an appropriate script and specify the name of the variable that
    contains that user-object instance.

  2. Disconnect from the pipeline’s source
    and destination databases.

    To do this, code two DISCONNECT statements
    in an appropriate script. In one, specify the name of the variable
    that contains your source transaction–object instance.
    In the other, specify the name of the variable that contains your
    destination transaction-object instance.

    Then test the result of each DISCONNECT statement.

  3. Destroy your source transaction-object instance
    and your destination transaction-object instance.

    To do this, code two DESTROY statements
    in an appropriate script. In one, specify the name of the variable
    that contains your source transaction–object instance.
    In the other, specify the name of the variable that contains your
    destination transaction-object instance.

For more information on coding the DESTROY and DISCONNECT statements, see
the PowerScript Reference.

Example

The following code in the Close event of the w_sales_extract window
takes care of these cleanup chores.

Destroying the user-object instance

At the beginning of the Close event script, code the following
statement to destroy the instance of the user object u_sales_pipe_logistics (which
is stored in the iuo_pipe_logistics variable):

Disconnecting from the source database

Next, code these statements to disconnect from the source
database, test the result of the disconnection, and destroy the
source transaction-object instance (which is stored in the itrans_source variable):

Disconnecting from the destination database

Finally, code these statements to disconnect from the destination
database, test the result of the disconnection, and destroy their
destination transaction-object instance (which is stored in the itrans_destination variable):


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x