|
Sybernet / Supplied Packages Reference
Release 3.00 Apr 23, 2006 |
|
The MYSELF package provides subprograms for interrogating information about your process. You can interrogate your name, the line number when you asked for this information as well as other useful information that may be important. This package uses the dbms_utility package and provides a simpler interface to the information that you actually need.
The most useful function in this package is myself.name. Your stored procedure probably refers to its name in several places. If you change the name of your procedure, then all references must also be changed. If you instead reference this name dynamically, then only the name in the procedure heading needs to be changed.
All funtions expect a one-relative parameter that points to the object name that you are interested in. This can be omitted if the object you are interested in is the object that invoked http.myself. To interrogate the object that invoked your function, the paramter should set to 2, and to interrogate the object that invoked that function (which then called your object), the parameter should be set to 3.
| Subprogram | Description |
|---|---|
CONTENTTYPE |
The content-type of this Sybercron job. |
CUSTODIAN |
The custodian of this object from the register file. |
CUSTOMER |
The customer of this object from the register file. |
DESCRIPTION |
The description of this object from the register file. |
DEVELOPER |
The developer of this object from the register file. |
DISPOSITION |
The disposition of this Sybercron job. |
GROUPNAME |
The groupname of this object from the register file. |
GROUPTYPE |
The grouptype of this object from the register file. |
LINENUMBER |
The current line number of the procedure or function that called this package. |
MAILTO |
The e-mail (EMAIL) address for this Sybercron job. |
MAILCC |
The e-mail (CC) address for this Sybercron job. |
MAILBCC |
The e-mail (BCC) address for this Sybercron job. |
MAILFROM |
The e-mail (SENDER) address for this Sybercron job. |
NAME |
The fully qualified procedure name that called this function. |
NLS_DATE_FORMAT |
The NLS_DATE_FORMAT for this session. |
PATCH_NUMBER |
The latest patch number of this object. |
PATCH_DATE |
The latest patch date of this object. |
PATCH_DESCRIPTION |
The latest patch description of this object. |
PLATFORM |
The platform where user invoked this object. |
SCRIPTNAME |
The scriptname of this Sybercron job. |
TITLE |
The description of this stored procedure in the register table. |
TYPE |
The type of object that called this function. |
USERNAME |
The username (USER) that created this Sybercron job or the username that is invoking this procedure. |
VERSION |
The version of this object. |
If invoked from Sybercron, this function retrieves a procedure's content-type. NULL is returned if the content-type cannot be determined.
Function CONTENTTYPE RETURN VARCHAR2;
The following example illustrates how to call CONTENTTYPE:
begin
if http.myself.contenttype = 'text/html' then
http.writeln('<html>');
http.writeln('<body>');
else
http.writeln('<pre>');
end if;
end;
This function returns the custodian of this procedure. This could be useful if you want to display an alert that contains this name.
Function CUSTODIAN
(
I BINARY_INTEGER
)
RETURN VARCHAR2;
| Parameter | Description |
|---|---|
i |
The level number. |
The following example illustrates how to call CUSTODIAN:
begin
null;
exception when others then
http.writeln('<script>');
http.writeln('alert("Oops!\n \nPlease contact ' || http.peopletools.name(http.myself.custodian) || ' for assistance.");');
http.writeln('</script>');
end;
This function returns the customer of this procedure. This could be useful if you want to display an alert that contains this name.
Function CUSTOMER
(
I BINARY_INTEGER
)
RETURN VARCHAR2;
| Parameter | Description |
|---|---|
i |
The level number. |
The following example illustrates how to call CUSTOMER:
begin
null;
exception when others then
http.writeln('<script>');
http.writeln('alert("Oops!\n \nPlease contact ' || http.peopletools.name(http.myself.customer) || ' for assistance.");');
http.writeln('</script>');
end;
This function retrieves the description of your stored procedure or subprogram from the register table.
Function DESCRIPTION
(
I BINARY_INTEGER
)
RETURN VARCHAR2;
| Parameter | Description |
|---|---|
i |
The level number. |
The following example illustrates how to call DESCRIPTION:
http.writeln(http.myself.description);
This function returns the customer of this procedure. This could be useful if you want to display an alert that contains this name.
Function DEVELOPER
(
I BINARY_INTEGER
)
RETURN VARCHAR2;
| Parameter | Description |
|---|---|
i |
The level number. |
The following example illustrates how to call DEVELOPER:
begin
null;
exception when others then
http.writeln('<script>');
http.writeln('alert("Oops!\n \nPlease contact ' || http.peopletools.name(http.myself.developer) || ' for assistance.");');
http.writeln('</script>');
end;
If invoked from Sybercron, this function retrieves a procedure's disposition. NULL is returned if disposition cannot be determined.
Function DISPOSITION RETURN VARCHAR2;
The following example illustrates how to call DISPOSITION:
begin
if http.myself.disposition = 'inline' then
http.writeln('inline');
else
http.writeln('attachment');
end if;
end if;
This function retrieves the groupname of your procedure from the Register table. This function is useful when calling sp_html_menubar so that a user will go to this group when they click Main Menu.
Function GROUPNAME
(
I BINARY_INTEGER
)
RETURN VARCHAR2;
| Parameter | Description |
|---|---|
i |
The level number. |
The following example illustrates how to call GROUPNAME:
http.sp_html_menubar(groupname=>http.myself.groupname);
This function retrieves the grouptype of your stored procedure from the http register. This
function is useful if you need to determine if your procedure is a child or adult. Adults
(for example) are executed inline within the Sybernet main menu. Children are executed on
their own page.
Function GROUPTYPE
(
I BINARY_INTEGER
)
RETURN VARCHAR2;
| Parameter | Description |
|---|---|
i |
The level number. |
The following example illustrates how to call GROUPTYPE:
begin
if http.myself.grouptype = 'Child' then
http.writeln('<html>');
http.writeln('<body>');
end if;
end;
This function determines the line number of the procedure or function that called this package.
HTTP.MYSELF.LINENUMBER
(
I IN BINARY_INTEGER := 1
)
RETURN NUMBER;
| Parameter | Description |
|---|---|
i |
The level number. |
The line number of that obect that invoked this function.
This following example illustrates how to call linenumber:
create or replace procedure sp_html_test(button in varchar2:=null)
is
begin
if (button is null) then
http.sp_html_frame
(
button => NULL
, procname => http.myself.name
, version => http.myself.version
, title => http.myself.title
, center => '*'
) ;
return;
end if;
if (button = 'CENTER') then
http.writeln(http.myself.linenumber);
return;
end if;
end;
This function returns the BCC value of a procedure running in Sybercron.
Function MAILBCC RETURN VARCHAR2;
The following example illustrates how to call MAILBCC:
begin
http.sp_sendmail
(
subject => http.myself.name
, mailfrom => http.myself.mailfrom
, mailto => http.myself.mailto
, mailcc => http.myself.mailcc
, mailbcc => http.myself.mailbcc
, message => 'The process is completed!'
) ;
end;
This function returns the CC value of a procedure running in Sybercron.
Function MAILCC RETURN VARCHAR2;
The following example illustrates how to call MAILCC:
begin
http.sp_sendmail
(
subject => http.myself.name
, mailfrom => http.myself.mailfrom
, mailto => http.myself.mailto
, mailcc => http.myself.mailcc
, mailbcc => http.myself.mailbcc
, message => 'The process is completed!'
) ;
end;
This function returns the sender of a procedure running in Sybercron.
Function MAILFROM RETURN VARCHAR2;
The following example illustrates how to call MAILFROM:
begin
http.sp_sendmail
(
subject => http.myself.name
, mailfrom => http.myself.mailfrom
, mailto => http.myself.mailto
, mailcc => http.myself.mailcc
, mailbcc => http.myself.mailbcc
, message => 'The process is completed!'
) ;
end;
This function returns the recepient of a procedure running in Sybercron.
Function MAILTO RETURN VARCHAR2;
The following example illustrates how to call MAILTO:
begin
http.sp_sendmail
(
subject => http.myself.name
, mailfrom => http.myself.mailfrom
, mailto => http.myself.mailto
, mailcc => http.myself.mailcc
, mailbcc => http.myself.mailbcc
, message => 'The process is completed!'
) ;
end;
This function returns the fully qualified object name that called this function. This includes the schema (or owner) and its object name.
Your stored procedure probably refers to its name in several places. If you change the name of your procedure, then all references must also be changed. If you instead reference this name dynamically, then only the name in the procedure heading needs to be changed.
HTTP.MYSELF.NAME
(
I IN BINARY_INTEGER := 1
)
RETURN VARCHAR2;
| Parameter | Description |
|---|---|
i |
The level number. |
The fully-qualified object name that invoked this function or BLOCK if invoked from an anonymous block.
Ths following example illustrates how to call name:
create or replace procedure sp_html_test(button in varchar2:=null)
is
begin
if (button is null) then
http.sp_html_frame
(
button => NULL
, procname => http.myself.name
, version => http.myself.version
, title => http.myself.title
, center => '*'
) ;
return;
end if;
if (button = 'CENTER') then
http.writeln('Hello World');
return;
end if;
end;
This function retrieves the NLS_DATE_FORMAT for this session.
Function NLS_DATE_FORMAT RETURN VARCHAR2;
The following example illustrates how to call NLS_DATE_FORMAT:
http.javascript.script(true);
http.javascript.ltrim;
http.javascript.rtrim;
http.javascript.trim;
http.javascript.to_char;
http.javascript.validatedate(http.myself.nls_date_format);
http.javascript.script(false);
http.writeln('<form>');
http.writeln('<input type="text" value="' || to_char(sysdate,http.myself.nls_date_format) || ' onChange="validateDate(this);">');
http.writeln('</form>');
All of the NLS_SESSION_PARAMETERS are available with this package (though they are undocumented). NLS_DATE_FORMAT is
documented because it is the most useful.
This function returns the latest patch date for this object.
Function PATCH_DATE
(
I BINARY_INTEGER
)
RETURN DATE;
| Parameter | Description |
|---|---|
i |
The level number. |
The following example illustrates how to call PATCH_DATE:
http.writeln(http.myself.patch_date);
This function returns the latest patch description for this object.
Function PATCH_DESCRIPTION
(
I BINARY_INTEGER
)
RETURN VARCHAR2;
| Parameter | Description |
|---|---|
i |
The level number. |
The following example illustrates how to call PATCH_DESCRIPTION:
http.writeln(http.myself.patch_description);
This function returns the latest patch number for this object.
Function PATCH_NUMBER
(
I BINARY_INTEGER
)
RETURN NUMBER;
| Parameter | Description |
|---|---|
i |
The level number. |
The following example illustrates how to call PATCH_NUMBER:
http.writeln(http.myself.patch_number);
This function returns the platform that this object was invoked from. Platform is unique to the copy of Sybernet that is invoking this function. Since you can connect to the same instance of Oracle from many platforms, this function returns that specific hostname.
Function PLATFORM RETURN VARCHAR2;
The following example illustrates how to call PLATFORM:
http.writeln(http.myself.platform);
This function returns the type of object that called this function.
HTTP.MYSELF.TYPE
(
I IN BINARY_INTEGER := 1
)
RETURN VARCHAR2;
| Parameter | Description |
|---|---|
i |
The level number. |
PROCEDURE or FUNCTION.
Ths following example illustrates how to call type:
create or replace procedure sp_html_test(button in varchar2:=null)
is
begin
if (button is null) then
http.sp_html_frame
(
button => NULL
, procname => http.myself.name
, version => http.myself.version
, title => http.myself.title
, center => '*'
) ;
return;
end if;
if (button = 'CENTER') then
http.writeln(http.myself.type);
return;
end if;
end;
This function retrieves the description of a stored procedure from HTTP_REGISTER. It calls http.myself.name and uses that value to look up your procedure's procname from this table. The obvious use of this function guarantees that the title displayed on Sybernet's menu screen matches with the title displayed by your application.
HTTP.MYSELF.TITLE
(
I IN BINARY_INTEGER := 1
)
RETURN VARCHAR2;
| Parameter | Description |
|---|---|
i |
The level number. |
The title or description of this stored procedure or NULL if the object is not registered.
Ths following example illustrates how to call title:
create or replace procedure sp_html_test(button in varchar2:=null)
is
begin
if (button is null) then
http.sp_html_frame
(
button => NULL
, procname => http.myself.name
, version => http.myself.version
, title => http.myself.title
, center => '*'
) ;
return;
end if;
if (button = 'CENTER') then
http.writeln('Hello World');
return;
end if;
end;
If invoked from Sybercron, this function returns the user that registered this procedure. If not invoked from Sybercron, this function returns USER.
It is safe to replace all references to USER with HTTP.MYSELF.USERNAME in your stored procedures. It is unsafe to reference USER in your stored procedure if that procedure can be invoked through Sybercron and that procedure relies on row level security that you wrote and depends on the user that is invoking this procedure.
Function USERNAME RETURN VARCHAR2;
The following example illustrates how to call USERNAME:
begin
for r in
(
select *
from ps_job
, dataprotects
where dataprotects.deptid = ps_job.deptid
and dataprotects.username = http.myself.username
and dataprotects.procname = http.myself.name(2)
) loop
http.writeln(r.emplid || ' (' || r.hourly_rt || ')');
end loop;
end;
In this example, the table dataprotects contains three columns: procname, username, and deptid. Based on your permissions in this table (what departments you are allowed to see when invoking this procedure), the above select works correctly if invoked online or offline via Sybercron.
This function retrieves the version number of your stored procedure or function. It does this by reading your procedure's source looking for the text "Version:" which must exist within the first 10 lines.
HTTP.MYSELF.VERSION
(
I IN BINARY_INTEGER := 1
)
RETURN VARCHAR2;
| Parameter | Description |
|---|---|
i |
The level number. |
The version of your object or NULL if the version can't be determined.
Ths following example illustrates how to call version:
create or replace procedure sp_html_test(button in varchar2:=null)
is
begin
if (button is null) then
http.sp_html_frame
(
button => NULL
, procname => http.myself.name
, version => http.myself.version
, title => http.myself.title
, center => '*'
) ;
return;
end if;
if (button = 'CENTER') then
http.writeln('Hello World');
return;
end if;
end;