Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: tzafrir on March 18, 2016, 06:40:10 pm
-
Hi,
Is there an SQL query that I can get all (and only) packages in the model?
-
Select * from t_package (http://Select * from t_package) ???
Geert
-
When I run the following command:
EA.Collection result = repository.GetElementSet("Select Package_id from t_package", 2);
I am getting the following error:
DAO.fields [3265] item not found in this collection
When running,
EA.Collection result = repository.GetElementsByQuery("Select Package_id from t_package","");
I am getting
"Search Not found"
This query extracts values using EA Builder with no errors, what is the correct way of getting those Ids?
-
Hi Tzafrir,
GetElementSet() expects a list of IDs, comma separated, not a SQL query.
GetElementsByQuery() expects a EA Search, not a SQL Query, like 'Simple' or so. Have a look in the search window (CTRL+F) for available searches. For a start try Simple.
See documentation: http://sparxsystems.com/enterprise_architect_user_guide/12.1/automation_and_scripting/repository3.html
Regards,
Helmut
-
Actually, GetElementSet() can use a SQL Query, but it can only return a collection of Element objects, not Package objects.
You might be able to use something like:
EA.Collection result = Repository.GetElementSet("select object_id from t_object where object_type = 'Package'", 2);
Then make sure to handle the contents of this collection as EA.Element types, not EA.Package. To get the corresponding EA.Package for each of these elements, try calling Repository.GetPackageByGUID( element.ElementGUID ).
-
thanks