I'd like to align elements of my code for easier reading, but ignore the extra spaces on compile. For example, I'd like to convert:
+navOption('biography', 'Biography and Timeline')
+navOption('books-articles', 'Books and Articles about Paul Rand')
+navOption('events-exhibits', 'Events and Exhibits')
+navOption('videos-interviews', 'Videos and Interview')
+navOption('portraits', 'Portraits')
+navOption('rand-house', 'The Rand House')
+navOption('his-inspirations', 'Inspirations')
+navOption('personal-items', 'Personal Items')
+navOption('death', 'Death')
to:
+navOption('biography ', 'Biography and Timeline ')
+navOption('books-articles ', 'Books and Articles about Paul Rand')
+navOption('events-exhibits ', 'Events and Exhibits ')
+navOption('videos-interviews', 'Videos and Interview ')
+navOption('portraits ', 'Portraits ')
+navOption('rand-house ', 'The Rand House ')
+navOption('his-inspirations ', 'Inspirations ')
+navOption('personal-items ', 'Personal Items ')
+navOption('death ', 'Death ')
Is there a way to ignore the extra spaces created between the last letter/number/symbol of the argument and the closing apostrophe?
Related
Any ideas on how to use spatial functions in either a procedure or a calculation view? I cannot use a table function, as I need a cursor. Please see issues below:
I tried dynamic SQL in a stored procedure with select into (Doesn't allow into):
(About three months back it did work, but now cannot activate?)
This blog says it should work:
https://blogs.sap.com/2017/04/18/sap-hana-2.0-sps-01-new-developer-features-database-development/
Dynamic SQL:
EXECUTE IMMEDIATE 'SELECT NEW ST_Point(' || char(39) || 'POINT(' || decEndPointLong1 || ' ' || decEndPointLat1 || ')' || char(39) || ', 4326).ST_Distance( NEW ST_Point(' || char(39) || 'POINT(' || CURRLONG || ' ' || CURRLAT || ')' || char(39) || ', 4326)) FROM DUMMY' INTO dDistEP1;
Then, I thought that I would create a calculation view,
This blog says it should work:
https://blogs.sap.com/2018/02/23/compute-distance-using-a-calculation-view-xs-advanced-model/
But, does not allow the use of spatial functions in ether columnengine or SQL engine.
Calculated Column:
I went back and tried to re-activate the procedure that contains this code and has been working, and still works, but if I edit it and try to activate it has the same compile error. Cannot select into variable. So, something has changed since I first created this procedure.
Wow, I stumbled upon an alternate syntax that does not need single quotes:
https://blogs.sap.com/2017/02/17/transforming-spatial-data-in-sap-hana/
SELECT NEW ST_Point(-117.0400842, 32.92197086).ST_SRID(4326).ST_Distance( NEW ST_Point(-117.0394467, 32.92241185).ST_SRID(4326)) FROM DUMMY
Now, I think that I can eliminate the Dynamic SQL.
Looking at the two differ ways:
1) SELECT NEW ST_Point(-117.0400842, 32.92197086).ST_SRID(4326).ST_Distance( NEW ST_Point(-117.0394467, 32.92241185).ST_SRID(4326)) FROM DUMMY;
2) SELECT NEW ST_Point('POINT(-117.0400842 32.92197086)', 4326).ST_Distance( NEW ST_Point('POINT(-117.0394467 32.92241185)', 4326)) FROM DUMMY;
They yield slightly different results (meters):
77.06
77.12
Probably, because (1) converts a calculated point to 4326, and (2) calculates the point based on 4326.
So, this code:
EXECUTE IMMEDIATE 'SELECT NEW ST_Point(' || char(39) || 'POINT(' || decEndPointLong1 || ' ' || decEndPointLat1 || ')' || char(39) || ', 4326).ST_Distance( NEW ST_Point(' || char(39) || 'POINT(' || CURRLONG || ' ' || CURRLAT || ')' || char(39) || ', 4326)) FROM DUMMY' INTO dDistEP1;
Boiled down to:
SELECT r1.FROMLAT INTO decEndPointLat1 FROM DUMMY;
SELECT r1.FROMLONG INTO decEndPointLong1 FROM DUMMY;
SELECT NEW ST_Point(decEndPointLong1, decEndPointLat1).ST_SRID(4326) INTO stEndCoord1 FROM DUMMY;
SELECT NEW ST_Point(CURRLONG, CURRLAT).ST_SRID(4326) INTO stCurrCoord FROM DUMMY;
SELECT stEndCoord1.ST_Distance(stCurrCoord) INTO dDistEP1 FROM DUMMY;
select replace(substring(CONVERT(varchar,SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30'),100),13,
LEN(CONVERT(varchar,SYSDATETIMEOFFSET(),100))), ' +05:30','')
I am getting output=> 4:06PM
but I want output=> 4:06 PM
how can I get this output??
Use this SELECT replace(substring(STUFF(CONVERT(varchar,SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30'),100), 18,0,' '),13,LEN(CONVERT(varchar,SYSDATETIMEOFFSET(),100))), ' +05:30','');
instead of
select replace(substring(CONVERT(varchar,SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30 '),100),13,
LEN(CONVERT(varchar,SYSDATETIMEOFFSET(),100))),' +05:30',' ')
select replace(substring(CONVERT(varchar,SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30 '),100),13,
LEN(CONVERT(varchar,SYSDATETIMEOFFSET(),100))),' +05:30',' ')
You can use stuff
select STUFF(replace(substring(CONVERT(varchar(50),SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30'),100),13, LEN(CONVERT(varchar,SYSDATETIMEOFFSET(),100))), ' +05:30',''),6,0,' ')
It will stuff a space at the 6th position replacing 0 characters.
Below query will give you the expected output.
SELECT replace(substring(STUFF(CONVERT(varchar,SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30'),100), 18, 0, ' '),13,LEN(CONVERT(varchar,SYSDATETIMEOFFSET(),100))), ' +05:30','');
output: 4:22 PM
I have the following tsql that sends db mail. This works with one formatting exception. The last two lines generated do not have a line feed or carriage return in the email body. The data types are varchar(255) and varchar(300) respectively.
I have tried with and with out cast and I have tried CHAR(10), CHAR(13) separately and together.
Why does these last two NOT split into separate lines?
DECLARE #errMsg VARCHAR(max)
-- review edit fact UMDNSID values and catch orphans with out parents in CategoryList
select #errMsg =
'====================================================================' + char(10) +
'Orphan UMDNSID: ' + cast(ef.umdnsid as varchar(50)) + char(10) +
'Edit Fact VendorItemID: ' + cast(ef.vendoritemid as varchar(50)) + char(10) +
'Current VendorItem UMDNSID: ' + cast(ip.umdnsid as varchar(50)) + char(10) +
'Current VendorItem Category: ' + ipcl.categoryname + char(10) +
'Item Description: ' + ef.LongDescription + char(10) + char(13)
from EditFact ef
join itemprovider ip
on ef.vendoritemid = ip.itemprovider_pk
join categorylist ipcl
on ipcl.umdnsid = ip.umdnsid
where 1=1
AND editstatusid = 0
AND settled is null
AND ef.UMDNSID not in (
select umdnsid from categorylist)
EXEC dbo.ProcessFile_SendMail #ProcessFile_id=0, #Subject='Orphan UMDNSID', #Message=#errMsg, #To='someone#email.com';
The email body ends up looking like the following and I expect a new line where you see **.
Orphan UMDNSID: 27854
Edit Fact VendorItemID: 4654178
Current VendorItem UMDNSID: 99936
Current VendorItem Category: Custom Packs **Item Description: TRAY CARDIAC CATH CUSTOM
In case that was the final answer
Test a print(#errMsg).
The problem may be in ProcessFile_SendMail.
My orchestration is triggered by a HTTP message and then the following SQL query is executed (field and table names have been changed for security reasons):
SELECT Distinct '900' AS 'Type',
(DeTeamPATH.PKEY) AS 'Personal_ID',
ISNULL(CONVERT(nVarChar(30), DeTeam.TENTLOGON, 121), ' ')
AS 'TLG',
ISNULL(CONVERT(nVarChar(30), DeTeam.CIV_NAMES01, 121), ' ')
AS 'First name',
ISNULL(CONVERT(nVarChar(30), DeTeam.CIV_NAMES02, 121), ' ')
AS 'Middle name',
ISNULL(CONVERT(nVarChar(30), DeTeam.SURNAME, 121), ' ')
AS 'Surname',
ISNULL(CONVERT(nVarChar(30), UsTeam.STREET01, 121), ' ')
AS 'Corporation',
ISNULL(CONVERT(nVarChar(30), DeTeam.GENDER, 121), ' ')
AS 'Gender',
ISNULL(CONVERT(nVarChar(30), DeTeam.LOCAL_ADDRESS01 + ', '
+ DeTeam.LOCAL_ADDRESS03, 121), ' ')
AS 'Street Address',
ISNULL(CONVERT(nVarChar(30), DeTeam.LOCAL_ADDRESS04, 121), ' ')
AS 'Suburb',
ISNULL(CONVERT(nVarChar(30), DeTeam.COUNTRY, 121), ' ')
AS 'Country',
ISNULL(CONVERT(nVarChar(30), DeTeam.LOCAL_POST, 121), ' ')
AS 'Postcode',
ISNULL(CONVERT(nVarChar(30), DeTeam.BIRTHDATE, 121), ' ')
AS 'Date of Birth',
ISNULL(CONVERT(nVarChar(30), DeTeam.EMAIL, 121), ' ')
AS 'Email address',
ISNULL(CONVERT(nVarChar(30), DeTeam.DOME_PHONE, 121), ' ')
AS 'Primary phone',
DeTeam.ICEPHONE AS 'Phone_2',
ISNULL(CONVERT(nVarChar(30), DeTeamPATH.Person_START, 121), ' ')
AS 'Session_start',
ISNULL(CONVERT(nVarChar(30), DeTeamPATH.Person_FINISH, 121), ' ')
AS 'Session_expiry'
FROM DeTeam
INNER JOIN DeTeamPATH
ON DeTeamPATH.PKEY = DeTeam.DeTeamKEY
INNER JOIN Fort
ON DeTeamPATH.ROUTEID = Fort.ROUTEID OR DeTeamPATH.STREAM=Fort.ROUTEID
INNER JOIN US_DE_SEM
ON US_DE_SEM.US_DE_SEMER = DeTeamPATH.SEM_START
OR US_DE_SEM.US_DE_SEMER = DeTeamPATH.SEM_FINISH
INNER JOIN UsTeam
ON UsTeam.TeamUS = DeTeamPATH.TeamUS
where DeTeam.TENTLOGON != ' ' and DeTeamPATH.PKEY != ' ' and
DeTeam.CIV_NAMES01 != ' ' and DeTeam.CIV_NAMES02 != ' ' and
DeTeam.SURNAME != ' ' and UsTeam.STREET01 != ' ' and
DeTeam.GENDER != ' ' and DeTeam.COUNTRY != ' ' and
DeTeam.TENTLOGON != ' ' and DeTeam.LOCAL_POST != ' ' and
DeTeam.BIRTHDATE != ' ' and DeTeam.EMAIL != ' ' and
DeTeam.DOME_PHONE != ' ' and DeTeamPATH.Person_START != ' ';
It then writes the data to a flat file (a text file) and puts it in a directory on my FTP server. However, the text file only has one line - that being one result from the SQL SELECT query. And when I run the query directly on the server, I get about six results. I want the file to contain all six results but I expect more results to come through that SELECT statement in the near future so I don't want to set a limit on how many results the query will retrieve as I want it to get all results.
Can someone please help me or tell me what I'm doing wrong? Let me know if you need any further details and I'll edit this question to include them.
I have the answer to my own question!
In the Write Flat File activity, the rows in the From Orchestration section of the Map Inputs tab were recurring whereas the ones in the To Activity section where not. So, to fix this, I had to edit my Flat File Schema, and change the properties for data so that the occurrence was marked as Unbounded. (It had a Range of 1 previously so only 1 row would ever get put in the text file.) I also had to remove all previous input mappings in my Write Flat File activity and map the row in From Orchestration To the data in To Activity.
If I may say so, I have put this answer up here in case anyone in future has the same issue. I've found that finding people on the Internet with experience in the use of WebSphere Cast Iron is difficult... so I'll be happy if this helps anyone!
#DaleM Thank you for your comments and for trying to help!
I've implemented an autosuggest search using jQuery, php and SQL server 2008. I'm looking for people by their name. The name of the person is divided in three fields 'nombres, 'apellido_paterno' and 'apellido_materno'. My autosuggest matches results where one of the three fields looks like the pattern in the input text.
$values = array(':x'=>$data['term'].'%',':y'=>$data['term'].'%',':z'=>$data['term'].'%');
$sql = "SELECT TOP 10 id_persona, nombres +' '+ apellido_paterno +' '+ apellido_materno AS value
FROM personas WHERE nombres LIKE :x OR apellido_paterno LIKE :y OR apellido_materno LIKE :z";
So my query is working fine if you search by name or lastname, however if you search by full name there are no matches. So, how do I add criteria to my query in order to bring full name matches?
Assuming all three are varchar fields, and you are querying a somewhat limited number of records, I would just do:
$values = array(':x'=>'%'.$data['term'].'%');
$sql = "SELECT TOP 10 id_persona, nombres +' '+ apellido_paterno +' '+ apellido_materno AS value
FROM personas
WHERE
nombres + ' ' + apellido_paterno + ' ' + apellido_materno LIKE :x";