This discussion is archived
6 Replies Latest reply: Jan 29, 2013 2:06 AM by barisist RSS

dynamic block name

barisist Newbie
Currently Being Moderated
hi everybody
ı have two different database block, both have a column named SCL_DATE.
In pre-insert trigger of BLOCK1 I write sth like this : BLOCK1.SCL_DATE = SYSDATE;
And in pre-insert trigger of BLOCK2 I write sth like this : BLOCK2.SCL_DATE = SYSDATE;

But ı wonder if ı can write a procedure such as :SYSTEM.CURRENT_BLOCK.SCL_DATE = SYSDATE and can I use this procedure in pre-insert trigger of two blocks. I tried but this syntax didn't work.

I hope ı could make clear what ı mean. Sorry about my english. Thanks for any help...
  • 1. Re: dynamic block name
    HamidHelal Guru
    Currently Being Moderated
    barisist wrote:
    hi everybody
    ı have two different database block, both have a column named SCL_DATE.
    In pre-insert trigger of BLOCK1 I write sth like this : BLOCK1.SCL_DATE = SYSDATE;
    And in pre-insert trigger of BLOCK2 I write sth like this : BLOCK2.SCL_DATE = SYSDATE;

    But ı wonder if ı can write a procedure such as :SYSTEM.CURRENT_BLOCK.SCL_DATE = SYSDATE and can I use this procedure in pre-insert trigger of two blocks. I tried but this syntax didn't work.
    hi,
    :SYSTEM.CURRENT_BLOCK return values, you code will give error. Try
    .....
    variable_name:=:SYSTEM.CURRENT_BLOCK;
    variable_name||.SCL_DATE=sysdate;
    not tested.


    Hope this helps


    Hamid
  • 2. Re: dynamic block name
    barisist Newbie
    Currently Being Moderated
    thanks for help but sorry, this also give errror.
    ı also tried,
    .....
    variable_name:=:SYSTEM.CURRENT_BLOCK;
    variable_name||'.SCL_DATE'=sysdate;

    but it is error again.
  • 3. Re: dynamic block name
    Amatu Allah Guru
    Currently Being Moderated
    hi
    pls share us the procedure u tried cause what u tried is not a syntax procedure if u tried it as i thought more simply u can use different solution to achieve this..

    :blockname1.urdate := sysdate ;
    there is a property called copy value in the date item property of ur dsteitem in second block here u can write the date item name of the block1 where it has sysdate .
    u can use different triggers as ...
    post or per text item or when validate item triggers
    in order to assign the sysdate to date on block1

    Amatu Allah
  • 4. Re: dynamic block name
    barisist Newbie
    Currently Being Moderated
    hi Amatu Allah
    the problem is not only about sysdate, it is just an example. the important point is how can ı use block name dynamicly?
    thanks...
  • 5. Re: dynamic block name
    Amatu Allah Guru
    Currently Being Moderated
    pls try any
    IF :SYSTEM.CURSOR_BLOCK = 'BL1' THEN
    _
    __do assigment __
    
    END if;
    hope it helps

    Amatu Allah
  • 6. Re: dynamic block name
    barisist Newbie
    Currently Being Moderated
    I have the solution, ı used copy.
    Here is my whole procedure

    PROCEDURE LOG_UPDATE IS

         TARIH VARCHAR2(20);
         CUR_VAL_TRH VARCHAR2(75);
         
         
    BEGIN
         
         CUR_VAL_TRH := :SYSTEM.CURRENT_BLOCK||'.UPD_ISL_TRH';

         SELECT TO_CHAR(SYSDATE,'DD/MM/YYYY HH24:MI')
         INTO TARIH
         FROM DUAL;
         
         COPY(TARIH,CUR_VAL_TRH);
         
    END;

    thanks for all replies

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points