cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get StringValue from database if it is null

adev
1-Newbie

How to get StringValue from database if it is null

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 3
TomU
23-Emerald II
(To:adev)

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.

tstacy
1-Newbie
(To:adev)

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.

BineshKumar1
12-Amethyst
(To:adev)

Left outer join is the option, like Tom said

Announcements
Learn more about how we are using our browser poll here