Dynamic XML Source to a Fixed Target Table
Hi gurus,
Please help me on this one, I've been trying to work it around for 2 weeks now, and unfortunately, I can't think of any solutions anymore.
So here is the case:
I'm using ODI 11g and I'm loading XML files to Oracle Tables.
But in this case I have a dynamic XML file (number of columns varies, depends on the user input) as the source and I have to load it into a fixed Target Table.
Example:
XML SOURCE FILE (dynamic number of columns):
Column_A1 | Column_B1 | Column_C1 | Column_A2 | Column_B2 | Column_C3 | Column_A3 | Column_B3 | Column_C3 | | **
**means I don't have idea how many columns in one XML would be. It can be 6 columns, 9 columns, 3 columns. I do reverse engineer to get the latest XML structure.*
FIXED TARGET OUTPUT TABLE (3 columns only):
Column_A1 | Column_B1 | Column_C1
Column_A2 | Column_B2 | Column_C2
Column_A3 | Column_B3 | Column_C3
** | * | **
--END OF EXAMPLE*
So what I want to happen is that, everytime ODI detects that it is already the 4th column, 4th - 6th columns would append to the next row and 7th-9th would append to the next row, and goes on and goes on.
What do you think is the best way to do this? Or if there is any way?
Please please help me, it would be of great great help to the project I'm working.
If there's no way, I'm thinking of creating a PL/SQL within a KM for this one.
Thank you gurus'!
Regards,
-Vince
Edited by: Vindi on Aug 22, 2012 2:45 AM
Edited by: Vindi on Aug 23, 2012 6:57 PM
What is the minimum number of columns from source side..if the minimum number of column will be 3 then my logic may work.
Please confirm.
Because in case of odi reverse, odi will add the extra column to the datastore. If initially the souurce file has 3 columns then the target datastore will 3. In next reverse if the source file has 5 column then in the next reverse it will add 2 more column to the datastore. Again nexttime if the source file has 2 column ODI is not going remove/drop these 3 extra column.
Similar Messages
-
Hierarchical menu tree from dynamic xml
Can anyone give me ideas on how to create a hierarchical tree using xml / xsl / javascript. Please note that the xml data is dynamic and changes for each user/company. I have downloaded the xalan processor. Any ideas on the line of approach is highly appreciated.
Thanks in advanceI've used Joust Outliner, www.ivanpeters.com. This a free javascript package that builds treeviews for html. A XSL-stylesheet was used to produce the javascript code from a dynamic xml source. (Although the structure of the xml was more or less the same, the content was changed from time to time)
-
How to load data dynamically into target tables using files as a source
Hi ,
My scenario needs a single interface to load the data of 5 different files into five target tables using a single interface. All target tables have the same structure. It is possible to point to variable source files using ODI. But the same approach is not working with Database tables. I am getting errors while trying to make my target /source table as a dynamic one.
Can anybody suggest anything. The last option would be writing a dynamic PL/SQL block in the KM. Any other suggestions friends ?
Regards,
AtishAfter creating a pair of identical source and target tables, I have carried out the following steps:
I am trying just keeping the target as variable
a)created a one to one interface,
b)tested that it is running.
c)created a variable(type =text),
d)used the variable as #v_name in the resource of the target table datastore.
e)in a package used the variable in a set variable step (first step).
f) used the interface as the second step.
g)executed the same in my context.
the <project_code>.variable_name is not getting substituted in the sql_code that is generated by the KM. My KM is SQL Control Append and following is the code that it generates in the Insert into I$ step:
/* DETECTION_STRATEGY = NOT_EXISTS */
insert /*+ APPEND */ into HR.I$_JOBS_COPY1
JOB_ID,
JOB_TITLE,
MIN_SALARY,
MAX_SALARY,
IND_UPDATE
select
JOBS.JOB_ID JOB_ID,
JOBS.JOB_TITLE JOB_TITLE,
JOBS.MIN_SALARY MIN_SALARY,
JOBS.MAX_SALARY MAX_SALARY,
'I' IND_UPDATE
from HR.JOBS JOBS
where (1=1)
and not exists (
select 'X'
from HR.#PLAYGROUND."v_tab_name" T
where T.JOB_ID = JOBS.JOB_ID
and ((JOBS.JOB_TITLE = T.JOB_TITLE) or (JOBS.JOB_TITLE IS NULL and T.JOB_TITLE IS NULL))
and ((JOBS.MIN_SALARY = T.MIN_SALARY) or (JOBS.MIN_SALARY IS NULL and T.MIN_SALARY IS NULL))
and ((JOBS.MAX_SALARY = T.MAX_SALARY) or (JOBS.MAX_SALARY IS NULL and T.MAX_SALARY IS NULL))
) -
How do I map the source file name to a target table?
I am mapping a source fixed length flat file to oracle target tables. One of the tables is a parent transaction table that stores the date, record number, status, etc. and the file name of the source flat file. The file name will change daily because the date is part of the naming convention. Is there an easy way to determine the source file name and map it?
One option a co-worker is working on is writing a pre-mapping stored procedure. It would insert the file name into a table prior to the mapping. But I was hoping for a cleaner solution.
Thanks!Hi
Use extarnel table to load the data from the file into the table.
Create a procedure which changes the external table definition as the filename chnages.
Use this proceudre in the mapping as a premapping process.
Ott Karesz
http://www.trendo-kft.hu -
Dynamic XSLT source code generation based upon internal table
Hi,
Is there anyway to generate dynamic XSLT source code based upon final structure of output internal table and call dynamic generated XSLT in program?
CALL TRANSFORMATION z_transformation
PARAMETERS
p_shared_string = lo_shared_str_nodeset
SOURCE XML g_sheet_data
RESULT lt_data = i_data[].
Source code example of XSLT transformation -
<xsl:template match="/">
<asx:abap version="1.0">
<asx:values>
<LT_DATA> "Internal table
<xsl:for-each select="ss:worksheet/ss:sheetData/ss:row">
<xsl:if test="position() > 1">
<item>
<FIELD1>
<xsl:variable name="cell_id" select="concat('A', position())"/>
<xsl:variable name="v_index" select="ss:c[@r=$cell_id][@t='s']/ss:v"/>
<xsl:if test="$v_index">
<xsl:value-of select="$V_SHARED_STRING/sst/si[$v_index + 1]/t"/>
</xsl:if>
<xsl:if test="not($v_index)">
<xsl:value-of select="ss:c[@r=$cell_id]/ss:v"/>
</xsl:if>
</FIELD1>
</item>
</xsl:if>
</xsl:for-each>
</LT_DATA> "internal table
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>In addition,
We are converting binary data of excel from application server into internal table but currently we created two XSLT transformation to achieve this one for deleting name space and other for converting data into internal table format.
We want to make our source code for future use also,Is there anyway to generate XSLT source code dynamically?Above mentioned code is snippet of data extracting which we are doing but this transformation is hard coded.
Any help is appreciated.
BR,
Praveen -
How do I create a target table with the same PK as the source table?
I am trying to create a target table in a mapping that will end up with the same primary key as the source table.
It is a simple map that simply uses a subset of the columns of the source table in the target table. I was wanting to create and bind a new table by dragging the columns I want from the source to the initially blank target table operator, change the column names and create a primary key to match the source table.
I can't seem to be able to create a constraint on the table in the mapping. I can create the constraint after the table is created and boound to the database object but the PK doesn't carry back into the mapping.
I need it in the mapping so I can use the UPDATE/INSERT operation and use the 'All Constraints' implementation. The mapping won't let me validate the object without the PK on it in the map.
Believe it or not folks, I am getting better at this.
Thanks very much for the guidance.
GaryHi Gary
You are close, you are really close... :-))
You need to do exactly as you propose plus one extra step. Build the map as you describe, binding the new table to the target. Then you edit the table definition to add the primary key and any other constraints you need. After this is the step that you are missing.
You need to do the following:
1. Go back and re-edit the map
2. Right click on the table
3. From the pop up menu, select Reconcile Inbound
4. Set any operators that you need for the UPDATE/INSERT
5. Save the map
6. Commit your changes
The first three steps above make the map read in the indexes and constraints that you set on the table. Finally, you need to deploy the table and then deploy the map.
Hope this helps
Regards
Michael -
How to get source table name according to target table
hi all
another question:
once a map was created and deployed,the corresponding information was stored in the repository and rtr repository.My question is how to find the source table name according to the target table,and in which table these records are recorded.
somebody help me plz!!
thanks a lot!This is a query that will get you the operators in a mapping. To get source and targets you will need some additional information but this should get you started:
set pages 999
col PROJECT format a20
col MODULE format a20
col MAPPING format a25
col OPERATOR format a20
col OP_TYPE format a15
select mod.project_name PROJECT
, map.information_system_name MODULE
, map.map_name MAPPING
, cmp.map_component_name OPERATOR
, cmp.operator_type OP_TYPE
from all_iv_xform_maps map
, all_iv_modules mod
, all_iv_xform_map_components cmp
where mod.information_system_id = map.information_system_id
and map.map_id = cmp.map_id
and mod.project_name = '&Project'
order by 1,2,3
Jean-Pierre -
Insert/select one million rows at a time from source to target table
Hi,
Oracle 10.2.0.4.0
I am trying to insert around 10 million rows into table target from source as follows:
INSERT /*+ APPEND NOLOGGING */ INTO target
SELECT *
FROM source f
WHERE
NOT EXISTS(SELECT 1 from target m WHERE f.col1 = m.col2 and f.col2 = m.col2);There is a unique index on target table on col1,col2
I was having issues with undo and now I am getting the follwing error with temp space
ORA-01652: unable to extend temp segment by 64 in tablespace TEMPI believce it would be easier if I did bulk insert one million rows at a time and commit.
I appriciate any advice on this please.
Thanks,
Ashok902986 wrote:
NOT EXISTS(SELECT 1 from target m WHERE f.col1 = m.col2 and f.col2 = m.col2);
I don't know if it has any bearing on the case, but is that WHERE clause on purpose or a typo? Should it be:
NOT EXISTS(SELECT 1 from target m WHERE f.col1 = m.COL1 and f.col2 = m.col2);Anyway - how much of your data already exists in target compared to source?
Do you have 10 million in source and very few in target, so most of source will be inserted into target?
Or do you have 9 million already in target, so most of source will be filtered away and only few records inserted?
And what is the explain plan for your statement?
INSERT /*+ APPEND NOLOGGING */ INTO target
SELECT *
FROM source f
WHERE
NOT EXISTS(SELECT 1 from target m WHERE f.col1 = m.col2 and f.col2 = m.col2);As your error has to do with TEMP, your statement might possibly try to do a lot of work in temp to materialize the resultset or parts of it to maybe use in a hash join before inserting.
So perhaps you can work towards an explain plan that allows the database to do the inserts "along the way" rather than calculate the whole thing in temp first.
That probably will go much slower (for example using nested loops for each row to check the exists), but that's a tradeoff - if you can't have sufficient TEMP then you may have to optimize for less usage of that resource at the expense of another resource ;-)
Alternatively ask your DBA to allocate more room in TEMP tablespace. Or have the DBA check if there are other sessions using a lot of TEMP in which case maybe you just have to make sure your session is the only one using lots of TEMP at the time you execute. -
Collect data from a dynamic XML file into multiple internal tables
I need to convert the XML file into multiple internal tables. I tried many links and posts in SDN but still was facing difficulty in achieving this. Can some one tell me where I am going wrong.
My XML file is of the following type.It is very complex and the dynamice.
The following tags occur more than once in the XML file. The "I" and "L" tags and its child tags can occur ones or more than once for each XML file and it is not constant. i.e in one file they can occur 1 time and in another they can occur 100 times.
"I" and "L" are child tags of <C>
<I>
<J>10</J>
<K>EN</K>
</I>
<L>
<J>20</J>
<N>BB</N>
</L>
Tags <C> and <F> occur only ones for each XML file. <C> is the child tag of "A" and "F" is the child tag of <C>.
I need to collect <D>, <E> in one internal table ITAB.
I need to collect <G>, <H> in one internal table JTAB.
I need to collect <J>, <K> in one internal table KTAB.
I need to collect <J>, <N> in one internal table PTAB.
Below is the complete XML file.
?xml version="1.0" encoding="iso-8859-1" ?>
<A>
<B/>
<C>
<D>RED</D>
<E>999</E>
<F>
<G>TRACK</G>
<H>PACK</H>
</F>
<I>
<J>10</J>
<K>EN</K>
</I>
<I>
<J>20</J>
<K>TN</K>
</I>
<I>
<J>30</J>
<K>KN</K>
</I>
<L>
<J>10</J>
<N>AA</N>
</L>
<L>
<J>20</J>
<N>BB</N>
</L>
<L>
<J>30</J>
<N>CC</N>
</L>
</C>
</A>
With the help of SDN I am able to gather the values of <D> <E> in one internal table.
Now if I need to gather
<G>, <H> in one internal table JTAB.
<J>, <K> in one internal table KTAB.
<J>, <N> in one internal table PTAB.
I am unable to do. I am following XSLT transformation method. If some one has some suggestions. Please help.
Here is my ABAP program
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\TEMP\ABCD.xml'.
* This is the structure for the data from the XML file
TYPES: BEGIN OF ITAB,
D(10) TYPE C,
E(10) TYPE C,
END OF ITAB.
* Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048.
* Table and work ares for the data from the XML file
DATA: gt_ITAB TYPE STANDARD TABLE OF ts_ITAB,
gs_ITAB TYPE ts_ITAB.
* Result table that contains references
* of the internal tables to be filled
DATA: gt_result_xml TYPE abap_trans_resbind_tab,
gs_result_xml TYPE abap_trans_resbind.
* For error handling
DATA: gs_rif_ex TYPE REF TO cx_root,
gs_var_text TYPE string.
* Get the XML file from your client
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = gs_file
CHANGING
data_tab = gt_itab1
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "IITAB".
GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
gs_result_xml-name = 'IITAB'.
APPEND gs_result_xml TO gt_result_xml.
* Perform the XSLT stylesheet
TRY.
CALL TRANSFORMATION zxslt
SOURCE XML gt_itab1
RESULT (gt_result_xml).
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
* Now let's see what we got from the file
LOOP AT gt_ITAB INTO gs_ITAB.
WRITE: / 'D:', gs_ITAB-D.
WRITE: / 'E :', gs_ITAB-E.
ENDLOOP.
Transformation
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<IITAB>
<xsl:apply-templates select="//C"/>
</IITAB>
</asx:values>
</asx:abap>
</xsl:template>
<item>
<D>
<xsl:value-of select="D"/>
</D>
<E>
<xsl:value-of select="E"/>
</E>
</item>
</xsl:template>
</xsl:transform>
Now the above pgm and transformation work well and I am able to extract data into the ITAB. Now what changes should I make in transformation and in pgm to collect
<G>, <H> in one internal table JTAB.
<J>, <K> in one internal table KTAB.
<J>, <N> in one internal table PTAB.
Please help..i am really tring hard to figure this out. I am found lot of threads addressing this issue but not my problem.
Kindly help.
Regards,
VSHi Rammohan,
Thanks for the effort!
But I don't need to use GUI upload because my functionality does not require to fetch data from presentation server.
Moreover, the split command advised by you contains separate fields...f1, f2, f3... and I cannot use it because I have 164 fields. I will have to split into 164 fields and assign the values back to 164 fields in the work area/header line.
Moreover I have about 10 such work areas. so the effort would be ten times the above effort! I want to avoid this! Please help!
I would be very grateful if you could provide an alternative solution.
Thanks once again,
Best Regards,
Vinod.V -
Join two source tables and replicat into a target table with BLOB
Hi,
I am working on an integration to source transaction data from legacy application to ESB using GG.
What I need to do is join two source tables (to de-normalize the area_id) to form the transaction detail, then transform by concatenate the transaction detail fields into a value only CSV, replicate it on the target ESB IN_DATA table's BLOB content field.
Based on what I had researched, lookup by join two source tables require SQLEXEC, which doesn't support BLOB.
What alternatives are there and what GG recommend in such use case?
Any helpful advice is much appreciated.
thanks,
XiaocunXiaocun,
Not sure what you're data looks like but it's possible the the comma separated value (CSV) requirement may be solved by something like this in your MAP statement:
colmap (usedefaults,
my_blob = @STRCAT (col02, ",", col03, ",", col04)
Since this is not 1:1 you'll be using a sourcedefs file, which is nice because it will do the datatype conversion for you under the covers (also a nice trick when migrating long raws to blobs). So col02 can be varchar2, col03 a number, and col04 a clob and they'll convert in real-time.
Mapping two tables to one is simple enough with two MAP statements, the harder challenge is joining operations from separate transactions because OGG is operation based and doesn't work on aggregates. It's possible you could end up using a combination of built in parameters and funcations with SQLEXEC and SQL/PL/SQL for more complicated scenarios, all depending on the design of the target table. But you have several scenarios to address.
For example, is the target table really a history table or are you actually going to delete from it? If just the child is deleted but you don't want to delete the whole row yet, you may want to use NOCOMPRESSDELETES & UPDATEDELETES and COLMAP a new flag column to denote it was deleted. It's likely that the insert on the child may really mean an update to the target (see UPDATEINSERTS).
If you need to update the LOB by appending or prepending new data then that's going to require some custom work, staging tables and a looping script, or a user exit.
Some parameters you may want to become familiar with if not already:
COLS | COLSEXCEPT
COLMAP
OVERRIDEDUPS
INSERTDELETES
INSERTMISSINGUPDATES
INSERTUPDATES
GETDELETES | IGNOREDELETES
GETINSERTS | IGNOREINSERTS
GETUPDATES | IGNOREUPDATES
Good luck,
-joe -
Mapping Issue with 7 source tables and one target table in one step
Hi,
Request for a small help in OWB.
I am trying to map 7 source tables to a single target table in one step.These source tables are in Oracle 10G database but dont have PK and FK relation ship.
I am able to link one table to the target by pointing some of the columns. But when coming to the second table it is giving some error message :
Ap18003: Connection target attribute group is already connected to a incompatible data source. Use a joiner or set operator to join the upstream data first before connection it to this operator.
As per the error message I used a Join operator and tried to map the second table to the target but still giving me the same error message. Could some body give me a hand to give out from this step.
Thanks for your help in advance.
Cheers,
Krishna.Hi,
like this:
Ingroup1
- id -> Number(9,0)
- name -> VARCHAR2(500)
Ingroup2
- my_id -> Number(9,0)
- name -> VARCHAR2(500)
Outgroup
- id -> point to target_table.id
- name -> point to target_table.name
Not:
Ingroup1
- id -> Number(9,0)
- name -> VARCHAR2(500)
Ingroup2
- name -> VARCHAR2(500)
- my_id -> VARCHAR2(9)
Regards
Detlef
null -
Dynamic data source in Excel Pivot Table
Hello there,
I am trying to have dynamic data source in pivot table using INDIRECT but getting the error "Reference not valid". Here is how I setup the reference:
Named range: ConsolLink = "'R:\Root\Sub1\Sub2\Consol File.xlsm'!Source_OpexConsol"
"Source_OpexConsol" is defined in the source file as a dynamic name using offset formula.
In the pivot data source, I have tried "=INDIRECT(ConsolLink)" as the data source but that does not work.
I have also tried using INDIRECT in ConsolLink and just referencing "ConsolLink" as the data source. That does not work either.
I am not using Power Pivot. Appreciate it if someone can help.
Thanks.If it is open, then try
Named range: ConsolLink = Range("Consol File.xlsm'!Source_OpexConsol")
And if it is not currently open, then try
Dim W As Workbook
Set W = Workbooks.Open("R:\Root\Sub1\Sub2\Consol
File.xlsm")
Named range: ConsolLink =
Range("Consol File.xlsm'!Source_OpexConsol")
W.Close False -
Loading to target table from multiple source table
Hi forum,
I have some doubts regarding selecting data by joining 2 or 3 tables and populate the target table in same schema(ora 10g).The way i need to load is first extract the data and do some some transformations(like derive new value based on existing column value ,eg: arithmetic operations) and then load data to target table in same schema...
GIve me a suggestion to do the same in best possible way..since the entire activity to be finished in 3 hrs and volume in each table is 377 million , 122 million and 120 million.
Thanks ,
Aneesh AIt is Rob who spend his freetime in answering you - not "bob".
> Can u explain me the time-lines for the mentioned volume...?
You mean "you" and not "u"? This is not a MXIT forum where IM SPEAK is the norm.
As for time-lines.. it is silly to expect anyone to give you estimated run times when the hardware platform, types of disks, o/s configuration, Oracle configuration, average loads and so on are unknown.
What Rob showed you is the most optimal way to write SQL to transform data from one or more source tables and insert these results into a destination table - using direct path inserts and parallel query. The only faster method would be a CTAS - Create Table As Select as oppose to an Insert Table with select. -
Hope you all are doing good.
I have a business issue to be implemented in ODI 11G. Here it is. I am trying to load a target table from two sources having same coulmn names. But one source is in file format and other is in Oracle Database.
This is what i think i will create two mappings in the same interface using Union between the sources. But i am not sure how the interface would connect to different logical architecture to connect to two different sources.
Thanks,
SMYou are on the right track, this can all be done in a single interface. Do the following
1) Pull your file data model into the source designer and and your target table model to the target pane.
2) Map all the relevant columns
3) In the source designer create a new dataset and choose the UNION join type (this will create a separate tab in the source designer pane)
4) Select the new dataset tab in the source designer pane and pull your source oracle table data model into the source designer. Map all the relevant columns to the target
5) Make sure that your staging location is defined on a relational technology i.e. in this case the target would be an ideal candidate as that is where ODI will stage the data from both file and oracle source and perform the UNION before loading to the target
If you want to look at some pretty screenshots showing the steps above take a look at http://odiexperts.com/11g-oracle-data-integrator-part-611g-union-minus-intersect/ -
Merge update source table and delete from target table problem
Hello Friends,
I am a newbie in SQL Server world and I am in a situation where I need to delete the bunch of records from the TARGET table using the values from the SOURCE table.
The TARGET table has close to 400 Million records, so I need to delete the records in small batches of about ~10,000 rows.
I figured out a way to delete in batches by refering the following 2 posts
http://sqlperformance.com/2013/03/io-subsystem/chunk-deletes
http://dba.stackexchange.com/questions/1750/methods-of-speeding-up-a-huge-delete-from-table-with-no-clauses
I think my best option to delete and update in 1 pass would be through using Merge statement, so for that I constructed following SQL.
MERGE dbo.table1 AS TARGET
USING
SELECT File_name FROM dbo.table2
WHERE FILE_DESC = 'EDI'
AND [Processed_date] < DATEADD (WEEK, -10, Getdate ()) AS SOURCE
ON (TARGET.File_name = SOURCE.File_name)
WHEN MATCHED THEN DELETE (FROM THE TARGET)
WHEN MATCHED
THEN UPDATE SET SOURCE.PROCESS_delete_date = GETDATE()
But, when executed, it throws following error and I am struggling to figure out what is wrong with the above syntax.
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'SELECT'.
Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'AS'.
Can any expert please help a newbie as I learn the new way.
Thanks a lot.Visakh, we can have more than 1 matched clause in merge as per the Microsoft sql statement, but we need to add a condition along with the match. thanks for your prompt response on this query. your query is logically fine but when executed, it throws
following error. Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'DELETE'. Msg 102, Level 15, State 1, Line 8 Incorrect syntax near ')'. remember, my server machine is 2005 version & my work machine is 2012. dont know why your query
is not working.
MERGE is available only from 2008 onwards
Yes you're correct but again not more than two MATCHED clauses even if you specify condition
see MSDN documentation below
WHEN MATCHED THEN <merge_matched>
Specifies that all rows of target_table that match the rows returned by <table_source> ON <merge_search_condition>, and satisfy any additional search condition, are either updated or deleted according to the <merge_matched> clause.
The MERGE statement can have at most two WHEN MATCHED clauses. If two clauses are specified, then the first clause must be accompanied by an AND <search_condition> clause
from
http://msdn.microsoft.com/en-us/library/bb510625.aspx
Also I guess Composable DML which used is also not present in 2005
So in your case you can try this instead
DECLARE @DELETED_FILES table
File_Name varchar(100)
DELETE t
OUTPUT DELETED.File_Name INTO @DELETED_FILES
FROM dbo.table1 t
INNER JOIN dbo.table2 s
ON t.File_name = s.File_name
WHERE s.FILE_DESC = 'EDI'
AND s.[Processed_date] < DATEADD (WEEK, -10, Getdate ())
UPDATE r
SET r.Process_Delete_Date = GETDATE()
FROM dbo.table2 r
INNER JOIN @DELETED_FILES AS p
ON p.File_Name = r.File_Name
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page
Maybe you are looking for
-
My movies are not showing up in iMovie application?
Hi, I just uploaded 5 movies from my camera to my iMac using iPhoto. I can see them all in there. Here is a photo. When I drag the movies out you can see in this picture above the iPhoto app (top left). If you notice an older one has the Quicktime sy
-
I'm having trouble instaling a printer driver for my Canon MG5220. I downloaded the latest printer driver from the Canon website (10.67.1.0) and installed it on my Intel iMac. It said the installation was sucessful, but when I try to add a printer, n
-
Which is more important for Adobe CS6 and FCX on imac? Processor or Graphics Card?
Hi, I want to get the new 27" imac when it comes out this December. It will be my first mac although I have both an iPhone and iPad. I'm and artist and aspiring filmmaker and want to run Adobe CS6 and Final Cut Pro on it. I'm looking at the highest 2
-
I hava a class where the printout is in dos.....
I hava a class where the printout is in dos now I want it to print out itin a Gui application or applet instead how do I do. Here is the class file: import filenet.vw.api.*; public class QueueSample extends Object public QueueSample(VWSession vwSessi
-
Is it possible to install software without the CD but with the product key
I purchased a Mac Pro notebook whiile working out of town but do not have my Micro Office for Mac CD but I do have my product key. Any way to get it installed via internet with haviCD sent to me from home?