Friday, July 23, 2010

reports questions

Oracle Report Question Bank

1. Summary column:-

A summary column performs a computation on another column's data. Sum, average, count, minimum, maximum, %, first, last,
standard deviation, variance.

2. Formula column:-

A formula column performs a user-defined computation on another column(s) data, including placeholder columns.

Note: Formula Column Should not be used to set value of Parameters.

3. Place Holder Column:-

A placeholder is a column for which you set the data type and value in PL/SQL that you define. You can set the value of a
placeholder column in the following places:

1. The Before Report Trigger, if the placeholder is a report-level column

2. A report-level formula column, if the placeholder is a report-level column

3. A formula in the placeholder's group or a group below it (the value is set once for each record of the group).

4. Types of Trigger:- 1.Report Trigger • Before Parameter Form • After Parameter Form • Before Report • Between
Pages • After Report 2.Validation Trigger 3.Format Trigger

5. Anchor: -

Anchors are used to determine the vertical and horizontal positioning of a child object relative to its parent. The end
of the anchor with a symbol on it is attached to the parent object..

Positioning is based on the size of the objects after the data has been fetched rather than on their size in the editor.
It should also be noted that the position of the object in the Layout editor effects the final position in the report
output.

6. Confine mode:-

To set or override Confine mode: In the Layout Model view, click in the toolbar to toggle the mode:

On: child objects cannot be moved outside their enclosing parent objects. Off: child objects can be moved outside their
enclosing parent objects.

ii)Flex mode:-

To set or override Flex mode:

In the Layout Model view, click in the toolbar to toggle the mode:

On: parent borders "stretch" when child objects are moved against them. Off: parent borders remain fixed when child
objects are moved against them.

7. Bit Map Vs Character:-

MODE specifies whether to run the report in character mode or bitmap. This enables you to run a character-mode report
from bit-mapped Report Builder or vice versa. For example, if you want to send a report to a Postscript printer from a
terminal (e.g., a vt220), you could invoke character-mode RWRUN60 and run the report with MODE=BITMAP. On Windows,
specifying MODE=CHARACTER means that the Report Builder ASCII driver will be used to produce editable ASCII output.

Syntax [MODE=]{BITMAP|CHARACTER|DEFAULT} Values BITMAP DEFAULT means to run the report in the mode of the current
executable being used. CHARACTER Default DEFAULT

8. Types of Report:-

1. Tabular
2. Form-like
3. Mailing Label
4. Form Letter
5. Group Left
6. Group Above
7. Matrix
8. Matrix With Group.

9. Srw.Package:-

To save you time, Report Builder is shipped with a built-in package (SRW), a collection of PL/SQL constructs, which
include many functions, procedures, and exceptions you can reference in any of your libraries or reports.

In addition to the Report Builder built-in package, Procedure Builder provides built-in PL/SQL packages that contain many
PL/SQL constructs you can reference while debugging your program units.


10. Matrix Report: -

A matrix (cross tab) report contains one row of labels, one column of labels, and information in a grid format that is
related to the row and column labels. A distinguishing feature of matrix reports is that the number of columns is not
known until the data is fetched from the database.

To create a matrix report, you need at least four groups: one group must be a cross-product group, two of the groups must
be within the cross-product group to furnish the "labels," and at least one group must provide the information to fill the
cells. The groups can belong to a single query or to multiple queries.

11. Matrix with Report:-

A matrix with group report is a group above report with a separate matrix for each value of the master group.

12. Srw.Do_sql: -

This procedure executes the specified SQL statement from within Report Builder. The SQL statement can be DDL
(statements that define data), or DML (statements that manipulate data). DML statements are usually faster when they
are in PL/SQL, instead of in SRW.DO_SQL.

Since you cannot perform DDL statements in PL/SQL, the SRW.DO_SQL packaged procedure is especially useful for performing
them within Report Builder, instead of via a user exit. For more information on DDL or DML statements, see the ORACLE8
Server SQL Language Reference Manual.

Syntax SRW.DO_SQL (sql_statement CHAR);

Parameters sql_statement Is any valid SQL statement. Remember to precede any Report Builder object names with a
colon (:).

Example:-

/* Suppose you want your report to create a table named CHECK ** just before the Runtime Parameter Form is displayed. **
Because CREATE TABLE is a SQL DDL statement (and PL/SQL ** cannot perform DDL statements), you need to use SRW.DO_SQL. **
Therefore, your PL/SQL could look like this in the Before Form trigger: */ /* Additional Information: If you use a table
created in this way for your ** report output, the table must exist before you create your query in the ** data model.
Otherwise, Report Builder would not be able to parse your query. */

FUNCTION CREATETAB RETURN BOOLEAN IS BEGIN SRW.DO_SQL('CREATE TABLE CHECK (EMPNO NUMBER NOT NULL PRIMARY KEY, SAL NUMBER
(10,2)) PCTFREE 5 PCTUSED 75'); RETURN (TRUE); EXCEPTION WHEN SRW.DO_SQL_FAILURE THEN SRW.MESSAGE(100, 'ERROR WHILE
CREATING CHECK TABLE.'); SRW.MESSAGE (50, 'REPORT WAS STOPPED BEFORE THE RUNTIME PARAMETER FORM.'); RAISE
SRW.PROGRAM_ABORT; END;

/* Suppose you want to create a "table of contents" by getting the ** first character of a column's value, and page number
on which its ** field fires to print. Assume that you want to put the "table of contents" ** into a table named SHIP.
You could write the following construct: */

DECLARE PAGE_NO NUMBER; PAGE_FOR INDEX NUMBER; SORT_CHAR CHAR(1); CMD_LINE CHAR(200); BEGIN SORT_CHAR :=
:SORT_NAME ; IF :CALLED = 'Y' THEN SRW.GET_PAGE_NUM(PAGE_FOR_INDEX); SRW.USER_EXIT('RWECOP PAGE_FOR_INDEX
P_START_PAGENO'); SRW.MESSAGE(2,TO_CHAR(:P_START_PAGENO)); END IF; SRW.GET_PAGE_NUM(PAGE_NO); CMD_LINE := 'INSERT INTO
SHIP VALUES ('''||SORT_CHAR||''','||TO_CHAR(PAGE_NO)||')';

SRW.MESSAGE(2,CMD_LINE); SRW.DO_SQL(CMD_LINE); COMMIT; EXCEPTION WHEN DUP_VAL_ON_INDEX THEN NULL; WHEN
SRW.DO_SQL_FAILURE THEN SRW.MESSAGE(1,'FAILED TO INSERT ROW INTO SHIP TABLE'); WHEN OTHERS THEN COMMIT; END;

13. SRW.SET_MAXROW:-

This procedure sets the maximum number of records to be fetched for the specified query. This is useful when your
report formats (i.e., displays) fewer records than the query (or queries) that fetch them. Thus, with SRW.SET_MAXROW, you
can conditionally restrict data that is fetched for your report, enabling you to improve the report's performance. Syntax
SRW.SET_MAXROW (query_name CHAR, maxnum PLS_INTEGER);

Parameters query_name Is the query whose fetched records will be limited. maxnum Is maximum number of records you
want the query to fetch. Property Palette To define this attribute using the Property Palette, set the Maximum Rows to
Fetch property.

Example

/* Suppose your report has two queries, Q_Stocks and Q_Bonds. ** Suppose also, that you have a user-created parameter,
named ** WHICHDATA, that enables users to specify which data they want ** the report to display: either stocks or bonds.
In the ** Before Report trigger, you could use the SRW.SET_MAXROW ** procedure to ensure that only one query's data is
fetched: */

FUNCTION FETCHIT RETURN BOOLEAN IS BEGIN if :whichdata != 1 then srw.set_maxrow ('Q_Stocks', 0); else srw.set_maxrow
('Q_Bonds', 0); end if; RETURN (TRUE); END;

14. SRW.SET_FIELD_CHAR:-

Description This procedure sets the value of a character field. This is useful when you want to conditionally change a
field's character value.

Syntax SRW.SET_FIELD_CHAR (object_id, text CHAR);

Parameters object_id Is always 0. (The object must always set its own attributes.) text Is the character string
you want the field to display.

Example:- /* Suppose you want to conditionally change the value of a ** Character field, based on each employee's salary.
** In the format trigger for the field, you could type the following: */ FUNCTION CHGFIELD RETURN BOOLEAN IS BEGIN if :sal
>= 2000000 then srw.set_field_char (0, 'HIGH SALARY'); end if; RETURN (TRUE); END;

15. Format Trigger:-

Format triggers are PL/SQL functions executed before the object is formatted. The trigger can be used to dynamically
change the formatting attributes of the object. The function must return a Boolean value (TRUE or FALSE). Depending on
whether the function returns TRUE or FALSE, the current instance of the object is included or excluded from the report
output. You can access format triggers from the Object Navigator, the Property Palette, or the PL/SQL Editor.

On Failure Excludes the current instance of the object from the output.

Usage Notes

1 Format triggers do not affect the data retrieved by the report. For example, if a format trigger returns FALSE
for a field, the data for the field is retrieved even though the field does not appear in the output.

2 If a format trigger suppresses report output on the last page of the report, the last page will still be formatted
and sent to the

Example:-

/* Suppose that you want to create a comma-separated ** list for the names of employees. First, you create ** a field
inside a repeating frame with a Print ** Direction of Across. Next to the field, you create ** a boilerplate text object
that contains a comma ** followed by a space. To ensure that the comma does ** not appear after the last name in the
list, enter the ** following format trigger for the boilerplate object. ** LASTNAME is a summary column with a Source of
ENAME, ** a Function of Last, and Reset At of Report. */

function my_formtrig return BOOLEAN is begin if :ename <> :lastname then return (true); else return (false); end if; end;

16. Validation Trigger:-

Validation triggers are PL/SQL functions that are executed when parameter values are specified on the command line and
when you accept the Runtime Parameter Form. (Notice that this means each validation trigger may fire twice when you
execute the report.) Validation triggers are also used to validate the Initial Value property of the parameter. The
function must return a boolean value (TRUE or FALSE). Depending on whether the function returns TRUE or FALSE, the user
is returned to the Runtime Parameter Form. You can access validation triggers from the Object Navigator, the PL/SQL
Editor, or the Property Palette (Validation Trigger property).

Definition Level parameter On Failure The user is returned to the parameter value in the Runtime Parameter Form where
they can either change it or cancel the Runtime Parameter Form.

Example

/* This function prevents the runtime user from ** sending report output anywhere except a printer. ** The user will be
returned to the Runtime Parameter ** Form unless PRINTER is specified as the destination ** type (DESTYPE). */

function DESTYPEValidTrigger return boolean is begin IF UPPER(:DESTYPE) = 'PRINTER' THEN RETURN(TRUE); ELSE RETURN(FALSE);
END IF; end;

17. Bind Variable:- Description Binds a given value to a named variable in a SQL statement.

Syntax

PROCEDURE EXEC_SQL.Bind_Variable ([Connid IN CONNTYPE], Curs_Id IN CURSTYPE, Name IN VARCHAR2, Value IN
);

where can be one of the following:

NUMBER DATE VARCHAR2

PROCEDURE EXEC_SQL.Bind_Variable ([Connid IN CONNTYPE], Curs_Id IN CURSTYPE, Name IN VARCHAR2,
Value IN VARCHAR2, Out_Value_Size IN PLS_INTEGER);

Parameters

Connid Is the handle to the connection you want to use. If you do not specify a connection, EXEC_SQL.Default_Connection
retrieves the primary Developer connection handle from the cache. Curs_Id Is the cursor handle in which to bind the
variable. Name Is the name of the variable in the SQL statement. Value For IN and IN/OUT variables, the value is the data
you want to bind to the named variable. For OUT variables, the data is actually ignored but you must still use
Bind_Variable to indicate the type of PL/SQL variable to be retrieved later by Variable_Value. Out_Value_Size The
maximum OUT value size in bytes expected for the VARCHAR2 OUT or IN/OUT variables. If no size is specified, the current
length of the Value parameter is used. Usage Notes Use placeholders in SQL statements to mark where input data is to be
supplied during runtime. You must also use placeholders for output values if the statement is a PL/SQL block or a call to
a stored procedure with output parameters. For each input placeholder, you must use EXEC_SQL.Bind_Variable to supply the
value. For each output placeholder, you must also use EXEC_SQL.Bind_Variable to specify the type of variable to use for
retrieving the value in subsequent EXEC_SQL.Variable_Value calls.

The input placeholder or bind variable in a SQL statement is identified by a name beginning with a colon. For example, the
string ':X' is the bind variable in the following SQL statement: SELECT ename FROM emp WHERE SAL > :X; The corresponding
EXEC_SQL.Bind_Variable procedure is: BIND_VARIABLE(connection_handle, cursor_handle, ':X', 3500);

Example:- PROCEDURE getData(input_empno NUMBER) IS connection_id EXEC_SQL.CONNTYPE; cursorID EXEC_SQL.CURSTYPE; sqlstr
VARCHAR2(1000);

...

BEGIN connection_id := EXEC_SQL.OPEN_CONNECTION(connect_str); cursorID := EXEC_SQL.OPEN_CURSOR(connection_id); -- -- the
statement to be parsed contains a bind variable -- sqlstr := 'select ename from emp where empno = :bn'; -- -- perform
parsing -- EXEC_SQL.PARSE(connection_id, cursorID, sqlstr, exec_sql.V7); -- -- the bind_variable procedure assigns the
value of the input argument to the named -- bind variable. Note the use of the semi-colon and the quotes to designate
the -- bind variable. The bind_variable procedure is called after the parse procedure. --
EXEC_SQL.BIND_VARIABLE(connection_id, cursorID, ':bn', input_empno); EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 1,
mynum);

...

END;

18. Differences between Lexical and Bind parameters

Bind references are used to replace a single value in SQL or PL/SQL. Specifically, bind references may be used to replace
expressions in SELECT, WHERE, GROUP BY, ORDER BY, HAVING,CONNECT BY, and START WITH clauses of queries. Binds may not be
referenced in the FROM clause. An example is: SELECT ORDID,TOTAL FROM ORD WHERE CUSTID = :CUST Lexical references are
placeholders for text that you embed in a SELECT statement. You can use lexical references to replace the clauses
appearing after SELECT, FROM, WHERE, GROUP BY , ORDER BY , HAVING, CONNECT BY, and START WITH. You cannot make lexical
references in PL/SQL. Before you reference a lexical parameter in a query you must have predefined the parameter and
given it an initial value. An example is:

SELECT ORDID, TOTAL FROM &ATABLE

19. SRW.SET_FIELD_NUM:-

Description This procedure sets the value of a number field. This is useful when you want to conditionally change a
field's number value. Syntax SRW.SET_FIELD_NUM (object_id, number NUM); Parameters

object_id Is always 0. (The object must always set its own attributes.) number Is the number you want the field
to display.

/* Suppose you want to conditionally change the number of a field, ** based on each employee's salary. In the format
trigger for the ** field, you could type the following: */

Example:-

FUNCTION CHGFIELD RETURN BOOLEAN IS TMP NUMBER; BEGIN if :sal >= 2000 then tmp := :sal * 1.08; srw.set_field_num (0,
tmp); else srw.set_field_num (0, '2500'); end if; RETURN (TRUE); END;

20. SRW.SET FIELD :-

This procedure sets the value of a character, number, or date field. This is useful when you want to conditionally
change a field's value.

Syntax SRW.SET_FIELD (object_id, text CHAR|number NUM|date DATE);

Parameters object_id Is always 0. (The object must always set its own attributes.) text number date Is the character,
number, or date string you want the field to display.

Usage Notes

For date values, you need to convert the second argument to a date value with the TO_DATE function. For example:

srw.set_field(0, to_date('01-JAN-99'));

If you omit quotes around the value, the value is assumed to be a number. For

example:

srw.set_field(0, 99);

Alternatively, you can use the quotes if you also use the TO_NUMBER function. For

example:

srw.set_field(0, to_number('99'));

If you use quotes without a function, the value is assumed to be a character string. Alternatively, you can use
the TO_CHAR function for consistency with number and date values:

srw.set_field(0, to_char('my string'));

21. SRW.SET_FORMAT_MASK:-

It is now more convenient to set this attribute using the SRW.SET_FORMAT_MASK procedure. Setting this attribute via
SRW.SET_ATTR is still supported for compatibility, but it is highly recommended that you use the new, simplified
procedure. Description Is the format mask for the DATE, or NUMBER field.

Syntax: SRW.SET_FORMAT_MASK('mask'); Parameters

Mask : Is a valid format mask. See Date Format Mask Syntax or Number Format Mask Syntax

Property Palette : To define this attribute using the Property Palette, set the Format Mask property.

22. i) Vertical Elasticity:-

The Vertical Elasticity property is how the vertical size of the object may change at runtime to accommodate the
objects or data within it:

1 For frames and repeating frames, elasticity defines whether the size of the frame or repeating frame should vary
with the objects inside of it.

2 For objects containing text, elasticity defines whether the field or boilerplate should vary with the size of the
text. Fixed size text will wrap within the defined size of the object and may be truncated if there is not enough room.
Number or date data will appear as asterisks if the data cannot fit within the defined size.

3 For images, drawings, and chart objects, Report Builder uses proportional scaling. The elasticity options for
images, drawings, and chart objects determine the scaling factor.

Values

Contract Means the vertical size of the object decreases, if the formatted objects or data within it are short
enough, but it cannot increase to a height greater than that shown in the Report Editor. Truncation of data may occur;
look at the examples. (You can think of this option as meaning "only contract, do not expand.")

Expand Means the vertical size of the object increases, if the formatted objects or data within it are tall enough, but
it cannot decrease to a height less than that shown in the Report Editor. (You can think of this option as meaning "only
expand, do not contract.") Fixed Means the height of the object is the same on each logical page, regardless of the
size of the objects or data within it. Truncation of data may occur; look at the examples. The height of the object is
defined to be its height in the . Variable Means the object may expand or contract vertically to accommodate the
objects or data within it (with no extra space), which means the height shown in the Report Editor has no effect on the
object's height at runtime.

If you create a chart object in your report with a Vertical and Horizontal Elasticity of Fixed, Report Builder
scales the Graphics Builder display to fit within the dimensions you defined for the object.

ii) Horizontal Elasticity:-

Description The Horizontal Elasticity property is how the horizontal size of the object will change at runtime to
accommodate the objects or data within it:

1 For frames and repeating frames, elasticity defines whether the size of the frame or repeating frame should vary
with the objects inside of it.

2 For objects containing text, elasticity defines whether the field or boilerplate should vary with the size of the
text. Fixed size text will wrap within the defined size of the object and may be truncated if there is not enough room.
Number or date data will appear as asterisks if the data cannot fit within the defined size.

3 For images, drawings, and chart objects, Report Builder uses proportional scaling. The elasticity options for
images, drawings, and chart objects determine the scaling factor.

Values

Contract Means the horizontal size of the object decreases, if the formatted objects or data within it are wide
enough, but it cannot increase to a width greater than that shown in the Report Editor. Truncation of data may occur; look
at the examples. (You can think of this option as meaning "only contract, do not expand.")

Expand Means the horizontal size of the object increases, if the formatted objects or data within it are wide enough, but
it cannot decrease to a width less than that shown in the Report Editor. (You can think of this option as meaning "only
expand, do not contract.")

Fixed Means the width of the object is the same on each logical page, regardless of the size of the objects or data
within it. Truncation of data may occur; look at the examples. The width of the object is defined to be its width in the
Report Editor.

Variable Means the object may expand or contract horizontally to accommodate the objects or data within it (with no
extra space), which means the width shown in the Report Editor has no effect on the object's width at runtime.

If you create a Graphics object in your report with a Vertical and Horizontal Elasticity of Fixed, Report Builder
scales the display to fit within the dimensions you defined for the object.

23. System Parameters:-

BACKGROUND Is whether the report should run in the foreground or the background.

COPIES Is the number of report copies that should be made when the report is printed.

CURRENCY Is the symbol for the currency indicator (e.g., "$").

DECIMAL Is the symbol for the decimal indicator (e.g., ".").

DESFORMAT Is the definition of the output device's format (e.g., landscape mode for a printer). This parameter is
used when running a report in a character-mode environment, and when sending a bitmap report to a file (e.g. to create PDF
or HTML output).

DESNAME Is the name of the output device (e.g., the file name, printer's name, mail userid).

DESTYPE Is the type of device to which to send the report output (screen, file, mail, printer, or screen using PostScript
format).

MODE Is whether the report should run in character mode or bitmap.

ORIENTATION Is the print direction for the report (landscape, portrait, default).

PRINTJOB Is whether the Print Job dialog box should appear before the report is run.

THOUSANDS Is the symbol for the thousand's indicator (e.g., ",").

------------------------------------------------------------------------------------------------------

---: Oracle Report Questions End :---

Thursday, July 22, 2010

calling reports from oracle forms

DECLARE
report_id REPORT_OBJECT;
param_list ParamList;
param_name VARCHAR2(50):= 'rpt_data';
JOB_NUMBER NUMBER;
BEGIN
report_id := find_report_object('EMP');

SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_EXECUTION_MODE, RUNTIME);
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_COMM_MODE, ASYNCHRONOUS);
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESTYPE, cache);
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESFORMAT,'PDF');
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_SERVER,'192.168.0.20');
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_FILENAME, 'C:\New\'||'EMP');


--FIND_REPORT_OBJECT('EMP');
param_list := Get_Parameter_List(param_name);
IF NOT Id_Null(param_list) THEN
Destroy_Parameter_List(param_list);
END IF;

param_list := Create_Parameter_List(param_name);
--Add_Parameter(param_list,'BU',TEXT_PARAMETER,:GLOBAL.bu);
--Add_Parameter(param_list,'P_USER',TEXT_PARAMETER,:GLOBAL.bu$user);
--Add_Parameter(param_list,'P_LANG',TEXT_PARAMETER,:GLOBAL.lang);

:EMP.ctrl:=RUN_REPORT_OBJECT(report_id,param_list);
--MESSAGE(:EMP.ctrl);
--MESSAGE(' ');
JOB_NUMBER := length('192.168.0.20') + 2;
-- MESSAGE(JOB_NUMBER);
--MESSAGE(' ');
Web.Show_Document('/reports/rwservlet/getjobid=' ||substr (:EMP.ctrl,JOB_NUMBER)||'?server='||'192.168.0.20','_blank');
END;



/*
go to command prompt and set this path
\DevSuiteHome_1\BIN>rwserver server=192.168.0.20(local id address)
go to folder \DevSuiteHome_1\reports\config\192.168.0.20.config and change maxCacheFileNumber to 5000
*/

oracle forms questions

How do you pass the parameters from one form to another form?
To pass one or more parameters to a called form, the calling form must perform the following steps in a trigger or user named routine execute the create_parameter_list built-in function to programmatically. Create a parameter list to execute the add parameter built-in procedure to add one or more parameters list. Execute the call_form, New_form or run_product built_in procedure and include the name or id of the parameter list to be passed to the called form.

What is a Layout Editor?
The Layout Editor is a graphical design facility for creating and arranging items and boilerplate text and graphics objects in your application's interface.

List the Types of Items?
Text item.
Chart item.
Check box.
Display item.
Image item.
List item.
Radio Group.
User Area item.

List system variables available in forms 4.0, and not available in forms 3.0?
System.cordination_operation
System Date_threshold
System.effective_Date
System.event_window
System.suppress_working

What are the display styles of an alert?
Stop, Caution, note

What built-in is used for showing the alert during run-time?
Show_alert.

What built-in is used for changing the properties of the window dynamically?
Set_window_property
Canvas-View

What are the different types of windows?
Root window, secondary window.

What is a predefined exception available in forms 4.0?
Raise form_trigger_failure

What is a radio Group?
Radio groups display a fixed no of options that are mutually Exclusive. User can select one out of n number of options.

What are the different type of a record group?
Query record group
Static record group
Non query record group

What are the menu items that oracle forms 4.0 supports?
Plain, Check,Radio, Separator, Magic

Give the equivalent term in forms 4.0 for the following. Page, Page 0?
Page - Canvas-View
Page 0 - Canvas-view null.

What triggers are associated with the radio group?
Only when-radio-changed trigger associated with radio group
Visual Attributes.

What are the triggers associated with a check box?
Only When-checkbox-activated Trigger associated with a Check box.

Can you attach an alert to a field?
No

Can a root window be made modal?
No

What is a list item?
It is a list of text elements.

List some built-in routines used to manipulate images in image_item?
Image_add
Image_and
Image_subtract
Image_xor
Image_zoom

Can you change the alert messages at run-time?
If yes, give the name of the built-in to change the alert messages at run-time. Yes. Set_alert_property.

What is the built-in used to get and set lov properties during run-time?
Get_lov_property
Set_lov_property
Record Group

What is the built-in routine used to count the no of rows in a group?
Get_group _row_count
System Variables

Give the Types of modules in a form?
Form
Menu
Library

Write the Abbreviation for the following File Extension 1. FMB 2. MMB 3. PLL?
FMB ----- Form Module Binary.
MMB ----- Menu Module Binary.
PLL ------ PL/SQL Library Module Binary.

List the built-in routine for controlling window during run-time?
Find_window,
get_window_property,
hide_window,
move_window,
resize_window,
set_window_property,
show_View

List the built-in routine for controlling window during run-time?
Find_canvas
Get-Canvas_property
Get_view_property
Hide_View
Replace_content_view
Scroll_view
Set_canvas_property
Set_view_property
Show_view
Alert

What is the built-in function used for finding the alert?
Find_alert
Editors

List the editors availables in forms 4.0?
Default editor
User_defined editors
system editors.

What buil-in routines are used to display editor dynamically?
Edit_text item
show_editor
LOV



What is an Lov?
A list of values is a single or multi column selection list displayed in a pop-up window

What is a record Group?
A record group is an internal oracle forms data structure that has a similar column/row frame work to a database table

Give built-in routine related to a record groups?
Create_group (Function)
Create_group_from_query(Function)
Delete_group(Procedure)
Add_group_column(Function)
Add_group_row(Procedure)
Delete_group_row(Procedure)
Populate_group(Function)
Populate_group_with_query(Function)
Set_group_Char_cell(procedure)

List the built-in routines for the controlling canvas views during run-time?
Find_canvas
Get-Canvas_property
Get_view_property
Hide_View
Replace_content_view
Scroll_view
Set_canvas_property
Set_view_property
Show_view
Alert

System.effective_date system variable is read only True/False?
False

What are the built_in used to trapping errors in forms 4?
Error_type return character
Error_code return number
Error_text return char
Dbms_error_code return no.
Dbms_error_text return char

What is Oracle Financials? (for DBA)
Oracle Financials products provide organizations with solutions to a wide range of long- and short-term accounting system issues. Regardless of the size of the business, Oracle Financials can meet accounting management demands with:
Oracle Assets: Ensures that an organization's property and equipment investment is accurate and that the correct asset tax accounting strategies are chosen.
Oracle General Ledger: Offers a complete solution to journal entry, budgeting, allocations, consolidation, and financial reporting needs.
Oracle Inventory: Helps an organization make better inventory decisions by minimizing stock and maximizing cash flow.
Oracle Order Entry: Provides organizations with a sophisticated order entry system for managing customer commitments.
Oracle Payables: Lets an organization process more invoices with fewer staff members and tighter controls. Helps save money through maximum discounts, bank float, and prevention of duplicate payment.
Oracle Personnel: Improves the management of employee- related issues by retaining and making available every form of personnel data.
Oracle Purchasing: Improves buying power, helps negotiate bigger discounts, eliminates paper flow, increases financial controls, and increases productivity.
Oracle Receivables:. Improves cash flow by letting an organization process more payments faster, without off-line research. Helps correctly account for cash, reduce outstanding receivables, and improve collection effectiveness.
Oracle Revenue Accounting Gives an organization timely and accurate revenue and flexible commissions reporting.
Oracle Sales Analysis: Allows for better forecasting, planning. and reporting of sales information.

What are the design facilities available in forms 4.0?
Default Block facility.
Layout Editor.
Menu Editor.
Object Lists.
Property Sheets.
PL/SQL Editor.
Tables Columns Browser.
Built-ins Browser.

What is the most important module in Oracle Financials? (for DBA)
The General Ledger (GL) module is the basis for all other Oracle Financial modules. All other modules provide information to it. If you implement Oracle Financials, you should switch your current GL system first.GL is relatively easy to implement. You should go live with it first to give your implementation team a chance to be familiar with Oracle Financials.

What are the types of canvas-views?
Content View, Stacked View.

What is the MultiOrg and what is it used for? (for DBA)
MultiOrg or Multiple Organizations Architecture allows multiple operating units and their relationships to be defined within a single installation of Oracle Applications. This keeps each operating unit's transaction data separate and secure.
Use the following query to determine if MuliOrg is intalled:
select multi_org_flag from fnd_product_groups;

What is the difference between Fields and FlexFields? (for DBA)
A field is a position on a form that one uses to enter, view, update, or delete information. A field prompt describes each field by telling what kind of information appears in the field, or alternatively, what kind of information should be entered in the field.
A flexfield is an Oracle Applications field made up of segments. Each segment has an assigned name and a set of valid values. Oracle Applications uses flexfields to capture information about your organization. There are two types of flexfields: key flexfields and descriptive flexfields.

Explain types of Block in forms4.0?
Base table Blocks.
Control Blocks.
1. A base table block is one that is associated with a specific database table or view.
2. A control block is a block that is not associated with a database table. ITEMS

What is an Alert?
An alert is a modal window that displays a message notifies the operator of some application condition

What are the built-in routines is available in forms 4.0 to create and manipulate a parameter list?
Add_parameter
Create_Parameter_list
Delete_parameter
Destroy_parameter_list
Get_parameter_attr
Get_parameter_list
set_parameter_attr

What is a record Group?
A record group is an internal oracle forms data structure that has a similar column/row frame work to a database table

What is a Navigable item?
A navigable item is one that operators can navigate to with the keyboard during default navigation, or that Oracle forms can navigate to by executing a navigational built-in procedure.

What is a library in Forms 4.0?
A library is a collection of Pl/SQL program units, including user named procedures, functions & packages

How image_items can be populate to field in forms 4.0?
A fetch from a long raw database column PL/Sql assignment to executing the read_image_file built_in procedure to get an image from the file system.

What is the content view and stacked view?
A content view is the "Base" view that occupies the entire content pane of the window in which it is displayed. A stacked view differs from a content canvas view in that it is not the base view for the window to which it is assigned

Friday, July 16, 2010

tunning in sql advance

Also remember that there can be a disconnect between efficient SQL and comprehensible SQL. Always document your code.

* One: only "tune" SQL after code is confirmed as working correctly.

* Two: ensure repeated SQL statements are written absolutely identically to facilate efficient reuse: re-parsing can often be avoided for each subsequent use.

Writing best practices: all SQL verbs in upper-case i.e. SELECT; separate all words with a single space; all SQL verbs begin on a new line; SQL verbs aligned right or left within the initial verb; set and maintain a table alias standard; use table aliases and when a query involves more than one table prefix all column names with their aliases. Whatever you do, be consistent.

* Three: code the query as simply as possible i.e. no unnecessary columns are selected, no unnecessary GROUP BY or ORDER BY.

* Four: it is the same or faster to SELECT by actual column name(s). The larger the table the more likely the savings.
Use:
SELECT customer_id, last_name, first_name, street, city FROM customer; Rather than:
SELECT * FROM customer;

* Five: do not perform operations on DB objects referenced in the WHERE clause:
Use:
SELECT client, date, amount FROM sales WHERE amount > 0;
Rather than:
SELECT client, date, amount FROM sales WHERE amount!= 0;

* Six: avoid a HAVING clause in SELECT statements - it only filters selected rows after all the rows have been returned. Use HAVING only when summary operations applied to columns will be restricted by the clause. A WHERE clause may be more efficient.
Use:
SELECT city FROM country WHERE city!= 'Vancouver' AND city!= 'Toronto'; GROUP BY city;
Rather than:
SELECT city FROM country GROUP BY city HAVING city!= 'Vancouver' AND city!= 'Toronto';

* Seven: when writing a sub-query (a SELECT statement within the WHERE or HAVING clause of another SQL statement):
-- use a correlated (refers to at least one value from the outer query) sub-query when the return is relatively small and/or other criteria are efficient i.e. if the tables within the sub-query have efficient indexes.
-- use a noncorrelated (does not refer to the outer query) sub-query when dealing with large tables from which you expect a large return (many rows) and/or if the tables within the sub-query do not have efficient indexes.
-- ensure that multiple sub-queries are in the most efficient order.
-- remember that rewriting a sub-query as a join can sometimes increase efficiency.

* Eight: minimise the number of table lookups especially if there are sub-query SELECTs or multicolumn UPDATEs.

* Nine: when doing multiple table joins consider the benefits/costs for each of EXISTS, IN, and table joins. Depending on your data one or another may be faster.
Note: IN is usually the slowest.
Note: when most of the filter criteria are in the sub-query IN may be more efficient; when most of the filter criteria are in the parent-query EXISTS may be more efficient.

* Ten: where possible use EXISTS rather than DISTINCT.

* Eleven: where possible use a non-column expression (putting the column on one side of the operator and all the other values on the other). Non-column expressions are often processed earlier thereby speeding the query.
Use:
WHERE SALES <>
Rather than:
WHERE SALES + (n * SALES) <>

Twelve: the most efficient method for storing large binary objects, i.e. multimedia objects, is to place them in the file system and place a pointer in the DB.


Special cases

-----------------

Rewrite complex subqueries with temporary tables - Oracle created the global temporary table (GTT) and the SQL WITH operator to help divide-and-conquer complex SQL sub-queries (especially those with with WHERE clause subqueries, SELECT clause scalar subqueries and FROM clause in-line views). Tuning SQL with temporary tables (and materializations in the WITH clause) can result in amazing performance improvements.
Use minus instead of EXISTS subqueries - Some say that using the minus operator instead of NOT IN and NOT Exists will result in a faster execution plan.
Use SQL analytic functions - The Oracle analytic functions can do multiple aggregations (e.g. rollup by cube) with a single pass through the tables, making them very fast for reporting SQL.
Re-write NOT EXISTS and NOT EXISTS subqueries as outer joins - In many cases of NOT queries (but ONLY where a column is defined as NULL), you can re-write the uncorrelated subqueries into outer joins with IS NULL tests. Note that this is a non-correlated sub-query, but it could be re-written as an outer join.

select book_key from book
where
book_key NOT IN (select book_key from sales);

Below we combine the outer join with a NULL test in the WHERE clause without using a sub-query, giving a faster execution plan.

select b.book_key from book b, sales s
where
b.book_key = s.book_key(+)
and
s.book_key IS NULL;
Index your NULL values - If you have SQL that frequently tests for NULL, consider creating an index on NULL values. To get around the optimization of SQL queries that choose NULL column values (i.e. where emp_name IS NULL), we can create a function-based index using the null value built-in SQL function to index only on the NULL columns.
Leave column names alone - Never do a calculation on an indexed column unless you have a matching function-based index (a.k.a. FBI). Better yet, re-design the schema so that common where clause predicates do not need transformation with a BIF:

where salary*5 > :myvalue
where substr(ssn,7,4) = "1234"
where to_char(mydate,mon) = "january"
Avoid the use of NOT IN or HAVING. Instead, a NOT EXISTS subquery may run faster (when appropriate).
Avoid the LIKE predicate = Always replace a "like" with an equality, when appropriate.
Never mix data types - If a WHERE clause column predicate is numeric, do not to use quotes. For char index columns, always use quotes. There are mixed data type predicates:

where cust_nbr = "123"
where substr(ssn,7,4) = 1234
Use decode and case - Performing complex aggregations with the “decode” or "case" functions can minimize the number of times a table has to be selected.
Don't fear full-table scans - Not all OLTP queries are optimal when they uses indexes. If your query will return a large percentage of the table rows, a full-table scan may be faster than an index scan. This depends on many factors, including your configuration (values for db_file_multiblock_read_count, db_block_size), query parallelism and the number of table/index blocks in the buffer cache.
Use those aliases - Always use table aliases when referencing columns.



sorry for delay

SQL Constructs Ability to understand and implement Data Types, Basic
SQLSELECT Statements, Restricting and Sorting Data, Single-Row Functions,
Joins, Aggregate and Group Functions, Sub-Queries, Creating & Managing DB
Objects,Manipulating Data (DML), Constraints, Views SQL Query Tuning

Saturday, July 10, 2010

the collect function in 10g

Oracle 10g has introduced an extremely useful new group function, COLLECT. This function enables us to aggregate data into a collection, retaining multiple records of data within a single row (like a nested table). One of the main benefits of this function is that it makes "string aggregation" (one of the web's most-requested Oracle technique) very simple
SQL> SELECT deptno   2  ,      COLLECT(ename) AS emps   3  FROM   emp   4  GROUP  BY   5         deptno;  
    DEPTNO EMPS ---------- ------------------------------------------------------------------------------------         10 SYSTPXeCjDqbWSqWrshgYrRPR4Q==('CLARK', 'KING')         20 SYSTPXeCjDqbWSqWrshgYrRPR4Q==('SMITH', 'JONES', 'SCOTT', 'ADAMS', 'FORD')         30 SYSTPXeCjDqbWSqWrshgYrRPR4Q==('ALLEN', 'WARD', 'MARTIN', 'BLAKE', 'TURNER', 'JAMES')         40 SYSTPXeCjDqbWSqWrshgYrRPR4Q==('MILLER')  4 rows selected.

10g regular expression

regular expressions in 10g

This article briefly introduces Oracle’s support for regular expressions in 10g, considered by many developers to be long overdue. The new functions (available in both SQL and PL/SQL) are:

  • REGEXP_LIKE
  • REGEXP_INSTR
  • REGEXP_SUBSTR
  • REGEXP_REPLACE

Each of these functions are covered below. This article assumes that the reader has some knowledge of regular expressions and pattern matching. For further details, see the SQL Reference in the online Oracle documentation.

setup

To demonstrate regular expressions we’ll use a small set of arbitrary test data, created as follows.

SQL> CREATE TABLE t (x VARCHAR2(30));  
Table created.  
SQL> INSERT ALL   2     INTO t VALUES ('XYZ123')   3     INTO t VALUES ('XYZ 123')   4     INTO t VALUES ('xyz 123')   5     INTO t VALUES ('X1Y2Z3')   6     INTO t VALUES ('123123')   7     INTO t VALUES ('?/*.')   8     INTO t VALUES ('\?.')   9  SELECT * FROM dual;  
7 rows created.  
SQL> SELECT * FROM t;  
X ------------ XYZ123 XYZ 123 xyz 123 X1Y2Z3 123123 ?/*. \?.  7 rows selected. 

regexp_like

First we’ll look at REGEXP_LIKE and use this to introduce the basic means of specifying regular expressions. This function returns TRUE when it matches patterns using standard (or POSIX) notation. The pattern to match is passed as the second parameter to the function and is represented as a string using a combination of literal or meta characters. These can be quite sophisticated and flexible and it is worth reading the documentation for a full list of meta-characters, POSIX classes and references.

First we’ll look for data with a lower-case letter followed by a space and a number using standard pattern notation.

SQL> SELECT * FROM t WHERE REGEXP_LIKE(x, '[a-z] [0-9]');  
X ------------------------------ xyz 123 

Next we look for data with a lower-case letter followed by any single character (represented by the “.”) then a number.

SQL> SELECT * FROM t WHERE REGEXP_LIKE(x, '[a-z].[0-9]');  
X ------------------------------ xyz 123 

The question mark character in the following expression represents either zero or one occurrence of the previous pattern (in this example a lower-case letter). Hence this regular expression matches a wider range of records.

SQL> SELECT * FROM t WHERE REGEXP_LIKE(x, '[a-z]?[0-9]');  
X ------------------------------ XYZ123 XYZ 123 xyz 123 X1Y2Z3 123123 

The “*” wildcard represents zero or more occurrences of the preceding expression, so it could be argued that the following pattern is simply looking for any data containing at least one number (zero or more lower-case characters followed by a digit).

SQL> SELECT * FROM t WHERE REGEXP_LIKE(x, '[a-z]*[0-9]');  
X ------------------------------ XYZ123 XYZ 123 xyz 123 X1Y2Z3 123123 

To search for a specific number of occurrences of an expression, it is followed by the number of occurrences in braces. The following expression is searching for data with three consecutive capital letters.

SQL> SELECT * FROM t WHERE REGEXP_LIKE(x, '[A-Z]{3}');  
X ------------------------------ XYZ123 XYZ 123 

This time we search for a capital letter followed by three numbers (note that to search for at least three digits, the number of occurrences would be followed by a comma, i.e. {3,}).

SQL> SELECT * FROM t WHERE REGEXP_LIKE(x, '([A-Z][0-9]){3}');  
X ------------------------------ X1Y2Z3 

The following expression is one way of searching for all-numeric data. The caret (^) and dollar ($) denote start and end of line, respectively. The plus (+) after the digit class represents one or more occurrences.

SQL> SELECT * FROM t WHERE REGEXP_LIKE(x, '^[0-9]+$');  
X ------------------------------ 123123 

We might sometimes need to match meta-characters, meaning that these must be “escaped”. For example, we’ve seen above that the question mark (?) is a special character meaning zero or one of the preceding pattern in the expression. To search explicitly for data containing this character, we must escape it using a backslash (\).

SQL> SELECT * FROM t WHERE REGEXP_LIKE(x, '\?');  
X ------------------------------ ?/*. \?. 

To specify “not” in a regular expression, a caret (^) is used within the brackets to exclude the referenced characters. Note that outside of these brackets the caret denotes start of line. The following example searches for data that is not all digits, which in our dataset is all but one record. Note that this is not the same as searching for data without any digits at all (that would require a NOT REGEXP_LIKE() or a REGEXP_INSTR() = 0 expression).

SQL> SELECT * FROM t WHERE REGEXP_LIKE(x, '[^0-9]+');  
X ------------ XYZ123 XYZ 123 xyz 123 X1Y2Z3 ?/*. \?.  6 rows selected. 

Finally, we can also specify “either-or” using a pipe (|) meta-character. The following searches for all data containing either an ‘X’ or a ‘1’.

SQL> SELECT * FROM t WHERE REGEXP_LIKE(x, 'X|1');  
X ------------ XYZ123 XYZ 123 xyz 123 X1Y2Z3 123123  5 rows selected. 

regexp_instr

REGEXP_INSTR returns the position of a string that matches a given pattern. As with the INSTR function, we can specify a starting point within the string (default 1) and the nth occurrence to search for. There are additional parameters to REGEXP_INSTR that we shall briefly cover below. First, we’ll search for the position of a literal question mark in our test data.

SQL> SELECT x   2  ,      REGEXP_INSTR(x, '\?') AS "POSITION_OF_?"   3  FROM   t;  
X                              POSITION_OF_? ------------------------------ ------------- XYZ123                                     0 XYZ 123                                    0 xyz 123                                    0 X1Y2Z3                                     0 123123                                     0 ?/*.                                       1 \?.                                        2  7 rows selected. 

As mentioned above, REGEXP_INSTR has additional (optional) parameters over and above those we use for standard INSTR-type operations. These additional parameters allow for offset and matching. Offset enables us to specify whether we want the position of the start of the expression match (0) or the position immediately after the end of the regex match (1). A match parameter enables us to request case sensitivity using flags (e.g. 'i' for ignore or 'c' for case sensitivity. Default is whatever is specified in NLS_SORT). The following demonstrates three variations while searching for three capital letters in our test data.

SQL> SELECT x   2         --<>--   3  ,      REGEXP_INSTR(   4            x,   5            '[A-Z]{3}', --expression   6            1,          --start at   7            1,          --nth occurrence   8            0           --offset position   9            ) AS regexp_offset_0  10         --<>--  11  ,      REGEXP_INSTR(  12            x,  13            '[A-Z]{3}',  14            1,  15            1,  16            1  17            ) AS regexp_offset_1  18         --<>--  19  ,      REGEXP_INSTR(  20            x,  21            '[A-Z]{3}',  22            1,  23            1,  24            0,  25            'i'        --match parameter  26            ) AS regexp_case_insensitive  27         --<>--  28  FROM   t;  
X            REGEXP_OFFSET_0 REGEXP_OFFSET_1 REGEXP_CASE_INSENSITIVE ------------ --------------- --------------- ----------------------- XYZ123                     1               4                       1 XYZ 123                    1               4                       1 xyz 123                    0               0                       1 X1Y2Z3                     0               0                       0 123123                     0               0                       0 ?/*.                       0               0                       0 \?.                        0               0                       0  7 rows selected. 

regexp_substr

REGEXP_SUBSTR is incredibly useful. It returns the part of the string that matches the pattern only. It follows the same convention as REGEXP_INSTR with respect to starting position, nth occurrence and match-parameter arguments. However, it doesn't work like the standard SUBSTR, for which you specify the length of string to return.

For a very simple demonstration of REGEXP_SUBSTR, we’ll look at the default behaviour when searching for a string of one or more digits. We’ll also try to strip a second occurrence of the same pattern by using the relevant parameter. Incidentally, I’ve deliberately introduced an alternative means of expressing “digits-only” by using the POSIX character class (there are quite a few of these classes described in the online documentation).

SQL> set null {null}  SQL> SELECT x   2         --<>--   3  ,      REGEXP_SUBSTR(   4            x,   5            '[[:digit:]]+' --note POSIX char-class   6            ) AS first_occurrence   7         --<>--   8  ,      REGEXP_SUBSTR(   9            x,  10            '[[:digit:]]+',  11            1,  12            2  13            ) AS second_occurrence  14  FROM   t;  
X            FIRST_OCCURRENCE     SECOND_OCCURRENCE ------------ -------------------- -------------------- XYZ123       123                  {null} XYZ 123      123                  {null} xyz 123      123                  {null} X1Y2Z3       1                    2 123123       123123               {null} ?/*.         {null}               {null} \?.          {null}               {null}  7 rows selected. 

regexp_replace

Finally, we’ll take a brief look at REGEXP_REPLACE. As its name suggests, this function searches for a specified number of occurrences (default all) of a pattern and replaces it with a given string or NULL. As with REGEXP_INSTR and REGEXP_SUBSTR, we can supply starting position, nth occurrence and a match-parameter. In the following simple example, we’ll replace all digits with a hyphen (-).

SQL> SELECT x   2  ,      REGEXP_REPLACE(x, '[[:digit:]]', '-') AS nums_to_hyphens   3  FROM   t;  
X            NUMS_TO_HYPHENS ------------ -------------------- XYZ123       XYZ--- XYZ 123      XYZ --- xyz 123      xyz --- X1Y2Z3       X-Y-Z- 123123       ------ ?/*.         ?/*. \?.          \?.  7 rows selected. 

What if we need to replace a given pattern with the pattern itself plus some additional data? REGEXP_REPLACE enables us to back-reference the regular expression (up to 500 expressions in fact) and include it in our replacement. The following example shows how we can replace all digits with the digits themselves followed by an asterisk. We enclose the regular expression in parentheses and reference it in the replacement string using \n (in our case \1 as we only have one preceding expression).

SQL> SELECT x   2  ,      REGEXP_REPLACE(   3            x,   4            '([0-9])', --note the parentheses   5            '\1*'      --\1 means include 1st pattern   6            ) AS search_pattern_included   7  FROM   t;  
X            SEARCH_PATTERN_INCLUDED ------------ ----------------------------------- XYZ123       XYZ1*2*3* XYZ 123      XYZ 1*2*3* xyz 123      xyz 1*2*3* X1Y2Z3       X1*Y2*Z3* 123123       1*2*3*1*2*3* ?/*.         ?/*. \?.          \?.  7 rows selected.