I use SqlExecute activity of Build Extension
I wish pass params in arguments of my activity
But my problem is Te parameters are not injected into the SQL script, can you help me please. have you used SqlExecute activity?
Parameters Section in editor, in my build designer of template tfs / wwf :
New String(5) {
"BackupFilePath = F:\MSSQL10.IS_CLTLIVE_DE\DUMP\ClearProdDump\CP.dmp",
"LogicalDataFile = CP_Data01",
"DataFilePath = F:\MSSQL10.IS_CLTLIVE_DE\data\",
"LogicalLogFile = CP_TLog01",
"LogFilePath = F:\MSSQL10.IS_CLTLIVE_DE\log\",
"DatabaseName = AghilasCP_Tmp"
}
My Script.sql
IF EXISTS (SELECT name FROM sys.databases WHERE name = $(DatabaseName ))
Reading the code of that activity it seems that you need to specify the parameters as
New String(5) {
"#BackupFilePath='F:\MSSQL10.IS_CLTLIVE_DE\DUMP\ClearProdDump\CP.dmp'",
"#LogicalDataFile='CP_Data01'",
"#DataFilePath='F:\MSSQL10.IS_CLTLIVE_DE\data\'",
"#LogicalLogFile='CP_TLog01'",
"#LogFilePath='F:\MSSQL10.IS_CLTLIVE_DE\log\'",
"#DatabaseName='AghilasCP_Tmp'"
}
And the statement as
IF EXISTS (SELECT name FROM sys.databases WHERE name = #DatabaseName)
With no spaces around the '=', with a unique name as a parameter name, this scares me a bit, I'd personally have written built this activity differently, and with quotes around the parameter value either in the parameter array or in the SQL code.
Related
I am trying to get the values in "ID" column of DOORS and I am currently doing this
string ostr=richtext_identifier(o)
When I try to print ostr, in some modules I get just the ID(which is what I want). But in other modules I will get values like "{\rtf1\ansi\ansicpg1256\deff0\nouicompat{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}{\f1\froman\fcharset0 Times New Roman;}} {*\generator Riched20 10.0.17134}\viewkind4\uc1 \pard\f0\fs20\lang1033 SS_\f1\fs24 100\par } " This is the RTF value and I am wondering what the best way is to strip this formatting and get just the value.
Perhaps there is another way to go about this that I am not thinking of as well. Any help would be appreciated.
So the ID column of DOORS is actually a composite- DOORS builds it out of the Module level attribute 'Prefix' and the Object level attribute 'Absolute Number'.
If you wish to grab this value in the future, I would do the following (using your variables)
string ostr = ( module ( o ) )."Prefix" o."Absolute Number" ""
This is opposed to the following, which (despite seeming to be a valid attribute in the insert column dialog) WILL NOT WORK.
string ostr = o."Object Identifier" ""
Hope this helps!
Comment response: You should not need the module name for the code to work. I tested the following successfully on DOORS 9.6.1.10:
Object o = current
string ostr = ( module ( o ) )."Prefix" o."Absolute Number" ""
print ostr
Another solution is to use the identifier function, which takes an Object as input parameter, and returns the identifier as a plain (not RTF) string:
Declaration
string identifier(Object o)
Operation
Returns the identifier, which is a combination of absolute number and module prefix, of object o as a string.
The optimal solution somewhat depends on your underlying requirement for retrieving the object ID.
I want to create basically an update query on Open Office Base (the same way with Ms ACCESS).
Base does not typically use update queries (but see below). Instead, the easiest way to do an update command is to go to Tools -> SQL. Enter something similar to the following, then press Execute:
UPDATE "Table1" SET "Value" = 'BBB' WHERE ID = 0
The other way is to run the command with a macro. Here is an example using Basic:
Sub UpdateSQL
REM Run an SQL command on a table in LibreOffice Base
Context = CreateUnoService("com.sun.star.sdb.DatabaseContext")
databaseURLOrRegisteredName = "file:///C:/Users/JimStandard/Desktop/New Database.odb"
Db = Context.getByName(databaseURLOrRegisteredName )
Conn = Db.getConnection("","") 'username & password pair - HSQL default blank
Stmt = Conn.createStatement()
'strSQL = "INSERT INTO ""Table1"" (ID,""Value"") VALUES (3,'DDD')"
strSQL = "UPDATE ""Table1"" SET ""Value"" = 'CCC' WHERE ID = 0"
Stmt.executeUpdate(strSQL)
Conn.close()
End Sub
Note that the data can also be modified with a form or by editing the table directly.
Under some circumstances it is possible to create an update query. I couldn't get this to work with the default built-in HSQLDB 1.8 engine, but it worked with MYSQL.
In the Queries section, Create Query in SQL View
Click the toolbar button to Run SQL Command directly.
Enter a command like the following:
update mytable set mycolumn = 'This is some text.' where ID = 59;
Hit F5 to run the query.
It gives an error that The data content could not be loaded, but it still performs the update and changes the data. To get rid of the error, the command needs to return a value. For example, I created this stored procedure in MYSQL:
DELIMITER $$
CREATE PROCEDURE update_val
(
IN id_in INT,
IN newval_in VARCHAR(100)
)
BEGIN
UPDATE test_table SET value = newval_in WHERE id = id_in;
SELECT id, value FROM test_table WHERE id = id_in;
END
$$
DELIMITER ;
Then this query in LibreOffice Base modifies the data without giving any errors:
CALL update_val(2,'HHH')
See also:
https://forum.openoffice.org/en/forum/viewtopic.php?f=5&t=75763
https://forum.openoffice.org/en/forum/viewtopic.php?f=61&t=6655
https://ask.libreoffice.org/en/question/32700/how-to-create-an-update-query-in-base-sql/
Modifying table entries from LibreOffice Base, possible?
Trying to know all the mandatory fields for an issue type Testcase in JIRA using the below statement
defined params as list with items projectIds, IssueType = Testcase, IssueType Id =
"jira._get_json('issue/createmeta', params)".
But i am not able to retrieve the fields
output is alist with
projects
issuetypes,
subtask,
description,
avatarUrls,
key,
Self,
expand
Let me know is there any issue with statement I used or please post a way to retrieve all the mandatory fields for specific issue type using jira python
The way I have been doing this for specific fields:
issue = jira.issue(TestCase)
issue_type_name = issue.fields.issuetype.name
issue_type_id = issue.fields.issuetype.id
Another way to do this getting all the meta is:
issue = jira.issue(TestCase)
print(issue.raw)
or
jira.createmeta(projectKeys='TestCaseProject', projectIds=['TestCase'],expand=None)
Source: http://pythonhosted.org/jira/
I wanted to access TFS data via TFS API and WIQL using a custom field in WIQL where clause:
string wiqlQueryDoorsProxy =
"Select * from WorkItems where ([Work Item Type] = 'DoorsProxy' AND [Object Id] = '\" + requirementId + "\')";
where [Object Id] is the custom field. But TFS API gave exception message:
"TF51005: The query references a field that does not exist. The error is caused by «[Object Id]»."
The field definition has name = "Object Id" and reference name = "DoorsTool.DoorsArtifactType.ObjectId". I tried both Object Id and DoorsTool.DoorsArtifactType.ObjectId in the WIQL. Same result.
I changed the code as follows and it worked perfectly:
string wiqlQueryDoorsProxy ="Select * from WorkItems where ([Work Item Type] = 'DoorsProxy' )";
WorkItemCollection witCollectionDoorsProxy = wiStore.Query(wiqlQueryDoorsProxy);
foreach (WorkItem workItemDoorsProxy in witCollectionDoorsProxy)
{
workItemDoorsProxy.Open();
if (workItemDoorsProxy.Fields["Object Id"].OriginalValue.ToString() == requirementId)
{
...
}
}
But now the performance is bad.
What can I do. The problem looks similar to this but still I cannot solve the problem based on that discussion.
The way way is to create the query that you want in visual studio first. Once you have It working you can "save as" to local disk and open It in notepad. You can just copy the query from there.
I got a domain like this:
ZZPartAndTeam
String parts
String team
Parts may have many team.
For ex: part:part1 team:10
part:part1 team:20
part:part2 team:30
How can I query in the domain that get all parts which have multi team?
result:part:part1 team:10
part:part1 team:20
Thanks.
The HAVING clause is not supported by Hibernate Criteria. A way around is to use DetachedCriteria.
import org.hibernate.criterion.DetachedCriteria as HDetachedCriteria
query: { builder, params ->
// This query counts the number of teams per part
HDetachedCriteria innerQry = HDetachedCriteria.forClass(ZZPartAndTeam.class)
innerQry.setProjection(Projections.projectionList()
.add(Projections.count('team').as('teamCount'))
)
innerQry.add(HRestrictions.eqProperty('part', 'outer.part')
// Using innerQuery, this criteria returns the parts having more than one team.
HDetachedCriteria outerQry = HDetachedCriteria.forClass(ZZPartAndTeam.class, 'outer')
outerQry.setProjection(Projections.projectionList()
.add(Projections.distinct(Projections.property('part').as('part')))
)
outerQry.add(Subqueries.gt(1, innerQry))
builder.addToCriteria(Property.forName('part').in(outerQry))
}