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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How to realize the SQL by Windchill API?

WhiteChen
8-Gravel

How to realize the SQL by Windchill API?

Hi,

Need help to create QuerySpec by using Windchill API, the sql like below :


select LENGTHSCALE from EPMDOCUMENT WHERE IDA3MASTERREFERENCE IN (SELECT ida2a2 from EPMDOCUMENTMASTER WHERE DOCUMENTNUMBER='TEST.PRT')


Who can help me?

1 REPLY 1
jmomber
12-Amethyst
(To:WhiteChen)

This is the query you want, but for WTParts. Just change to EPMDocument and EPMDocumentMaster. It also doesn't restrict to just the LENGTHSCALE value, but it's most of what you asked for. There are probably examples in the Customization Guide for just selecting a specific column.

QuerySpec spec = new QuerySpec();

int wtpartIndex = spec.addClassList(WTPart.class, true);

int wtpartMasterIndex = spec.addClassList(WTPartMaster.class, false);

ClassAttribute ida3MasterReference = new ClassAttribute(WTPart.class, WTPart.MASTER_REFERENCE + "." + WTAttributeNameIfc.REF_OBJECT_ID);

ClassAttribute masterIda2a2 = new ClassAttribute(WTPartMaster.class, WTAttributeNameIfc.ID_NAME);

SearchCondition masterNumber = new SearchCondition(WTPartMaster.class, WTPartMaster.NUMBER, SearchCondition.EQUAL, "TEST.PRT");

SearchCondition masterJoin = new SearchCondition(ida3MasterReference, SearchCondition.EQUAL, masterIda2a2);

spec.appendWhere(masterJoin, new int[]{wtpartIndex, wtpartMasterIndex});

spec.appendAnd();

spec.appendWhere(masterNumber, new int[]{wtpartMasterIndex});

System.out.println(spec.toString());

QueryResult qR = PersistenceHelper.manager.find((StatementSpec)spec);

Announcements

Top Tags