TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abumiyan Muqri
NA
43
48.2k
Insert/Update in MySql
Jul 16 2012 5:37 AM
Hi all,
I have written following procedure in MySql.I want to insert record if it is not exist in table or update it if it is already exist.
But when i call it from C# code to fetch data from XMl file, it gives error as "Cannot isert record" because in table
sid
is Primary Key.
Please Help...
DELIMITER $$
DROP PROCEDURE IF EXISTS `dbsims`.`SystemInfoInsert` $$
CREATE PROCEDURE `dbsims`.`SystemInfoInsert`
(
IN p_sid varchar(100),
IN p_host_name varchar(20),
IN p_ip varchar(20),
IN p_solution varchar(50)
)
BEGIN
IF EXISTS(select * from system_info where sid = p_sid) THEN
UPDATE system_info set sid=p_sid, host_name=p_host_name, ip=p_ip, solution=p_solution;
ELSE
INSERT INTO system_info
(
sid,
host_name,
ip,
solution,
last_updated_date
)
VALUES
(
p_sid,
p_host_name,
p_ip,
p_solution,
NOW()
);
END IF;
END $$
DELIMITER ;
Reply
Answers (
2
)
Sql Upation error: in sql2008: Error converting data type varchar to numeric
List alll tables from a database