below is my API
https://abc/api/data/v9.1/accounts?$apply=filter((_ownerid_value ne null) and (owningteam/teamtype eq 0 and contains(owningteam%2fname, 'xyz')))/aggregate($count as values)
and i'm trying add paramters to it(linkedservice().entityname) ,so in dynamic content i have made the following changes , but it is giving error at 'xyz'.
#concat('https://abc.api.crm.dynamics.com/api/data/v9.0/',linkedService().entityname,'?$apply=filter((_ownerid_value ne null) and (owningteam/teamtype eq 0 and contains(owningteam%2fname,',''','xyz',''',')))/aggregate($count as values)')
#concat('https://abc.api.crm.dynamics.com/api/data/v9.0/',linkedService().entityname,'?$apply=filter((_ownerid_value ne null) and (owningteam/teamtype eq 0 and contains(owningteam%2fname,',''','xyz',''',')))/aggregate($count as values)')
this way it worked for me
#{concat('data/v9.0/',linkedService().Entityname,'?$apply=filter((_ownerid_value',' ','ne',' ','null)',' ','and',' ','(owningteam/teamtype',' ','eq',' ','0',' ','and',' ','contains(owningteam%2fname,','''','xez','''',')',')',')','/aggregate($count',' ','as',' ','PROD)')}
Use two single quotes '' in the expression to get the string value with a single quote ' in the result.
#concat('https://abc/api/data/v9.1/',pipeline().parameters.entityname,'?$apply=filter((_ownerid_value ne null) and (owningteam/teamtype eq 0 and contains(owningteam%2fname, ''xyz'')))/aggregate($count as values)')
Results:
Related
I am using CI 'in'operator is not work sql error please check its and share valuable idea...
table
enter image description here
id | coach_name
------------------
9 | GS
------------------
10 | SLR
view and function
$coachID = explode(',',$list['coach']);
$coachname = $this->rail_ceil_model->display_coach_name($coachID);
show result
SLR
need result
GS,SLR
last query result here
SELECT coach_name FROM mcc_coach WHERE id IN('9', '10')
CI code
public function display_coach_name($coachID='')
{
$db2 = $this->load->database('rail',TRUE);
$db2->select('coach_name');
$db2->from('mcc_coach');
$db2->where_in('id',$coachID);
$query = $db2->get();
echo $db2->last_query(); die;
if ($query->num_rows() > 0):
//return $query->row()->coach_name;
else:
return 0;
endif;
}
You must provide an array to in operator so #coachId must be an array not a string
If you are writing this query
SELECT coach_name FROM mcc_coach WHERE id IN('9,10')
it means you are applying in operator on a single id which contains a comma separated value.
So, right query will be
SELECT coach_name FROM mcc_coach WHERE id IN('9','10')
I have the following code:
var approver = _context.approver.Where(x => x.ApproverName != "").Select(x => x.ApproverUserId).Distinct();
And the generated SQL is
SELECT DISTINCT "x"."approveruserid"
FROM "approver" "x"
WHERE (("x"."approvername" <> '') OR "x"."approvername" IS NULL )
I'm expecting the SQL should be
SELECT DISTINCT "x"."approveruserid"
FROM "approver" "x"
WHERE (("x"."approvername" <> '') OR "x"."approvername" IS NOT NULL )
So, the generated SQL is missing the NOT clause and this causes to return wrong result. By the way, I'm using Oracle Database. In Oracle, null equals to empty string.
How to fix it?
[UPDATE]: I'm using
var approver = _context.approver.Where(x => x.ApproverName.Length > 0).Select(x => x.ApproverUserId).Distinct();
as a workaround. But I'm open to another suggestion that can generate the SQL properly for empty string checking.
The generated SQL is correct. You are asking for the string to be something other than "", and null != "".
String.IsNullOrEmpty() is not supported by Linq to SQL but your workaround works fine.
Alternatively you can use something like this:
_context.approver.Where(x => (x.ApproverName ?? "" ) != "")
I have data in a column 'fruits' like this:
apple/green/
apple/red/
apple/brown
what i need to do is remove the '/' character at the end in rows 1 and 2. No change needs to be done in the 3rd row. My output should be
apple/green
apple/red
apple/brown
I have tried doing this..
b = foreach a generate (fruits), ENDSWITH(fruits,'/')==true ? REPLACE(SUBSTRING(fruits, (INT)LAST_INDEX_OF(fruits, '/'), (INT)SIZE(fruits)),'');
Basically I am trying to replace the '/' symbol with space ' ' in the ending.
But i am getting error with this command. Can anyone please help?
Bincond operator has this synthax:
(condition ? value_if_true : value_if_false)
Therefore, else part is mondatory and write like this :
b = foreach a generate (fruits), ENDSWITH(fruits,'/')? REPLACE(SUBSTRING(fruits, (INT)LAST_INDEX_OF(fruits, '/'), (INT)SIZE(fruits)),'') :fruits ;
Or more easier, think about using REPLACE function :
b = foreach a generate REPLACE(fruits,'[/]$','');
I am trying to convert the below Hive statement to Pig:
max(substr(case when url like 'http:%' then '' else url end,1,50))
My pig statement for the above is:
url_group = GROUP data by (uid);
max_substr_url= FOREACH url_group generate SUBSTRING(MAX(((Coalesce(data.url) matches '.*http:%.*') ? '' : Coalesce(data.url))), 0, 49);
For some of the data, the url can be null. So I have written a pig UDF called Coalesce(String) which returns an empty string if the data is either null or empty. If the data is not null or not empty it returns the string back.
The above pig statement is giving me lot of trouble and tried n different options/ways but nothing worked. Anyone got any ideas on how to implement this? Please help me.
Thanks in advance
You are going to want to use a nested FOREACH so that you can do the substring transformation on each tuple in the data bag then take the MAX of the transformed bag.
A = GROUP data by (uid);
B = FOREACH url_group {
-- MAX needs a one column bag
transformed = FOREACH data
GENERATE SUBSTRING((Coalesce(url) matches '.*http:.*' ? '' : Coalesce(url)), 0, 49);
GENERATE group AS uid, MAX(transformed) ;
}
I'm using mksqlite to create and access an SQL database from matlab, and I want to get the number of rows in a table. I've tried this:
num = mksqlite('SELECT COUNT(*) FROM myTable');
, but the returned value isn't very helpful. If I put a breakpoint in my script and examine the variable, I find that it's a struct with a single field, called 'COUNT(_)', which seems to actually be an invalid name for a field, so I can't access it:
K>> class(num)
ans =
struct
K>> num
num =
COUNT(_): 0
K>> num.COUNT(_)
??? num.COUNT(_)
|
Error: The input character is not valid in MATLAB statements or expressions.
K>> num.COUNT()
??? Reference to non-existent field 'COUNT'.
K>> num.COUNT
??? Reference to non-existent field 'COUNT'.
Even the MATLAB IDE can't access it. If I try to double click the field in the variable editor, this gets spat out:
??? openvar('num.COUNT(_)', num.COUNT(_));
|
Error: The input character is not valid in MATLAB statements or expressions.
So how can I access this field?
You are correct that the problem is that mksqlite somehow manages to create an invalid field name that can't be read. The simplest solution is to add an AS clause to your SQL so that the field has a sensible name:
>> num = mksqlite('SELECT COUNT(*) AS cnt FROM myTable')
num =
cnt: 0
Then to remove the extra layer of indirection you can do:
>> num = num.cnt;
>> num
num =
0