Advertisement

06.02.2008 at 01:34AM PDT, ID: 23449202
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

I am having trouble writing a propert update statement??

Asked by salman_sulaiman_2008 in SQL Server 2005

Tags: , , ,

Greetings experts!
I am trying to use a cursor inside my stored procedure, but I am getting the following error:
----
Msg 156, Level 15, State 1, Procedure for_final_statement_revenus, Line 33
Incorrect syntax near the keyword 'cursor'.
Msg 156, Level 15, State 1, Procedure for_final_statement_revenus, Line 36
Incorrect syntax near the keyword 'for'.
Msg 102, Level 15, State 1, Procedure for_final_statement_revenus, Line 42
Incorrect syntax near ';'.
Msg 102, Level 15, State 1, Procedure for_final_statement_revenus, Line 54
Incorrect syntax near 'END'.
-------
I have attached my stored procedure inside the code snippet.
what actually I am trying  to do is update a certain field in the :Final_revenu"  table, by taking the sum of another field in another table.
I wish someone could help me with it.
Thanks in advance.

~salman~Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
USE [MasterFileSQL]
GO
/****** Object:  StoredProcedure [dbo].[for_final_statement_revenus]    Script Date: 06/02/2008 11:23:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
ALTER PROCEDURE [dbo].[for_final_statement_revenus]
@givenTKN_NO int
 
 
 
AS
BEGIN
 
delete from final_revenus
where tkn_no = @givenTKN_NO;
 
INSERT INTO [MasterFileSQL].[dbo].[final_revenus]
           ([tkn_no]
           ,[id_main]
           ,[id_sub]
           ,[dailyTransSum]
           ,[original_balance]
           ,[afterTransbalance]
           ,[available_balance])
select @givenTKN_NO,
       acc_sub.ID_main,
       acc_sub.id_sub,
       0.000,
       0.000,
       0.000,
       0.000
from acc_sub
where acc_sub.id_main = 2;
 
declare
 
       cursor c1 is select  trans_amount  from daily_trans where tkn_no = @givenTKN_NO  and ID_MAIN = 2;
    
begin
    for i  in c1 loop
	      
		         update final_revenu set dailyTransSum = sum(i.trans_amount) where ID_MAIN = i.ID_MAIN and ID_SUB = i.ID_SUB;
 
		
		
	end loop;
	commit;
 
end
 
 
 
 
 
 
 
 
END
[+][-]06.02.2008 at 01:46AM PDT, ID: 21690389

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 01:46AM PDT, ID: 21690391

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 01:46AM PDT, ID: 21690392

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 01:47AM PDT, ID: 21690400

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 01:49AM PDT, ID: 21690408

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 02:18AM PDT, ID: 21690527

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 02:21AM PDT, ID: 21690540

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 02:48AM PDT, ID: 21690654

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 03:10AM PDT, ID: 21690725

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 03:16AM PDT, ID: 21690744

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Server 2005
Tags: Microsoft, Microsoft SQL SERVER 2005, 2005, Stored Procedure, Cursor, Update Statement
Sign Up Now!
Solution Provided By: HuyBD
Participating Experts: 3
Solution Grade: A
 
 
[+][-]06.02.2008 at 03:52AM PDT, ID: 21690875

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 06:49AM PDT, ID: 21691907

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628