Professional Documents
Culture Documents
DECLARE FH UTL_FILE.FILE_TYPE; LN VARCHAR2(300); V_NAME VARCHAR2(30); V_JOB VARCHAR2(30); V_SAL NUMBER(7,2); POS1 NUMBER(2); POS2 NUMBER(2); BEGIN FH :=UTL_FILE.FOPEN ( 'D:\ORACLE\VISDB\8.1.6\PLSQL\TEMP', 'A.LST', 'R'); LOOP UTL_FILE.GET_LINE(FH, LN); POS1 := INSTR(LN,',',1,1); POS2 := INSTR(LN,',',1,2); V_NAME := SUBSTR(LN,1,POS1-1); V_JOB := SUBSTR(LN,POS1+1,POS2 - POS1 -1); V_SAL := RTRIM(SUBSTR(LN,POS2+1)); INSERT INTO UTLX VALUES (V_NAME, V_JOB, V_SAL); -- DBMS_OUTPUT.PUT_LINE(V_NAME||' '||V_JOB||' '||V_SAL); END LOOP; EXCEPTION WHEN NO_DATA_FOUND THEN UTL_FILE.FCLOSE(FH); COMMIT; WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(SQLERRM(SQLCODE)); END; /
SUM Monthly total orders shipped AVG Average shipping delay by month MAX Maximum shipping delay by month Also, create the appropriate validation triggers for the individual parameters. Next, create a placeholder column at the report level called SELECTION_DATA. Set this field as a character field with a width of 100 characters and assign a default value of h.hist_ord_shipped. Next, create a before report trigger as follows: function Before_Report_Trigger return boolean is begin if :P_REPORT_TYPE = `SUM' then :SELECTION_CRITERIA := `h.hist_ord_shipped'; elsif :P_REPORT_TYPE = `AVG' then :SELECTION_CRITERIA := `h.hist_ship_days / h.hist_ord_shipped'; else :SELECTION_CRITERIA := `h.hist_max_days'; end if; end; Finally, modify the query: select w.wh_name WAREHOUSE, h.hist_month_no MONTHNO, to_char (to_date (to_char (h.hist_month_no), `MM'),'MON') RPT_MONTH, &SELECTION_CRITERIA from warehouses w, warehouse_history h where w.wh_code = h.hist_wh_code and h.hist_year = :P_year h.hist_month_no MONTHNO, to_char (to_date (to_char (h.hist_month_no), `MM'),'MON') RPT_MONTH, &SELECTION_CRITERIA from warehouses w, warehouse_history h where w.wh_code = h.hist_wh_code and h.hist_year = :P_year You reference the lexical parameter in the query using an ampersand (&) before the parameter name. Lexical parameters within a query substitute the text stored in the parameter directly into the query. For this reason, when using a lexical parameter, you must enter a default value for NULL values to assist with compilation in the designer.
When adding an additional break level to an existing report, 90 percent of the time it is faster to redo the default layout. Adding another intermediate level frame is one of the most difficult tasks to be done. It can be done but is often not worth the effort. Rather than try to resize or reposition objects in the Layout Editor, use the Size Objects and Align Objects tools. You can select several columns at once, quickly make them all the same custom size, and then align and space them with minimal effort. To lock the relative position of multiple objects, select them and create a group to join them together. Use the Magnify tool to zoom in to view the relative positions of the objects or to zoom out to view the total report structure. When you make a mistake in the editor, use Edit | Undo to reverse the action rather than try to correct it with the mouse. Before running any report, save it in a file to make sure that it can be recovered. Also, save different versions to facilitate recovery.
SQL Loader Mostly asked Interview questions 1. What is SQL*Loader and what is it used for?
SQL*Loader is a bulk loader utility used for moving data from external files into the Oracle database. Its syntax is similar to that of the DB2 Load utility, but comes with more options. SQL*Loader supports various load formats, selective loading, and multi-table loads.
8. Can one selectively load only the records that one need?
Look at this example, (01) is the first character, (30:37) are characters 30 to 37: LOAD DATA
INFILE 'mydata.dat' BADFILE 'mydata.bad' DISCARDFILE 'mydata.dis' APPEND INTO TABLE my_selective_tableWHEN (01) <> 'H' and (01) <> 'T' and (30:37) = '19991217'(region CONSTANT '31', service_key POSITION(01:11) INTEGER EXTERNAL, call_b_no POSITION(12:29) CHAR )
CONCATENATE: - use when SQL*Loader should combine the same number of physical records together to form
one logical record.
CONTINUEIF - use if a condition indicates that multiple records should be treated as one. Eg. by having a '#' character in column 1. 11. How can get SQL*Loader to COMMIT only at the end of the load file?
One cannot, but by setting the ROWS= parameter to a large value, committing can be reduced. Make sure you have big rollback segments ready when you use a high value for ROWS=.
13. What is the difference between the conventional and direct path loader?
The conventional path loader essentially loads the data by using standard INSERT statements. The direct path loader (DIRECT=TRUE) bypasses much of the logic involved with that, and loads directly into the Oracle data files. More information about the restrictions of direct path loading can be obtained from the Utilities Users Guide.