SRW Package:
The report execution can be controlled
Display messages at run time
Layout field can be initialized
Formatting can be done
Make the user to exit report
DDL statements can be performed
Displaying messages:
The SRW.MESSAGE procedure displays the message. It also displays the code and text that the user has specified.
The message text is displayed in a small dialog box in the following syntax.
Msg-code: Text
Code: digits from 0 – 10
Text: Max 190 characters
Warning or Error Messages:
SRW.MESSAGE will not terminate the user from continuing. So this can be used for displaying warning messages.
SRW.PROGRAM_ABORT will terminate the program after displaying the message
RAISE SRW.PROGRAM_ABORT;
Running nested reports:
For running one report from another report the user has to use SRW.RUN_REPORT
Go to layout editor, create a button and label it as ‘Click this button’
Open the property palette of the button and set the Button Behaviour: Type=pl/sql: Pl/sql Trigger= provide the code
procedure U_ButtonButtonAction is
begin
srw.run_report('module=C:\Documents and Settings\Administrator\Desktop\POXDETIT.rdf destype=Screen');
end;
Restricting data:
the srw.set_maxrow procedure sets the max number of records that can be retrieved for a specific query.
In the BEFORE REPORT trigger, you could use the srw.set_maxrow procedure to ensure that only the required num of records are fetched.
begin
if :p_dname = 'RESEARCH' then
srw.set_maxrow ('Q_2', 2);
end if;
end;
Using DDLs in Reports:
If the user has to execute any SQL Statement from the report builder then the srw.do_sql procedure is to be used. With the help of SRW.DO_SQL the user can add any DDL or DML operation to the report.
DML are faster in pl/sql, instead in DO_SQL. Since DDLs can not be performed in pl/sql we make use DO_SQL in report builder.
Srw.do_sql (sqlstatement char);
Setting Format Attributes:
Use the SRW.SET_<attributes> procedure to set the format attributes. Mainly used to make some change in the appearance of the layout objects.
Format attributes | Value |
Text Color | Red |
Font Face | Impact |
Font Weight | Bold |
Font Style | Italic |
Font Pattern | Solid diamond |
Function age_mask return Boolean is
Begin
If :age < 25 then
Srw.set_text_color(‘Red’);
Srw.set_font_face(‘Impact’) ;
Srw.set_font_weight(‘’srw.bold_weight) ;
Srw.set_font_style(‘srw.italic_style’);
Srw.set_fill_pattern(‘solid diamond’);
End if;
End;