Thursday, April 20, 2023

Retaining Date Format in Excel Output from RTF template

Sometimes we face issue in getting correct date format in XLS output generated using RTF template.

We can retain format selected in Data Template query and use same in XLS output using below syntax 

Double Click on RTF field value

It will open "Text Form Field Options" window , click on "Add Help Text" button

Use below to force literal format 

<fo:bidi-override direction="ltr" unicode-bidi="bidi-override"><?ACCOUNTING_DATE?></fo:bidi-override>


Thanks!


Tuesday, September 22, 2020

Parameterized sql query in PL/SQL block - Bind Variables

Beware of parameterized queries. Parameters are sequential and the number changes when you add any additional parameter for new requirement, subsequently you will need to change the later used bind variables accordingly.

Moreover it does not matter what number you use after colon (:) , it will simple consider it next parameter.

In PL/SQL query does not recognize bind variable number used, instead it will accept based on position


e.g

set serveroutput on size 10000;

declare

l_x number := 1;

l_y number := 2;

l_z number := 3;

l_op1 varchar2(15) :='No';

l_op2 varchar2(15) :='No';

l_op3 varchar2(15) :='No';

begin

execute immediate '

select sysdate from dual

where 1 =:1

and 2 =:3

and 3 = :2'

into l_op1

using l_x , l_y, l_z;

dbms_output.put_line (' Output 1 : '||l_op1);


execute immediate '

select sysdate from dual

where 1 =:1

and 2 =:35

and 3 = :2'

into l_op2

using l_x , l_y, l_z;

dbms_output.put_line (' Output 2 : '||l_op2);


execute immediate '

select sysdate from dual

where 1 =:1

and 2 =:3

and 3 = :2'

into l_op3

using l_x ,  l_z,l_y;

dbms_output.put_line (' Output 3 : '||l_op3);


exception when no_data_found then 

dbms_output.put_line (' ERROR : '||SQLERRM);

end;


Results

 Output 1 : 22-SEP-20

 Output 2 : 22-SEP-20

 ERROR : ORA-01403: no data found

PL/SQL procedure successfully completed.

Last select in the block fails to identify l_y is at position 3 .

If you use simple sql query , this will work but not in PL/SQL

select sysdate from dual

where 1 =:1

and 2 =:3

and 3 = :2;

Input values 

:1 = 1

:2 = 3

:3 = 2

Results

22-SEP-20

Friday, August 10, 2018

Business Issue : Form with multiple tabs taking long time to Open

Reason : One of block was having multiple Order by clauses and was picking all runs data ,
all data was not needed on initial form opening.

Solution : Get only recent run data at time of form opening , that will reduce the records to load.
Used onetime_where block property and populated it dynamically on WHEN_NEW_BLOCK_INSTANCE

SET_BLOCK_PROPERTY ('WB_BLK', onetime_where, l_where);

As name suggests onetime_where is appended to block query only once.
On F11 afterwards , regular where condition and supplied value is used by block query.




 

FRM-41042: No such property

Error while running form - FRM-41042: No such property for set_item_property

Cuase : Some visual attribute classes were causing properties to be set for displayed Item

Solution - changed Item Type from "Displayed Item" to "Text Item"

Thursday, August 2, 2018

link to ‘Compare to Original PO ‘ – I receive the error that I do not have privileges

Custom Responsibility to PO Inquiry causes error - "You have insufficient privileges for the current Operation. Please contact your System Administrator."
Navigation : XXX PO Inquiry ALL(Resp) > Purchase Orders > PO Change History 

To resolve this issue -

We need to add function ‘View Purchase Order History’ to Custom Menu : XXXX:PO_PURCHASE_ORDERS_GUI_B.

Friday, November 8, 2013

Higher is not better always..

Higher is not better always..

I had very tough time with Reports 10g today...

I was having below query in After Report trigger..

SELECT a.trx_number,rct.name ,rc.customer_name , hcsu.location
     into v_trx , v_trx_type, v_trx_cust , v_b2s
                FROM APPS.RA_CUSTOMER_TRX_ALL A , APPS.HZ_CUST_SITE_USES_ALL HCSU,
                   APPS.HZ_CUST_ACCT_SITES HCAS , APPS.RA_CUSTOMERS  RC , APPS.RA_CUST_TRX_TYPES RCT
                WHERE 1=1
                AND HCSU.SITE_USE_CODE = 'BILL_TO'
                AND HCAS.CUST_ACCOUNT_ID = A.BILL_TO_CUSTOMER_ID
                AND HCSU.CUST_ACCT_SITE_ID = HCAS.CUST_ACCT_SITE_ID
                AND HCSU.SITE_USE_ID = A.BILL_TO_SITE_USE_ID
                AND RC.CUSTOMER_ID=A.BILL_TO_CUSTOMER_ID
                AND A.CUST_TRX_TYPE_ID = RCT.CUST_TRX_TYPE_ID
                and  TRX_NUMBER = trim(l_trx)
                and rownum < 2;


The trim function was NOT recognized by reports 10g compiler and neither it gave any ERROR message...

Running report caused error

REP-0736: There exist uncompiled program unit(s).

REP-1247: Report contains uncompiled PL/SQL.

This error led me to compile report several times - incremental as well as all..but to no use

I tried dynamic sql , native sql , porting logic to procedure but nothing worked..

Finally I got this error message when I opened the report with 6i and compiled invidual unit.. husshh!!!

I reached solution not before spending 8 hours and running report for whooping 52 times..  poor I!
No wonder Edison had to try 1830 times to invent bulb.. after all  he was doing it before anyone else..

Friends reports 10g can be better but sometimes being on higher version sucks!



Comma separated string

Using Analytic functions  - 25-Oct-18

pass string as  '1,2,4,5,678'

SELECT REGEXP_SUBSTR (:i_string, '[^,]+', 1, level)
      FROM dual
      CONNECT BY LEVEL <= LENGTH(regexp_replace(:i_string,'[^,]*'))+1;

---Below is longer route


Below code can be used to separate trx numbers from comma separated sting..

Definitely re-usable ...

set serveroutput on
DECLARE
  l_list  VARCHAR2(240) := '8345825,9999003,8233347';
  l_trx VARCHAR2(50);
 
  l_start number;
  l_len number;
  l_cnt number;
 
BEGIN
l_cnt := length(l_list) - length(replace(l_list, ',',''));

dbms_output.put_line(' Cnt '||l_cnt);

l_start:=0;  -- start from 0


for i in 1..l_cnt+1
loop

--l_len:= INSTR(l_list,',',1,i) - decode(l_start,0,1,l_start) ;

select INSTR(l_list,',',1,i) - decode(l_start,0,1,l_start) into l_len from dual;

if l_len < 0 then l_len:= 100; end if; -- for last trx

dbms_output.put_line( i ||'**St '||l_start);
dbms_output.put_line( i ||'**Ln '||l_len);

 l_trx := SUBSTR(l_list,l_start,l_len);

 dbms_output.put_line( i ||'    ' ||l_trx );

 l_start := INSTR(l_list,',',1,i)+1;
end loop;

end;