A trigger that changes an insert into an update?
This is probably a quite unusual question, but is it possible to create a trigger that changes an insert into an update?
So, if someone tries to do something like this:
INSERT INTO SOME_TABLE (column1, column2, column3) VALUES (value1, value2, value3);
...the trigger is able to change it into:
UPDATE SOME_TABLE column1=value1, column2=value2, column3=value3 WHERE ID=1;
Can it be done?
Hi,
You can do things like that in an INSTEAD OF INSERT trigger.
See the PL/SQL manual for details:
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/create_trigger.htm#sthref2864
INSTEAD of triggers only work on views. Of course, you can create a view as "SELECT * FROM some_table" just so you can use an INSTEAD OF trigger.
Similar Messages
-
Trigger that makes concatenation rows into cols and inserts to another tab.
Hi,
I have a trigger to do. Let me explain you how everything looks like in my DB.
TABLE A
O_ID | NAME
1 | A_Name1
2 | A_Name2
3 | A_Name3
4 | A_Name4
TABLE B
O_ID | NAME | DATE
1 | ATT_15 |2011-01-01
1 | ATT_16 |2011-01-02
2 | ATT_15 |2011-03-03
4 | ATT_19 |2011-03-05
TABLE C (dictionary)
P_ID | P_NAMEATTRIBUTE
1 | P1
2 | P2
3 | P3
4 | P4
TABLE D
O_ID | P_ID
1 | 1
1 | 2
1 | 4
2 | 3
2 | 4
4 | 2
Basicly, all I'm trying to do is make a trigger based on:
When you update Table A do an insert into Table B. What should be inserted?
All ID’s from table C that matches trough TABLE D
A.O_ID = D.O_ID and C.P_ID = D.P_ID but concatenated.
I would like to have in this case inserted into table B records like that:
O_ID | P_ID | P_NAMEATTRIBUTE
1 | 1 2 | P1 P2 P4
2 | 3 4 | P3 P4
4 | 2 | P2
Let's hope it's comprehensive. :)
Regards!nodex wrote:
I have tried to fire procedure from trigger. It works almost fine but there is always one row less than expected. I tried to reconfigure trigger in many ways but it didn't help.I meant show us an example your code with some data so we can see what you're doing.
It's not really hard to concatenate rows into columns (wm_concat e.g.). It's hard to store it in a trigger.I wouldn't use wm_concat as it is an unsupported function, which can render your whole system unsupported by Oracle if the issue is found to be due to you using that. Also, Oracle can choose to change the functionality of that function in later versions if they want which could effect your expected output.
In 10g or below, you should use sys_connect_by_path method to aggregate data. In 11gR2 there is the new LISTAGG analytical function.
Saying "It's hard to store it in a trigger" doesn't tell us anything. Why is it hard? What problem are you experiencing? -
I have been creating online tutorials for my University's student organization and events department and accesibility issues require that all posted video or tutorials be captioned. This requirement was the main reason that my office purchased Captivate, so I am very hopeful that there is a means to caption video that I insert into a Captivate project. Please let me know.
I sort of asked the same question a while back and I'm wondering if you have done the same as me...I kind of answered my own question:
see this post: http://forums.adobe.com/thread/675448
Hope that helps, although I never got an answer to my additional question on that thread -
Urgent : Performance Issue DELETE , INSERT INTO SELECT, UPDATE
Hi,
NEED ASSISTANCE TO OPTIMIZE THE INSERT STATEMENT (insert into select):
=================================================
We have a report.
As per current design following steps are used to populate the custom table whcih is used for reporting purpose:
1) DELETE all the recods from the custom table XXX_TEMP_REP.
2) INSERT records in custom table XXX_TEMP_REP (Assume all the records related to type A)
using
INSERT..... INTO..... SELECT.....
statement.
3) Update records in XXX_TEMP_REP
using some custom logic for the records populated .
4) INSERT records in custom table XXX_TEMP_REP (Records related to type B)
using
INSERT..... INTO..... SELECT.....
statement.
Stats gathered related to Insert statement are:
Event Wait Information
SID 460 is waiting on event : db file sequential read
P1 Text : file#
P1 Value : 20
P2 Text : block#
P2 Value : 435039
P3 Text : blocks
P3 Value : 1
Session Statistics
redo size : 293.84 M
parse count (hard) : 34
parse count (total) : 1217
user commits : 3
Transaction and Rollback Information
Rollback Used : 35.1796875 M
Rollback Records : 355886
Rollback Segment Number : 12
Rollback Segment Name : _SYSSMU12$
Logical IOs : 1627182
Physical IOs : 136409
RBS Startng Extent ID : 14
Transaction Start Time : 09/29/10 04:22:11
Transaction_Status : ACTIVE
Please suggest how this can be optimized.
Regards,
NarenderHello,
Is there any relation with the Oracle Forms tool ?
Francois -
DataGrid not reflecting changes after INSERT into Table. Delete from Table does.
Wow, it's been a while.
Hope you guys can help.
This is my DataGrid:
<DataGrid DataContext="{StaticResource TableAssetsViewSource}" ItemsSource="{Binding}" x:Name="TableAssetsDataGrid" AutoGenerateColumns="False" EnableRowVirtualization="True" Margin="15,10,10,10" RowDetailsVisibilityMode="VisibleWhenSelected" Grid.Column="1" HeadersVisibility="Column" CanUserResizeRows="False" IsReadOnly="True">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness" Value="0"/>
</Style>
</DataGrid.CellStyle>
<DataGrid.Columns>
<DataGridTextColumn x:Name="NodeColumn" Binding="{Binding node}" Header="VS Number" Width="*"/>
<DataGridTextColumn x:Name="SerialColumn" Binding="{Binding serial}" Header="Serial Number" Width="*"/>
<DataGridTextColumn x:Name="NameColumn" Binding="{Binding name}" Header="Asset Name" Width="*"/>
<DataGridTextColumn x:Name="TypeColumn" Binding="{Binding type}" Header="Asset Type" Width="*"/>
<DataGridTextColumn x:Name="_dateColumn" Binding="{Binding date}" Header="Date Allocated" Width="*"/>
<DataGridTextColumn x:Name="PoColumn" Binding="{Binding po}" Header="Purchase Order" Width="*"/>
</DataGrid.Columns>
</DataGrid>
This is where I add a new Row to the Table:
Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
Dim cbblocation As ComboBox = Me.FindName("LocationComboBox")
Dim row As DataRowView = DirectCast(cbblocation.SelectedItem, DataRowView)
Dim cbbtext As String = row.Item("node")
Dim cbbtype As ComboBox = Me.FindName("comboBoxType")
Dim cbbtext2 As String = cbbtype.Text
Dim RETAILISOAMDDataSet As Retail_ISO_AMD.RETAILISOAMDDataSet = CType(Me.FindResource("RETAILISOAMDDataSet"), Retail_ISO_AMD.RETAILISOAMDDataSet)
Dim RETAILISOAMDDataSetTableAssetsTableAdapter As Retail_ISO_AMD.RETAILISOAMDDataSetTableAdapters.tableAssetsTableAdapter = New Retail_ISO_AMD.RETAILISOAMDDataSetTableAdapters.tableAssetsTableAdapter()
RETAILISOAMDDataSetTableAssetsTableAdapter.AddNewAsset(cbbtext, txbSerial.Text, txbName.Text, cbbtext2, Date.Today, txbPO.Text)
node = cbbtext
Dim mp As New MainPage
mp.RefreshGrid(node)
Me.Close()
End Sub
The RefreshGrid method:
Public Sub RefreshGrid(node As String)
Dim RETAILISOAMDDataSet As Retail_ISO_AMD.RETAILISOAMDDataSet = CType(Me.FindResource("RETAILISOAMDDataSet"), Retail_ISO_AMD.RETAILISOAMDDataSet)
Dim RETAILISOAMDDataSetTableAssetsTableAdapter As Retail_ISO_AMD.RETAILISOAMDDataSetTableAdapters.tableAssetsTableAdapter = New Retail_ISO_AMD.RETAILISOAMDDataSetTableAdapters.tableAssetsTableAdapter()
RETAILISOAMDDataSetTableAssetsTableAdapter.FillByNode(RETAILISOAMDDataSet.tableAssets, node)
Dim TableAssetsViewSource As System.Windows.Data.CollectionViewSource = CType(Me.FindResource("TableAssetsViewSource"), System.Windows.Data.CollectionViewSource)
Dim be As BindingExpression = BindingOperations.GetBindingExpression(TableAssetsViewSource, CollectionViewSource.SourceProperty)
be.UpdateTarget()
End Sub
And this is what I use to delete a row from the table (and without doing anything special, the DataGrid auto-updates with the changes):
Private Sub Button_Click_4(sender As Object, e As RoutedEventArgs)
If TableAssetsDataGrid.SelectedIndex = -1 Then
MsgBox("You have selected nothing to Delete!", MsgBoxStyle.OkOnly, "Nothing Selected")
Else
Dim dgv As DataGridTextColumn = Me.FindName("NodeColumn")
Dim row As DataRowView = DirectCast(Me.TableAssetsDataGrid.SelectedItem, DataRowView)
Dim dgvText As String = row.Item("node")
Dim dgv2 As DataGridTextColumn = Me.FindName("SerialColumn")
Dim row2 As DataRowView = DirectCast(Me.TableAssetsDataGrid.SelectedItem, DataRowView)
Dim dgvText2 As String = row.Item("serial")
Dim dgv3 As DataGridTextColumn = Me.FindName("NameColumn")
Dim row3 As DataRowView = DirectCast(Me.TableAssetsDataGrid.SelectedItem, DataRowView)
Dim dgvText3 As String = row.Item("name")
Dim dgv4 As DataGridTextColumn = Me.FindName("TypeColumn")
Dim row4 As DataRowView = DirectCast(Me.TableAssetsDataGrid.SelectedItem, DataRowView)
Dim dgvText4 As String = row.Item("type")
Dim dgv5 As DataGridTextColumn = Me.FindName("_dateColumn")
Dim row5 As DataRowView = DirectCast(Me.TableAssetsDataGrid.SelectedItem, DataRowView)
Dim dgvText5 As String = row.Item("date")
Dim dgv6 As DataGridTextColumn = Me.FindName("POColumn")
Dim row6 As DataRowView = DirectCast(Me.TableAssetsDataGrid.SelectedItem, DataRowView)
Dim dgvText6 As String = row.Item("po")
Dim RETAILISOAMDDataSet As Retail_ISO_AMD.RETAILISOAMDDataSet = CType(Me.FindResource("RETAILISOAMDDataSet"), Retail_ISO_AMD.RETAILISOAMDDataSet)
Dim RETAILISOAMDDataSetTableAssetsTableAdapter As Retail_ISO_AMD.RETAILISOAMDDataSetTableAdapters.tableAssetsTableAdapter = New Retail_ISO_AMD.RETAILISOAMDDataSetTableAdapters.tableAssetsTableAdapter()
RETAILISOAMDDataSetTableAssetsTableAdapter.RemoveAsset(dgvText, dgvText2, dgvText3, dgvText4, dgvText5, dgvText6)
Dim cbb As ComboBox = Me.FindName("cbbLocation")
Dim row7 As DataRowView = DirectCast(cbb.SelectedItem, DataRowView)
Dim cbbtext As String = row.Item("node")
RefreshGrid(cbbtext)
End If
End Sub
--------- End of Edit
It is bound to a Dataset which gets it's data from a SQL Database.
Loading the Data and Filtering the data based on certain conditions work 100%. The problem I am having is as follows:
I have a form on the Page that takes input and inserts a row into the Database. When this happens, the DataGrid won't automatically reflect the changes (even if I recall the Fill Method of the Dataset). No matter what I do, I have to refresh the entire page
and THEN Fill the Dataset to see any changes.
This is what strikes me as odd...
When I do a delete row operation on the Database (Custom Method on the Dataset with conditions), and just Fill the Dataset again (without doing anything special), the row deletes and the changes is reflected IMMEDIATELY.
What am I doing wrong here? Why would Delete Row reflect the changes on the DataGrid but no Insert Row?
Thanks in Advance.
(P.S. I am very rusty with my developing skills, I haven't done this in YEARS)>>And what about the the most important question, how exactly is TableAssetsViewSource defined in the XAML markup and what is
its Source property set or bound to? And what about the reproducable sample...?
Here is the Markup of the TableAssetsViewSource:
<Page.Resources>
<local:RETAILISOAMDDataSet x:Key="RETAILISOAMDDataSet"/>
<CollectionViewSource x:Key="TableRegionsViewSource" Source="{Binding tableRegions, Source={StaticResource RETAILISOAMDDataSet}}"/>
<CollectionViewSource x:Key="TableLocationsViewSource" Source="{Binding tableLocations, Source={StaticResource RETAILISOAMDDataSet}}"/>
<CollectionViewSource x:Key="TableAssetsViewSource" Source="{Binding tableAssets, Source={StaticResource RETAILISOAMDDataSet}}"/>
</Page.Resources>
The ItemsSource of the DataGrid is bound to the TableAssetsViewSource:
<DataGrid DataContext="{StaticResource TableAssetsViewSource}" ItemsSource="{Binding}" x:Name="TableAssetsDataGrid" AutoGenerateColumns="False" EnableRowVirtualization="True" Margin="15,10,10,10" RowDetailsVisibilityMode="VisibleWhenSelected" Grid.Column="1" HeadersVisibility="Column" CanUserResizeRows="False" IsReadOnly="True">
Just remember, this code was auto-generated with the drag & drop onto the Page, so I did little in terms of setting the actual bindings.
All in all, what I have done so far works as intended, except that when I want to add a row to the table it does not reflect, and that it only shows after refreshing/restarting the application.
I will try and put together a reproducable sample. -
FRM-40602: Cannot insert into or update data in a view
Hi all!
I have a form based on a view and I want to get rid off this message.
I set the properties blocks query only but it still doesn't work.
Does someone met with this situation?
Many thanks!Hello
I've just been messing about with a similar problem. Basically, I have a view that involves a join across two tables, I have a data block in my form that's based on the view, and I've written an INSTEAD OF trigger to insert/update/delete from the two tables.
I was getting the error message 'Cannot insert or update data in a view', and it turned out that the error was happening because the join column between the two tables was the primary key on one of the tables, but the corresponding column on the join table had no unique key on it. This meant that Oracle couldn't establish a one-to-one relationship between rows in the view and rows in the underlying tables. The column on the join table was in fact unique on that table, and adding a unique constraint on that column in the database cured the problem.
Hope that's of use.
regards
Andrew
UK -
Strange result from insert into...select query
Hello guys,
I need your preciuos help for a question maybe simple, but that I can't explain by myself!
I have a query of "insert into...select" that, as I have explained in the title, returns a strange result. In facts, If I execute ONLY the SELECT statement the query returns the expected result (so 2 rows); instead If I execute the entire statement, that is the "insert into...select", the query returns 0 rows inserted!!
Following an example of the query:
INSERT
INTO TITOLI_ORI
COD_TITOLO_RICCONS ,
D_ESTRAZIONE ,
COD_SOCIETA ,
COD_PIANO_CONTABILE ,
COD_CONTO_CONTABILE ,
COD_RUBRICATO_STATISTICO_1 ,
COD_NDG ,
NUM_ESEGUITO ,
CUR_IMPORTO_RICCONS ,
CUR_IMPORTO_BICO ,
FLG_MODIFICATO ,
CUR_NON_ASSEGNATO ,
FLG_QUOTATO ,
COD_CATEG ,
TIP_COPERTURA ,
TIPTAS_TITOLO
SELECT NEWID,
'28-feb-2111',
COD_SOCIETA,
COD_PIANO_CONTABILE,
COD_CONTO_CONTABILE,
COD_RUBRICATO_STATISTICO_1,
COD_NDG,
NUM_ESEGUITO,
CUR_VAL_IMPEGNI,
'ABC' as CUR_IMPORTO_BICO,
0 as FLG_MODIFICATO,
NULL as CUR_NON_ASSEGNATO,
FLG_QUOTATO,
COD_CATEG,
TIP_COPERTURA,
TIP_TASSO
FROM
(SELECT S.COD_SOC AS COD_SOCIETA,
S.TIP_PIANO_CNTB AS COD_PIANO_CONTABILE,
S.COD_CONTO_CNTB AS COD_CONTO_CONTABILE,
S.COD_RUBR_STAT AS COD_RUBRICATO_STATISTICO_1,
TRC.COD_RAGGR_IAS AS COD_RAGGRUPPAMENTO_IAS,
TRC.COD_NDG AS COD_NDG,
TRC.COD_ESEG AS NUM_ESEGUITO,
CAST((TRC.IMP_PLUS_MINUS_VAL/TRC.IMP_CAMB) AS FLOAT) AS CUR_VAL_IMPEGNI,
TRC.TIP_QUOTAZ AS FLG_QUOTATO,
TRC.COD_CAT_TIT AS COD_CATEG,
TIP_COP AS TIP_COPERTURA,
T.TIP_TASSO AS TIP_TASSO
FROM S_SLD_CNTB S
INNER JOIN
(SELECT DISTINCT COD_SOC,
TIP_PIANO_CNTB,
COD_CONTO_CNTB,
COD_RUBR_STAT ,
COD_INTER_TIT AS COD_INTER
FROM S_COLLEG_CONTO_CNTB_TIT
WHERE COD_SOC = 'ME'
) CCC
ON S.COD_SOC = CCC.COD_SOC
AND S.TIP_PIANO_CNTB = CCC.TIP_PIANO_CNTB
AND S.COD_CONTO_CNTB = CCC.COD_CONTO_CNTB
AND S.COD_RUBR_STAT = CCC.COD_RUBR_STAT
INNER JOIN S_TIT_RICCONS TRC
ON CCC.COD_INTER = TRC.COD_INTER_TIT
AND CCC.COD_SOC = TRC.COD_SOC
AND TRC.COD_RAGGR_IAS = RTRIM('VALUE1 ')
AND TRC.COD_RAGGR_IAS NOT IN ('VALUE2')
AND TRC.DES_TIP_SLD_TIT_RICCONS IN ('VALUE3')
AND TRC.DES_MOV_TIT = RTRIM('VALUE4 ')
AND TRC.COD_CAT_TIT = RTRIM('VALUE4 ')
AND TRC.COD_INTER_TIT = RTRIM('VALUE5')
AND '28-feb-2011' = TRC.DAT_RIF
LEFT JOIN S_TIT T
ON T.COD_INTER_TIT = TRC.COD_INTER_TIT
AND T.COD_SOC = TRC.COD_SOC
AND '28-feb-2011' = T.DAT_RIF
INNER JOIN S_ANAG_SOGG AG
ON TRC.COD_NDG = AG.COD_NDG
AND AG.COD_SOC = TRC.COD_SOC
AND '28-feb-2011' = AG.DAT_RIF
WHERE S.DAT_RIF = '28-feb-2011'
AND (S.FLG_ANULL_BICO = 0
OR S.FLG_ANULL_BICO IS NULL)
AND S.COD_SOC = 'V6'
AND LENGTH(RTRIM(S.COD_CONTO_CNTB)) = 10
AND S.TIP_PIANO_CNTB = 'V7'
AND TRC.IMP_PLUS_MINUS_VAL < 0
AND SUBSTR(S.COD_CONTO_CNTB,1,7) IN (RTRIM('VALUE8 '))
Thanks a lotRight, I have executed this steps:
- I have changed the query with the select count(*)
- Changed the insert into with the select count(*)
- Executed the insert into
These are the result:
SQL> select count(*) from TITOLI_ORI2;
COUNT(*)
1
BUT:
SQL> select * from TITOLI_ORI2;
A
0
The insert into that I've modified is this:
INSERT INTO bsc.TITOLI_ORI2
select count(*)
FROM
(SELECT bsc.NEWID,
TO_DATE('28-feb-2111','DD-MON-YYYY') as data,
COD_SOCIETA,
COD_PIANO_CONTABILE,
COD_CONTO_CONTABILE,
COD_RUBRICATO_STATISTICO_1,
COD_NDG,
NUM_ESEGUITO,
CUR_VAL_IMPEGNI,
'ABC' AS CUR_IMPORTO_BICO,
0 AS FLG_MODIFICATO,
NULL CUR_NON_ASSEGNATO,
FLG_QUOTATO,
COD_CATEG,
TIP_COPERTURA,
TIP_TASSO
FROM
(SELECT S.COD_SOC AS COD_SOCIETA,
S.TIP_PIANO_CNTB AS COD_PIANO_CONTABILE,
S.COD_CONTO_CNTB AS COD_CONTO_CONTABILE,
S.COD_RUBR_STAT AS COD_RUBRICATO_STATISTICO_1,
TRC.COD_RAGGR_IAS AS COD_RAGGRUPPAMENTO_IAS,
TRC.COD_NDG AS COD_NDG,
TRC.COD_ESEG AS NUM_ESEGUITO,
CAST((TRC.IMP_PLUS_MINUS_VAL/TRC.IMP_CAMB) AS FLOAT) AS CUR_VAL_IMPEGNI,
TRC.TIP_QUOTAZ AS FLG_QUOTATO,
TRC.COD_CAT_TIT AS COD_CATEG,
TIP_COP AS TIP_COPERTURA,
T.TIP_TASSO AS TIP_TASSO
FROM bsc.S_SLD_CNTB S
INNER JOIN
(SELECT DISTINCT COD_SOC,
TIP_PIANO_CNTB,
COD_CONTO_CNTB,
COD_RUBR_STAT ,
COD_INTER_TIT AS COD_INTER
FROM bsc.S_COLLEG_CONTO_CNTB_TIT
WHERE COD_SOC = 'ME'
) CCC
ON S.COD_SOC = CCC.COD_SOC
AND S.TIP_PIANO_CNTB = CCC.TIP_PIANO_CNTB
AND S.COD_CONTO_CNTB = CCC.COD_CONTO_CNTB
AND S.COD_RUBR_STAT = CCC.COD_RUBR_STAT
INNER JOIN bsc.S_TIT_RICCONS TRC
ON CCC.COD_INTER = TRC.COD_INTER_TIT
AND CCC.COD_SOC = TRC.COD_SOC
AND TRC.COD_RAGGR_IAS = RTRIM('HFT ')
AND TRC.COD_RAGGR_IAS NOT IN ('GPO')
AND TRC.DES_TIP_SLD_TIT_RICCONS IN ('DISPONIBILI')
AND TRC.DES_MOV_TIT = RTRIM('CONSEGNARE ')
AND TRC.COD_CAT_TIT = RTRIM('OBBLIGAZIONE ')
AND TRC.COD_INTER_TIT = RTRIM('334058')
AND '28-feb-2011' = TRC.DAT_RIF
LEFT JOIN bsc.S_TIT T
ON T.COD_INTER_TIT = TRC.COD_INTER_TIT
AND T.COD_SOC = TRC.COD_SOC
AND '28-feb-2011' = T.DAT_RIF
INNER JOIN bsc.S_ANAG_SOGG AG
ON TRC.COD_NDG = AG.COD_NDG
AND AG.COD_SOC = TRC.COD_SOC
AND '28-feb-2011' = AG.DAT_RIF
WHERE S.DAT_RIF = '28-feb-2011'
AND (S.FLG_ANULL_BICO = 0
OR S.FLG_ANULL_BICO IS NULL)
AND S.COD_SOC = 'ME'
AND LENGTH(RTRIM(S.COD_CONTO_CNTB)) = 10
AND S.TIP_PIANO_CNTB = 'IS'
AND TRC.IMP_PLUS_MINUS_VAL < 0
AND SUBSTR(S.COD_CONTO_CNTB,1,7) IN (RTRIM('P044C11 '))
Another time the strange result returns!!
And I've created the table TITOLI_ORI2 as create table TITOLI_ORI2 (a number); to contain the number result of the query. -
INSERT INTO with SELECT invalid column name error
I have a problem where I wish to update a table with only records that have changed or insert into a table with only new records. The Source table is queried using OPENQUERY as we have no staging db for this.
I have the following code (adapted from a working example):
INSERT INTO dbo.Contact
SELECT contactID, lastUpdatedDateTime
FROM
MERGE INTO dbo.Contact AS DT
USING (SELECT * FROM OPENQUERY(LINKED_SERVER,'SELECT contactID, lastUpdatedDateTime FROM Contact')) AS DS
ON (DT.ContactID = DS.ContactID)
WHEN NOT MATCHED THEN
INSERT VALUES (DS.contactID, DS.lastUpdatedDateTime)
WHEN MATCHED AND (DT.lastUpdatedDateTime <> DS.lastUpdatedDateTime) THEN
UPDATE SET DT.contactID = DS.contactID, DT.lastUpdatedDateTime = DS.lastUpdatedDateTime
OUTPUT $Action Action_Out
AS MERGE_OUT
WHERE MERGE_OUT.Action_Out = 'UPDATE';
GO
When I run this query I am getting the following errors referring to the columns in the SELECT:
Msg 207, Level 16, State 1, Line 2
Invalid column name 'contactID'.
Msg 207, Level 16, State 1, Line 2
Invalid column name 'lastUpdatedDateTime'.
Am I missing something obvious as I can't quite work out why? The Target and source definitely exist with the specified columns present in both...Hello,
The issue is because you are not outputting those values from the inner merge statement. All you are currently outputting is the action, so the error is correct as those columns do not exist.
Change your output portion to be:
OUTPUT inserted.contactID, inserted.lastUpdatedDateTime, $Action Action_Out
Then it should work.
Sean Gallardy | Blog | Microsoft Certified Master -
Insert into mdsys.cs_srs error
Hi list,
i Creating a User-Defined Coordinate System
ERROR 1: ORA-13199:
ORA-06512: at "MDSYS.MD", line 1723
ORA-06512: at "MDSYS.MDERR", line 8
ORA-06512: at "MDSYS.CS_SRS_TRIGGER", line 2
ORA-04088: error during execution of trigger 'MDSYS.CS_SRS_TRIGGER' in
INSERT INTO mdsys.cs_srs
VALUES (
'Asia_North_Lambert_Conformal_Conic',
102027,
102027,
'PROJCS["Asia_North_Lambert_Conformal_Conic",GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["False_Easting",0],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",95],PARAMETER["Standard_Parallel_1",15],PARAMETER["Standard_Parallel_2",65],PARAMETER["Latitude_Of_Origin",30],UNIT["Meter",1],AUTHORITY["EPSG","102027"]]',
null
);several days ago i have similar problem....
the solution was to define all necessary (missing) entries in the tables (in the following order):
SDO_DATUMS
SDO_COORD_OPS
SDO_COORD_OP_PARAM_VALS
SDO_COORD_REF_SYS
SDO_CS_SRS
the entries in the SDO_CS_SRS table can be automaticly updated if all other data are properly defined:
call SDO_CS.UPDATE_WKTS_FOR_EPSG_CRS(xxx);
refer to Oracle Spatial User Guide (chapter 6.8) how to insert data in all mentioned tables.
my sugestion is:
- find SRS that has similar definition like SRC you need (SRID from SDO_COORD_REF_SYS table).
- read what is written in the SDO_COORD_REF_SYS
- find all related entries in other tables
- following predefine patern from predefined oracle srid add new entries with the new values for your crs parameters
... maybe you don't have to define new datum parameters but i think the workflow is clear.
i have tried this aproach and for me everything works well. i'm using oracle 10g R2 and i have to add new projected coordinate system based on transverse mercator.
regards,
sp -
How to read the data from XML file and insert into oracle DB
Hi All,
I have below require ment.
I will receive data in the XML file. then i need to read that data and insert into oracle tables. please let me know how this can be handled.
Many Thanks.Sounds a lot like this question, only with less details.
how to read data from XML variable and insert into table variable
We can only help if you provide us details to help as we cannot see what you are doing and only know what you tell us. Plenty of examples abound on the forums that cover the topics you seek as well. -
I have a script task written in C# that creates an array of strings "arrayFields" after parsing a text file. It saves the array of strings in a DTS variable.
Each row in array represents a row is comma separated and is a row that must be inserted into a table. For example,
X and Z are fields in the table
X1, X2,....Xn
Z1,Z2,...Zn
I am using a Foreach Loop to grab each row and then Execute SQL Task to take each row from the array and insert each field per row in a table,
The SQL is something like,
INSERT dbo.table values(field1, field2,...fieldn) arrayFields?
What should this this INSERT look like?I guess you implemented
Shredding a Recordset
Based on what I understood (correct me if I am wrong) you have difficulties mapping the input parameters, if so here is the guide
http://www.sqlis.com/sqlis/post/The-Execute-SQL-Task.aspx
In short it might look like
INSERT dbo.table (ColumnA, ColumnB,...) VALUES (?,?...)
The syntax for the T-SQL INSERT is http://technet.microsoft.com/en-us/library/dd776381%28v=sql.105%29.aspx
Arthur
MyBlog
Twitter -
How do I insert cells using INSERT INTO & SET? (Excel oledb)
Updating a cell works:
oledbConnect = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\__\\test.xls;Extended Properties='Excel 12.0 Xml;HDR=NO;'");
oledbConnect.Open();
oledbCmd.Connection = oledbConnect;
string stSheetName = "Sheet2";
string sql;
sql = "UPDATE [" + stSheetName + "$A1:B1] SET F1=1";
oledbCmd.CommandText = sql;
oledbCmd.ExecuteNonQuery();
Inserting a cell does not:
sql = "INSERT INTO [" + stSheetName + "$A2:B2] SET F1=2'";
oledbCmd.CommandText = sql;
oledbCmd.ExecuteNonQuery();
I understand that inserting will add a new row ... but this doesn't work either.
sql = "INSERT INTO [" + stSheetName + "$] SET F1=3";
oledbCmd.CommandText = sql;
oledbCmd.ExecuteNonQuery();
bhs67Hi hbs67,
No, we can't use Insert into with Set, it's the basic syntax in SQL statement. Give the worksheet a header row, then use Insert into or Update syntax with the field name.
Check more information in this kb article:
https://support.microsoft.com/en-us/kb/316934?wa=wsignin1.0
If you have Office application installed on your machine, you could also automate the Excel files with Excel PIA:
How to automate Microsoft Excel from Microsoft Visual C#.NET
It's easy to insert or update cell values with the cell address.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Hi,
I`m doing an import from FDM using SqlIntegration script, as suggested in the manual. This script use rsappend, and this command has a memory limit of 2GB. When the limit was reached the process stops with error OUT OF MEMORY. Oracle suggests that I use INSERT INTO. I`m not able to execute this command using API.
Somebody has an example like that?
Thanks advanced.You are not limited to the API when it comes to database handling; however, it obviously makes your life easier.
You can use ADO and create any type of query you want.
http://msdn.microsoft.com/en-us/library/ms676589(v=VS.85).aspx
Execute is the method you'll want to focus on to execute the SQL you'd need.
http://msdn.microsoft.com/en-us/library/ms681559(v=vs.85).aspx -
Getting cache items in the order that they were inserted
Hi,
Is there a way to get the cache items in the order that they were inserted into the cache?
I tried the following but that does not work - the result is not in order of insertion...
NamedCache cache = CacheFactory.getCache("XXXX");
Set setKeys = cache.keySet();
debug("key size: " + setKeys.size());
Iterator keysIt = setKeys.iterator();
while (keysIt.hasNext())
Object object = (Object) keysIt.next();
debug("key: " +object);
debug ("----------------------------------------------\n\n\n");
Thanks
Gkhanna111 wrote:
Hi,
Is there a way to get the cache items in the order that they were inserted into the cache?
I tried the following but that does not work - the result is not in order of insertion...
NamedCache cache = CacheFactory.getCache("XXXX");
Set setKeys = cache.keySet();
debug("key size: " + setKeys.size());
Iterator keysIt = setKeys.iterator();
while (keysIt.hasNext())
Object object = (Object) keysIt.next();
debug("key: " +object);
debug ("----------------------------------------------\n\n\n");
Thanks
GHi G,
in general there is no way to do this with get/iterate calls.
Particularly because you can't define a time order in the cache as there is no shared timesource to relate to without relying on explicit cluster-wide locking which is not done in caches by default.
Best regards,
Robert -
"trigger to audit when insert fails"
Hi all ,
there was a qn thrown to me by my friend.
the qn is " I am trying to insert into a table say tab1. i want to write a trigger which will audit the date and time of insert . I want the audit table to be populated even if the insert fails ".
Is there an option to do so ..
Please let me know asap.
thanks
harshaBerfore Insert row-level autonomous trigger can help:
SQL> create table t (id number check (id < 10));
Table created.
SQL> create table t_aud (id number, ts# timestamp);
Table created.
SQL> create or replace trigger t_aud_tr
2 before insert on t
3 for each row
4 declare
5 pragma autonomous_transaction;
6 begin
7 insert into t_aud values(:new.id, systimestamp);
8 commit;
9 end;
10 /
Trigger created.
SQL> insert into t values(1);
1 row created.
SQL> select * from t_aud;
ID TS#
1 18.08.05 12:57:19,781000
SQL> insert into t values(20);
insert into t values(20)
ERROR at line 1:
ORA-02290: check constraint (SCOTT.SYS_C008240) violated
SQL> select * from t_aud;
ID TS#
1 18.08.05 12:57:19,781000
20 18.08.05 12:57:40,125000Rgds.
Maybe you are looking for
-
When I try to drag and drop to combine events in iPhoto, the drag accelerates out of control when it reaches the top or bottom of the screen. How can I slow it down?
-
Not able to connect after changing the password using ALTER VALUES clause
Hi, Just now John explained about VALUES clause in below thread. Expired Status I created a new account called SURI and tried to use the user account HR's password using VALUES clause. I was able to alter the password but not able to connect SURI wit
-
Adding scrollpane to JEditorPane
I was trying my GUI to show a .gif file on a JEditorPane but when it does so, since the .gif file is big, it takes up the whole spaceon the GUI but messes up the components underneath it as well. Then I tried using a scrollPane, but the scroll pane s
-
SMB and EPS Files (all files have .eps extensions)
HI All, We've turned off Appleshare on our Microsoft SBS Server and have all our mac clients connecting via SMB - previews of folders within apps is now much much faster and we can now have longer file names. However, all of our eps images are screwe
-
Please help me to change the language from Danish to swedish i PS CS5
please help me to change the language from Danish to swedish i PS CS5 In the program (interfaces) i can only choose Danish