Insert one table and update another???
Hello,
I was wondering if it is possible to insert a record in one table and update another another record in a different table.
I have a form on my company's intranet that allows employees to add comments (ADDT Insert transaction) about new products we are going to bring to the market. At the same time, I would like to count the numbers of comments on a particular product and update that number for each product to see which product is getting the most reviews.
Right now the products are on the homepage with the title and inserted date. From there, the employees click on the product get the info and make comments about it. The problem for me is that I would like to see the comment counts for each product on the home page, which means I would have to update the product table with the count.
Sorry, I am using PHP as the technology.
When I used to do it in ASP, I would insert the comment using the POST from the form, but add another hidden field with the count in it and I would use the "Command" Server behavior to retrieve the number and update the other table field.
I noticed that dreamweaver removed the "Command" server behavior when using PHP.
All help is greatly appreciated
Charles.
Hi Charles,
you can generally execute queries on a different table using Custom Triggers, and in regards to your "update the product table with the count" scenario the ADDT help file has a helpful pointer in the chapter "Custom transactions and triggers : Save additional information on login" -- in here you´ll find a sample "incremental counter" query which should be easy to adapt.
Cheers,
Günter Schenk
Adobe Community Expert, Dreamweaver
Similar Messages
-
Selecting from one table and Update another in the same Page
Could someone help me with this HTMLDB task. In my page design, I am selecting data from two tables (masters: DEPT, EMP) which I want to display on the left column of the page and at the same time a user would be able to update another table (ATTENDANCE:with many children) which would have a radiogroup on the right side for each value of the master such as employee name. The placement of data has to appear in corresponding rows on the page. For instance, employee names of the master table must appear on the same row with its corresponding child value. The page would be grouped by DEPT_NO. The user would click on the department name, a new page with the employee name would apprar. From that page, the user would then update attendance column for each employee in that department. In this operation, it is only the ATTENDANCE table that is being updated. I can send out more information about the structure of the tables if you need more information. I tried many HTMLDB options, forms, reports, etc. I have not been able to get quite right. Your help will be appreciated.
Raju,
Thanks for responding to my problem. I have actually tried using the example on how-to you sent me a link to but it did not help as I expected. You see, the page would be updated every meeting date for each employee. I can send you more information about the table structure if you like. However, let me see if this will help you a bit.
Tables are: 1) Dept [dept_no (pk),dept_name] 2) EMP [emp_no (pk),emp_name, dept_no(fk)] 3) Meetings [meet_key(pk),attended, meeting_date, emp_no(fk)]
What I want to do is create two pages, one would list the departments, when a user selects a department, the user would be linked to a meeting attandance page. The meeting attendance page would list department name once, Meeting date once, and then list employees in that department. At the right column of every employee would be a checkbox for meeting.attended for update. The meeting_date would be pre-populated so that what the user would do is just check Yes/NO. The second page is the one I'm having the most problem with.
If I can do a fetch from dept, emp, and meetings and then do an update on the Meetings table on the same page, I think that might solve the problem. That was how I solved it in MS Access three years ago.
Here is email address in case you want to contact me directly. [email protected]
Thanks again for your help. -
How to display contents of one table and update another one
Hi all
My requirement is the following:
- Three tables, guard, site and guard_site where guard_site shows which guards are linked to a particular site and vice-versa
- I need to create one front-end where i allow all guards to be linked with a particular site
- so the panel must show all guards available (so get display data from guard table) and then i need to introduce a row selector, which allows user to select whichever guards he/she wants
- There will be a save button and upon pressing it, i will create an entry on the guards_site table for the selected guards against the siteId provided when user goes to this page.
- Also upon loading this page if there are already any linked guards these must show as ticked in the row selector.
so I first attempted using a Tabular form or a form on a table/view, but it then forces me to select a table to update, which is not what i want, the data i display is from guard table, which is not the table i want to update... so I then tried a blank page and I created a SQL Query report region... but it doesn't allow me to add a row selector (even if I have added a button on the region).
Any ideas?
Regards and thanks
Jose
Ps- im using version Application Express 4.0.2.00.09 that came with Oracle Database Express Edition 11gJose,
Three tables, guard, site and guard_site where guard_site shows which guards are linked to a particular site and vice-versaso I first attempted using a Tabular form or a form on a table/view, but it then forces me to select a table to update, which is not what i want, the data i display is from guard table, which is not the table i want to update...>
Maybe I am not understanding what you are trying to do but it appears that the table guard_site is the table you should be updating. Doesn't the guard_site table contain foreign keys from both the guard and site tables?
Jeff -
How to insert One table value to Another Table
Hi friends
Please have a look on this Code. Since i am new Java i am not able to findout the Solution for it
private void displayavailablity(String selecteditem1)
try
Vector columnNames = new Vector();
Vector data1 = new Vector();
String bname,bauthor,bcategory,bref1,bavail,bid;
int bref,mid,num;
rs = st.executeQuery("SELECT * FROM Books where BAuthorandPublisher='" + selecteditem1 +"'");
while(rs.next())
bname = rs.getString("BName");
bauthor = rs.getString("BAuthorandPublisher");
bcategory = rs.getString("BCat");
bref = rs.getInt("BRef");
if(bref==1)bref1="Yes";
else bref1 = "No";
mid = rs.getInt("Mid");
if(mid==0)bavail="Available";
else bavail="Issued To:"+mid;
bid = rs.getString("BId");
System.out.println("Book Name is::"+bname);
System.out.println("Book Availabilty::"+bavail);
num = st.executeUpdate("insert into BSearch Values('"+bid+"','"+bname+"','"+bcategory+"','"+bauthor+"','"+bavail+"','"+bref1+",')");
System.out.println("Inseted in the table");
/**ResultSetMetaData md= rs.getMetaData();
int columns =md.getColumnCount();
String booktblheading[]={"Book ID","Book NAME","BOOK AUTHOR/PUBLISHER","REFRENCE","CATEGORY"};
for(int i=1; i<= booktblheading.length;i++)
columnNames.addElement(booktblheading[i-1]);
while(rs.next())
Vector row = new Vector(columns);
for(int i=1;i<=columns;i++)
row.addElement(rs.getObject(i));
data1.addElement(row);
//System.out.println("data is:"+data);
((DefaultTableModel)table.getModel()).setDataVector(data1,columnNames);
//DefaultTableModel model = new DefaultTableModel(data1,columnNames);
//table.setModel(model);
rs.close();
//st.close(); */
catch(SQLException ex)
}I trigger this Method when a JComboBox Item is Selected.
For an example when i select an Item the select Query brings all the Record Equals to the Selected item. Now i want to insert the Selected items with some Modification to Another Table.
Now the Problem is My Program Inserts Only One Record (Though there are Many Records Equals to Selected Item)
Please give me a Better Solution
Thank youjolif,
If you're "new to java" then might I suggest you leave swing until you're "not so new to java"... it involves so many "advanced concepts" (unlike VB) that it constitutes a biohazard... i.e. it's fundamentally inimical to humanoid lifeforms.
Now... Having duly vented my spleen, try rs.updateRow(); -
On submit perform an insert on one table and an update on aother table
I am trying to perform and insert on the table one table (the wizard created my form the insert is going against the table that I created using the wizard) and on the form is on field that is also in another table. Therefore, I am trying to perform an update on one attribute of one table and a insert into another table. How do I do this in apex?
If you have used wizard to create form, then you may see a process of type 'Automatic Row Processing (DML)' in your page which will perform INSERT/UPDATE/DELETE on your form table. Here you can see APEX performs INSERT only when REQUEST is in 'INSERT, CREATE, CREATE_AGAIN, CREATEAGAIN'
So create one more PL/SQL page process which will execute at 'on Submit after validations' and write update process as follows
begin
-- pseudo table/columns
update tbl_second
set col1 = :p1_item
where pk_col = :p1_pk_item;
end;Make this process conditional so that it will perform UPDATE only when request value is in 'INSERT, CREATE, CREATE_AGAIN, CREATEAGAIN' ( i.e. only when you are inserting into your form table)
Cheers,
Hari
p.s. I think you may also need to update the second table when some-one updates your form table.
Edited by: Hari_639 on Oct 26, 2009 9:46 AM -
How to insert some records in one table and some records in another table
Interview question
how insert records in two tables by using trigger
CREATE or REPLACE TRIGGER Emp_Ins_Upd_Del_Trig
BEFORE delete or insert or update on EMP
FOR EACH ROW
BEGIN
if UPDATING then
UPDATE emp2
SET
empno = :new.empno,
ename = :new.ename
--, job = :new.job
--, mgr = :new.mgr
--, hiredate = :new.hiredate
, sal = :new.sal
--, comm = :new.comm
--, deptno = :new.deptno;
sdate = :new.sdate,
edate = :new.edate
end if;
if INSERTING then
INSERT INTO emp2
VALUES
( :new.empno
, :new.ename
--, :new.job
--, :new.mgr
--, :new.hiredate
, :new.sal
--, :new.comm
--, :new.deptno
new.sdate,
new.edate);
end if;
if DELETING then
DELETE FROM emp2
WHERE empno = emp2.empno;
end if;
END;
it is working fine but he wants to insert some specific litimit on one table and some specified limit of records in one ..
In this senerio can i insert records by use count of records...
please help me..Can you be more specific on the "Limit"
Conditional insert can be used in this case. -
How to get the data from one table and insert into another table
Hi,
We have requirement to build OA page with the data needs to be populated from one table and on save data into another table.
For the above requirement what the best way to implement in OAF.
I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
ThanksYou can achieve this in many different ways, one is
1. Create another VO based on the EO which is based on the dest table.
2. At save, copy the contents of the source VO into the dest VO (see copy routine in dev guide).
3. commiting the transaction will push the data into the dest table on which the dest VO is based.
I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
if by table you mean a DB table, then no, you can have a VO based on multiple EOs which will do DMLs accordingly.Thanks
Tapash -
How to update one table based on another table ??
Hello Friends:
I am trying to run the following query in oracle but it won't run.
UPDATE BOYS
SET
BOYS.AGE = GIRLS.AGE
FROM GIRLS
WHERE
BOYS.FIRSTNAME = GIRLS.FIRSTNAME AND
BOYS.LASTNAME = GIRLS.LASTNAME;
This query runs fine in sql server but in oracle its saying can't find "SET". PLease tell me what is the correct syntax in oracle to update one table based on another table.
thanksSee if this helps.
If you wrote an SQL statement:
update boys set age = 10;
Every row in the boys table will get updated with an age of 10. But if you wrote:
update boys set age = 10
where firstname = 'Joe';
Then only the rows where the firstname is Joe would be updated with an age of 10.
Now replace the 10 in the above statements with (select g.age from girls g where g.firstname = b.firstname and g.lastname = b.lastname) and replace where firstname = 'Joe' in the second statement with where exists (select null from girls g where g.firstname = b.firstname and g.lastname = b.lastname). The same concepts apply whether 10 is an actual value or a query and whether you have a where clause with the update statement to limit rows being updated.
About the select null question regarding the outer where clause:
Since the query is checking to see if the row in the girls table exists in the boys table what the column is in this select statement doesn't matter, this column isn't being used anywhere. In this case Todd chose to use null. He could have also used a column name from the table or a lot of times you'll see the literal value 1 used here. -
Importing a Flat File to Oracle and updating another table
Hey everyone,
I am a newbie with Oracle, and I've tried for the last 2 days to solve this problem below. But all my searches and attempts have failed.
I have a text file called ReturnedFile.txt. This is a comma separated text file that contains records for two fields.... Envelope and Date Returned.
At the same time, I have a table in Oracle called Manifest. This table contains the following fields:
Envelope
DateSentOut
DateReturned
I need to write something that imports the ReturnedFile.txt into a temporary Oracle table named UploadTemp, and then compares the data in the Envelope field from UploadTemp with the Envelope field in Manifest. If it's a match, then the DateReturned field in Manifest needs updated with the DateReturned field in UploadTemp.
I've done this with SQL Server no problem, but I've been trying for two days to make this work with Oracle and I can't figure it out. I've been trying to use SQL*Loader, but I can't even get it to run properly on my machine.
I did create a Control file, saved as RetFile.ctl. Below is the contents of the CTL file:
LOAD DATA
INFILE 'C:\OracleTest\ReturnedFile.txt'
APPEND
INTO TABLE UploadTemp
FIELDS TERMINATED BY "'"
ENVELOPE,
DATERETURNED
If I could get SQL*Loader running, below is the code I came up with to import the text file and then to do the compare to the Manifest table and update as appropriate:
sqlldr UserJoe/Password123 CONTROL=C:\OracleTest\RetFile.ctl LOG=RetFile.log BAD=RetFile.bad
update Manifest m set m.DateReturned =
(select t.DateReturned
from UploadTemp t
where m.Envelope = t.Envelope
That's all I got. As I said, I can't find a way to test it and I have no idea if it's even close.
PLEASE...can anyone assist me? Am I even close on this thing?
JoeIf your ReturnedFile.txtfile is comma separated then you need TERMINATED BY "," not TERMINATED BY "'" in your control file. If there happens to not be an ending comma in any row, then you also need to add TRAILING NULLCOLS to your control file. You should also use a date format for your date in your control file that corresponds to the date format in your ReturnedFile.txt file, in case it does not match the date format on your system. You need to add a WHERE EXISTS clause to your update statement to prevent any rows that do not match from having the DateReturned updated to a null value. Please see the example below. If this does not help then please do a copy and paste as I did, that includes a few rows of sample data and table structure. It would also help to see your SQL*Loader log file or a SQL*Loader error message. If you can't get SQL*Loader to run properly, then you may have other issues, such as file permissions at the operating system level. There are also other options besides the methods below. For example, you could use an external table, instead of SQL*Loader, if your ReturnedFile.txtfile is on your serer, not your client. You could also use merge instead of update.
SCOTT@orcl_11gR2> host type returnedfile.txt
env2,03-07-2013
env3,04-07-2013
env4,05-07-2013
SCOTT@orcl_11gR2> host type retfile.ctl
LOAD DATA
INFILE 'ReturnedFile.txt'
APPEND
INTO TABLE UploadTemp
FIELDS TERMINATED BY ","
trailing nullcols
(ENVELOPE
, DATERETURNED date "dd-mm-yyyy")
SCOTT@orcl_11gR2> create table uploadtemp
2 (envelope varchar2(15),
3 datereturned date)
4 /
Table created.
SCOTT@orcl_11gR2> create table Manifest
2 (Envelope varchar2(15),
3 DateSentOut date,
4 DateReturned date)
5 /
Table created.
SCOTT@orcl_11gR2> insert all
2 into manifest values ('env1', sysdate-7, sysdate-3)
3 into manifest values ('env2', sysdate-6, null)
4 into manifest values ('env3', sysdate-5, null)
5 select * from dual
6 /
3 rows created.
SCOTT@orcl_11gR2> select * from manifest
2 /
ENVELOPE DATESENTO DATERETUR
env1 28-JUN-13 02-JUL-13
env2 29-JUN-13
env3 30-JUN-13
3 rows selected.
SCOTT@orcl_11gR2> host sqlldr scott/tiger CONTROL=RetFile.ctl LOG=RetFile.log BAD=RetFile.bad
SQL*Loader: Release 11.2.0.1.0 - Production on Fri Jul 5 13:15:06 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 3
SCOTT@orcl_11gR2> select * from uploadtemp
2 /
ENVELOPE DATERETUR
env2 03-JUL-13
env3 04-JUL-13
env4 05-JUL-13
3 rows selected.
SCOTT@orcl_11gR2> update Manifest m
2 set m.DateReturned =
3 (select t.DateReturned
4 from UploadTemp t
5 where m.Envelope = t.Envelope)
6 where exists
7 (select t.DateReturned
8 from UploadTemp t
9 where m.Envelope = t.Envelope)
10 /
2 rows updated.
SCOTT@orcl_11gR2> select * from manifest
2 /
ENVELOPE DATESENTO DATERETUR
env1 28-JUN-13 02-JUL-13
env2 29-JUN-13 03-JUL-13
env3 30-JUN-13 04-JUL-13
3 rows selected. -
Data type with large size in a table and updating it
Hi guys,
i am working on a requirement in which i need to create 4 tables. Here, 2 tables will be updated by the user and a program will update this content to the other 2 table.
2 days before i posted a query on this, Previously i stucked on a part where, table need to entries with size char 400 and char 9000. As from the reply, i changed it to STRING with which table was sucessfully created and i was able to update data through a report program.
Now we ned to provide an sm30 option to users, so they can insert new contents and update the status of old contents. But when i tried this table maintanance generator, i got an error that table contains string, so maintanance generator cannot be done ! i changed the data type to rawstring also. Now maintanance generator got saved, but when i open the table in sm30, i am getting dump saying tht table is using string/char etc.
can anyone tell me what data type to use in this scenario with which we can enter data through sm30 ?Hi Kithu,
you can use STRING (or XSTRING) fields. Then there is no limit on the field size. As long as it is not (fully) filled with data, no space is wasted.
The disadvantage is that STRING type data are treated as 'deep' structures. That leads to some trouble in the definition of interfaces. Give it a try!
Regards,
Clemens -
Is it possible to create an invoive that keeps a running total in one column and in another column keep total of monies spent from a starting amount of funding?
Hi Sara,
Many thanks for your reply. We just brought Adobe Acrobat XI Pro complete
with Adobe Forms Central, My manager asked whether I could use the forms
part to create a summary tracking sheet for all of our contracts.
Having looked at it I could see how to create a table that in the first
column deleted costs from a starting fund, and in the last keeps a running
total of all monies spent.
I agree, Excel does seem to be much better suited to the task. I was try
trying to comply with her request
Regards, -
Insert One Word Document into another using OLE ABAP
Hi,
I want to insert one word document into another Word Document called by OLE ABAP.
ie.first word document having 6 pages have been displayed and I want first page of
second document as a 7th page.I want to dispaly the entire data in one document.
Hope to get the reply soon.
Thanks & Regards,
Divya.T.code :- DWDM
u can check OLE and OFFICE INTEGRATION tree have so many demo report
Report :- RSOLETT1
Edited by: Krupaji on Feb 18, 2010 2:00 PM -
After move tables and index another tablespace, indexes got unusable?
Hi,
I moved table and indexes another tablespace. After move many indexes got unusable state. I couldn't understand thiis?
How can I make them again usable?
regards and thanks?hi,
check this query below
create table test (id number(10));
create table succeeded.
insert into test values (10);
1 rows inserted
commit;
create index test_indx on test(id);
select index_name, status from user_indexes
where table_name = 'TEST';
INDEX_NAME STATUS
TEST_INDX VALID
alter table test move tablespace users;
select index_name, status from dba_indexes
where table_name = 'TEST';
INDEX_NAME STATUS
TEST_INDX UNUSABLE
rebuliding index
alter index test_indx rebuild
alter index test_indx succeeded.
then check
select index_name, status from user_indexes
where table_name = 'TEST';
INDEX_NAME STATUS
TEST_INDX VALID -
how can I remove the Apple ID authorization only on one computer and authorize another in his place?
De-authorize the computer in question.
Then authorize the new computer.
Or de-authorize all computers and authorize only the ones that actually exist. -
i was trying to restore my itouch because it showed on my itouch the itunes bar on top and the charger on bottom so i went on itunes and when i pressed "restore" and then pressed "restore and update", another sign popped up saying "The ipod "ipod" could not be restored. The disk you are attempting is full. Removing files and empty the recycle bin will free up additional space. What do I do?!?!?! please help me ASAP
Hi
I followed this guy's instructions and it worked:
http://evsiphone.blogspot.com/2009/05/iphone-iphone-could-not-be-restored.html
I did disable the security (AVG and Zone Alarm) when I tried on my own PC. My wife's laptop which eventually got it working also uses AVG and Zone Alarm but on an XP O/S whereas my PC is Vista - maybe this is why.
Cheers for you help.
Andy
Message was edited by: bigbadandy
Maybe you are looking for
-
I just picked up a used Mac Pro 1,1 (2006). It has 2x2.0 GHz dual-core processors and 5GB of RAM with the 7300GT card. In this configuration, the machine was running perfectly. I, of course, wanted to upgrade.... I ordered a pair of 5160 3.0GHz pr
-
Error in installing Application server
Hi all, I am trying to install application server for the first time. while installing I am getting the error in the REGISTER with Internet directory screen, It has two fields to enter 1. HOST : I assume machine name in which the S/w is getting insta
-
IBook not connecting to the Internet
I have a weird problem with my iBook G4. I cannot get access to the Internet at all. I connect using a TimeCapsule. In total I do have 3 Macs, 2 of them connect just fine just my old iBook gives me headaches. It doesn't acquire a correct IP address e
-
Set password for sleeping computer
How can I set a password on my imac following sleep so no one can access except me?
-
Advice needed on getting 2-G4s up to speed
Here's my dilema; I have 2 G4s, (1)-Dual 1Ghz MDD and (2)-867Mhz QS. Both have the original Airport cards(slow speed) installed and I have a Graphite Base Station. I'd like to get both of these machines up to the current wireless speeds if possible.