January 16, 2008 at 11:19 pm
Hi All,
I have a Stored Procedure where i need a block of code to be Execute repeatedly if condition satisfy.
It is possible by using a outside function,
But I wants the Concepts of Member Function present in OOPS.
More Clear...
Ex: ---
Proc Tests
{
Fun1() {};
Fun2() {};
Begin
If (@var = 1) Fun1();
End
Begin
If (@var =2) Fun1();
End
Begin
If (@var = 3) Fun2();
End
Begin
If (@var = 4) Fun2();
End
}
Please help me....
How to do this?
Cheer!
Sandy
--
January 16, 2008 at 11:35 pm
More Clear to all,
Here In Above Post,
My Stored Procedure is calling one function almost 30 nos. of time
after checking the condition.
if also i am using the out side function its very slow performing,
So I need the suggestion from you all,
how can i make it faster...?
Cheers!
Sandy.
--
January 17, 2008 at 12:16 am
Jeff,
Can you Please Look into this topic?
Cheers!
Sandy.
--
January 17, 2008 at 7:01 am
Hey Sandy,
Can you simply use a WHILE loop?
WHILE [SomeCondition = TRUE]
BEGIN
EXEC sp_proc
[Change Condition]
END
Or do you need something more like:
exec sp_who
go 5
Putting the number next to the GO statement will make something execution multiple times.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 17, 2008 at 7:21 pm
Sandy (1/17/2008)
Jeff,Can you Please Look into this topic?
Cheers!
Sandy.
Another obvious cheat, Sandy?
--Jeff Moden
Change is inevitable... Change for the better is not.
January 17, 2008 at 9:41 pm
Hey Grant,
Nope, Actually I don't want to call any other Store Procedure or function from out side to main procedure.
I wants to define a small block of code in side the same procedure, which can be executed as per the condition ...
Actually Grant, it is not possible by While loop, I have already checked it..and due to the number of calling external function my store procedure performance getting slow..so I need you help.
Can you please clear this line..
exec sp_who
go 5
Cheers!
Sandy.
--
January 18, 2008 at 6:01 am
I still don't understand the problem fully, so I'm not sure I can help.
The second line is just a short cheat that's available with the "go" statement that makes it execute multiple times. So the code would have executed sp_who 5 times in a row.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 18, 2008 at 6:44 am
For the original problem given where certain parameters determine which function may be exercised and returned, a simple CASE statement would be in order whether it be for a RBAR Gui proc or a set based process.
If the parameters are to drive different processes, the processes should be in individual procs and a "Master" proc with IF blocks and EXEC's should control the flow. These are particularlly useful for RBAR GUI code but also have their application in set based batch code.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 18, 2008 at 7:14 am
Unless someone is trying to teach that god-awful four-letter instruction I will not repeat here.
Why someone would ever bring that directive back in, and into SQL Server of all things is beyond me.
Sorry - post-traumatic stress syndrome. I think I will go huddle over in the corner for a while.....
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
January 18, 2008 at 7:17 am
Guess I havn't had enough coffee yet, Matt... which 4-letter instruction? Exec?
--Jeff Moden
Change is inevitable... Change for the better is not.
January 18, 2008 at 7:21 am
The one VB programmers fear most.... I'll give you a hint... G_T_ where underscore is the same letter.
you need a bigger bat for THAT one....
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
January 18, 2008 at 7:38 am
OOOOHHHHHHHH!!! THAT 4-letter word! You're correct... it's a mortal sin to even speak it! 😛
I have a "special" oversize bat for that one... forgot all about it 'cause haven't had to use it on anyone for years. :w00t:
--Jeff Moden
Change is inevitable... Change for the better is not.
January 18, 2008 at 7:42 am
Oh man, don't they have to kick you off the boards for 8 months like Don Imus if you use language like that?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 18, 2008 at 8:15 am
No, no... you have to eat the boards if you use that word 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
January 18, 2008 at 8:17 am
I think we need the bat for the MS programmer that left that command in T-SQL. I mean - what were they thinking?
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Viewing 15 posts - 1 through 15 (of 20 total)
You must be logged in to reply to this topic. Login to reply