Solved

Checking conditions in Sybase Stored Procedure

Posted on 2012-04-02
5
571 Views
Last Modified: 2012-06-21
Hi Experts...
I have around 52 values among which are half of them are of type int and the other half are float.
I need to check whether all the integer values are 0 and all the float values are 0.0 which in this case i need to update the 52 columns as null.
How can i easily check this condition.
Is the syntax just to compare as follows: if( val==0 && val2==0.0....and so on).
Is ther an efficient way to do the same.
Can anyone give syntax for the same.
Please help...
0
Comment
Question by:gaugeta
  • 3
  • 2
5 Comments
 
LVL 14

Expert Comment

by:Jan_Franek
ID: 37799509
The syntax is

IF @val1 = 0 and @val2 = 0.0 ...

or you can just add up absolute values and then check the sum

IF ( abs(@val1) + abs(@val2) + .... ) = 0.0
0
 

Author Comment

by:gaugeta
ID: 37799521
@Jan_Franek:Thanks for the reply.
I need to do this check before updating about 5 million records.
How much time consuming is this process.
Will it increase overall execution time.
0
 
LVL 14

Expert Comment

by:Jan_Franek
ID: 37799595
What exactly are you going to check ? Values in database table (5 million times 52 values) ? Or just stored procedure parameters (1 times 52 values) ?
0
 

Author Comment

by:gaugeta
ID: 37799822
@Jan_Franek:Thanks for the reply.
I am going to check  values sent to the stored procedure.
Since there are 5 million records I'll have to call the stored procedure  (5 million times 52 values).
Please help...
0
 
LVL 14

Accepted Solution

by:
Jan_Franek earned 500 total points
ID: 37800183
Check of the stored procedure parameters is quick. Definitely much quicker then following update. However, calling this procedure 5 million times will take some time. Probably quite a lot of time.

What are you trying to accomplish ? Are you sure, that you need stored procedure ? If you can do it using set based operations (like update), it will be very probably much quicker.

Something like this:

update your_table
set val1 = null, val2 = null ...
where val1 = 0 and val2 = 0.0 and ...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now