Current location: Hot Scripts Forums » Other Discussions » Database » Problem with stored procedure


Problem with stored procedure

Reply
  #1 (permalink)  
Old 06-08-07, 01:18 AM
omniman's Avatar
omniman omniman is offline
Coding Addict
 
Join Date: Aug 2006
Location: Baltimore, MD
Posts: 342
Thanks: 0
Thanked 1 Time in 1 Post
Problem with stored procedure

I have a situation where I want to call a stored procedure (from another stored procedure) depending on a value in the first procedure. My first SP is:

sql Code:
  1. CREATE PROCEDURE [dbo].[getAdminPending] AS
  2.  
  3. declare @rPrice numeric
  4. SELECT     search_tracker.file_number, client.client_name, client_pricing.price, search_tracker.search_id,
  5. case search_tracker.recording when 'Y' then exec @rPrice = getRecordingPrice search_tracker.client_id, search_tracker.state else 'NO' end AS recording_price
  6. FROM         search_tracker INNER JOIN
  7.                       client ON client.client_id = search_tracker.client_id INNER JOIN
  8.                       client_pricing ON client_pricing.order_type_id = search_tracker.order_type_id AND client_pricing.state = search_tracker.state AND
  9.                       client_pricing.client_id = search_tracker.client_id
  10. WHERE     (search_tracker.status_id = 2) OR
  11.                       (search_tracker.status_id = 4)
  12. ORDER BY client.client_name
  13. GO

getRecordingPrice stored procedure looks like:
sql Code:
  1. CREATE PROCEDURE [dbo].[getRecordingPrice]
  2.     @clientID int,
  3.     @clientState varchar(2)
  4. AS
  5. declare @recordingAmt numeric
  6. SELECT price
  7. FROM client_pricing
  8. WHERE client_pricing.client_id = @clientID AND client_pricing.state = @clientState AND client_pricing.order_type_id = 7
  9. RETURN @recordingAmt
  10. GO

I get the following errors:
---------------------------
Microsoft SQL-DMO (ODBC SQLState: 42000)
---------------------------
Error 156: Incorrect syntax near the keyword 'exec'.
Line 5: Incorrect syntax near '.'.
---------------------------

Any help would be great.
__________________
"Political Correctness is a doctrine, fostered by a delusionary, illogical, liberal minority and rabidly promoted by an unscrupulous mainstream media, which holds forth the proposition that it is entirely possible to pick up a turd by the clean end."

Last edited by Christian; 06-08-07 at 01:43 AM. Reason: Please use [highlight=sql] tags when posting SQL code.
Reply With Quote
  #2 (permalink)  
Old 06-08-07, 05:23 PM
mattyblah mattyblah is offline
Newbie Coder
 
Join Date: Mar 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
use a user defined function instead of stored procedure.
Reply With Quote
  #3 (permalink)  
Old 06-09-07, 08:49 PM
omniman's Avatar
omniman omniman is offline
Coding Addict
 
Join Date: Aug 2006
Location: Baltimore, MD
Posts: 342
Thanks: 0
Thanked 1 Time in 1 Post
Worked great; thanks.
__________________
"Political Correctness is a doctrine, fostered by a delusionary, illogical, liberal minority and rabidly promoted by an unscrupulous mainstream media, which holds forth the proposition that it is entirely possible to pick up a turd by the clean end."
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
login, roles problem dbrook007 ASP.NET 10 11-10-06 03:42 PM
Count problem kasic ASP.NET 1 10-20-04 12:23 AM
Asp and Microsoft Access 2002 problem gop373 ASP 2 10-06-04 09:13 AM
mysq stored procedure with variable table name axelmangr PHP 5 08-31-04 02:24 PM
using stored procedure in dreamweaver samkry ASP 1 06-10-04 10:09 PM


All times are GMT -5. The time now is 04:58 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.