[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Checking conditions in Sybase Stored Procedure

Posted on 2012-04-02
5
Medium Priority
?
599 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 2000 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
What we learned in Webroot's webinar on multi-vector protection.
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

656 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