[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 606
  • Last Modified:

Checking conditions in Sybase Stored Procedure

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
gaugeta
Asked:
gaugeta
  • 3
  • 2
1 Solution
 
Jan FranekCommented:
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
 
gaugetaAuthor Commented:
@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
 
Jan FranekCommented:
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
 
gaugetaAuthor Commented:
@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
 
Jan FranekCommented:
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 Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now