Home » Developer & Programmer » Forms » How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger?
How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577309] Thu, 14 February 2013 03:21 Go to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
I have two tables one is
1)create table abc(c_name varchar2(10),c_number number(6),c_loc varchar2(8)); --having values
2)create table temp(sname varchar2(10),sid number(4),address varchar2(10));---no having


and my question is how to insert a values into temp using when-button-pressed trigger based on abc table in oracle form
please please help me....

[EDITED by LF: split the message from an unrelated topic. Applied [code] tags]

[Updated on: Thu, 14 February 2013 03:34] by Moderator

Report message to a moderator

Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577316 is a reply to message #577309] Thu, 14 February 2013 03:36 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Simply write an INSERT statement and put it into the WHEN-BUTTON-PRESSED trigger. Unless there's some hidden quirk, I don't see a problem here.
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577360 is a reply to message #577309] Thu, 14 February 2013 08:14 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
Be aware that the second column in table abc is larger than the second column in table temp, potentially causing a failure upon insert. Why would you design a destination table that does not match the source?
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577518 is a reply to message #577360] Mon, 18 February 2013 00:37 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Thanks a lot..
i got a solution and used insert only checkboxes checked when-button-triggers.

Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577532 is a reply to message #577316] Mon, 18 February 2013 04:29 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hello sir,
i used when-button-pressed trigger but,i want to insert values based on checked checkboxes only,others are m=not allowed
please help me...
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577533 is a reply to message #577532] Mon, 18 February 2013 04:32 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member

DECLARE
C_NAME VARCHAR(10);
C_NUMBER NUMBER(6);
C_LOC VARCHAR2(10);
C_MAIL VARCHAR2(6);
BEGIN
Go_Block('TEMP');
Last_Record;
C_MAIL:= :system.trigger_Record;
First_Record;
C_NAME:= :system.trigger_Record;
For i in C_NAME..C_MAIL-3 Loop
if :TEMP.FLAG = 'Y' then
insert into TEMP
values (:TEMP.SNAME,:TEMP.SID,:TEMP.ADDRESS,:TEMP.FLAG);
end if;
Next_Record;
End Loop;
commit;
message('complete');
END;
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577534 is a reply to message #577532] Mon, 18 February 2013 04:34 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As checkbox item doesn't seem to be part of a source table (so you can't store checkbox values into a table), you'll have to do that in a loop. See the search results (keywords: "checkbox loop") in order to see how it is to be done.
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577567 is a reply to message #577533] Mon, 18 February 2013 08:06 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
sivasurya wrote on Mon, 18 February 2013 05:32

insert into TEMP
values (:TEMP.SNAME,:TEMP.SID,:TEMP.ADDRESS,:TEMP.FLAG);


And where does this mysterious 4th value go if the table only has 3 columns? The way you code is just asking for disaster.
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577591 is a reply to message #577567] Tue, 19 February 2013 00:13 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Thanks for reply,
i have 2 tables one table having values another one is not having and i want insert into table when checkbox checked only that is after insertion only checked.
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577599 is a reply to message #577591] Tue, 19 February 2013 00:52 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
OK; so, what code did you produce after researching the results I pointed you to and fixing what Joy Division warned you of?
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577603 is a reply to message #577599] Tue, 19 February 2013 01:04 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Here i have a table with values:
--->create table abc(empno number(6),ename varchar2(10),sal number(8,2),selected_flag char(4));

insert into abc values(&empno,'&ename',&sal,NULL);

SELECT * FROM ABC;


--->CREATE TABLE TEMP(SNO NUMBER(6),SNAME VARCHAR2(10),LOC VARCHAR2(10));---->no values
SELECT * FROM TEMP;

And my query is that inserted values with the help of already inserted table , when only checked check boxes

DECLARE
v_message varchar2(10);
v_empno number(6);
r_rec cur1%type;
cursor cur1 is select * from abc where empno=v_empno;
BEGIN
v_message:=('insert into temp table');
for r_rec in cur1 loop
if :abc.selected_flag is not null then
insert into abc values(r_rec.empno,r_rec.ename,r_rec.sal,r_rec.selected_flag);
end if;
end loop;
close cur1;
commit;
end;
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577604 is a reply to message #577603] Tue, 19 February 2013 01:04 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
please! help me..
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577606 is a reply to message #577604] Tue, 19 February 2013 01:15 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Clean up that code first.
  • What is V_EMPNO used for? Where does it get its value?
  • What is ":abc.selected_flag"? If it is a checkbox, it can't be null as it has to have some value (Y or N, 1 or 0, whatever) so testing whether it is NULL or not is useless. Besides, you'd rather use CHECKBOX_CHECKED built-in.
  • Are you sure you want to insert into ABC again? You said that it contains data, but TEMP is empty. As your code suggests different, I'm somewhat confused.

[Updated on: Tue, 19 February 2013 01:15]

Report message to a moderator

Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577618 is a reply to message #577606] Tue, 19 February 2013 02:52 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
No sir,
i want insert values into empty temp table through abc table using when-button-pressed-trigger
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577656 is a reply to message #577618] Tue, 19 February 2013 07:21 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Describe what you mean by inserting into a table through another table.
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577666 is a reply to message #577618] Tue, 19 February 2013 08:25 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
sivasurya wrote on Tue, 19 February 2013 03:52
No sir,
i want insert values into empty temp table through abc table using when-button-pressed-trigger


There is no empty temp table in your code. The code and table is different from the original question. What is this mess you keep posting? Why don't you take some time and a question properly with things clearly described. You surely have not done that as of yet.
Re: How to copy values from one table to another using WHEN-BUTTON-PRESSED trigger? [message #577772 is a reply to message #577666] Wed, 20 February 2013 06:34 Go to previous message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Thanks,
i got an output... : Smile
Previous Topic: how to config forms reports service?
Next Topic: problem with BLOB column in cursor
Goto Forum:
  


Current Time: Thu Apr 25 19:46:33 CDT 2024