How do I update a column in another block?
I have a form that has dorm room assignment information in one block--multiple rows, and a related block with check in/out information, one row for each assignment row. If the user updates the assignment information, setting a room assignment to inactive and inserting a new row for the new room assingment, then I need to update the check in/out info associated with the old room to set a 'move out by' date. I'm having difficulty doing this because the focus is usually but not always, on the new room assignment, rather then the old, when the form is committed--which makes it hard to get the correct row updated in the check in/out block. If I do a sql to update the underlying table instead, then the change doesn't necessarily show in the form. So what is the proper way to update data in an associated block when data in the master block changes?
So what is the proper way to update data in an associated block when data in the master block changes? There are a couple of ways you can do this. Which is the proper way is up to you to decide.
First, you could use the On-Update or Post-Update triggers to update the corresponding record(s). After the commit, then requery your form to display the updated records.
Second, you could use the Validation process (eg; When-Validate-Item) of the updated room to update the corresponding record(s). This is harder, because you can't use Restricted Built-ins easily with this method.
If I do a sql to update the underlying table instead, then the change doesn't necessarily show in the form.Third, you could update the corresponding record(s) through a SQL Statement and then requery the updated records.
Were it me, I think I would choose the 3rd option.
Hope this helps,
Craig B-)
If someone's response is helpful or correct, please mark it accordingly.
Similar Messages
-
HT204266 how can I update my app with another account?
how can I update my app with another account?
kambiz.fakhr wrote:
how can I update my app with another account?
Anything Downloaded with a Particular Apple ID is tied to that Apple ID and Cannot be Merged or Transferred to a Different Apple ID
Apple ID FAQs > http://support.apple.com/kb/HT5622 -
How can i update all column of table without know it's structure
hi to all
i want to make update to all columns of table with record type of this table
ex- consider the emp table and contain any number of columns
and you make record is row type of this table (emp) as emp_rec
and fech in it any record by select * from emp
and i want to update another record this the return record from data base as
update emp by using the emp_rec
i want to know how this will be acheiveIt is all written in the docs:
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/collections.htm#i20479
Although updating all columns for a table is VERY, VERY BAD practice.
Gints Plivna
http://www.gplivna.eu -
How to auto update date column without using trigger
Hi,
How to write below MYSQL query in Oracle 10g :
CREATE TABLE example_timestamp (
Id number(10) NOT NULL PRIMARY KEY,
Data VARCHAR(100),
Date_time TIMESTAMP DEFAULT current_timestamp on update current_timestamp
I need to auto update the Date_Time column without using trigger when ever i update a record.
Example shown below is from MYSQL. I want to perform the below steps in ORACLE to auto update Date_Time column.
mysql> INSERT INTO example_timestamp (data)
VALUES ('The time of creation is:');
mysql> SELECT * FROM example_timestamp;
| id | data | Date_Time |
| 1 | The time of creation is: | 2012-06-28 12:37:22 |
mysql> UPDATE example_timestamp
SET data='The current timestamp is: '
WHERE id=1;
mysql> SELECT * FROM example_timestamp;
| id | data | Date_Time |
| 1 | The current timestamp is: | 2012-06-28 12:38:55 |
Regards,
Yogesh.Is there no functionality in oracle to auto update date column without using trigger??
I dont want to update the date column in UPDATE statement.
The date column should automatically get updated when ever i execute an Update statement. -
Need to update multiple columns using another table
I have 2 tables. and i need to update rows of 1 table using another table
Table1
Serial_no. payment_date Payment_amt
101 22/11/2010 150
101 18/03/2011 355
102 15/04/2011 488
103 20/05/2011 178
102 14/06/2011 269
101 28/06/2011 505
Table2
Serial_no Charge_amt Last_paymt_dt Last_paymt_amt
101 255
102 648
103 475
I want to update Last_paymt_dt and Last_paymt_amt of table2 using Table1, I have written following update statement but it gives error that single row subquery return multiple row.
Update Table2
set (Last_paymt_dt,Last_paymt_amt) = (select max(payment_date, payment_amt) from table1
where table1.Serial_no = table2.Serial_no group by payment_amt)
kindly suggest how should i update.SQL> select * from table1
2 /
SERIAL_NO PAYMENT_DA PAYMENT_AMT
101 22/11/2010 150
101 18/03/2011 355
102 15/04/2011 488
103 20/05/2011 178
102 14/06/2011 269
101 28/06/2011 505
6 rows selected.
SQL> select * from table2
2 /
SERIAL_NO CHARGE_AMT LAST_PAYMT LAST_PAYMT_AMT
101 255
102 648
103 475
SQL> update table2
2 set (last_paymt_dt,last_paymt_amt) = (
3 select max(payment_date),
4 max(payment_amt) keep(dense_rank last order by payment_date)
5 from table1
6 where table1.serial_no = table2.serial_no
7 )
8 /
3 rows updated.
SQL> select * from table2
2 /
SERIAL_NO CHARGE_AMT LAST_PAYMT LAST_PAYMT_AMT
101 255 28/06/2011 505
102 648 14/06/2011 269
103 475 20/05/2011 178
SQL> SY. -
SQL update one column from another column
I'm looking for a way to update a SQL column with a portion
of info from another column in the same table.
example of a sql command
UPDATE table1
SET table1.columnname1 = table1.columnname2
FROM table
WHERE blah blah blah
Here's the thing... I only need a portion of the data found
in the source column. I'm not sure how I would do this then.
for example, the database has countries and states combined
into one column like this 'US-DC', 'US-CA', US-FL', etc. I want to
separate these into two columns, a country column and a state
column.... and I dont want to go though all the results and do this
line by line. How would I write the SQL command so that it puts
just the country in the country column, and puts just the state in
the state column, and it omits the dash all together.
any ideas?It depends. Are you using PHP and mySQL or ASP and SQL?
If you are using mysql and PHP you could use the following
code to loop through all records in your datatbase.
$sql="SELECT * FROM tablename"; //SET tablename to the name
of your database table.
$result=mysql_query($sql)or die(mysql_error(). " - $sql");
for($x = 0; $row=mysql_fetch_assoc($result); $x++){
//set up the variables from the table
$ID=$row['ID']; //this is the primary key
$var1=$row['contrystatecolumn']; //this is the name of the
column which holds the country-state
$var2=explode("-", $var1); //now we explode the string to get
the country and the state seperated and place the results into an
array
$country=$var2[0]; //this is the first piece of the exploded
string in the array
$state=$var2[1]; //this is the second piece of the exploded
string in the array
//now we update the database record with the new information
//remember to replace the tablename with your actual table
name and the columns country and state with the acutal names of
your columns in your table
$sql2="UPDATE tablename SET country='$country'.
state='$state' WHERE ID='$ID'";
$result2=mysql_query($sql2)or die(mysql_error() . " -
$sql2");
This code will loop through every record in your table and do
what you want very quickly.
Hope this helps
Stan Forrest
Senior Web Developer
ATG Internet -
Update table column from another
Hi,
I´m having trouble updating data from one table to another. I wish to syncronize the geometry field of the table FAROLFAROLIM from FAROLFAROLIM_OUT. By standard SQL I've tried this:
update FAROLFAROLIM f, FAROLFAROLIM_OUT ff set f.GEOM = ff.GEOMETRY
where f.IDFAROLFAROLIM = ff.IDFAROLFAROLIM
Can you help me figuring out what is wrong???
Thanks in advance
Operatordude you are doing wrong thing...
please use following command.
UPDATE FAROLFAROLIM f
SET (f.GEOM) =
( SELECT ff.GEOMETRY
FROM FAROLFAROLIM_OUT ff
WHERE f.IDFAROLFAROLIM = ff.IDFAROLFAROLIM );
cheers,
Sandy -
Update one column from another
Hi guys,
I have two columns in a table, FIRSTNAME and LASTNAME. Currently, both firstname and lastname are appearing in 'Firstname' column. I would like to split the last name from this column and insert into the 'LASTNAME' column.
For example, here's what I have currently:
Line: -----
Firstname Lastname
Peter Andre
James Dean
Watch Man
Jenna Klare
James Smith
Tina Adams
Blair Witch
Currently, my 'Lastname' column is empty. I would like to update the table to insert lastname from the 'FIRSTNAME' field into 'LASTNAME' column, so the output will look like:
Firstname Lastname
Peter Andre
James Dean
Watch Man
Jenna Klare
James Smith
Tina Adams
Blair Witch
Please help.
Thanks in advance.Hi,
maybe this,
SQL> with t As(Select 'Peter Andre' Name From Dual union all
2 Select 'James Dean' Name From Dual union all
3 Select 'Watch Man' Name From Dual union all
4 Select 'Jenna Klare' Name From Dual union all
5 Select 'James Smith' Name From Dual union all
6 Select 'Tina Adams' Name From Dual union all
7 Select 'Blair Witch' Name From Dual)
8 SELECT regexp_substr(Name,'[^ ,]+' ) First
9 , regexp_substr(Name,'[^ ,]+$') LastName
10 FROM t;
FIRST LASTNAME
Peter Andre
James Dean
Watch Man
Jenna Klare
James Smith
Tina Adams
Blair Witch
7 rows selectedor
SQL> with t As(Select 'Peter Andre' Name From Dual union all
2 Select 'James Dean' Name From Dual union all
3 Select 'Watch Man' Name From Dual union all
4 Select 'Jenna Klare' Name From Dual union all
5 Select 'James Smith' Name From Dual union all
6 Select 'Tina Adams' Name From Dual union all
7 Select 'Blair Witch' Name From Dual)
8 SELECT Substr(Name,1,Instr(Name,' ',1)-1) First
9 , Substr(Name, Instr(Name,' ',1)+1) LastName
10 FROM t;
FIRST LASTNAME
Peter Andre
James Dean
Watch Man
Jenna Klare
James Smith
Tina Adams
Blair Witch
7 rows selectedRegards,
Christian Balz
Edited by: Christian Balz on 17/06/2009 15:33 -
How can I update a JTextArea from another class
I am new to Java so forgive me if this is confusing, or if I seem to be taking an overly complex route to acheiving my goal.
I've got a JTextArea component added to a JPanel object, which is then inserted into the JFrame. I have a JMenuBar with a JMenu "file" and a JMenuItem "connect" on this same JFrame. When clicked, the actionEvent of JMenuItem "connect" calls a class "ConnectToDb" to establish a connection with the Database. On a successful connection, I want to append the String "Connection Successful" to the JTextArea component, but since the component is a part of the JPanel object, I cannot seem to get access to the JTextArea component to update it. I tried instantiating the JPanel object from within the "ConnectToDb" class and then called a method I created to set the JTextArea. No luck. Can someone give me an idea of what I need to do that would allow me to update the text of the JTextArea component from anywhere in my program? Once it has been contained in the JPanel or JFrame, can it be updated?
This is the class that establishes the simple Db Connection
package cjt;
import java.io.*;
import java.sql.*;
* Get a database connection
* Creation date: (04/01/2002 4:08:39 PM)
* @author: Yaffin
public class ConnectToDB {
public Connection dbConnection;
// ConnectToDB constructor
public ConnectToDB() {
public Connection DbConnect() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sourceURL = new String("jdbc:odbc:CJTSQL");
Connection dbConnection = DriverManager.getConnection(sourceURL, "Encryptedtest", "pass");
System.out.println("Connection Successful\n");
//this is where I originally tried to append "Connection Successful
//to the JTextArea Object in WelcomePane()
} catch (ClassNotFoundException cnfe) {
//user code
System.out.println("This ain't working because of a class not found exeption/n");
} catch (SQLException sqle) {
//user code
System.out.println("SQL Exception caused your DB Connection to SUCK!/n");
return dbConnection;
This is the JPanel that contains the JTextArea "ivjStatusArea" I am trying to update from other classes. Specifically the "ConnectToDb" class above.
package cjt;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
* Build Welcome Pane
* Creation date: (04/01/2002 3:42:50 PM)
* @author: yaffin
public class WelcomePane extends JPanel {
private JTextArea ivjtxtConnect = null;
private JLabel ivjwelcomeLbl = null;
private JTextArea ivjStatusArea = null;
* WelcomePane constructor comment.
public WelcomePane() {
super();
initialize();
* Return the StatusArea property value.
* @return javax.swing.JTextArea
private javax.swing.JTextArea getStatusArea() {
if (ivjStatusArea == null) {
try {
ivjStatusArea = new javax.swing.JTextArea();
ivjStatusArea.setName("StatusArea");
ivjStatusArea.setLineWrap(true);
ivjStatusArea.setWrapStyleWord(true);
ivjStatusArea.setBounds(15, 153, 482, 120);
ivjStatusArea.setEditable(false);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
return ivjStatusArea;
* Initialize the class.
private void initialize() {
try {
// user code begin {1}
// user code end
setName("WelcomePane");
setLayout(null);
setSize(514, 323);
add(getStatusArea(), getStatusArea().getName());
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
// user code begin {2}
// user code end
This is the main class where evrything is brought together. Notice the BuildMenu() method where the JMenuItem "connect" is located. Also notice the PopulateTabbedPane() method where WelcomePane() is first instantiated.
* The main application window
* Creation date: (04/01/2002 1:31:20 PM)
* @author: Yaffin
public class CjtApp extends JFrame {
private JTabbedPane tabbedPane;
private ConnectToDB cdb;
private Connection dbconn;
public CjtApp() {
super("CJT Allocation Application");
// Closes from title bar
//and from menu
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
tabbedPane = new JTabbedPane(SwingConstants.TOP);
tabbedPane.setForeground(Color.white);
//add menubar to frame
buildMenu();
//populate and add the tabbed pane
populateTabbedPane(dbconn);
//tabbedPane.setEnabledAt(1, false);
//tabbedPane.setEnabledAt(2, false);
getContentPane().add(tabbedPane);
pack();
* Build menu bar and menus
* Creation date: (04/01/2002 2:42:54 PM)
private void buildMenu() {
// Instantiates JMenuBar, JMenu,
// and JMenuItem.
JMenuBar menubar = new JMenuBar();
JMenu menu = new JMenu("File");
JMenuItem item1 = new JMenuItem("Connect");
JMenuItem item2 = new JMenuItem("Exit");
//Opens database connection screen
item1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//call the ConnectToDb class for a database connection
ConnectToDB cdb = new ConnectToDB();
dbconn = cdb.DbConnect();
}); // Ends buildMenu method
//Closes the application from the Exit
//menu item.
item2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}); // Ends buildMenu method
//Adds the item to the menu object
menu.add(item1);
menu.add(item2);
//Adds the menu object with item
//onto the menu bar
menubar.add(menu);
//Sets the menu bar in the frame
setJMenuBar(menubar);
} //closes buildMenu
public static void main(String[] args) {
CjtApp mainWindow = new CjtApp();
mainWindow.setSize(640, 480);
mainWindow.setBackground(Color.white);
mainWindow.setVisible(true);
mainWindow.setLocation(25, 25);
* Add tabs to the tabbedPane.
* Creation date: (04/01/2002 2:52:19 PM)
private void populateTabbedPane(Connection dbconn) {
Connection dbc = dbconn;
tabbedPane.addTab(
"Welcome",
null,
new WelcomePane(),
"Welcome to CJT Allocation Application");
tabbedPane.addTab(
"Processing",
null,
new ProcessPane(dbc),
"Click here to process an allocation");
tabbedPane.addTab(
"Reporting",
null,
new ReportPane(),
"Click here for reports");
//End
Thanks for any assistance you can provide.
YaffinThanks gmaurice1. I appreciate the response. I believe I understand your explanation. I am clear that the calling code needs access to the WelcomPane() object. I am assuming that the constructor for the calling class must have the JPanel WelcomePane() instance passed to it as an argument. This way I can refer directly to this specific instance of the object. Is this correct?
Also, where would you create the set method? I tried to create a set method as part of the WelcomePane() class, and then call it from the calling class, but it didn't seem to work. Lastly, a globally accessible object? Can you explain this concept briefly? Thanks again for your help.
yaffin -
How to union mulitple itemset column with another tables
Hi ,
i have the following table called itemset as below ,
A
;1;10;2;3;4;5;7;8
;10;2;3;4;5;8;9
;10;2;3;4;8;9
and another table called temp as below ,
B
1
2
6
and need to find the union of those 2 tables as below ,
A---------------------| B--| A Union B
;1;10;2;3;4;5;7;8 | 1 |;1;10;2;3;4;5;7;8
;1;10;2;3;4;5;7;8 | 2 |;1;10;2;3;4;5;7;8
;1;10;2;3;4;5;7;8 | 6 |;1;10;2;3;4;5;7;8;6
;10;2;3;4;5;8;9 |1 |;10;2;3;4;5;8;9;1
;10;2;3;4;5;8;9 |2 |;10;2;3;4;5;8;9
;10;2;3;4;5;8;9 |6 |;10;2;3;4;5;8;9;6
;10;2;3;4;8;9 |1 |;10;2;3;4;8;9;1
;10;2;3;4;8;9 |2 |;10;2;3;4;8;9
;10;2;3;4;8;9 |6 |;10;2;3;4;8;9;6
any help please ,
Edited by: user11309581 on Jun 26, 2011 10:43 PM
Edited by: user11309581 on Jun 26, 2011 10:47 PMwith a as (
select ';1;10;2;3;4;5;7;8' str from dual union all
select ';10;2;3;4;5;8;9' from dual union all
select ';10;2;3;4;8;9' from dual
b as (
select '1' str from dual union all
select '2' from dual union all
select '6' from dual
-- end of on-the-fly data sample
select a.str,
b.str,
case
when a.str || ';' like '%;' || b.str || ';%' then a.str
else a.str || ';' || b.str
end combined_str
from a,
b
STR S COMBINED_STR
;1;10;2;3;4;5;7;8 1 ;1;10;2;3;4;5;7;8
;1;10;2;3;4;5;7;8 2 ;1;10;2;3;4;5;7;8
;1;10;2;3;4;5;7;8 6 ;1;10;2;3;4;5;7;8;6
;10;2;3;4;5;8;9 1 ;10;2;3;4;5;8;9;1
;10;2;3;4;5;8;9 2 ;10;2;3;4;5;8;9
;10;2;3;4;5;8;9 6 ;10;2;3;4;5;8;9;6
;10;2;3;4;8;9 1 ;10;2;3;4;8;9;1
;10;2;3;4;8;9 2 ;10;2;3;4;8;9
;10;2;3;4;8;9 6 ;10;2;3;4;8;9;6
9 rows selected.
SQL> SY. -
How do I update a Nested Table of inherited Object Types?
Does anyone know why the following line (commented out) doesn't work and what I can do? Is there some way to cast the column I am trying to update? I think I am going crazy....
create or replace type person_ot as object (name varchar2(10)) not final;
create or replace type student_ot under person_ot (s_num number) not final;
create type person_tt as table of person_ot;
declare
lv_person_list person_tt;
lv_sql varchar2(1000);
ref_cur sys_refcursor;
begin
lv_sql:= 'select new student_ot(''fred'', 100) from dual
union all
select new student_ot(''sally'', 200) from dual';
open ref_cur for lv_sql;
fetch ref_cur bulk collect into lv_person_list;
close ref_cur;
dbms_output.put_line(lv_person_list.count);
for i in lv_person_list.first..lv_person_list.last loop
lv_person_list(i).name := initcap(lv_person_list(i).name ); -- This works!
lv_person_list(i).s_num := 9999; Why doesn't this line work and how can I update the column s_num ??? :-(
end loop;
end;
/Hi Tubby - You are right...It would make sense to create the Type as type of student_ot. Only problem is I am trying to keep it generic. I will include full listing to show what I am doing...
create or replace type person_ot as object (name varchar2(10)) not final;
create or replace type student_ot under person_ot (s_num number) not final;
create type person_tt as table of person_ot;
create table persons of person_ot;
declare
lv_person_list person_tt;
lv_sql varchar2(1000);
ref_cur sys_refcursor;
begin
lv_sql:= 'select new student_ot(''fred'', 100) from dual
union all
select new student_ot(''sally'', 200) from dual';
open ref_cur for lv_sql;
fetch ref_cur bulk collect into lv_person_list;
close ref_cur;
for i in lv_person_list.first..lv_person_list.last loop
lv_person_list(i).name := initcap(lv_person_list(i).name );
lv_person_list(i).s_num := 9999;* Why doesn't this line work?? :-(
end loop;
forall i in lv_person_list.first..lv_person_list.last
insert into persons values lv_person_list(i);
end;
/ -
Hi All,
How can I update the column of a table?
More precisely, I am having a table with five rows and five columns and I already put values
in all by using the program.When user clicks a button, I have to show different values in
each cells of my last column.
Thanks
priya.Hi Priya,
Lets say that you have a view controller's context structure as follows...
YBAPI_INPUT
|_OUTPUT
|_TABLE_NODE
|_COLUMN1
|_COLUMN2
|_COLUMN3
|_COLUMN4
|_COLUMN5
The follwoing code will help you in accessing values in the last row.
for (int i = 0; i < wdContext.nodeYBAPI_INPUT().nodeOUTPUT().nodeTABLE_NODE().size(); i++) {
wdComponentAPI.getMessageManager().reportSuccess(wdContext.nodeYBAPI_INPUT().nodeOUTPUT().nodeTABLE_NODE().getTABLE_NODEElementAt(i).setCOLUMN5("SET NEW VALUE HERE"));
Hope this helps.
Regards,
Rekha Malavathu -
Updating a column in the database
Hi,
My requirement is to update a column in the database just before calling
OAException.raiseBundledOAException(getExceptionList());
I am calling the above in a method in the AM
Just before calling this I am Getting the handle of the VO (which is based on an EO, which in turn is based on the table which I want to update) and setting the value of that column as null. But the value is not getting updated at the database level.
When I query the database I can still see the earlier value and not the updated value.
In some cases I can see the value on the screen is updated but the value in the database remains same.
Please let me know how do I update a column in the database and
Thanks
MeenalHi,
I guess, since an excpetion is raised the transaction is not commited automatically by the framework.
Try commiting the transaction explicity after the update and before the exception. But i dont think, its a good design... anybody any idea ?! -
How to update the COST column using another table's column
Dear All,
I have table:
table parts: pno, pname, qoh, price, olevel
table orders: ono, cno, eno, received, shipped
table odetails: ono, pno, qty
view:orders_view: ono, cno, eno, received, shipped,sum(qty*price)order_costview:odetails_view: ono, pno, qty, (qty*price)cost
after I update the price in parts, I need to update COST and ORDER_COST too. The orders_view does not have pno, qty, and price, the odetails_view does not have price, how can I update the COST and ORDER_COST. Please help and Thanks in advance!!!
I wrote the update the price in parts:
create or replace procedure change_price(ppno in parts.pno%type, pprice in parts.price%type) as
begin
update parts
set price = pprice
where pno = ppno;
end;
show errorsthis procedure works fine.
I wrote the trigger:
create or replace trigger update_orders_v
after update of price on parts
for each row
begin
update orders_view
set order_cost = sum(parts.(:new.price)*parts.qty)
where parts.pno = :new.pno;
end;
show errorsIt gives me:Errors for TRIGGER UPDATE_ORDERS_V:
LINE/COL ERROR
3/5 PL/SQL SQL Statement ignored
4/22 PL/SQL ORA-00934: group function is not allowed hereplease help!You could add the columns to the tables and then you would need a trigger to update those columns. However, you could just as easily select the price * qty to get the cost, without creating an additional column or trigger. I have no idea what you might want to do with a global temporary table. I think you need to explain what your purpose is, before any of us can suggest the best method. Since I have already demonstrated an update with a view, I will demonstrate an update with the cost column added to the odetails table and a trigger as you asked about. Notice that you will need triggers on both tables, the one that has qty and the one that has price.
scott@ORA92> create table parts
2 (pno number(5) not null primary key,
3 pname varchar2(30),
4 qoh integer check(qoh >= 0),
5 price number(6,2) check(price >= 0.0),
6 olevel integer)
7 /
Table created.
scott@ORA92> create table odetails
2 (ono number(5),
3 pno number(5) references parts,
4 qty integer check(qty > 0),
5 cost number,
6 primary key (ono,pno))
7 /
Table created.
scott@ORA92> create or replace procedure change_price
2 (ppno in parts.pno%type,
3 pprice in parts.price%type)
4 as
5 begin
6 update parts
7 set price = pprice
8 where pno = ppno;
9 end;
10 /
Procedure created.
scott@ORA92> create or replace trigger update_cost1
2 after insert or update of price on parts
3 for each row
4 begin
5 update odetails
6 set cost = qty * :new.price
7 where pno = :new.pno;
8 end update_cost1;
9 /
Trigger created.
scott@ORA92> show errors
No errors.
scott@ORA92> create or replace trigger update_cost2
2 before insert or update of qty on odetails
3 for each row
4 declare
5 v_price parts.price%type;
6 begin
7 select price
8 into v_price
9 from parts
10 where pno = :new.pno;
11 --
12 :new.cost := :new.qty * v_price;
13 end update_cost2;
14 /
Trigger created.
scott@ORA92> show errors
No errors.
scott@ORA92> insert into parts values (1, 'name1', 1, 10, 1)
2 /
1 row created.
scott@ORA92> insert into odetails values (1, 1, 22, null)
2 /
1 row created.
scott@ORA92> -- starting data:
scott@ORA92> select * from parts
2 /
PNO PNAME QOH PRICE OLEVEL
1 name1 1 10 1
scott@ORA92> select * from odetails
2 /
ONO PNO QTY COST
1 1 22 220
scott@ORA92> -- update:
scott@ORA92> execute change_price (1, 11)
PL/SQL procedure successfully completed.
scott@ORA92> -- results:
scott@ORA92> select * from parts
2 /
PNO PNAME QOH PRICE OLEVEL
1 name1 1 11 1
scott@ORA92> select * from odetails
2 /
ONO PNO QTY COST
1 1 22 242
scott@ORA92> -- select works without extra cost column or trigger:
scott@ORA92> select o.ono, o.pno, o.qty, (o.qty * p.price) as cost
2 from odetails o, parts p
3 where o.pno = p.pno
4 /
ONO PNO QTY COST
1 1 22 242
scott@ORA92> -
How can I Move data from one column to another in my access table?
I have two columns, one that stores current month’s data and one that stores last month’s data. Every month data from column 2 (this month’s data) needs to be moved to column 1 that holds last month’s data. I then null out column 2 so I can accumulates this month’s data.
I understand how to drop a column or add a column, how do I transfer data from one column to another.
Here is my trial code:
<cfquery name="qQueryChangeColumnName" datasource="#dsn#">
ALTER TABLE leaderboard
UPDATE leaderboard SET points2 = points3
</cfquery>
Unfortunately, I get the following error:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in ALTER TABLE statement.
How can I transfer my data with the alter table method?I looked up the Access SQL reference (which is probably a
good place to start when having issues with Access SQL), and
it suggests you probably need a WHERE clause in there.
I agree the documentation is a good place to start. But you should not need a WHERE clause here.
Too few parameters. Expected 1.
If you run the SQL directly in Access, what are the results? At the very least, it should provide a more informative error message..
Maybe you are looking for
-
How to create Schema Header and footer with Pipe delimiter file..?
Hi all, I have issue with creating Schema Header and footer with body file ..The file format is Pipe delimiter.. The follwing file below like is... Adapters:File Adapter(Read)-11g. 1|000|2025|SDFG|54787 1|2055|244|9566|000|000|044|2577|361147|45554|w
-
XMP – Metadata related question
I would greatly appreciate if members can assist me with the anomalies that I am noticing in InstanceID and DocumentID within XMP fields within Acrobat (pdf) files. I have some pdf files, copies of which were sent to different offices. I am under the
-
Problems sharing internet connection - works only one way...
hey all, i'm having a problem sharing my internet connection between our "new" iBook G4 and "old" iMac G5. (both machines are running 10.4.10.) i've seen several posts here that seem related, but no answers that have worked in my case. here's the gis
-
WS14000133 using BADi not able to activate
Hi Guys, We are going for Z workflow development using WS14000133.We have built a Z table for the same.Now i have deactivated all the other workflows.But when i go in the "Define starting conditions for workflows" node and i see workflows for object
-
To solve the problem I re-install Ver 4.01 and Firefox runs without a problem.