Nested IF THEN ELSE Operator in SSIS Derived Column - ssis-2012

I have an excel which I am trying to load in to a table in my database. The excel file has a column called 'Location Code'. I am using a derived column in my SSIS package to fullfill the condition
If 'Location Code' = "NULL" OR If 'Location Code' ISNULL OR If 'Location Code' = "" then 'Location Code' else "5"+""+'Location Code' //(concatenating '5' with the Location Code).
How do I achieve the above in my derived column?

I finally found the answer to my question. Below, I have provided the exact syntax:
(DT_WSTR,50)[Location Code] == "NULL" || ISNULL([Location Code]) || (DT_WSTR,50)[Location Code] == "" ? (DT_WSTR,50)[Location Code] : (DT_WSTR,10)5 + (DT_WSTR,50)[Location Code]

Related

DOORS DXL Recreating the Main Column

I would like to create an DXL attribute in DOORS that contains the same information as the main column.
It is important to maintain the same heading font style in the attribute as in the main column as this is used for automatic creation of "Table of content" in the Word document after DOORS Publish.
I found the below dxl-script on the internet, but getCanvas does not seem to work.
All text are passed fine to my new attribute, but the heading have the same font style as normal text.
if (obj."Object Heading" "" != "")
{
font(getCanvas, level(obj), HeadingsFont)
displayRich(number(obj) " " obj."Object Heading" "")
}
if (obj."Object Text" "" != "")
{
font(getCanvas, level(obj), TextFont)
displayRich(richTextWithOle(obj."Object Text"))
}
Can anyone help?
KR
Klaus
For me, the code actually does work in a Layout-DXL column (which is not a DXL attribute).
if (obj."Object Heading" "" != "") {
DBE dbCanvas = getCanvas()
font(dbCanvas, level(obj), HeadingsFont)
displayRich(number(obj) " " obj."Object Heading" "")
}
My DOORS version is 9.6, although the methods don't seem to be that new, so DOORS version does not seem to be the issue.
If nothing else helps regarding the DXL code, I would suggest that you have a look at your target word document. There, you should be able to control anything you paste into the document via VBA code in a post-processing step. Although I didn't really get, why you are avoiding using the main column for your source content. Are you trying to show content of a linked or referenced module?
Thanks a lot for the answer. It helped me somehow.
My problem was that I was trying to enter the dxl-code in an attribute. I followed your suggestion and made an Layout-DXL Column instead and it worked almost immediately :-)
I ended up with the dxl-code as shown below.
if (obj."Object Heading" "" != "")
{
DBE dbCanvas = getCanvas()
if( dbCanvas != null )
font(dbCanvas, level(obj), HeadingsFont)
displayRich(number(obj) " " obj."Object Heading" "")
}
else
{ // insert rest of text
if ( probeAttr_(obj, "Requirement") == "Requirement" )
{ // insert requirement text from DT module
displayRich(richText(obj."DXL to DT - ID & Object Text"))
}
else
{ // insert rest of text from this module
displayRich(richTextWithOle(obj."Object Text"))
}
}
I would like to have a publish of the Test Procedure where every Test Case starts with the requirement text followed by the test steps necessary to perform the test as shown in Fig 1.
Test Procedure Publish view
The view in DOORS now looks like I want, but I get error when publishing in DOORS.
DOORS publish error
I therefore protected the line "font(dbCanvas, level(obj), HeadingsFont)", but now I get no headings in the Word document and Table of Content is empty.
Word snip
Is there a solution to this?
KR
Klaus

How would I run a .exe from within TD 6.3 program (SalLoadApp?)

Ahoy thar,
I am attempting to run a .exe program (a small helper app written in another language) from within an existing TD6.3 application.
Going by the documentation, I'd think this works with SalLoadApp (or ideally with SalLoadAppAndWait, since I do need to wait for it to finish and would like it to be invisible to the user - the app is a console app with no visible output or user interaction), but trying to call it like that does nothing at all.
I've tried both just the appname as a parameter (it's in the same folder as the TD application):
Call SalLoadApp('HelperApp.exe', '')
as well as the full path:
Call SalLoadApp('C:\Users\user\ProjectFolder\HelperApp.exe', '')
Am I misunderstanding how this works or missing something there? Does it only work with TD applications? Is there another way of executing an existing non-TD .exe file via code?
Yes you can use SalLoadApp for that purpose. The function can be used for invoking
any exe file(no restrictions like only td exe's). For example, If you want call windows calculator just write,
SalLoadApp( "calc.exe", "" )
Also if you want specify file path, then please use double slash(instead of singleslash) as shown below,
Call SalLoadApp('C:\\Users\user\\ProjectFolder\\HelperApp.exe', '')
The format for SalLoadApp is: SalLoadApp( strAppName, strParameters )
strAppName - Name of exe file.
strParameters - Parameter array(space in strParameters marks the end of one argument).
Also If you want call salloadapp without specifying the filelocation, then you can keep the both exe's in same folder- ( HelperApp.exe and calling application)
Use ShellExecuteW(). This way you have more control
1) Include it as an external function as part of SHELL32.dll:
Library name: SHELL32.DLL
ThreadSafe: No
Function: ShellExecuteW
Description: The ShellExecute function opens or prints a specified file. The file can be an executable file or a document file. See ShellExecuteEx also.
Export Ordinal: 0
Returns
Number: DWORD
Parameters
Window Handle: HWND
String: LPWSTR
String: LPWSTR
String: LPWSTR
String: LPWSTR
Number: INT
2) Run your exe with the following syntax ( or lookup 'ShellExecute' for more info )
Call ShellExecuteW( hWndNULL, "open", "C:\\Program Files (x86)\\Gupta\\TeamDeveloper6.2.1\\Your.exe", STRING_Null, STRING_Null, SW_SHOWNORMAL )
3) Optionally write a wrapper function, so you can check any return codes you want e.g. :
Select Case nRet
Case SE_ERR_FNF
If spApplication
Set sError = 'Either the Application, or the specified file was not found. ' || sCTRL || sCTRL ||
'Check the Application ' || spApplication || ' and any Compatibility Packs have been installed on this machine .' || sCTRL || sCTRL ||
'Check the file ' || spFile || ' exists. '
Else
Set sError = 'The specified file was not found. ' || sCTRL || sCTRL ||
'Check the file ' || spFile || ' exists. '
Break
Case SE_ERR_PNF
Set sError = 'The specified Path was not found'
Break
Case SE_ERR_ACCESSDENIED
Set sError = 'The operating system denied access to the specified file.'
Break
Case SE_ERR_ASSOCINCOMPLETE
Set sError = 'The filename association is incomplete , invalid, or has not been defined within Windows'
Break
Case SE_ERR_DDEBUSY
Set sError = 'The DDE transaction could not be completed because other DDE transactions are being processed.'
Break
Case SE_ERR_DDEFAIL
Set sError = 'The DDE transaction failed.'
Break
Case SE_ERR_DDETIMEOUT
Set sError = 'The DDE transaction could not be completed because the request timed out'
Break
Case SE_ERR_NOASSOC
Set sError = 'There is no application associated with the given filename extension'
Break
Case SE_ERR_OOM
Set sError = 'There was not enough memory to launch the application'
Break
Case SE_ERR_SHARE
Set sError = 'Another user has this document open.'
Break
Case 0
Set sError = 'The operating system is out of memory or resources'
Break
Default
Break
If nRet <=32
If spApplication
Call SalMessageBox( sError || sCTRL || sCTRL ||
'File Name = ' || spFile || sCTRL || sCTRL ||
'Application Name = ' || spApplication , 'Application or File Open Error' , MB_IconStop | MB_Ok )
Else
Call SalMessageBox( sError || sCTRL || sCTRL ||
'File Name = ' || spFile , 'File Open Error' , MB_IconStop | MB_Ok )
If nRet = SE_ERR_NOASSOC or nRet = SE_ERR_ASSOCINCOMPLETE
! Now open the OpenAs dialog from Windows to select an application from a list or browse.
Call ShellExecuteW( hWndNULL, "open", "rundll32.exe", "shell32.dll,OpenAs_RunDLL " || spFile, STRING_Null, npShowState )
Set bOk = FALSE

What does "::int[]" means at the SQL line below?

I am trying to understand a SQL line code at a RoR app. Does anybody know what ::int[] means? It appears at each "case" after "and".
case
when (array_length(array_remove(company_profiles.blocked_trails_ids,null),1) IS NOT NULL) and array[trails.id]::int[] && array_remove(company_profiles.blocked_trails_ids,null) then
false
else
true
end and
case
when (array_length(array_remove(company_profiles.blocked_components_ids,null),1) IS NOT NULL) and array[components.id]::int[]&& array_remove(company_profiles.blocked_components_ids,null) then
false
else
true
end and
case
when (array_length(array_remove(company_profiles.blocked_academies_ids,null),1) IS NOT NULL) and array[academies.id]::int[] && array_remove(company_profiles.blocked_academies_ids,null) then
false
else
true
end
In PostgreSQL, every data type has a companion array type. If you define your own data type, PostgreSQL creates a corresponding array type in the background for you. For example, integer has an integer array type integer[], character has a character array type character[], and so forth.
The :: is a type cast, a conversion from one data type to another.
Notice this line array[components.id]::int[]&& array_remove(...) might not work as expected.

Setting a default description based on a custom field selection in Jira

I am new into using Velocity but this is what I am attempting to do.
Based on a issue type "service request" and custom field option 'a' set description to display 'x'
Based on a issue type "service request" and custom field option 'b' set description to display 'y'
Based on a issue type "service request" and custom field option 'c' set description to display 'z'
I have used the following for this
if (($issue.key == '') & ($issue.type().getname == 'service request') & ($customfieldmanager().getcustomfieldoption = '11504') & ($id == 'a'))
set ($description = 'x')
elseif ($id == 'b')
set ($description = 'y')
else ($id == 'c')
set ($description = 'z')
Seems not to recognise the the custom field id or the custom field selection id.
Anyone recommend what could be going wrong here, I have had no luck and have tried a few different ways and have spent a few days attempting to work this out.
Help would be appreciated.
For logical "AND" use "&&" instead "&". Please see here: http://velocity.apache.org/engine/devel/user-guide.html#relationalandlogicaloperators
if, else, set should have "#" in front.
if else need "end": https://click.apache.org/docs/velocity/user-guide.html#conditionals
In your sample, issue and customfieldmanager should be in velocity scope. So JIRA (or your JIRA plugin) action should have appropriate getIssue() and getCustomFieldManager() methods and you can access them in velocity as $issue and $customFieldManager (or $getIssue() and $getCustomFieldManager()). Pay attention to cases and brackets. Similar situation with getname and getcustomfieldoption. Please see here: https://stackoverflow.com/a/17069545/1537800
I am not sure about lower/upper cases in method names, but corrected version may look like:
#if ($issue.key == '' && $issue.getType().getName() == 'service request' && $customFieldManager.getCustomFieldOption() == '11504' && $id == 'a')
#set ($description = 'x')
#elseif ($id == 'b')
#set ($description = 'y')
#else ($id == 'c')
#set ($description = 'z')
#end

IBM Informix Spatial datablade LIneFromText function

I am using IBM-Informix for my school project as part of "Informix on-campus" ativity conduted by IBM.
however it is giving me error as "(USE31) - Too few points for geometry type in ST_LineFromText.", in the second linefromtext function.
The problem in the second call to ST_LineFromText() is that you are attempting to pass parameters into it, which isn't possible. You have:
ST_LineFromText('linestring (0 0,v1.pre 0,v1.pre v1.post,0 v1.post,0 0 )',5)
The string contains 'v1.pre' which is not a valid number, etc. If you need to parameterize your query, you either need to generate the string with those values in place, or you need to use a different method. One crude but possible solution is:
ST_LineFromText('linestring (0 0,' || v1.pre || ' 0,' || v1.pre || ' ' ||
v1.post || ',0 ' || v1.post || ',0 0 )', 5)
This may not do the job - but illustrates the problem.

Resources