?
Solved

Checking conditions in Sybase Stored Procedure

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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
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…
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…

771 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