Solved

Checking conditions in Sybase Stored Procedure

Posted on 2012-04-02
5
592 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about achieving the basic levels of HRIS security in the workplace.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

695 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