TeamcenterKnowledge

Query utilities

query_xml

Creates, modifies, writes, deletes, and runs queries from an XML formatted file. Syntax query_xml [-u=user-id {-p=password | -pf=password-file} -g=group] -v -f=xml-command-file [-o=output-file-name] [-h] Arguments -u= Specifies the user ID. This is a user with Teamcenter administration privileges. If this argument is used without a value, the operating system user name is used. Note If Security Services single sign-on (SSO) is enabled for your server, the -u and -p arguments are authenticated externally through SSO rather than being authenticated against the Teamcenter database. If you do not supply these arguments, the utility attempts to join an existing SSO session. If no session is found, you are prompted to enter a user ID and password. -p= Specifies the password. If used without a value, the system assumes a null value. If this argument is not used, the system assumes the user-ID value to be the password. This argument is mutually exclusive with the -pf argument. -pf Specifies the password file. If used without a value, the system assumes a null value. If this argument is not used, the system assumes the user-ID value to be the password. For more information about managing password files, see Manage password files. This argument is mutually exclusive with the -p argument. -g= Specifies the group associated with the user. If used without a value, the user's default group is assumed. -f= xml-command-file Specifies the fully qualified name of the XML file used to control processing. This argument is mandatory. -o= output-file-name Specifies the name of the file to which the output from the write and execute processes are written. This argument is optional. If unspecified, the output is sent to the console. This parameter is required for the execute and execute_tuple command types. The -o argument specified for outputting a generated query result file does not support appending the results of multiple queries to the specified output file. If you have more than one query specified in the query_xml utility, only the last query is included in the defined output file. The documentation for -o usage is correct for a single query but does not describe the scenario or required parameter for multiple queries and output files. If you execute multiple queries using query_xml, add a parameter called outputFileName to the query definition to specify a unique output file for each query. Because queries can result in structurally different XML content per context, queries cannot be appended together and must be treated as unique files per query. For example: Copy Copy Copy Copy Copy Copy Copy Copy Copy <ImanQueryCommand command="execute" Copy Copy Copy Copy Copy Copy Copy Copy Copy Copy Copy Running query_xml -u=Tc-admin-user -p=password -input=myfile generates three output files (outpff1.xml, outpff2.xml, outpff3.xml). -v Specifies verbose mode. -h Displays help for this utility. Environment As specified in Setting up a Teamcenter command-line environment. If the TC_TMP_DIR variable is not set, set it to a temporary location. Files As specified in Log files produced by Teamcenter and the following files: qry_filerunner_def.dtd Defines the format of the driving file. pffdef.dtd Defines the output format when the PFF option is used. Restrictions None. Return Values Return value upon success 0 Return value upon failure Nonzero Examples To create a query, enter the following command on the command line: Copy query_xml -f=xml-file-name -u=Tc-admin-user -p=password -o=output-file To receive output for the execute and execute_tuple command types, you must supply a pffName in the input XML command file and an output file name in the -o=output-file-name parameter on the query_xml call. Output file names specified in the input XML command file are ignored. If the query definition includes a query_input_parameter, where the value is a date and time, the time must be defined in Coordinated Universal Time (UTC). Teamcenter interprets the time supplied in the following example as 09:00 UTC. It does not return the time in the time zone where the program is being run. Copy XML File Format and Examples The XML file must conform to the format shown in the following code segments. XML file format Copy <!DOCTYPE ImanQueryCommandFile [

<!ELEMENT name EMPTY>
<!ATTLIST name value  CDATA #REQUIRED>
<!ELEMENT description EMPTY>
<!ATTLIST description value  CDATA #REQUIRED>
<!ELEMENT class EMPTY>
<!ATTLIST class value  CDATA #REQUIRED>
<!ELEMENT clauses_real (#PCDATA)>
<!ELEMENT clauses_display (#PCDATA)>
<!ELEMENT uniqueid EMPTY>
<!ATTLIST uniqueid value  CDATA #REQUIRED>
<!ELEMENT iflag EMPTY>
<!ATTLIST iflag value  CDATA #REQUIRED>
<!ELEMENT ImanQueryDefinition (name, description, class, clauses_real,

clauses_display?, uniqueid, iflag)>

<!ELEMENT query_input_parameter EMPTY>
<!ATTLIST query_input_parameter name  CDATA #REQUIRED>
<!ATTLIST query_input_parameter value CDATA #REQUIRED>
<!ELEMENT query_pff_post EMPTY>
          outputFileName CDATA #REQUIRED> <!-- file to write data  (no longer used)-->

Copy

<!ELEMENT ImanQueryCommandFile (ImanQueryCommand)*>
<!ATTLIST ImanQueryCommandFile  site_name CDATA #IMPLIED
                                site_id   CDATA #IMPLIED> 

]> SELECT qid FROM ItemRevision WHERE "Form:IMAN_specification.ECOSample:data_file.charge_number" = "${charge = }" SELECT qid FROM ItemRevision WHERE "Form:IMAN_specification.ECOSample:data_file.charge_number" = "${charge = }" XML file example Copy SELECT qid FROM ItemRevision WHERE "object_name" = "${Name = }" AND "item_revision_id" = "${Revision = }" XML file example Copy Query Types Create, modify, and delete the following query types using the query_xml utility. Use the following values in the iflag field to specify the query type in the .xml file for create and modify tasks. The value for delete remains the same. Local Query “0” Remote Query “1” User Exit Query “8” User Query “16” Structure Query “40” For information about where these query types are applicable, see Search and Query Builder. The following code is an example for a BOM structure query modification. BOM structure query modification Copy SELECT qid FROM ItemRevision WHERE "Form:IMAN_specification.ECOSample: Copy data_file.charge_number" = "${charge = }"

Source: https://docs.sw.siemens.com/documentation/external/PL20251212545240207/en-US/tc_help/utilities_reference/jhb1737253704745/query_xml.html · retrieved Fri Jul 31 2026 00:00:00 GMT+0000 (Coordinated Universal Time)