Home » Developer & Programmer » Forms » How to use data block and non database item checkbox together
How to use data block and non database item checkbox together [message #608230] Mon, 17 February 2014 18:18 Go to next message
desmond82
Messages: 6
Registered: February 2014
Junior Member
I have a data block and a non database checkbox at the same block. I want to get the value of the checkbox. If the checkbox selected, i want to insert the related company to another table. Please help,thanks


Here is my code:

declare
p_company varchar2(10);
p_control number;
begin
go_block('T1');
execute_query;
first_record;

loop
go_item('T1.company');
p_company := :T1.company;
go_item('T1.control);
p_control := :T1.control;
if p_control = 1 then
--insert another table the value of p_company
end if;
exit when :system.last_record = 'TRUE';
next_record;
end loop;

end;
Re: How to use data block and non database item checkbox together [message #608240 is a reply to message #608230] Tue, 18 February 2014 01:12 Go to previous messageGo to next message
Littlefoot
Messages: 21809
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You don't need to use variables; there's no problem in checking item value directly.
begin
  go_block('T1');
  execute_query;
  first_record;

  loop
    if :t1.control = 1 then
       insert into another_table (company) values (:t1.company);
    end if;
  
    exit when :system.last_record = 'TRUE';
    next_record;
  end loop;
end;
Re: How to use data block and non database item checkbox together [message #608243 is a reply to message #608240] Tue, 18 February 2014 01:48 Go to previous messageGo to next message
desmond82
Messages: 6
Registered: February 2014
Junior Member
I know we can use value directly, but the problem here is that the heckbox value t1.control can not be seen.
To see the value on t1.control, I use alert_message.

Please someone who knows what I have to do, helps me. I think I need to use system.cursor_record, but how?
begin
go_block('T1');
execute_query;
first_record;

loop
if :t1.control = 1 then
SET_ALERT_PROPERTY( 'msg', ALERT_MESSAGE_TEXT,:t1.company );
cevap := SHOW_ALERT( 'msj');
end if;

exit when :system.last_record = 'TRUE';
next_record;
end loop;
end;
Re: How to use data block and non database item checkbox together [message #608246 is a reply to message #608243] Tue, 18 February 2014 02:09 Go to previous messageGo to next message
Littlefoot
Messages: 21809
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
problem here is that the checkbox value t1.control can not be seen


You mean, it is not displayed on the screen? It doesn't matter, as long as it exists in that block. I *think* that code I posted previously should do what you asked.

I'm not sure I understood what you meant to accomplish by displaying an alert (not to mention :system.cursor_record).
Re: How to use data block and non database item checkbox together [message #608250 is a reply to message #608246] Tue, 18 February 2014 02:29 Go to previous messageGo to next message
desmond82
Messages: 6
Registered: February 2014
Junior Member
I want to insert compnay to another table. I use alert_property to see the value of the checkbox.

The below code is not working !!

begin
go_block('T1');
execute_query;
first_record;

loop
if :t1.control = 1 then
insert into another_table (company) values (:t1.company);
end if;

exit when :system.last_record = 'TRUE';
next_record;
end loop;
end;
Re: How to use data block and non database item checkbox together [message #608254 is a reply to message #608250] Tue, 18 February 2014 03:04 Go to previous messageGo to next message
Littlefoot
Messages: 21809
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
The below code is not working !!


What does that mean? Did you get any error? If so, which one? If not, explain what it means.

What values does this checkbox item have? 1 and ...? What is its datatype?
Re: How to use data block and non database item checkbox together [message #608257 is a reply to message #608254] Tue, 18 February 2014 03:35 Go to previous messageGo to next message
desmond82
Messages: 6
Registered: February 2014
Junior Member
Checkbox item :1 when value is checked, 0 when value is unchecked.
Checkbox data type is number.
There is a database block and a checkbox which is non database item at the same block.Also, I have a button.

When button is pressed , if the checkbox is checked, i want to insert the selected to another table.

İnsert does'nt work. Because 'if condition' never success despite that the checkbox is checked.

WHEN_BUTTON_PRESSED TRIGGER :
declare
p_company varchar2(10);
p_control number;
begin
go_block('T1');
execute_query;
first_record;

loop
go_item('T1.company');
p_company := :T1.company;
go_item('T1.control);
p_control := :T1.control;
if p_control = 1 then
--insert another table the value of p_company
end if;
exit when :system.last_record = 'TRUE';
next_record;
end loop;

end;

Re: How to use data block and non database item checkbox together [message #608262 is a reply to message #608257] Tue, 18 February 2014 04:00 Go to previous messageGo to next message
Littlefoot
Messages: 21809
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
It is kind of difficult to assist as you are going back and forth, without any progress. You're now back to your initial code (which doesn't work anyway, and can be rewritten in a better manner as I suggested). Furthermore, you aren't answering questions. I asked what do you mean by saying that checkbox' value "can not be seen"; so, what does it mean?

What information did alert reveal (if any)? I think that you didn't post your actual code (typos with "msg" and "msj"). What is that checkbox value, after all?

Did you try to switch to CHECKBOX_CHECKED built-in in IF statement?
Re: How to use data block and non database item checkbox together [message #608267 is a reply to message #608262] Tue, 18 February 2014 04:23 Go to previous messageGo to next message
desmond82
Messages: 6
Registered: February 2014
Junior Member
ok. I know i don't need to use variables.
I said that i put an alert into if statement, to see if it will show the checkbox values and the selected companies.
I tried checkbox_checked too. The alert shows all companies without looking the checkbox values.(show non checked companies too )

begin
go_block('T1');
execute_query;
first_record;

loop

if CHECKBOX_CHECKED(t1.control) then
---HERE
SET_ALERT_PROPERTY( 'msg', ALERT_MESSAGE_TEXT,:t1.company ||' '|| :t1.control);
cevap := SHOW_ALERT( 'msg');

insert into another_table (company) values (:t1.company);
end if;

exit when :system.last_record = 'TRUE';
next_record;
end loop;
end;
Re: How to use data block and non database item checkbox together [message #608270 is a reply to message #608267] Tue, 18 February 2014 04:33 Go to previous messageGo to next message
cookiemonster
Messages: 13923
Registered: September 2008
Location: Rainy Manchester
Senior Member
Why are you using execute_query here? That would reset the checkbox.
Re: How to use data block and non database item checkbox together [message #608271 is a reply to message #608270] Tue, 18 February 2014 04:36 Go to previous messageGo to next message
Littlefoot
Messages: 21809
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Right! Genius! (where were you for the past 3 hours!?)

I created a form which is supposed to do what Desmond wanted and - when I saw empty checkboxes - I realized what the problem was.
Re: How to use data block and non database item checkbox together [message #608277 is a reply to message #608271] Tue, 18 February 2014 05:48 Go to previous message
desmond82
Messages: 6
Registered: February 2014
Junior Member
Thank youuu cookiemonster, Littlefoot so much:)) I am very grateful to you.

When I removed execute_query, my problem was solved.
Previous Topic: frm-10043 cannot open file !!!
Next Topic: api-2034 the operation is not allowed
Goto Forum:
  


Current Time: Fri May 17 02:09:32 CDT 2024