Tuesday, September 29, 2009

Manual Ordering Block Data

PROCEDURE Prc_ordering_REF ( pBlock VARCHAR2, pClause VARCHAR2, pExec VARCHAR2 default 'NO') IS
vOrder_by VARCHAR2(5);
V_ORDER VARCHAR2(500);
begin
-- Checking whether pBlock is DB Block or not
if get_block_property(pBlock, query_data_source_type) = 'TABLE' then

-- Finding out " ASC" or " DESC" from the existing "null" or "1 ASC" order clause.
-- Set " DESC" if null


vOrder_by := nvl(substr(get_block_property(pBlock, order_by),2), ' a');

-- Assigning vice-versa
if Upper(vOrder_by) = ' A' then
vOrder_by := ' ASC';
elsif Upper(vOrder_by) = ' ASC' then
vOrder_by := ' DESC';
else
vOrder_by := ' ASC';
end if;

-- Setting order by clause to the supplied block
set_block_property (pBlock, order_by, pClause||vOrder_by);

if upper(pExec) = 'YES' then
go_block(pBlock);
:system.message_level := 5;
execute_query;
:system.message_level := 0;
end if;
set_block_property(pBlock, order_by, '1'||vOrder_by);
end if;
end;

No comments:

Post a Comment