Home » Developer & Programmer » Forms » clear block (10g)
clear block [message #553625] Mon, 07 May 2012 05:51 Go to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
when i press when button pressed trigger,i want first the form will delete all the previous data and then populate the data from the table, that's why i used clear_block first, but this clear_code is not working here. my coding is given below

go_block('show');
clear_block(NO_VALIDATE);

declare
cursor c1 is select *
from qtr_demand order by 1;
begin
go_block('show');
clear_block(no_validate);
open c1;
loop
fetch c1 into
-----------
exit when c1%notfound;
next_record;
end loop;
close c1;
first_record;
end;


Re: clear block [message #553630 is a reply to message #553625] Mon, 07 May 2012 06:28 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Your description suggests that - instead of using default, built-in Forms functionalities - you are reinventing the wheel.

If the block is based on a table (again - according to your words, it should be), you should only press <EXECUTE QUERY> button on the toolbar. If you made any changes, you'll be warned that changes might be lost if you don't save them. If not, querying mechanism will simply replace current block contents with newly fetched data.

Generally speaking, you should NOT code anything that Forms is capable of doing itself. It is useless, and - more important - won't work as good as solution provided from those nice people from Oracle.
Re: clear block [message #553631 is a reply to message #553630] Mon, 07 May 2012 06:49 Go to previous messageGo to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
i have coding on when new form instace, so as i open the form it populates the data from table wihhout pressing any button. i have also a button re-calculate on that form i just want when i click that re-calculate button, first it flush off all the previous data and then give the new calculated data.
i have coading in this manner on button recalculate, everything is fine except when i press the button it doesn't clear the block.
go_block('show');
clear_block(NO_VALIDATE);

declare
cursor c1 is select *
from qtr_demand order by 1;
begin
go_block('show');
clear_block(no_validate);
open c1;
loop
fetch c1 into
-----------
exit when c1%notfound;
next_record;
end loop;
close c1;
first_record;
end;
Re: clear block [message #553634 is a reply to message #553631] Mon, 07 May 2012 06:55 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
i have coding on when new form instace, so as i open the form it populates the data from table wihhout pressing any button

The same can be done as
-- WHEN-NEW-FORM-INSTANCE trigger
execute_query;


Recalculate button? What does it do? Where are these calculations stored? Do you update the table (UPDATE your_table SET ...), or records in a form (:block.item := recalculated_value)? Whichever it is, it should look like
-- recalculate here

commit;       -- or, possibly, "standard.commit;"
execute_query;



Saying that "it doesn't clear the block", what does it do, then? Nothing? Raises an error? If so, which one?
Re: clear block [message #553636 is a reply to message #553634] Mon, 07 May 2012 07:09 Go to previous messageGo to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
i am fetching data from a table and this table is updated by a procedure every time. first the procedure executes and then this procedure dumps the updated information in that table


begin
procedure name;
go_block('show');
clear_block(no_validate);
open c1;
loop
fetch c1 into
-----------
exit when c1%notfound;
next_record;
end loop;
close c1;
first_record;
end;
Re: clear block [message #553637 is a reply to message #553636] Mon, 07 May 2012 07:19 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
OK, but WHY would you populate a block with a cursor loop, when simple EXECUTE_QUERY does the same? If necessary, you can restrict retrieved records by setting ONETIME_WHERE or DEFAULT_WHERE for SET_BLOCK_PROPERTY, or even use PRE-QUERY trigger and set certain items' values. I just can't see a point in doing it the way you insist on.

You didn't say what "clear_block is not working" means. Maybe it works, but your "procedure_name" doesn't update anything so fetched records are the same as previous ones.
Re: clear block [message #553678 is a reply to message #553637] Mon, 07 May 2012 15:38 Go to previous messageGo to next message
owais_baba
Messages: 289
Registered: March 2008
Location: MUSCAT
Senior Member
I think dear you are trying to do something like that

 GO_BLOCK('B');
           clear_block(no_commit);
     declare 
     	  cursor c1 is
     	          select * from a WHERE NO=:A.NO ;
                  a_record c1%rowtype;
     begin
           open c1;
     loop
           fetch c1 into a_record;
           exit when c1%notfound;
               :b.no:=a_record.no;
               :b.name:=a_record.name;
     next_record;
              --insert into b values(a_record.no,a_record.name);
    end loop;
      close c1;
         end;
   first_Record;


Hope your problem is solved


regards
baba


Re: clear block [message #554196 is a reply to message #553678] Fri, 11 May 2012 04:52 Go to previous messageGo to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
go_block('show');
clear_block(no_validate);
go_block('total');
clear_block(no_validate);

declare
cursor c1 is select distinct qtr_type, payfr, payto, stock, stock_gp, stock_dp, occupied, occupant, stock_sp, pr_vacancy, occupant_5cpc, eligible, eligible_wait
from qtr_demand order by 1;

t1 number := 0;
t2 number := 0;
t3 number := 0;
t4 number := 0;
t5 number := 0;
t6 number := 0;
t7 number := 0;
t8 number := 0;
t9 number := 0;
t10 number := 0;

begin
qtr_shortage;
open c1;
loop
fetch c1 into
:show.qtr_type,
:show.pay_fr,
:show.pay_to,
:show.total_hs,
:show.gp,
:show.dp,
:show.entitled,
:show.actual,
:show.stk_to_be_vac,
:show.pr_vac_stk,
:show.et_not_known,
:show.et_known,
:show.waiting;

exit when c1%notfound;

t1 := t1 + :show.total_hs;
t2 := t2 + :show.gp;
t3 := t3 + :show.dp;
t4 := t4 + :show.entitled;
t5 := t5 + :show.actual;
t6 := t6 + :show.stk_to_be_vac;
t7 := t7 + :show.pr_vac_stk;
t8 := t8 + :show.et_known;
t9 := t9 + :show.et_not_known;
t10 := t10 + :show.waiting;


next_record;

end loop;
close c1;
first_record;
go_block('total');
:total.total1 := t1;
:total.total2 := t2;
:total.total3 := t3;
:total.total4 := t4;
:total.total5 := t5;
:total.total6 := t6;
:total.total7 := t7;
:total.total8 := t8;
:total.total9 := t9;
:total.total10 := t10;

end;

in this form,i have 2 blocks show and total, one procedure qtr_shortage. this procedure executes and dump the data in qtr_demand table.the above coding is on recalculate button, when button pressed.
The problem is, that the CLEAR_BLOCK issued in the form doesn't seem to take effect (i.e. screen refresh). as the procedure takes some time to calculate data i want till that form erases its previous value and remains blank till execution of procedure.




Re: clear block [message #554198 is a reply to message #554196] Fri, 11 May 2012 05:20 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
Please read and follow How to use [code] tags and make your code easier to read?

You don't need any of that code, get rid of it.
Populate the show block by basing the block on the qtr_demand table and using execute_query.
Populate the totals by using the item summary functions - look at the calculation section of an items property palette.
Re: clear block [message #554374 is a reply to message #554198] Mon, 14 May 2012 00:52 Go to previous messageGo to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
go_block('show');
clear_block(no_validate);
go_block('total');
clear_block(no_validate);

go_block('SHOW');
execute_query;

begin
select distinct qtr_type, payfr, payto, stock, stock_gp, stock_dp, occupied,
occupant, stock_sp, pr_vacancy, occupant_5cpc, eligible, eligible_wait
into :show.qtr_type, :show.pay_fr, :show.pay_to, :show.total_hs, :show.gp, :show.dp,:show.entitled,
:show.actual, :show.stk_to_be_vac, :show.pr_vac_stk, :show.et_known, :show.et_not_known, :show.waiting
from qtr_demand order by 1;
end;


as you said to use execute_query, i did the same bt this is not working, no any data is coming from table to form.
Re: clear block [message #554376 is a reply to message #554374] Mon, 14 May 2012 00:58 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If EXECUTE_QUERY did nothing, then either a table is empty, datablock's WHERE clause prevents anything to be retrieved, or block is not a database block (but control block).

(If you meant to fill the block with the above SELECT statement, well - that won't do what you think it would. A LOOP is required in such a case, but first you need to know why EXECUTE_QUERY doesn't work properly.)
Re: clear block [message #554389 is a reply to message #554376] Mon, 14 May 2012 01:45 Go to previous messageGo to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
database data block: yes
where clause: ------(it is blank)
and the table has data, as i checked it in database.
but after this that coding was not working.
Re: clear block [message #554391 is a reply to message #554389] Mon, 14 May 2012 01:54 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
This is how it goes: you decide to create a brand new form based on a table. So you run a Datablock Wizard which guides you through the process. Once it is done, you simply run the form. All basic functionalities work - you are able to query existing records, update them, delete them, or add new ones. No additional coding is required.

Now, I have no idea what you might have done so that it doesn't work. Maybe you should start over and first make it work, and then make it fancy. I'd suggest you to do the latter step-by-step. Test frequently.
Re: clear block [message #554420 is a reply to message #554391] Mon, 14 May 2012 07:04 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
Have you set the Query Data Source Name property?
Re: clear block [message #554422 is a reply to message #554420] Mon, 14 May 2012 07:07 Go to previous messageGo to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
yes
query data source type: table
name: qtr_demand
Re: clear block [message #554426 is a reply to message #554422] Mon, 14 May 2012 07:32 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
use get_block_property(<block name>, last_query) to see what query the form sent to the DB.
Re: clear block [message #554577 is a reply to message #554426] Tue, 15 May 2012 12:47 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
Do you have any Item Type=LIST ITEM objects on in your block?
Re: clear block [message #555077 is a reply to message #554577] Mon, 21 May 2012 04:00 Go to previous messageGo to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
why only the first message 'hello' is working, second message is not working.

declare
cursor c1 is select distinct qtr_type, payfr, payto, stock, stock_gp, stock_dp, occupied,
occupant, stock_sp, pr_vacancy, occupant_5cpc, eligible, eligible_wait
from qtr_demand order by 1;
begin
message('hello'); message('');
message('hi'); message('');

--qtr_shortage;
open c1;
loop
fetch c1 into
:show.qtr_type,
:show.pay_fr,
:show.pay_to,
:show.total_hs,
:show.gp,
:show.dp,
:show.entitled,
:show.actual,
:show.stk_to_be_vac,
:show.pr_vac_stk,
:show.et_not_known,
:show.et_known,
:show.waiting;

exit when c1%notfound;


next_record;

end loop;
close c1;

first_record;
end;
Re: clear block [message #555078 is a reply to message #555077] Mon, 21 May 2012 04:02 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I guess you meant to double these messages (not "clear" them):
message('hello'); message('hello');
message('hi');    message('hi');
Re: clear block [message #555081 is a reply to message #554426] Mon, 21 May 2012 04:42 Go to previous messageGo to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
i am sending u my form in attachment. can u please tell me the problem why clear_form is not keep clear the form untill the procedure is running.
Re: clear block [message #555199 is a reply to message #553678] Tue, 22 May 2012 06:22 Go to previous messageGo to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
my clear_form only show its effect if there is any message, then clear_form clears the form and form remains blank till the procedure run.i don't whats the reason.
can u suggest me some other way for the form remains blank till the procedure runs
i am attaching my form also
Re: clear block [message #556221 is a reply to message #554198] Fri, 01 June 2012 00:47 Go to previous messageGo to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
Begin

qry := 'select distinct qtr_type, payfr, payto, stock, stock_gp, stock_dp, occupied,
occupant, stock_sp, pr_vacancy, occupant_5cpc, eligible,eligible_wait
from qtr_demand order by 1';


set_block_property('qtr_demand', default_where, qry);
go_block('qtr_demand');
execute_query;
End;


i wrote this code, but this is not working. here qtr_demand is a batablock, based upon table qtr_demand.
Re: clear block [message #556230 is a reply to message #556221] Fri, 01 June 2012 01:06 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
DEFAULT_WHERE property is supposed to contain WHERE clause, not the whole SELECT statement. As your "qry" doesn't contain WHERE clause at all, it appears that you completely missed the point.
Re: clear block [message #556232 is a reply to message #556230] Fri, 01 June 2012 01:33 Go to previous messageGo to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
that means if i haven't any where clause in my query then i can't use this set_block_property
Re: clear block [message #556234 is a reply to message #556232] Fri, 01 June 2012 01:42 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
In what query?

Data block is based on a table. If you just create it (using a wizard) and execute query, it would be the same as if you ran (in SQL*Plus)
select * from your_table
Obviously, you'd get ALL records from the table.

If you want to restrict them by some condition (for example, col_1 = 25), in SQL*Plus that would be
select * 
from your_table
where col_1 = 25
In Forms, you can do that with SET_BLOCK_PROPERTY and its DEFAULT_WHERE, so you'd put it as
set_block_property('block_name', default_where, 'col_1 = 25');

Once again: WHERE clause goes into DEFAULT_WHERE, not the whole SELECT statement.
Re: clear block [message #556245 is a reply to message #556234] Fri, 01 June 2012 03:28 Go to previous messageGo to next message
kriti.akanksha
Messages: 28
Registered: March 2012
Junior Member
i got it, as i haven't any restriction on selecting rows (cann't use where clause), so i am not able to use set_block_property in this form.
thanks.

but i have one another form in which data block is created by data wizard, based on table ol_registration. in this form coding is like this

Begin
if :control.REC_FROM is not null and :control.REC_TO is not null then
qry :=' RECD_ON between :control.REC_FROM and :control.REC_TO '; set_block_property('ol_registration', default_where , qry );

go_block('ol_registration');
execute_query;
end if;

this is working fine, but through this i also get duplicate records in this. i want distinct records only, so i modify this like this

Begin
if :control.REC_FROM is not null and :control.REC_TO is not null then
qry := ' select distinct form_no, edt, regno, name, desgn, form_status, recd_on
from ol_registration_vu where RECD_ON between :control.REC_FROM and :control.REC_TO'; set_block_property('ol_registration', default_where , ' RECD_ON between :control.REC_FROM
and :control.REC_TO ' );

go_block('ol_registration');
execute_query;
end if;

but this coding is not retrieve data from database, it is not doing anything.
how can i get distinct records only.

Re: clear block [message #556277 is a reply to message #556245] Fri, 01 June 2012 06:14 Go to previous message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
We answered this in your remove duplicate value thread the other day.
Ignoring what we tell you isn't a good idea if you want our help.
Previous Topic: Passing info. thru forms
Next Topic: Not entering into a block(non-database block)
Goto Forum:
  


Current Time: Fri Jul 05 22:16:03 CDT 2024