Ruleframe + Updates in same table on different records
I have following problem :
Change event with DML for one column in one record have to result in an update of different records in same table
if business rule is validated, I get a problem in the cg$AUS trigger, No data found.
In the business rule (on after row triggering level), I call a procedure, which do the updates on the same table.
What do I do wrong. Do I have to start a new transaction for this ?
I hope someone can help me.
Regards
Jo-an
Jo-an,
You definitely don't have to start a new transaction, you should just use the tapi upd procedure to perform the update, as described in the Headstart User's Guide.
Could you try again and report back if you still have the problem?
kind regards,
Sandra
Similar Messages
-
How to import a table which is in mdb file(same table in different mdb's)
Hello,
how to import a table which is in mdb file(same table in different mdb's)
e.g. table 'EMPLOYEE' is in 'test.mdb' the same table 'EMPLOYEE' is in 'current.mdb'
How this can be done on click of a button on my form if the path of mdb is provided?
ThanksThis question is not related with ora dev forms, its about Microsoft Access.
Use import option (File >> Get External Data >> Import)
or use TransferDatabase action. -
Import data from few tables and export into the same tables on different db
I want to import data from few tables and export into the same tables on different database. But on the target database, additional columns have been added
to the same tables. how can i do the import?
Its urgent can anyone please help me do this?
Thanks.Hello Junior DBA,
maybe try it with the "copy command".
http://download.oracle.com/docs/cd/B14117_01/server.101/b12170/apb.htm
Have a look at the section "Understanding COPY Command Syntax".
Here is an example of a COPY command that copies only two columns from the source table, and copies only those rows in which the value of DEPARTMENT_ID is 30:Regards
Stefan -
Updating values with in the same table for other records matching conditions
Hi Experts,
Sorry for not providing the table structure(this is simple structure)
I have a requirement where i need to update the columns of a table based on values of the same table with some empid and date match. If the date and empid match then i have take these values from other record and update the one which is not having office details. I need the update query
Before update my table values are as below
Sort_num Emp_id office start_date
1 101 AUS 01/01/2013
2 101 01/01/2013
3 101 15/01/2013
4 103 USA 05/01/2013
5 103 01/01/2013
6 103 05/01/2013
7 104 FRA 10/01/2013
8 104 10/01/2013
9 104 01/01/2013
After update my table should be like below
Sort_num Emp_id office start_date
1 101 AUS 01/01/2013
2 101 AUS 01/01/2013
3 101 15/01/2013
4 103 USA 05/01/2013
5 103 01/01/2013
6 103 USA 05/01/2013
7 104 FRA 10/01/2013
8 104 FRA 10/01/2013
9 104 01/01/2013
Thanks in advanceI do not have time to create the table with data but basically you should be able to code the following
update table a
set office = ( select office from table b where b.emp_id = a.emp_id
and b.start_date = a.start_date
and b.office is not null
where exists ( [same query as in set] )
and a.office is null
I believe that will do the trick.
HTH -- Mark D Powell -- -
Updating the same row in different sessions
Hi,
I've one table application(appl_no varchar2(10), locked_user varchar2(8)) which is used to track which user is logged in at present.
As soon as any user is logged in to the system via front end, the user ID is populated to locked_user column so that no other user cannot access the same appl_no. As soon as the user exits from the front end, the locked_user is updated to null.
We've experiencing a strange behaviour in our system where one user exits from front end and at the same time(previous transaction is not committed) the same user ID opens the same application in another session, but the session session doesn't gets hanged(waiting for the lock to be released) and tries to update the same row which was locked by first user's session. We come to know this thing when the trigger on the table gets fired in both sessoins.
Now I want to know if there is any locking machanism in Oracle where the same row can be updated in 2 different sessons one after another when the first session has not committed its changes?
Thanks
DeepakAnd obviously no two sessions can update the same record at the same time
Yes I know that and I tried the same thing by myself on 2 different sql sessions which is not happening, but this is happening when the same is being done from front end(Power Builder based application).
Just wanted to check is there any possibility where this can be possible?
Thanks
Deepak -
Insert / update in same table
SQL> select * from test;
TT NAME
1 hi
1 re
1 go
2 rw
2 gh
2 lk
6 rows selected.
This is just a dummy table,but I would like to know how can I update the values of TT=2 to make it identical with the values of TT=1
The table should look like
SQL> select * from test;
TT NAME
1 hi
1 re
1 go
2 hi
2 re
2 go
In reality the records go into lacsOne way:
(untested)
Delete from Test where TT=2;
Insert into test t1
select 2, t2.name from test t2 where tt=1;Added where clause, just in case if there are more values for TT.
Message was edited by:
Sven W. -
Can Cells in the same Table have different padding ????
I have a table with 2 rows and 10 columns.
I have the cell padding set to "10", however in the far right
column I would like to have NO PADDING "0".
Anyone know how to do this?
Thank you!<td width="175" rowspan="2" valign="top" bgcolor="#990000"
class="maintext"
style="padding:0;">
(all hex color values have to be preceded by an octothorpe)
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"StarPilot1" <[email protected]> wrote in
message
news:e6cqbj$dpb$[email protected]..
> Where would I insert that code? I tried and it scrambled
my design. I am
> using a master page that affects my whole site so I want
to make sure I
> don't
> screw the whole thing up.
>
> This is the code that highlights when I select the cell
i want to affect:
>
> <td width="175" rowspan="2" valign="top"
bgcolor="990000"
> class="maintext"><a
> href="../karaoke.html"><img
> src="../images/allpurpose/graphics/karaokebanner.jpg"
width="175"
> height="500"
> border="0" /></a></td>
>
> Any ideas?
>
>
quote:
Originally posted by:
Newsgroup User
> <td style="padding:0;">
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
>
http://www.dreamweavermx-templates.com
- Template Triage!
>
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
>
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
>
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
> ==================
>
>
> "StarPilotProductions"
<[email protected]> wrote in message
> news:e6cbbt$pc6$[email protected]..
> >I have a table with 2 rows and 10 columns.
> >
> > I have the cell padding set to "10", however in the
far right column I
> > would like to have NO PADDING "0".
> >
> > Anyone know how to do this?
> >
> > Thank you!
>
>
>
>
>
> -
How can i update two block that they data source is same table .
i design user interface .
there are tow block ,they datasource is same table but differe field .
when i input a record ,i must input tow block ,then commit . for this .the total record is save in database .
how can i write those code .Trying to hide your identity?
Why do you have two separate blocks here if there are different fields in each. The feilds in a block can be spread over multiple canvases / windows so layout is not a reason.
If you are in a situation where two blocks are displaying the same record for update them you'll have the potential of data consistancy problems as well.
So explain what you're trying to do with the two separate blocks and maybe we can come up with a better way to implement it. -
Trigger to Update in the same table.
Hi,
I would like to create a trigger that when we insert into table ALL_CAPACITY_SNS_CELL1 it updates column Action on teh same table,if teher is an update, it will update the same table , column ACTION.
This is what I have attempted but seems to be technically wrong.
<pre>
create table ALL_CAPACITY_SNS_CELL1
( A varchar2,
action char(2),
date_executed date);
create or replace
TRIGGER ALL_CAPACITY_HISTORY_TRACKING
AFTER INSERT OR DELETE OR UPDATE ON ALL_CAPACITY_SNS_CELL1 FOR EACH ROW
DECLARE
v_operation VARCHAR2(10) := NULL;
BEGIN
IF INSERTING THEN
v_operation := 'I';
ELSIF UPDATING THEN
v_operation := 'U';
ELSE
v_operation := 'D';
END IF;
IF INSERTING
UPDATE ALL_CAPACITY_SNS_CELL1
SET ACTION =v_operation,
DATE_EXECUTED =sysdate ;
ELSIF UPDATING THEN
UPDATE ALL_CAPACITY_SNS_CELL1
SET ACTION =v_operation,
DATE_EXECUTED =sysdate ;
END IF;
END;
</pre>CrackerJack wrote:
But above query made all ACTION nul...so we shoudl after insert or update trigger right?Obviously it is not working. You modified my code the way it does not make sense.
IF INSERTING
THEN
:NEW.ACTION := 'I';
IF UPDATING
THEN
:NEW.ACTION := 'U';
ELSE
:NEW.ACTION := 'X';
END IF;The code above checks if trigger fired on INSERT (IF INSERTING). In THEN branch of that IF you check if trigger fired on UPDATE. It makes no sense. Now, if you would use my trigger:
SQL> create table ALL_CAPACITY_SNS_CELL1
2 ( A varchar2(1),
3 action char(2),
4 date_executed date);
Table created.
SQL> create or replace
2 TRIGGER ALL_CAPACITY_HISTORY_TRACKING
3 BEFORE INSERT
4 OR UPDATE
5 ON ALL_CAPACITY_SNS_CELL1
6 FOR EACH ROW
7 BEGIN
8 IF INSERTING
9 THEN
10 :NEW.ACTION := 'I';
11 ELSE
12 :NEW.ACTION := 'U';
13 END IF;
14 :NEW.DATE_EXECUTED := sysdate ;
15 END;
16 /
Trigger created.
SQL> insert into ALL_CAPACITY_SNS_CELL1(a) values('A')
2 /
1 row created.
SQL> insert into ALL_CAPACITY_SNS_CELL1(a) values('B')
2 /
1 row created.
SQL> alter session set nls_date_format='mm/dd/yyyy hh24:mi:ss'
2 /
Session altered.
SQL> select * from ALL_CAPACITY_SNS_CELL1
2 /
A AC DATE_EXECUTED
A I 05/13/2009 08:56:02
B I 05/13/2009 08:56:09
SQL> update ALL_CAPACITY_SNS_CELL1
2 set a = 'X'
3 where a = 'B'
4 /
1 row updated.
SQL> select * from ALL_CAPACITY_SNS_CELL1
2 /
A AC DATE_EXECUTED
A I 05/13/2009 08:56:02
X U 05/13/2009 08:57:05
SQL> update ALL_CAPACITY_SNS_CELL1
2 set a = 'Y'
3 /
2 rows updated.
SQL> select * from ALL_CAPACITY_SNS_CELL1
2 /
A AC DATE_EXECUTED
Y U 05/13/2009 08:57:21
Y U 05/13/2009 08:57:21
SQL> insert into ALL_CAPACITY_SNS_CELL1(a) values('C')
2 /
1 row created.
SQL> select * from ALL_CAPACITY_SNS_CELL1
2 /
A AC DATE_EXECUTED
Y U 05/13/2009 08:57:21
Y U 05/13/2009 08:57:21
C I 05/13/2009 08:57:53
SQL> SY. -
Insert then update on same row in bean Transaction leads to deadlock
<b>Setup Details</b>
Hibernate version: 3.1.2
EJB version: 2.0
Name and version of the database : MS SQL Server 2000
Datasource implmentation class being used : com.sap.nwmss.jdbcx.sqlserver.SQLServerDataSource
We are using SAP NetWeaver Application Server 6.0 and Hibernate 3.1.2 in our application. We have StalessSessionBeans which use Hibernate to interact with the database. We are running into a situation where the application goes into a hang state when the following flow is bein executed:
//transaction attribute = "Required"
beanMethod() {
myObj = new MyObj();
myObj.setSomeValue();
session = SessionFactory.openSession();
//id is auto generated by database
id = session.insert(myObj);
//retrieve the recently inserted obj
myUpdatedObj = session.load(id);
//modify the myUpdatedObj
myUpdatedObj.modifySomeValue();
//update using hibernate session
session.update(myUpdatedObj);
//return from method
Here's the flow:
1) In a CMT stateless session bean, there's a method which has transaction atrribute as "Required"
2) This method creates a new object and inserts it
3) Then loads this saved object and modifies some values in it
4) Then invokes the update method on the session to update this modified object in the database.
Note: We have enabled auto flush on transaction in the hibernate configuration file.
And here's what we are observing:
- The insert obtains a lock on the row as part of the transaction
- When the update is called on the same row as part of the auto flush, the update never completes. The update statement is unable to obtain a lock on the same row.
Here is some additional info:
- We have set :
session.connection().setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
hibernate.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.jndi.class">
com.sap.engine.services.jndi.InitialContextFactoryImpl
</property>
<property name="hibernate.session_factory_name">
HibernateSessionFactory
</property>
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>
<property name="hibernate.connection.datasource">jdbc/SQLPool1</property>
<property name="hibernate.connection.pool_size">25</property>
<property name="show_sql">true</property>
<property name="hibernate.connection.isolation">1</property>
<property name="hibernate.prepare_sql">true</property>
<property name="hibernate.statement_cache.size">10000</property>
<!--property name="hibernate.jdbc.use_scrollable_resultset">true</property-->
<property name="transaction.manager_lookup_class">
com.tdemand.server.util.hibernate.SAPWebASTransactionManagerLookup
</property>
<property name="hibernate.jdbc.use_get_generated_keys">
false
</property>
<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.jdbc.batch_size">1000</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
</session-factory>
</hibernate-configuration>
Any clue why the update query is having problem in completing, even though update and insert are being called from the same bean method as part of a transaction?
Here's the log:
2006-11-01 22:10:00,310 INFO [com.tdemand.server.planning.ejbs.ForecastPlanningSessionBean] - Starting save
2006-11-01 22:10:00,310 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] - saving transient instance
2006-11-01 22:10:00,310 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] - saving transient instance
2006-11-01 22:10:00,310 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] - saving [com.tdemand.generated.pojo.TdForecastPlan#<null>]
2006-11-01 22:10:00,310 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] - saving [com.tdemand.generated.pojo.TdForecastPlan#<null>]
2006-11-01 22:10:00,310 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] - executing insertions
2006-11-01 22:10:00,310 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] - executing insertions
2006-11-01 22:10:00,310 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] - Inserting entity: com.tdemand.generated.pojo.TdForecastPlan (native id)
2006-11-01 22:10:00,310 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] - Inserting entity: com.tdemand.generated.pojo.TdForecastPlan (native id)
2006-11-01 22:10:00,310 DEBUG [org.hibernate.jdbc.AbstractBatcher] - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-11-01 22:10:00,310 DEBUG [org.hibernate.jdbc.AbstractBatcher] - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-11-01 22:10:00,325 DEBUG [org.hibernate.SQL] - insert into trd0nedbo.TD_FORECAST_PLAN (ORGANIZATION_TBL_ID, USER_TBL_ID, PLAN_NAME, IS_ACTIVE, PLAN_TYPE, TIMECREATED, TIMEUPDATED, START_TIME, END_TIME, HORIZON, HORIZON_UOM, REVIEW_FREQ, ACCU_THRESHOLD, REVIEW_FREQ_UOM, FORECAST_METRIC, BASE_FORECAST, PRECISION_FORECAST, ADJUSTED_FORECAST, ORG_ID, CRON_TRIG_NAME) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) select scope_identity()
2006-11-01 22:10:00,325 DEBUG [org.hibernate.SQL] - insert into trd0nedbo.TD_FORECAST_PLAN (ORGANIZATION_TBL_ID, USER_TBL_ID, PLAN_NAME, IS_ACTIVE, PLAN_TYPE, TIMECREATED, TIMEUPDATED, START_TIME, END_TIME, HORIZON, HORIZON_UOM, REVIEW_FREQ, ACCU_THRESHOLD, REVIEW_FREQ_UOM, FORECAST_METRIC, BASE_FORECAST, PRECISION_FORECAST, ADJUSTED_FORECAST, ORG_ID, CRON_TRIG_NAME) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) select scope_identity()
2006-11-01 22:10:00,325 DEBUG [org.hibernate.jdbc.AbstractBatcher] - preparing statement
2006-11-01 22:10:00,325 DEBUG [org.hibernate.jdbc.AbstractBatcher] - preparing statement
2006-11-01 22:10:00,325 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] - Dehydrating entity: [com.tdemand.generated.pojo.TdForecastPlan#<null>]
2006-11-01 22:10:00,325 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] - Dehydrating entity: [com.tdemand.generated.pojo.TdForecastPlan#<null>]
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.LongType] - binding '6' to parameter: 1
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.LongType] - binding '6' to parameter: 1
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.LongType] - binding '1' to parameter: 2
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.LongType] - binding '1' to parameter: 2
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding 'jaikiranpai' to parameter: 3
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding 'jaikiranpai' to parameter: 3
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding 'Y' to parameter: 4
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding 'Y' to parameter: 4
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding 'RetailDCOrderForecast' to parameter: 5
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding 'RetailDCOrderForecast' to parameter: 5
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.TimestampType] - binding '2006-11-01 22:10:00' to parameter: 6
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.TimestampType] - binding '2006-11-01 22:10:00' to parameter: 6
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.TimestampType] - binding null to parameter: 7
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.TimestampType] - binding null to parameter: 7
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.TimestampType] - binding '2006-11-01 22:10:00' to parameter: 8
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.TimestampType] - binding '2006-11-01 22:10:00' to parameter: 8
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.TimestampType] - binding null to parameter: 9
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.TimestampType] - binding null to parameter: 9
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.BigDecimalType] - binding '14' to parameter: 10
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.BigDecimalType] - binding '14' to parameter: 10
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding 'DAY' to parameter: 11
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding 'DAY' to parameter: 11
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.BigDecimalType] - binding '7' to parameter: 12
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.BigDecimalType] - binding '7' to parameter: 12
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.BigDecimalType] - binding '0' to parameter: 13
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.BigDecimalType] - binding '0' to parameter: 13
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding 'DAY' to parameter: 14
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding 'DAY' to parameter: 14
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding 'MAPE' to parameter: 15
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding 'MAPE' to parameter: 15
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding null to parameter: 16
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding null to parameter: 16
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding null to parameter: 17
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding null to parameter: 17
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding null to parameter: 18
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding null to parameter: 18
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.BigDecimalType] - binding null to parameter: 19
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.BigDecimalType] - binding null to parameter: 19
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding null to parameter: 20
2006-11-01 22:10:00,341 DEBUG [org.hibernate.type.StringType] - binding null to parameter: 20
2006-11-01 22:10:00,341 DEBUG [org.hibernate.id.IdentifierGeneratorFactory] - Natively generated identity: 103
2006-11-01 22:10:00,341 DEBUG [org.hibernate.id.IdentifierGeneratorFactory] - Natively generated identity: 103
2006-11-01 22:10:00,341 DEBUG [org.hibernate.jdbc.AbstractBatcher] - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-11-01 22:10:00,341 DEBUG [org.hibernate.jdbc.AbstractBatcher] - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-11-01 22:10:00,341 DEBUG [org.hibernate.jdbc.AbstractBatcher] - closing statement
2006-11-01 22:10:00,341 DEBUG [org.hibernate.jdbc.AbstractBatcher] - closing statement"insert into aa values ('1', '2', '3','4','5',6,7);
if sql%rowcount <> 1 then
RAISE_APPLICATION_ERROR(-20999, 'insert aa err');
END IF;
/* skip some code
update aa set dept_code = '3' where fee_month = '1';
if sql%rowcount <> 1 then"
Is Dept_Code the 2nd Column in the table aa. If so then
why update the table ?
Why not Insert Into aa Values ('1', '3', '3' ......);
Have a look at the sample script which is doing Insert followed by updating the same table using the ROWID.
Test Db>desc temp;
Name Null? Type
COL1 VARCHAR2(10)
COL2 VARCHAR2(10)
COL3 VARCHAR2(10)
COL4 VARCHAR2(10)
ID NUMBER
Test Db>select * from temp;
no rows selected
Test Db>get t1
1 Set ServerOutput On Size 999999;
2 Declare
3 lRow Varchar2(50);
4 Begin
5 Insert Into Temp (Col1, Col2, Col3, Col4, Id)
6 Values ('A', 'B', 'C', 'D', 100)
7 RETURNING RowId Into lRow;
8 Dbms_Output.Put_Line ('RowId = ' || lRow);
9 Update Temp Set col2 = 'B1'
10 Where RowId = lRow;
11 Dbms_Output.Put_Line ('Row Updated');
12* End;
13 /
Test Db>@t1
RowId = AAAKsqAAJAAAEbsAAG
Row Updated
PL/SQL procedure successfully completed.
Test Db>select * from temp;
COL1 COL2 COL3 COL4 ID
A B1 C D 100
-- Shailender Mehta -- -
Help in query required – Insert, Select in same table
Hi All
I need your help on writing the queries effectively.
Oracle Version: 10.2.0.3.0
OS: UNIX
I have a table METRICS_TBL as mentioned below.
CYCLE_DATE METRICS VALUE
08/17/2008 COST-TV 100
08/17/2008 COST-NEWSPAPER 50
08/17/2008 COST-POSTALMAIL 25
08/17/2008 PROD-TV 10
08/17/2008 PROD-NEWSPAPER 25
08/17/2008 PROD-POSTALMAIL 5
Based on the above data, I need to append (Insert into METRICS_TBL select from METRICS_TBL) the same table with the records as mentioned below.
08/17/2008 COSTPERPROD-TV 10
08/17/2008 COSTPERPROD-NEWSPAPER 2
08/17/2008 COSTPER PROD-POSTALMAIL 5
Basically, I need to calculate Cost per Product for each category. Depending upon the available metrics, metrics also should be changed like COSTPERPROD and values should be Cost/prod under each category.
Can somebody help me with the query.
ThanksSQL> WITH t AS
2 (
3 SELECT TO_DATE('8/17/2008', 'MM/DD/YYYY') AS CYCLE_DATE, 'COST-TV' AS METRICS, 100 AS VALUE
4 FROM DUAL
5 UNION ALL
6 SELECT TO_DATE('08/17/2008', 'MM/DD/YYYY'), 'COST-NEWSPAPER', 50
7 FROM DUAL
8 UNION ALL
9 SELECT TO_DATE('08/17/2008', 'MM/DD/YYYY'), 'COST-POSTALMAIL', 25
10 FROM DUAL
11 UNION ALL
12 SELECT TO_DATE('08/17/2008', 'MM/DD/YYYY'), 'PROD-TV', 10
13 FROM DUAL
14 UNION ALL
15 SELECT TO_DATE('08/17/2008', 'MM/DD/YYYY'), 'PROD-NEWSPAPER', 25
16 FROM DUAL
17 UNION ALL
18 SELECT TO_DATE('08/17/2008', 'MM/DD/YYYY'), 'PROD-POSTALMAIL', 5
19 FROM DUAL)
20 SELECT COST.CYCLE_DATE, 'COSTPERPROD-' || SUBSTR(COST.metrics, 6) AS Metrics,
21 COST.VALUE / prod.VALUE AS COSTPERPROD
22 FROM t COST, t prod
23 WHERE COST.CYCLE_DATE = PROD.CYCLE_DATE
24 AND COST.metrics LIKE 'COST-%'
25 AND prod.metrics LIKE 'PROD-%'
26 AND SUBSTR(COST.metrics, 6) = SUBSTR(prod.metrics, 6)
27 /
CYCLE_DA METRICS COSTPERPROD
17.08.08 COSTPERPROD-NEWSPAPER 2
17.08.08 COSTPERPROD-POSTALMAIL 5
17.08.08 COSTPERPROD-TV 10 -
Saving data in same table simultaneously
Hi All
I have a question and here it goes. Suppose I have two users who are updating the same table through forms and Saving or commiting at the same time, exactly same time. What will happen in this kind of situation. Both of them will get error or one will get and the other will be able to commit or both will commit. Though i am quite sure that both cant commit at the same time. So my question to all is what will happen in this kind of a situation and what can i do to avoid this kind of situation. I have heard something about On-Lock trigger. Does this comes into picture during this situation.
Any kind of suggestion is appreciated. Thanks in advance.Thanks Francois
<<<You can delay this locking process to the commit time.>>>
1. I am sorry but i couldnt figure out what you mean by this.
2. Also if suppose i overload the ON-LOCK trigger, i will writing a code to throw an error msg to both the users and ask them to try later.
3. By the way, is there a way by which i can just randomly select one of the user to have commit first and then process commit for the second one.
Please advise. Thanks for the help. -
How can I update the trigger table?
I need a insert trigger on a table and also wants to insert the result value in one of its field.
it gives mutating error........
so wots the way of updating it? how can i update the same table.For example like this (inside the BEGIN/END section of the trigger):
:NEW.Col2 := :NEW.Col1;
C. -
Copy values from a filed to another in different blocks in same table
Hi All,
How to copy value from a filed to another field in different blocks in same form ?
example if i change value in Field A of block 1 it should reflect in Field B block 2 and again if i change in Field B block 2 it should reflect in Field A of block 1.
values will change twice or thrice then it will not change. It is happening like that.
how to do this ?
RegardsSame table / different blocks
I guess, both blocks will be marked for update, and when your user presses commit, the same table will be updated twice!
Are you sure that this is what you want to do? Is the same record current in both blocks? If so, you better use 1 block (it can be spread over several canvases and windows) and synchronize the items with the "synchronize item" property.
Anyway: If you can't apply the synchronize-property bcos the items are in different blocks, you can synchronize with 2 when-validate-item triggers.
Wolfram -
Triggers to Update rows in the same table
Hi,
I have a table called as "Cal" which has the following fields
CALID
Description
RecurringID
There will be many records with the same recurring id and If the Description field is Updated, then I would like to Update the same description to all the records with the same recurring id (same table). I have tried it with triggers and the I get the ORA-00036 Maximum number of Recursive SQL reached error.
I have a a row level trigger which captures the change and I use the statment level trigger to update the description field (same table) and I get the error mentioned above.
Thx in advance
RaviI have three kind of suggestion.
(1) Use session variables in a package as flag for prevention from infinitely recursive calling.
(2) Use temporary tables for similar reason.
(3) Use instead-of-trigger (need to create view).
Maybe you are looking for
-
Compile 9076 with LabVIEW 2014 Worked good with 2012 SP1
An internal software error has occurred. Please contact National Instruments technical support at ni.com/support with the following information: Error 7 occurred at Open VI Reference in nirviOpenVIRefByNameOrPath.vi->niFpgaRemapObjsAndListIfUnderXNod
-
HT1270 Please confirm macbook pro early 2011
I read in document of apple and on apple web, it write maximum Ram 8GB, i don't understand 8GB for 2 slot (2X4=8GB) or 8GB for one slot (2X8=16GB). please help me to make clear? thanks
-
Amount field KBETR mandatory in VA01
Hello Gurus, Can you guys give me any hints on how can I set the field "amount" (KBETR) in VA01 as a mandatory field? Already tried the incompleteness procedure and pricing, but no luck so far... Thanks! Douglas Haraguchi
-
Hi All, I am working in CRM-ISU projects...Kindly let me know any requirements are there in your organisation. I want to apply... My contact details are there at my business card. Regards, Shiv Kumar Edited by: Shiva Kumar on May 5, 2008 4:47 PM
-
it should be so easy !!!! why cant i do it ? i use preview to view one photo of many in a folder, i then goto VIEW and select SLIDESHOW, the photo fills the screen, fair enough, but what do i have to do to view a slideshow of ALL the files in the sam