By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,419 Members | 1,648 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,419 IT Pros & Developers. It's quick & easy.

Double Insert Statement Probs

P: 83
Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE [dbo].[get_user]
  2. (    
  3.     @user_id varchar(8),
  4.     @pwd varchar(12)
  5.     )
  6. AS
  7.  
  8. IF EXISTS(SELECT Personel_No From TblUser_ID where Personel_No = @user_id)
  9.   BEGIN
  10.   IF EXISTS(SELECT Password From TblUser_ID where Personel_No = @user_id AND Password = @pwd)
  11.            BEGIN
  12. INSERT INTO TblAudit_Trails(Personel_No,IC_Baru,Business_Area) 
  13. SELECT Personel_No,IC_Baru,Business_Area 
  14. From TblPeribadi 
  15. WHERE Personel_No = @user_id AND IC_Baru = @pwd
  16. RETURN(3)
  17.            END
  18.   ELSE
  19.            RETURN(1)
  20.   END
  21. ELSE
  22.   BEGIN
  23.   IF EXISTS(SELECT Personel_No From TblPeribadi where Personel_No = @user_id)
  24.     BEGIN
  25.     IF EXISTS(SELECT IC_Baru From TblPeribadi where Personel_No = @user_id AND IC_Baru = @pwd)
  26.         BEGIN
  27.         INSERT INTO TblAudit_Trails(Personel_No,IC_Baru,Business_Area) 
  28.         SELECT Personel_No,IC_Baru,Business_Area 
  29.                     From TblPeribadi 
  30.         WHERE Personel_No = @user_id AND IC_Baru = @pwd
  31.  
  32.                     INSERT INTO TblUser_ID(Personel_No,Password,Update_By) 
  33.         VALUES(@user_id,@pwd,@user_id)
  34.         RETURN(4)
  35.                                 END
  36.     ELSE
  37.         RETURN(2)
  38.     END
  39.   ELSE
  40.                 RETURN(0)
  41. END
  42.  
//Msg 207, Level 16, State 1, Procedure get_user, Line 15
Invalid column name 'Personel_No'.
Msg 207, Level 16, State 1, Procedure get_user, Line 30
Invalid column name 'Personel_No'.

It appears as my thought cannot be double INSERT statement.but some example of SQL statement that I search for make it successful
So someone please help me..........
Sep 24 '08 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
Moved to the SQL Server forum (I'm guessing slightly - might belong to Oracle). If it's the wrong forum, could a moderator kindly move it to the correct forum.

@OP, please post your questions in the correct forum. This does not belong in the Feedback forum.

Moderator.
Sep 24 '08 #2

iburyak
Expert 100+
P: 1,017
Check if TblUser_ID has a column Personel_No

It is hard to tell because I don't see your database objects.

Comment out pieces of your code and run it to find which one is having a problem.

Good Luck.
Sep 24 '08 #3

P: 83
Check if TblUser_ID has a column Personel_No

It is hard to tell because I don't see your database objects.

Comment out pieces of your code and run it to find which one is having a problem.

Good Luck.
Exactly you're right! I have check it it's my database field name probs.....
Anyway sorry to burst into wrong forum place
Sep 25 '08 #4

Post your reply

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