Click here to Skip to main content
16,021,285 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,,,



i want to insert data at first into the temptable then after the approval=true then only that data must be inserted into the corresponding main table ,


please give me an idea
Posted
Comments
Santhosh Kumar Jayaraman 4-Aug-12 7:25am    
what is meant by approval? If some one has to give approval explicitly?
sk. maqdoom ali 4-Aug-12 7:26am    
yes, from admin level approval is there
Santhosh Kumar Jayaraman 4-Aug-12 7:28am    
Then i dont think you can go with temptable concepts. You can copy into someother table and then after approval, copy to main table.. Once records are copied into maintable, delete records from other table.
sk. maqdoom ali 4-Aug-12 8:19am    
alter PROCEDURE sp_CSP_SaveTemp_Table
@ID INT,
@Account_Id INT=NULL,
@Application_Ref_No NVARCHAR(20),
@Balance_Repayable FLOAT=NULL,
@CheckBook_Status TINYINT=NULL,
@ATMCard_Status TINYINT=NULL,
@Closing_Type TINYINT=NULL,
@Closing_Interest_Rate TINYINT=NULL,
@Source_Funds TINYINT=NULL,
@Reason_Balance_Transfer TINYINT=NULL,
@ROI_OfferedBy_Bank FLOAT=NULL,
@Reason_Balance_Transfer_Others NVARCHAR(150),
@Mode_Payment TINYINT=NULL,
@Reason_Closure NVARCHAR(150),
@Is_Manager_Approved tinyint =NULL,
@Reason_Rejeted TEXT=NULL,
@User_ID INT=NULL,
@IP_Address NVARCHAR(15),
@ApprovedBy INT=NULL,

@Insertion_Approved BIT=NULL


AS
BEGIN

IF @Insertion_Approved IS NULL

BEGIN

CREATE TABLE #Closure_Copy(
[ID] [int] ,
[Account_Id] [int] NULL,
[Application_Ref_No] [nvarchar](20) NULL,
[Balance_Repayable] [float] NULL,
[CheckBook_Status] [tinyint] NULL,
[ATMCard_Status] [tinyint] NULL,
[Closing_Type] [tinyint] NULL,
[Closing_Interest_Rate] [float] NULL,
[Source_Funds] [tinyint] NULL,
[Reason_Balance_Transfer] [tinyint] NULL,
[ROI_OfferedBy_Bank] [float] NULL,
[Reason_Balance_Transfer_Others] [nvarchar](150) NULL,
[Mode_Payment] [tinyint] NULL,
[Reason_Closure] [text] NULL,
[Is_Manager_Approved] [tinyint] NULL,
[Reason_Rejeted] [text] NULL,
[User_ID] [int] NULL,
[IP_Address] [nvarchar](15) NULL,
[Date_Time] [datetime] NULL,
[ApprovedBy] [int] NULL)


INSERT INTO #Closure_Copy(ID ,
Account_Id,
Application_Ref_No,
Balance_Repayable,
CheckBook_Status,
ATMCard_Status,
Closing_Type,
Closing_Interest_Rate,
Source_Funds,
Reason_Balance_Transfer,
ROI_OfferedBy_Bank,
Reason_Balance_Transfer_Others,
Mode_Payment,
Reason_Closure,
Is_Manager_Approved,
Reason_Rejeted,
[User_ID],
IP_Address,
Date_Time,
ApprovedBy)
values(@id,@Account_Id,
@Application_Ref_No,
@Balance_Repayable,
@CheckBook_Status,
@ATMCard_Status,
@Closing_Type,
@Closing_Interest_Rate,
@Source_Funds,
@Reason_Balance_Transfer,
@ROI_OfferedBy_Bank,
@Reason_Balance_Transfer_Others,
@Mode_Payment,
@Reason_Closure,
@Is_Manager_Approved,
@Reason_Rejeted,
@User_ID,
@IP_Address,
GETDATE(),
@ApprovedBy)

END


ELSE

BEGIN

INSERT INTO Account_Closure(
Account_Id,
Application_Ref_No,
Balance_Repayable,
CheckBook_Status,
ATMCard_Status,
Closing_Type,
Closing_Interest_Rate,
Source_Funds,
Reason_Balance_Transfer,
ROI_OfferedBy_Bank,
Reason_Balance_Transfer_Others,
Mode_Payment,
Reason_Closure,
Is_Manager_Approved,
Reason_Rejeted,
[User_ID],
IP_Address,
Date_Time,
ApprovedBy)

VALUES(@Account_Id,
@Application_Ref_No,
@Balance_Repayable,
@CheckBook_Status,
@ATMCard_Status,
@Closing_Type,
@Closing_Interest_Rate,
@Source_Funds,
@Reason_Balance_Transfer,
@ROI_OfferedBy_Bank,
@Reason_Balance_Transfer_Others,
@Mode_Payment,
@Reason_Closure,
@Is_Manager_Approved,
@Reason_Rejeted,
@User_ID,
@IP_Address,
GETDATE(),
@ApprovedBy)

END
END


i am using the above procedure but after execution i am getting the result as Invalid object name '#Closure_Copy'.
Santhosh Kumar Jayaraman 4-Aug-12 8:26am    
The temp table will hold only till the current connection for the user is active. Thats what i said, save it in some other physical table.
Create new table Account_closure1 and save it there. Then finally once it gets approval, remove from account_closure1 and insert into account_Closure

1 solution

Then i dont think you can go with temptable concepts. You can copy into someother table and then after approval, copy to main table.. Once records are copied into maintable, delete records from other table.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900