Saving data into two tables "in one transaction"
Hello everybody!
My scenario is the following: SAP PI receives message containing some data (header and MULTIPLE details data in one message) and has to transfere this data to a database.
In the database there are two tables for storing the data contained in the message: one for HEADER data and one for DETAILS data. I need to save all the data (header and MULTIPLE details data) into these two tables "in one transaction" and roll back saving of HEADER data and DETAILS data if saving of some DETAILS data has failed.
I am going to use receiver JDBC adapter for this purpose.
My questions are:
1. How can I save all the data "in one transaction"? Will it work if I transform the source message into the target message which looks something like this?
<root>
<StatementName1>
<dbTableName action=u201CUPDATE_INSERTu201D>
<table>HEADER_table</table>
<access>
<col1>val1</col1>
<col2>val2</col2>
</access>
<key1>
<col1>val1</col1>
</key1>
</dbTableName>
</StatementName1>
<StatementName2>
<dbTableName action=u201CUPDATE_INSERTu201D>
<table>DETAILS_table</table>
<access>
<col1>val1</col1>
<col2>val3</col2>
</access>
<key1>
<col1>val1</col1>
</key1>
</dbTableName>
</StatementName2>
<StatementName3>
<dbTableName action=u201CUPDATE_INSERTu201D>
<table>DETAILS_table</table>
<access>
<col1>val1</col1>
<col2>val4</col2>
</access>
<key1>
<col1>val1</col1>
</key1>
</dbTableName>
</StatementName3>
</root>
2. How to roll back saving of HEADER data in the case of saving of DETAILS data has failed?
3. What will be the response structure returned by database look like in the case of success?
Thanks,
Vika
I guess the response in my case will be something as following?
<response>
<Statement1_response>
<row>
<update_count>1</update_count>
<insert_count>0</insert_count>
</row>
</Statement1_response>
<Statement2_response>
<row>
<update_count>0</update_count>
<insert_count>1</insert_count>
</row>
<row>
<update_count>0</update_count>
<insert_count>1</insert_count>
</row>
</Statement2_response>
</response>
Vika
Similar Messages
-
Insert the data into two tables at a time.
Hi ,
i have these two tables
create table [dbo].[test1](
[test1_id] [int] identity(1,1) primary key,
[test2_id] [int] not null
create table [dbo].[test2](
[test2_id] [int] identity(1,1) primary key,
[test1_id] [int] not null
alter table [dbo].[test1]
add constraint [fk_test1_test2_id] foreign key([test2_id])
references [dbo].[test2] ([test2_id])
alter table [dbo].[test2] add constraint [fk_test2_test2_id] foreign key([test1_id])
references [dbo].[test1] ([test1_id])
I want to insert the data into two tables in one insert statement. How can i do this using T-SQL ?
Thanks in advance.You can INSERT into both tables within one Transaction but not in one statement. By the way, you would need to alter your dbo.Test1 table to allow null for first INSERT test2_id column
See sample code below:
CREATE TABLE #test1(test1_ID INT IDENTITY(1,1),test2_id INT NULL)
CREATE TABLE #test2(test2_ID INT IDENTITY(1,1),test1_ID INT)
DECLARE @Test1dentity INT
DECLARE @Test2dentity INT
BEGIN TRAN
-- Insert NULL as test2_ID value is unknown
INSERT INTO #test1(test2_ID)
SELECT NULL;
-- get inserted identity value
SET @Test1dentity = SCOPE_IDENTITY();
INSERT INTO #test2(test1_ID)
SELECT @Test1dentity;
-- get inserted identity value
SET @Test2dentity = SCOPE_IDENTITY();
-- Update test1 table
UPDATE #test1
SET test2_ID = @Test2dentity
WHERE test1_ID = @Test1dentity;
COMMIT
SELECT * FROM #test1;
SELECT * FROM #test2;
-- Drop temp tables
IF OBJECT_ID('tempdb..#test1') IS NOT NULL
BEGIN
DROP TABLE #test1
END
IF OBJECT_ID('tempdb..#test2') IS NOT NULL
BEGIN
DROP TABLE #test2
END
web: www.ronnierahman.com -
How to insert data into two tables at once using XSJS
Hello Experts,
My requirement is to insert data into two tables at once. I have a XS JS app and want to update these tables via xsjs. How can I do this ?
Is there any mechanism like sql 'transactions' also in Hana ? If yes, how can I call it via xsjs ? If not, what are the ways to populate two different tables at once.
Please advice. Any help is really appreciated.
Thanks !There is nothing special about inserting into two tables at once in XSJS. Just issue two separate SQL Statements. Don't execute the COMMIT until after both commands. That way they are all one transaction.
-
How to insert data into two tables linke with foreign key..
I have two tables
1)EMP(emp_ID,username,emp_type_code)
emp_ID is primary key, emp_type_code is a foreign key references emptype table.
2)emptype(emp_type_code,emp_type_descripton)
emp_type_code is primary key
Could anyone help me ..how to insert data into EMP table. How to insert data into two tables linke with foreign key..CREATE TABLE "CATDB"."DWDIMUSER"
"USER_ID" NUMBER(10,0) NOT NULL ENABLE,
"SPECIALTY_ID" NUMBER(10,0),
"FULLNAME" VARCHAR2(20 BYTE),
"FNAME" VARCHAR2(20 BYTE),
"LNAME" VARCHAR2(20 BYTE),
"USER_SUBTYPE" VARCHAR2(20 BYTE),
CONSTRAINT "DIMUSER_PK" PRIMARY KEY ("USER_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE,
CONSTRAINT "DIMUSER_DIMSPECIALTY_FK" FOREIGN KEY ("SPECIALTY_ID") REFERENCES "CATDB"."DWDIMSPECIALTY" ("SPECIALTY_ID") DISABLE
CREATE TABLE "CATDB"."DIMSPECIALTY"
"SPECIALTY_ID" NUMBER(10,0) NOT NULL ENABLE,
"SPECIALTY_NAME" VARCHAR2(100 BYTE),
CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("SPECIALTY_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
INSERT INTO DIMUSER (FullName, FNAME, LNAME, USER_TYPE, USER_SUBTYPE)
SELECT DISTINCT
Engineer AS FullName,
regexp_substr(Engineer , '[^,| ]+', 1, 1) as FName,
regexp_substr(Engineer , '[^,| ]+', 1, 2) as LName ,
'Engineer'
FROM EMPLOYEELOOKUP;
INSERT INTO DIMSPECIALTY (SPECIALTY_NAME)
SELECT DISTINCT SPECIALITY
FROM EMPLOYEELOOKUP;
COMMIT;
CREATE TABLE employeelookup ...IS A TABLE THAT HAS ALL THE DATA NEDED TO BE FILLED IN BOTHE TABLES...
CREATE TABLE "CATDB"."EMPLOYEELOOKUP"
"EMPLOYEELOOKUP_ID" NUMBER(10,0) NOT NULL ENABLE,
"ENGINEER" VARCHAR2(25 BYTE),
"SPECIALTY" VARCHAR2(20 BYTE),
CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("EMPLOYEELOOKUP_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
DATA IN EMPLOYEELOOKUP
Engineer, Specialty,
John, Dow, Electronis,
Dow, Jons, Technician
Stan Smithers Sales
Mark, Richards Marketing
Jenny, Lane Marketing
John, Lee Sales
I NEED TO LOAD THE FOREIGN KEY IN DIMUSER FROM THE DIMSPECIALTY TABLE?
BY USING THE LOOKUP TABLE TO MARCH THE NAMES UNDER THE Engineer COLUMN, SPECIALTY COLUMNE DISTICTIVLY BY JOINING THE DIMSPECILTY TO RISTIVE THE PRIMARY KEY AND FILL IT IN THE DIMUSER TABLE AS A FOREIGNE KEY. -
SSAS Tabular - Merge data from two tables to one
Hi,
I have two ReportServer databases in two different instances of SQL Server. I want to extract the ExecutionLog3 data to a Tabular model. Now, I have two separate tables in Tabular with duplicated measures but I want to have the data from two ReportServer in
the same table.
Any idea?
Regards.Hi Numero4,
According to your description, there are two Reporting Services databases, and you want to merge the data in a tabular model, right?
As per my understanding, you can create a link server on one of the server, and then merge the data in database lever other than in tabular mode. In this case, import the merged data into the tabular model. Here are some useful links for you reference.
http://msdn.microsoft.com/en-IN/library/ff772782.aspx
http://support.flexquarters.com/esupport/index.php?/Default/Knowledgebase/Article/View/2458/52/how-to-create-link-server-with-ms-sql-200520082012-64-bit-using-qodbcqremote
Regards,
Charlie Liao
TechNet Community Support -
Inserting data into two tables
hi
i have two tables
table1
Column1......................................... Column2
Primary key ........................................Foreign key ref to column2 in table2
table2
col1............................................ ............... col2
foriegn key ref to col1 in tab1 ........................ primary key
now my question is how to insert data in to the two tables
thanks in advance
Edited by: [email protected] on Feb 15, 2009 12:13 PMuser_7000005 wrote:
now my question is how to insert data in to the two tablesBy defining the foreign keys as deferrable:
SQL> create table table1
2 ( col1 int primary key
3 , col2 int
4 )
5 /
Table created.
SQL> create table table2
2 ( col1 int
3 , col2 int primary key
4 )
5 /
Table created.
SQL> alter table table1 add constraint c1 foreign key (col2) references table2(col2) deferrable initially deferred
2 /
Table altered.
SQL> alter table table2 add constraint c2 foreign key (col1) references table1(col1) deferrable initially deferred
2 /
Table altered.
SQL> insert into table1 values (1,1)
2 /
1 row created.
SQL> insert into table2 values (1,1)
2 /
1 row created.
SQL> commit
2 /
Commit complete.Regards,
Rob. -
I want to input a set of data into form text fields then
insert that data into a table plus insert one of those fields into
another table when the form button is clicked.
I've played around with Recordsets etc but I can't work out
how to define a server behaviour which will enable me to do what I
want. I'm using DWMX 2004 by the way.
Probably simple but I'm new to this and can't find an
explanation anywhere in the help files. Perhaps one of the resident
gurus could offer me some advice?
TIA, Kenquote:
Originally posted by:
Newsgroup User
old-celt wrote:
> I want to input a set of data into form text fields then
insert that data into
> a table plus insert one of those fields into another
table when the form button
> is clicked.
You can't insert data into two tables in a single operation.
It requires
two insert record queries to be run in succession.
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Can I make the two insert queries run from a single form
button press? Shoould I have a recordset or write two separate
queries, one for each table? -
Hi
I have written sql loader script for loading data into two tables.
Script is working ..But output is not coming properly.
I want to load data into first table which lines are having first char 'R'.
In the second table I have to load data which are related from the first line. Incase
first line data is not properly (means discarded) then related second table data
will not be load.
But I am getting both rows.Though the first table record is discarded. Please find below
the output.
Any other solution also ....Ok..external tables..Utl_file.
LOAD DATA
infile "inputFileForRmaReceiptAcknowledgement.dat"
BADFILE 'inputFileForRmaReceiptAcknowledgement.bad'
DISCARDFILE 'inputFileForRmaReceiptAcknowledgement.dsc'
APPEND
INTO TABLE XXGW_RMA_HEDR_RCPTACK_TAB
WHEN (01)='R'
( LINE_TYPE POSITION(1:1) "substr(:Line_Type, 1)",
RMA_ORDER_NO POSITION(2:16) CHAR,
ACKNOWLEDGEMENT_NO POSITION(17:31) CHAR,
ACKNOWLEDGEMENT_DATE POSITION(32:45)
"to_date(substr(:acknowledgement_date,3),'YYMMDDHH24MISS')",
DETAIL_LINE_COUNT POSITION(46:51) INTEGER EXTERNAL,
FLAG CHAR)
INTO TABLE XXGW_RMA_RCPT_ACKLDGMNT_TAB
WHEN (01) = 'D'
( LINE_TYPE POSITION(1:1) "substr(:Line_Type, 1)",
RMA_ORDER_NO POSITION(2:16) CHAR,
RMA_ORDER_LINE POSITION(17:19) INTEGER EXTERNAL,
SERIAL_NUMBER POSITION(20:49) CHAR,
SKU POSITION(50:63) CHAR,
QUANTITY POSITION(64:69) INTEGER EXTERNAL,
WAREHOUSE_CODE POSITION(70:71) CHAR,
WAYBILL_NUMBER POSITION(72:121) CHAR,
COURIER POSITION(122:146) CHAR,
RETURN_DEALER_FLAG POSITION(147:156) CHAR)
inputFileForRmaReceiptAcknowledgement.dat
R12345678901 2345456789123200 21111228241113000002 --- discarded record
D12345678901 00159123687402 45678925803 00000102name
D12345678901 00159143687402 45678925603 00000102name
T000004Regards
ArPl post details of OS and database versions.
Create a foreign key constraint between the detail table and the master table. If the row fails to load into the master table, then the detail table rows will fail the foreign key constraint and will not load.
http://docs.oracle.com/cd/E11882_01/server.112/e25789/datainte.htm#CNCPT1649
HTH
Srini -
We want to set up a delta refresh from R/3 data that will pull data into two cubes. One cube I want all the records to be loaded, in the second cube I want to filter the records that are loaded into that cube. I can figure out how to load the data into two cubes, but can I place a filter on one of the loads. (i.e. only load records of where type = 'X')
Thanks,
ChrisYou can do that in the Update Rules to the second cube... In the Start Routine...
DELETE FROM DATA_PACKAGE
WHERE type EQ 'X'.
(Please, verify the right syntax)
Then with only one Infopackage, you can load both cube with different conditions.
Hope it helps.
Regards,
Luis -
Insert data into two related tables in one transaction
Hi all,
I’ve got problem with developing functionality.
Background:
I’ve got two tables: OFFER_HEADER and OFFER_CONTENT
For now, user has to insert and commit the OFFER_HEADER(single-row view), then content becomes reachable and OFFER_CONTENT(multi-row view) can be filled. It is being done by choosing record from PRODUCTS form and inserting values into OFFER_CONTENT. Product data can be modified on the CONTENT form canvas.
My goal:
I know that is not convenient way to implement the functionality. I want to insert all the data(header and content) in one transaction. What is the best way to do it?
Thanks in advance,
Best Regards,
Bartek1. User is on the OFFER_CONTENT canvasOk
2. User presses ‘+’ buttonOk
3. On the screen is displayer PRODUCT list
4. User set focus on desired product
5. Using popup menu user choose ‘Add’ option
6. PRODUCT list is being closedSo, the functionlatity is like a LoV?
7. OFFER_CONTENT is being shown with set of information from the productOk, you would either take the values directly from the fields of the PRODUCT-list and copy them into the OFFER_CONTENT-fields, or you just get something like the PRODUCT-ID from your PRODUCT-list and use a SELECT to read the product-details into the OFFER_CONTENT-block
8. User can then manually change desired elements of the recordOk.
So, where do you have the need to do an INSERT in your scenario? -
Fetch data from two tables and insert into one table
I have similar to the following data in two tables (@Plant, @PlantDirector) and need to consolidate into one table (@PlantNew) as follows.
DECLARE @Plant TABLE (PlantID INT, PlantName VARCHAR(100))
INSERT INTO @Plant (PlantID, PlantName) VALUES (1, 'Name One'),(2, 'Name Two'),(3, 'Name Three'),(4, 'Name Four'),(5, 'Name Five'),(6, 'Name Six')
Director data for the Plants exist in the following table. Assistant value 1 means Assistant Director and 0 means Director.
Data exists only for subset of plants and a Plant may have one or both roles.
DECLARE @PlantDirector TABLE (PlantID INT, PlantDirectorID INT, Assistant bit)
INSERT INTO @PlantDirector (PlantID, PlantDirectorID, Assistant) VALUES (2, 111, 1),(2, 222, 0),(4, 333, 0),(6,444,1)
The above data needs to be inserted into one table (@PlantNew) as follows:
PlantID in @Plant table is IDENTITY value and needs to be inserted as-is into this table.
PlantDirExists will get a value of 1 if at least one record exists in @PlantDirector table for a PlantID. PlantAssistantDirID and PlantDirID should be set to the corresponding PlantDirID or NULL appropriately depending on the data.
DECLARE @PlantNew TABLE (PlantID INT, PlantName VARCHAR(100), PlantDirExists bit, PlantAssistantDirID INT, PlantDirID INT)
INSERT INTO @PlantNew (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID)
VALUES (1, 'Name One', 0, NULL, NULL),(2, 'Name Two', 1, 111, 222),(3, 'Name Three', 0, NULL, NULL),(4, 'Name Four', 1, NULL, 333),(5, 'Name Five', 0, NULL, NULL),(6, 'Name Six',1, 444, NULL)
How do I achieve the above using SQL ? Thanks.like this
INSERT @PlantNew (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID)
SELECT p.PlantID,
p.PlantName,
CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
PlantAssistantDirID,
PlantDirID
FROM @Plant p
LEFT JOIN (SELECT PlantID,
MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
@PlantDirector
GROUP BY PlantID)pd
ON pd.PlantID = p.PlantID
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
You're missing a FROM
insert into @PlantNew
SELECT p.PlantID,
p.PlantName,
CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
PlantAssistantDirID,
PlantDirID
FROM @Plant p
LEFT JOIN (SELECT PlantID,
MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
from @PlantDirector
GROUP BY PlantID)pd
ON pd.PlantID = p.PlantID -
Retrive data from two tables into one internal table.
Hi SDN,
I am downloading the Assets data from two tables ANLA,ANLZ.
there is a common field ANL1in both tables and i have to retrive the data by using anl1 into the internal table.
can you please send me the SELECT Syntax for this probl.....
Thank you & Regards,
ManojHi manoj,
Please see the following sample code. But kindly don't use join as it may hamper ur performance. No trouble in using two select query.
data: begin of itab occurs 0,
BUKRS like anla-BUKRS,
ANLN1 like anla-ANLN1,
BDATU like anlz-BDATU,
end of itab.
select anlabukrs anlaANLN1 anlzBDATU into corresponding fields of table itab from anla inner join anlz on anlaanl1 eq anlz~anl1 where (logexp).
Please come back for any clarification.
Thanks and Regards,
saurabh -
To Select the data from two table one is transp table and onther is cluster
Hi All,
I want to select the data from two tables
Here i am giving with an example.
Fileds: kunnr belnr from bseg. table bseg
fields: adrnr from kna1 table: kna1.
Know i want to put these into one internal table based on kunnr and belnr.
Thanks in advance.
RameshHi,
U cant use joins on cluster table and BSEG is a cluster table so use FOR ALL ENTRIES for taht
refer this code
*& Form sub_read_bsak
text
--> p1 text
<-- p2 text
FORM sub_read_bsak.
*--Select data from BSAK Table
SELECT lifnr
augdt
augbl
gjahr
belnr
xblnr
blart
dmbtr
mwskz
mwsts
sgtxt
FROM bsak
INTO CORRESPONDING FIELDS OF TABLE it_bsak
WHERE belnr IN s_belnr
AND augdt IN s_augdt.
IF sy-subrc EQ 0.
*--Sort table by accounting document and vendor number
SORT it_bsak BY belnr lifnr.
ENDIF.
ENDFORM. " sub_read_bsak
*& Form sub_read_bseg
text
--> p1 text
<-- p2 text
FORM sub_read_bseg.
IF NOT it_bsak[] IS INITIAL.
*--Select data from BSEG table
SELECT belnr
gjahr
shkzg
kostl
hkont
ebeln
ebelp
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE it_bseg
FOR ALL ENTRIES IN it_bsak
WHERE belnr EQ it_bsak-belnr
AND gjahr EQ it_bsak-gjahr
AND shkzg EQ 'S'.
IF sy-subrc EQ 0.
*--Sort table by accounting document
SORT it_bseg BY belnr.
ENDIF.
ENDIF.
ENDFORM. " sub_read_bseg -
How to insert data from APEX form into two tables
Hi,
I'm running APEX 4.1 with Oracle XE 11g, having two tables CERTIFICATES and USER_FILES. Some of the (useless) fields are cut to reduce information:
CREATE TABLE CERTIFICATES
CERT_ID NUMBER NOT NULL ,
CERT_OWNER NUMBER NOT NULL ,
CERT_VENDOR NUMBER NOT NULL ,
CERT_NAME VARCHAR2 (128) ,
CERT_FILE NUMBER NOT NULL ,
) TABLESPACE CP_DATA
LOGGING;
ALTER TABLE CERTIFICATES
ADD CONSTRAINT CERTIFICATES_PK PRIMARY KEY ( CERT_ID ) ;
CREATE TABLE USER_FILES
FILE_ID NUMBER NOT NULL ,
FILENAME VARCHAR2 (128) ,
BLOB_CONTENT BLOB ,
MIMETYPE VARCHAR2 (32) ,
LAST_UPDATE_DATE DATE
) TABLESPACE CP_FILES
LOGGING
LOB ( BLOB_CONTENT ) STORE AS SECUREFILE
TABLESPACE CP_FILES
STORAGE (
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS UNLIMITED
FREELISTS 1
BUFFER_POOL DEFAULT
RETENTION
ENABLE STORAGE IN ROW
NOCACHE
ALTER TABLE USER_FILES
ADD CONSTRAINT CERT_FILES_PK PRIMARY KEY ( FILE_ID ) ;
ALTER TABLE CERTIFICATES
ADD CONSTRAINT CERTIFICATES_USER_FILES_FK FOREIGN KEY
CERT_FILE
REFERENCES USER_FILES
FILE_ID
NOT DEFERRABLE
What I'm trying to do is to allow users to fill out all the certificate data and upload a file in an APEX form. Once submitted the file should be uploaded in the USER_FILES table and all the fields along with CERT_ID, which is the foreign key pointing to the file in the USER_FILES table to be populated to the CERTIFICATES table. APEX wizard forms are based on one table and I'm unable to build form on both tables.
That's why I've created a view (V_CERT_FILES) on both tables and using INSTEAD OF trigger to insert/update both tables. I've done this before and updating this kind of views works perfect. Here is where the problem comes, if I'm updating the view all the data is updated correctly, but if I'm inserting into the view all the fields are populated at CERTIFICATES table, but for USER_FILES only the fields FILE_ID and LAST_UPDATE_DATE are populated. The rest three regarding the LOB are missing: BLOB_CONTENT, FILENAME, MIMETYPE. There are no errors when running this from APEX, but If I try to insert into the view from SQLDeveloper, I got this error:
ORA-22816: unsupported feature with RETURNING clause
ORA-06512: at line 1
As far as I know RETURNING clause in not supported in INSTEAD of triggers, although I didn't have any RETURNING clauses in my trigger (body is below).
Now the interesting stuff, after long tracing I found why this is happening:
First, insert is executed and the BLOB along with all its properties are uploaded to wwv_flow_file_objects$.
Then the following insert is executed to populate all the fields except the BLOB and it's properties, rowid is RETURNED, but as we know RETURNING clause is not supported in INSTEAD OF triggers, that's why I got error:
PARSE ERROR #1918608720:len=266 dep=3 uid=48 oct=2 lid=48 tim=1324569863593494 err=22816
INSERT INTO "SVE". "V_CERT_FILES" ( "CERT_ID", "CERT_OWNER", "CERT_VENDOR", "CERT_NAME", "BLOB_CONTENT") VALUES (:B1 ,:B2 ,:B3 ,:B4, ,EMPTY_BLOB()) RETURNING ROWID INTO :O0
CLOSE #1918608720:c=0,e=11,dep=3,type=0,tim=1324569863593909
EXEC #1820672032:c=3000,e=3168,p=0,cr=2,cu=4,mis=0,r=0,dep=2,og=1,plh=0,tim=1324569863593969
ERROR #43:err=22816 tim=1324569863593993
CLOSE #1820672032:c=0,e=43,dep=2,type=1,tim=1324569863594167
Next my trigger gets in action, sequences are generated, CERTIFICATES table is populated and then USER_FILES, but only the FILE_ID and LAST_UPDATE_DATE.
Finally update is fired against my view (V_CERT_FILES), reading data from wwv_flow_files it populates BLOB_CONTENT, MIMETYPE and FILENAME fields at the specific rowid in V_CERT_FILES, the one returned from the insert at the beginning. Last, file is deleted from wwv_flow_files.
I'm using sequences for the primary keys, this is only the body of the INSTEAD OF trigger:
select user_files_seq.nextval into l_file_id from dual;
select certificates_seq.nextval into l_cert_id from dual;
insert into user_files (file_id, filename, blob_content, mimetype, last_update_date) values (l_file_id, :n.filename, :n.blob_content, :n.mimetype, sysdate);
insert into certificates (cert_id, cert_owner, cert_vendor, cert_name, cert_file) values (l_cert_id, :n.cert_owner, :n.cert_vendor, :n.cert_name, l_file_id);
I'm surprised that I wasn't able to find a valuable source of information regarding this problem, only MOS note about running SQLoader against view with CLOB column and INSTEAD OF trigger. The solution would be to ran it against base table, MOS ID 795956.1.
Maybe I'm missing something and that's why I decided to share my problem here. So my question is how do you create this kind of architecture, insert into two tables with a relation between them in APEX ? I read a lot in the Internet, some advices were for creating custom form with APEX API, create a custom ARP, create two ARP or create a PL/SQL procedure for handing the DML?
Thanks in advance.
Regards,
SveThank you however I was wondering if there was an example available which uses EJB and persistence.
-
How to apply data into 2 tables AND to more than one record in same table?
Hello,
I am trying to apply/insert data into 2 tables AND at the same time apply data to more than one record (in the same table). How would I do this in APEX?
I have updated using one table with no problem, however, when I try updating with the two tables/ multiple record sets, I get errors.
I appreciate the help.
Thanks.
LindaYou can achieve what you want using PL/SQL. Can you post ur code?
Maybe you are looking for
-
Acrobat XI droplets not working in Acrobat DC and Preflight profiles gone
I can't find any of the custom preflight profiles from Acrobat XI in the newly installed Acrobat DC. Are they gone (deleted)? I expected them to be upgraded... not to be removed without any notice. Also preflight droplets no longer work. Dragging and
-
Page templates with predefined regions
Is it possible to create a page template with two predefined regions ? Much as createing a "page with components". This to be able to edit the regions after creating the page peråge
-
How to reset my mac 5 days back with time machine?
I will like to reset my Mac 5 days back to exactly how it was at that time. I have Time Capsule and Time Machine. Thanks, Victor.
-
Suitable Functional module for ABAP consultant
Hi all, I am an ABAPer with one and half years of experience. Can some body suggest me a functional module which will be easier to learn for me as I have no domain experience. Also please tell me the marketwise hottest module these days such that th
-
I want to buy a cellphone that will work WELL as a modem for my Mac Book Pr
I want to buy a cellphone that will work WELL as a modem for my Mac Book Pro. What cellphone works WELL as a modem? What is the script to activate the phone to work as modem? I have a Samsung a707 sych cellphone does not work as modem as far as I can