Skip to main content
1-Visitor
February 3, 2016
Question

How to get StringValue from database if it is null

  • February 3, 2016
  • 3 replies
  • 2055 views

Good Afternoon Team,

Can you help me how we can get the  StringValue.Value2 from part if it is null

here is the query I am running right now which gives only those parts which Have StringValue.Value2 something in DB

select pm.NAME,pm.WTPARTNUMBER, p.VERSIONIDA2VERSIONINFO ||'.'|| p.ITERATIONIDA2ITERATIONINFO as "Version",p.STATECHECKOUTINFO,p.STATESTATE,  sv.VALUE2  as Test1

from WTPartmaster pm, WTPart p ,PDMLINKPRODUCT prd, StringValue sv, STRINGDEFINITION sd

where  pm.IDA2A2 = p.IDA3MASTERREFERENCE and pm.IDA3CONTAINERREFERENCE = prd.IDA2A2 

and sd.NAME = 'test1'  and sv.IDA3A4 = p.IDA2A2 and p.versionsortida2versioninfo=(select max (c.versionsortida2versioninfo)

from wcadmin.wtpart c

where c.ida3masterreference = p.ida3masterreference) and p.LATESTITERATIONINFO = 1 and sd.ida2a2 = sv.IDA3A6 ;

3 replies

23-Emerald IV
February 3, 2016

I'm not quite following this part "from wcadmin.wtpart c" since I don't see a Windchill table called "wcadmin", but I think you need to left join the string value table and possibly even string definition table onto the rest of your query.  This will allow all entries from the main query to be listed, even if there are null values in the joined tables.

2-Explorer
February 3, 2016

I'm assuming this is the part of the query you want to modify?

and sd.NAME = 'test1'  and

Try changing it to this and see what you get:

and (sd.NAME = 'test1' or sd.NAME = '') and

or, if the value is actually null change it to this:

and (sd.NAME = 'test1' or sd.NAME is null)  and

See what happens.

1-Visitor
February 3, 2016

Left outer join is the option, like Tom said