?
Solved

How do I account for NULL fields?

Posted on 1998-12-18
4
Medium Priority
?
207 Views
Last Modified: 2010-03-19
How do I break this up so if the gsATASuffix is NULL abandon and run (line 1) then go to the Else section?  If gsATASuffix in NOT Null continue on...I have written this so many different ways that I cannot see the solution anymore.

msSQL = "SELECT " & gsATAPrefix & "+ '-' +" & gsATABase

msSQL = msSQL & "+ '-' +" & gsATASuffix & " AS Expr1 From " & gsTBL_ATAInfo & " WHERE " & gsPartIndex & " = " & _
mlPartIndex & " And Not IsNull(" & gsATASuffix & ") Group By " & gsATAPrefix & "+ '-' +" & gsATABase & "+'-'+" & gsATASuffix & ";"

Else

msSQL = msSQL & " AS Expr1 From " & gsTBL_ATAInfo & " WHERE " & gsPartIndex & " = " & _
mlPartIndex & " Group By " & gsATAPrefix & "+ '-' +" & gsATABase & ";"

End If

0
Comment
Question by:kmdisney
[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
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
tschill120198 earned 800 total points
ID: 1092332
Looks like you are doing this in VBScript, and that gsATASuffix is a string.  If by "gsATASuffix is NULL" you mean an empty string, this should work...

Or do you literally mean NULL?  Let me know if I've misunderstood your question...

msSQL = "SELECT " & gsATAPrefix & "+ '-' +" & gsATABase
If Len(gstaSuffix) = 0 then
    msSQL = msSQL & "+ '-' +" & gsATASuffix & " AS Expr1 From " & gsTBL_ATAInfo & " WHERE " & gsPartIndex & " = " & _
    mlPartIndex & " And Not IsNull(" & gsATASuffix & ") Group By " & gsATAPrefix & "+ '-' +" & gsATABase & "+'-'+" & gsATASuffix & ";"
Else
    msSQL = msSQL & " AS Expr1 From " & gsTBL_ATAInfo & " WHERE " & gsPartIndex & " = " & _
    mlPartIndex & " Group By " & gsATAPrefix & "+ '-' +" & gsATABase & ";"
End If
0
 

Author Comment

by:kmdisney
ID: 1092333
I am using VB 6 and literally the siffix column is NULL but I could set it to zero length.

In the meantime I will try your suggestion.


0
 

Author Comment

by:kmdisney
ID: 1092334
Nope - same problem...

See  the msSQL on line 3 basically says take the Prefix and the Base and go find the matching suffix using the gsPartIndex. Which when the suffix exists I return a string like XX-XXX-XXX.  The problem is IF the suffix is indeed NULL the code will NOT jump to the ELSE...The ELSE gives me just the correct Prefix and Base with no suffix.  Does this make sense?  What I need this to do is to take the prefix and base and see if there is a suffix - if there is continue on...if not just return the prefix and base.
Complicated huh?

msSQL = "SELECT " & gsATAPrefix & "+ '-' +" & gsATABase
If Len(gsATASuffix) = 0 Then
msSQL = msSQL & "+ '-' +" & gsATASuffix & " AS Expr1 From " & gsTBL_ATAInfo & " WHERE " & gsPartIndex & " = " & _
            mlPartIndex & " And Not IsNull(" & gsATASuffix & ") Group By " & gsATAPrefix & "+ '-' +" & gsATABase & "+'-'+" & gsATASuffix & ";"

            Else
            msSQL = msSQL & " AS Expr1 From " & gsTBL_ATAInfo & " WHERE " & gsPartIndex & " = " & _
            mlPartIndex & " Group By " & gsATAPrefix & "+ '-' +" & gsATABase & ";"
0
 
LVL 2

Expert Comment

by:tschill120198
ID: 1092335
Did you get it working?
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

777 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