Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Problem with conditionals in sproc


Message #1 by "Peter Scribner" <plscribner@w...> on Mon, 2 Sep 2002 02:10:35
Peter,

On seeing the values you have posted, I could figure our the problem. As I have observed, 

1) The following part of the SP, would return S alone. (ie:) @BAType would have only S as its value once executed. Since it returns
multiple values -- in this case A,C and S, and the final value is stored into it.

Declare @BAType char(1)
select @BAType=BATType from BATrans where BATContractorID = @CID and 
BATBankAcctID = @BAID

2) So due to this it doesn't execute the first part of the IF statement since you check for either A or C. So in the else part, you
get all the Owner's Names instead of its corresponding Vendor's Name. 

Also wondering why you get only 7 out of 9 records in resultset.

I thought it would be returning only one value on the 1st case. So it went wrong. After seeing your real time values, I would
suggest you to make the changes so as to run the following part of the SP for every BAType(A,C and S)
---------------------------------------------
Select BATrans.*, BATD_CheckNo, BATransDetail.BACheckToFrom,
Vendors.VName as SOURCENAME -- Vendors.VName
from BATrans, BATransDetail,Vendors 
WHERE BATrans.BATContractorID=@CID AND
BATrans.BATBankAcctID = @BAID AND
BATransDetail.BATransID=BATrans.BATTransID AND
BATransDetail.BACheckToFrom=Vendors.VendorID
--------------------------------------------
Only then you would get 5 corressponding rows for A, 3 for C and 1 for S.

Let me figure out that. By the time if you could (if it is not so confidential data) send the values of the tables you have posted
in the ask2.asp... URL.... in excel format along with the corresponding Vendor and Owner table values, it would be more helpful. I
would port them to a my DB and make changes accordingly in SP and send you at the earliest.

My Personal ID is - happygv@y...
Office Id - vijay.kumar@e... (I am working today)

Cheers!!!
Vijay G

 Peter Scribner 
wrote:
Vijay,

Thanks for your help thusfar; it is very much appreciated. I am having 
some hard time getting this working. When I read your sproc it looks like 
it should work fine. I have a detailed example of tables and output from 
the sp at www.wipschedule.com/ask2.asp Could you please take a look at it 
and help find out what's wrong.

Thanks again...
Peter



---------------------------------
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes

  Return to Index