Posted by: Edi Yanto on: March 7, 2009
One of the most often uses of the pseudo column rownum is to provide sequence numbers to the records in a query. This feature is widely used in reports to represent systematic display of information.
SELECT ROWNUM, rcta.trx_number, rcta.trx_date
FROM ra_customer_trx_all rcta;
ROWNUM TRX_NUMBER TRX_DATE
1 40881-05 12/14/2005
2 38384-05 11/24/2005
3 42740-05 12/28/2005
4 42742-05 12/28/2005
5 08883-07 3/12/2007
…………………………………..
…………………………………..
However, when we [...]
Posted by: Edi Yanto on: January 7, 2009
Operations such as upgrades, patches and DDL changes can invalidate schema objects. For this reason it makes sense to recompile invalid objects in advance of user calls. It also allows you to identify if any changes have broken your code base.
In order to compile a program, you must own that program (in other words, the [...]
Posted by: Edi Yanto on: October 28, 2008
CREATE OR REPLACE PACKAGE spell_number_pkg AS
/*
Spell Number in Indonesia and English
*/
AMOUNT_EXCEEDS_LIMIT EXCEPTION;
function to_words(
p_amount number
) return varchar2;
function spell_number(
p_number in number
) return varchar2;
END spell_number_pkg;
CREATE OR REPLACE PACKAGE BODY spell_number_pkg
IS
/*
Spell Number in Indonesia and English
*/
–*******************************************************************
–* PRIVATE MEMBERS
TYPE varchar2_tbl_t IS TABLE OF VARCHAR2 (30);
FUNCTION to_hundredth_words (p_amount NUMBER)
RETURN VARCHAR2
IS
l_translate_groups varchar2_tbl_t
:= varchar2_tbl_t (‘SATU’,
‘DUA’,
‘TIGA’,
‘EMPAT’,
‘LIMA’,
‘ENAM’,
‘TUJUH’,
‘DELAPAN’,
‘SEMBILAN’
);
l_tenth_groups varchar2_tbl_t
:= varchar2_tbl_t (”, ‘PULUH’, ‘RATUS’);
l_char VARCHAR2 (3);
l_length NUMBER;
l_number [...]
Posted by: Edi Yanto on: December 18, 2007
The cursor FOR UPDATE clause is only used with a cursor when you want to update tables in the database. Generally, when you execute a SELECT statement, you are not locking any rows. The purpose of using the FOR UPDATE clause is to lock the rows of the tables that you want [...]
Posted by: Edi Yanto on: May 31, 2007
PL/SQL sends SQL statements such as DML and queries to the SQL engine for execution, and SQL returns the result data to PL/SQL. You can minimize the performance overhead of this communication between PL/SQL and SQL by using the PL/SQL language features known collectively as bulk SQL. The FORALL statement sends INSERT, UPDATE, or DELETE [...]
Posted by: Edi Yanto on: May 25, 2007
Only INSERT, UPDATE, and DELETE statements can have output bind variables. You bulk-bind them with the RETURNING BULK COLLECT INTO clause of EXECUTE IMMEDIATE. With this clause, you can see which data have been inserted, updated or deleted.
Posted by: Edi Yanto on: May 25, 2007
Bulk SQL passes entire collections back and forth, not just individual elements. This technique improves performance by minimizing the number of context switches between the PL/SQL and SQL engines. You can use a single statement instead of aloop that issues a SQL statement in every iteration.
Bulk binding lets Oracle bind a variable in a SQL [...]
Posted by: Edi Yanto on: May 16, 2007
The SQL language has long offered the ability to apply set operations (UNION, INTERSECT, and MINUS) to the result sets of queries. In Oracle Database 10g, you can now use those same high-level, very powerful operators against nested tables (and only nested tables) in your PL/SQL programs and on nested tables declared as columns inside [...]
Posted by: Edi Yanto on: May 15, 2007
Assigning a value to a collection element can cause various exceptions:
If the subscript is null or is not convertible to the right datatype, PL/SQL raises the predefined exception VALUE_ERROR. Usually, the subscript must be an integer. Associative arrays can also be declared to have VARCHAR2 subscripts.
If the subscript refers to an uninitialized element, PL/SQL [...]
Posted by: Edi Yanto on: May 14, 2007
If you want to exit from any enclosing loop, but not just the current loop, you can label the enclosing loop and use the label in an EXIT statement.
<<outer>>
FOR i IN 1..5 LOOP
. . . . .
FOR j IN 1..10 LOOP
. . . . .
EXIT outer WHEN . . . .
. . . . .
END [...]
Recent Comments