473,395 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

sybase sp works from sql client but not from c# code

I have an sql statement with if statements that when run from an sql client works but when run from c# it seems to miss out the if statements.. has this happened to anyone before?

here is th stored proc, it is not evaluating the first if statement properly. I have tried loads of different ways of doing the same thing but no joy.

Expand|Select|Wrap|Line Numbers
  1. create procedure NewSingleRedemption  
  2.  
  3.   -- Input vars --  
  4.   -- return var...  
  5.   @action_id int output,  
  6.  
  7.   -- for Action table...  
  8.   @RedemptionDate date,  
  9.   @ActionType varchar(30),  
  10.   @Origin varchar(20),  
  11.   @PaperStatus varchar(30),  
  12.  
  13.   -- for RedemptionAction table...  
  14.   @ReceivedDate datetime,  
  15.   @ShortCode varchar(20),  
  16.   @Amount float,  
  17.   @AmountType varchar(20),  
  18.   @disregardDeferredAmt bit,  
  19.   @BaseDate varchar(11),  
  20.   @Waiver float  
  21.  
  22.  
  23.  
  24.  
  25. as  
  26.   begin 
  27.      -- first check to see if user has set the action id to -1 from flosuite which   
  28.     -- would indicate if they have selected to continue from the GUI   
  29.  
  30.     if action_id <> -1
  31.  --check to see if similar redemption exists  
  32.     select @action_id=0 
  33.     select @action_id=action_id from v_RedemptionAction  
  34.     where ShortCode=@ShortCode  
  35.     and RedemptionDate=@RedemptionDate  
  36.     if @action_id <> 0 
  37.      begin  
  38.      select @action_id = -@action_id    
  39.      select @action_id  
  40.      return
  41.     end  
  42.   end  
  43.  
  44.  
  45.   begin tran      
  46.     -- Internal vars --  
  47.  
  48.     -- for Action table...  
  49.     declare @updateDate datetime  
  50.     declare @type_id int  
  51.     declare @status_id int  
  52.  
  53.     -- for RedemptionAction table...  
  54.     declare @sub_id int  
  55.     declare @fund_id int  
  56.     declare @investor_id int  
  57.  
  58.     -- Set any NULL vals  
  59.     if @BaseDate = 'Jan 01 1900'  
  60.       SELECT @BaseDate = NULL  
  61.     if @BaseDate = 'Dec 31 1900'  
  62.       SELECT @BaseDate = "max"  
  63.     if @Waiver = 0  
  64.       SELECT @Waiver = NULL  
  65.  
  66.     -- Get sub_id and investor_id for short code --  
  67.     SELECT @sub_id=subscription_id, @fund_id=fund_id, @investor_id=investor_id FROM Investor..Subscription  
  68.     WHERE name = @ShortCode  
  69.  
  70.     -- Get other data --  
  71.     SELECT @updateDate=getdate()  
  72.     SELECT @type_id=type_id FROM Investor_nf1..ActionType WHERE description = @ActionType  
  73.     SELECT @status_id=status_id FROM Investor_nf1..ActionStatus WHERE description = @PaperStatus  
  74.  
  75.     -- Insert record into Action and get action_id --  
  76.     INSERT INTO Investor_nf1..Action (updateDate, actionDate, type_id, origin, parent_id, status_id, completedDate)  
  77.     VALUES (@updateDate, @RedemptionDate, @type_id, @Origin, NULL, @status_id, NULL)  
  78.     SELECT @action_id=@@identity  
  79.  
  80.     -- Insert into RedemptionAction --  
  81.     INSERT INTO Investor_nf1..RedemptionAction (action_id, fund_id, investor_id, sub_id, requestReceivedDate, amountRequested,   
  82.       amountType, percentBaseDate, disregardDeferredAmt, previouslySatisfied,  amountRedeeming, amountDeferred, waiver_id,   
  83.       investorGateInvoked, capitalInclusionGateInvoked, portfolioCompanyGateInvoked)  
  84.     VALUES (@action_id, @fund_id, @investor_id, @sub_id, @ReceivedDate, @Amount,   
  85.       @AmountType, @BaseDate, @disregardDeferredAmt, 0, NULL, NULL, @Waiver,   
  86.       0, 0, 0)  
  87.  
  88.     -- Return value --  
  89.     SELECT @action_id  
  90.  
  91.    commit tran  
  92.   end
  93.  
May 16 '07 #1
0 928

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ashish | last post by:
Hi, I am using PHP 4.2.3 and Sybase 12.0 I want to insert records in multiple tables in a database. I also want to use transactions so that I can rollback in case there was a problem. I...
3
by: Ilya Knizhnik | last post by:
I was wondering how to connect to postgresql and sybase databases. I'm assuming that I need to recompile php with the flags for both Do I also need to install sybase and postgresql themselves...
18
by: David Rysdam | last post by:
What module is most recommended for accessing Sybase from Python? This one: http://www.object-craft.com.au/projects/sybase/sybase/ ? Also, is there any module that provides a generic DB API and...
1
by: jamilah | last post by:
I am on windows xp, have installed sybase client, what driver do i need for tcp/ip connection to sybase12 sql server? For odbc, I only have Microsoft sql server driver Version 2000.81.9042.00
1
by: sleepite | last post by:
If I configure PHP with: ../configure --with-mysql --with-apxs2=/www/bin/apxs --with-sybase-ct=/usr/lo cal/freetds --enable-track-vars --with-xml --with-zlib-dir=/rpms/zlib-1.2.3 --with-png...
6
by: bala | last post by:
hi access guru's there is a requirement wherein i have to connect ms access frontend with sybase (backend). the data from the frontend should be saved in the table in sybase databae thro...
1
by: xinhuanet.com | last post by:
can you tell me how to connect to sybase database with vb.net? please give me one example.thank you!
4
by: Dan | last post by:
I have compiled and installed sybase-.037 , the module to add sybase to python. However, when I try to use it I get Import error: /usr/local/lib/python2.3/site-packages/sybasect.so undefined...
0
by: =?ISO-8859-1?Q?S=E9bastien_Sabl=E9?= | last post by:
WHAT IS IT: The Sybase module provides a Python interface to the Sybase relational database system. It supports all of the Python Database API, version 2.0 with extensions. The module is...
0
by: =?ISO-8859-1?Q?S=E9bastien_Sabl=E9?= | last post by:
WHAT IS IT: The Sybase module provides a Python interface to the Sybase relational database system. It supports all of the Python Database API, version 2.0 with extensions. The module is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.