473,385 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Merge SQL Statement Will Not Compile

2
Merge SQL statement will not compile. Can anyone help me out?

Expand|Select|Wrap|Line Numbers
  1.  Create Or Replace Procedure P_pvt_merge 
  2. As
  3. Begin 
  4. Merge Into Employees2 B
  5. Using (
  6. Select Employee_id, First_name, Last_name, Dept_no, Salary
  7. From Employees
  8. Where Dept_no = 20) E
  9. On (b.employee_id = E.employee_id)
  10. When Matched Then
  11. Update Set B.employee_id = E.employee_id,
  12. B.first_name = E.first_name,
  13. B.last_name = E.last_name,
  14. B.dept_no = E.dept_no,
  15. B.salary = E.salary 
  16. When Not Matched Then
  17. Insert (b.employee_id, B.first_name, B.last_name, B.dept_no, B.salary)
  18. Values (e.employee_id, E.first_name, E.last_name, E.dept_no, E.salary)
  19. Commit;
  20. End;
  21.  
/
Jan 4 '06 #1
1 2110
Mishit
1
Merge SQL statement will not compile. Can anyone help me out?

Expand|Select|Wrap|Line Numbers
  1.  Create Or Replace Procedure P_pvt_merge 
  2. As
  3. Begin 
  4. Merge Into Employees2 B
  5. Using (
  6. Select Employee_id, First_name, Last_name, Dept_no, Salary
  7. From Employees
  8. Where Dept_no = 20) E
  9. On (b.employee_id = E.employee_id)
  10. When Matched Then
  11. Update Set B.employee_id = E.employee_id,
  12. B.first_name = E.first_name,
  13. B.last_name = E.last_name,
  14. B.dept_no = E.dept_no,
  15. B.salary = E.salary 
  16. When Not Matched Then
  17. Insert (b.employee_id, B.first_name, B.last_name, B.dept_no, B.salary)
  18. Values (e.employee_id, E.first_name, E.last_name, E.dept_no, E.salary)
  19. Commit;
  20. End;
  21.  
/

Answer:
In merge statement u can not use thos columns in UPDATE SET statement which are specified in ON condition .....

here,u might be getting error like : Invalid Identifier Employee_id .... Rite?
so u just remove the line B.employee_id = E.employee_id from UPDATE SET
statement...
Feb 21 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Kevin King | last post by:
I have a question about an assignment I have. I need to count the number of comparisons in my merge sort. I know that the function is roughly nlog(n), but I am definately coming up with too many...
11
by: Bruce D | last post by:
I have a DataTable that I need to merge the 'lastname' and 'firstname' fields to be displayed in a datagrid. I know I can use the SQL statement to merge the fields into one, but I want to know if...
16
by: UDBDBA | last post by:
Hi All: I need some clarification on a MERGE statement. The database is on V8 FP12 (AIX) 64bit. The source table is tableA. The target is a View "FACT" with UNION ALL because of the 512 Gig...
13
by: ralphedge | last post by:
These sorts work fine on 100000 ints but if I go much higher they will both segmentation fault **************************MERGESORT********************* mergesort(int *a, int size) //a is...
16
by: Sam Durai | last post by:
Hello, I need to merge a small table (of rows less than 100,sometimes even 0 rows) to a big table (of rows around 4 billion). I used the PK of the big table as merge key but merge does a table scan...
4
by: Tom Jones | last post by:
I have an application that was originally built using Visual Studio 2003 that I upgraded to Visual Studio 2005. When I attempt to build the *.msi file in the deployment project, I am getting a...
1
by: UDBDBA | last post by:
Hi, If someone can clarify this, it would be of great help! We have a merge, which is written *only* to update the target table. but the access plan shows branches with inserts and deletes on...
1
by: =?Utf-8?B?S2F0aHll?= | last post by:
I am trying to merge multiple .chm files and cannot get the child TOC to merge correctly. I followed the instructions in the HHW Help on "Creating links from one contents file to another", but when...
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.