Home » Developer & Programmer » Forms » Problem with a button trigger
Problem with a button trigger [message #221196] Sun, 25 February 2007 02:52 Go to next message
nick048
Messages: 36
Registered: February 2006
Member
Hi to All,

I have create create a Form with:

1) Entries in an Header Block;
2) An Execute Query Button in the Header Block;
3) A Grid Block that must be populated from Execute Query Button.

In the button trigger WHEN-BUTTON-PRESSED I have placed this code:

Declare
   LC$Req  Varchar2(2000) ;
   AC$Req  Varchar2(256);
   TD$Req  Varchar2(256);
   TI$Req    Varchar2(256);
   DT$Req  Varchar2(256); 
Begin
  LC$Req := '';
  AC$Req := '';
  TD$Req := '';
  TI$Req := '';
  DT$Req := '';

-- Value of 4 Radio Button in the Header  
  If :BLOCK_HEADER.ACCOUNT_SITUATION = 1 then
   TI$Req := ' ';
  Elsif :BLOCK_HEADER.ACCOUNT_SITUATION = 2 then
    TI$Req := ' AND (D_MYTABLE.DOC_PAID <> 0) ';
  Elsif :BLOCK_HEADER.ACCOUNT_SITUATION = 3 then
    TI$Req := ' AND (D_MYTABLE.DOC_PAID = 0) ';
  Else
    TI$Req := ' AND (D_MYTABLE.DOC_INS <> 0) ';
  END IF;

-- Date Filters in the Header  
  If ((:BLOCK_HEADER.ACCOUNT_FROM_DATE is not null) AND (:BLOCK_HEADER.ACCOUNT_TO_DATE is not null)) then
    DT$Req := ' AND (D_MYTABLE.DOC_DATE >= :BLOCK_HEADER.ACCOUNT_FROM_DATE OR D_MYTABLE.DOC_DATE <= :BLOCK_HEADER.ACCOUNT_TO_DATE)';
  End if;   

-- Account Type and Account Code in the Header  
  If ((:BLOCK_HEADER.TEXT_ANA_TYPE is not null) AND (:BLOCK_HEADER.TEXT_ANA_CODE is not null)) Then

-- SELECT String Construnction for Query
    AC$Req := 'SELECT TYPE_CODE, DOC_CODE, DOC_DATE, DOC_TOTAL, DOC_INS, DOC_PAID, DOC_NOPAID FROM D_MYTABLE
     WHERE (D_MYTABLE.ANA_TYPE = :BLOCK_HEADER.TEXT_ANA_TYPE AND D_MYTABLE.ANA_CODE = :BLOCK_HEADER.TEXT_ANA_CODE)' ;
    LC$Req := RTRIM(AC$Req) || RTRIM(TI$Req) || RTRIM(DT$Req) ;
    Go_Block('BLOCK_BALANCE');
    Set_Block_Property( 'BLOCK_BALANCE', QUERY_DATA_SOURCE_NAME, LC$Req ) ;
    Execute_Query ;
    Go_Block('BLOCK_HEADER');
  End if;
    Go_Block('BLOCK_HEADER');
End ;


When I execute the Form and push on the Execute Query Button, the error FRM-40505 is returned. I have searched the cause of error: the trigger execute this SQL Instruction:

SELECT TYPE_CODE, DOC_CODE, DOC_DATE, ANA_TYPE, ANA_CODE, DOC_TOTAL, DOC_INS, DOC_PAID, DOC_NOPAID
FROM SELECT TYPE_CODE,  DOC_CODE,  DOC_DATE, DOC_TOTAL, DOC_INS, DOC_PAID, DOC_NOPAID FROM D_MYTABLE
WHERE (D_MYTABLE.ANA_TYPE = :BLOCK_HEADER.TEXT_ANA_TYPE AND D_MYTABLE.ANA_CODE = :BLOCK_HEADER.TEXT_ANA_CODE)

that is different from my query.

I suppose incorrect the code entered in the trigger, but I am a newbie and I am not able to resolve this problem without help.

Can You help me ? I hope... Razz

Thank You and Best Regards
Gaetano
Re: Problem with a button trigger [message #221229 is a reply to message #221196] Sun, 25 February 2007 20:04 Go to previous message
boyet-x
Messages: 23
Registered: August 2006
Junior Member
Hi,

I think this because of this code

===
Set_Block_Property( 'BLOCK_BALANCE', QUERY_DATA_SOURCE_NAME, LC$Req ) ;
===

The resulting statement has become
(though I'm not sure. I haven't use QUERY_DATA_SOURCE_NAME yet =P)
===
select [all db fields in your form] from [data block's QUERY_DATA_SOURCE_NAME]
===

I suggest to use DEFAULT_WHERE instead
===
Set_Block_Property( 'BLOCK_BALANCE', DEFAULT_WHERE, [your where clause here])
===

Hope this helps =)

- boyet
Previous Topic: To get item name dynamically and set a value to it
Next Topic: simple lov
Goto Forum:
  


Current Time: Sun Feb 02 10:11:05 CST 2025