How is it possible to write a couchbase request in order to choose the first condition in where if it is defined or the second one if the first one is undefined.
I tried somethings like :
SELECT id FROM auto as a WHERE IFMISSINGORNULL(ARRAY_LENGTH(a.data[0])>1, ARRAY_LENGTH(a.data[1])>1)
In this request if a.data[0] is defined, I want to check the length of a.data[0] and if a.data[0] is not defined, I want to check the length of a.data[1].
Condition should look as follows
WHERE ARRAY_LENGTH(IFNULL(a.data[0], a.data[1])) > 1
IFNULL(a.data[0], a.data[1])
returns first argument if it is NOT NULL
second argument when first one is NULL
Related
I have a subject like "accessTo" = ["123", "123-edit"]
and a resource like "interestedId" = "123"
Now I'm trying to write a condition - where it checks "interestedId" concatenated with "-edit" equals "123-edit" in "AccessTo".
Im trying to write rule like this
anyOfAny_xacml1(function[stringEqual], "accessTo", "interestedId"+"-edit")
It is not allowing to do this.
Any help is appreciated.
In addition to the answer from Keerthi S ...
If you know there should only be one value of interestedId then you can do this to prevent the indeterminate from happening:
stringBagSize(interestedId) == 1 && anyOfAny(function[stringEqual], accessTo, stringOneAndOnly(interestedId) + "-edit")
If more than value is present then evaluation stops prior to reaching the function that expects only one value. This condition would return false if more than one value is present.
On the other hand if interestedId can have multiple values then this would work:
anyOfAny(function[stringEqual], accessTo, map(function[stringConcatenate],interestedId, "-edit"))
The map function will apply the stringConcatenate function to all values in the bag.
Since Axiomatics products are compliant with XACML specification, all attributes by default are assumed to contain multiple values(called as 'bags').
So if you would like to append a string to an attribute use stringOneAndOnly XACML function for the attribute to indicate that the attribute can have only one value.
So assuming you mean accessTo has attribute ID as Attributes.access_subject.subject_id, interestedId has the attribute ID as Attributes.resource.resource_id and anyOfAny_xacml1 is equivalent to anyOfAny XACML function, the resulting condition would look like,
anyOfAny(function[stringEqual], Attributes.access_subject.subject_id, stringOneAndOnly(Attributes.resource.resource_id) + "-edit")
I'm building a SSRS report and would like one of my parameters to be optional where data is entered or not.
Here is an example query for a better understanding:
SELECT
C1
,C2
,C3
FROM
db_Database..tb_Table
WHERE
tb_Table_DateTime between [THEN] and [NOW]
AND
tb_Table_Integer IN (#Integer)
I'm trying to work out if, in my query, I can ignore the whole:
AND tb_Table_Integer IN (#Integer)
line if user chooses not to input any number.
Bascially, I want all data returned unless specified otherwise via #integer.
If not possible in the query, can this be achieved in the Visual Studio?
Cheers.
This is typically handled by doing:
WHERE . . . AND
(#Integer IS NULL OR tb_Table_Integer = #Integer)
Do not use IN (#Integer). It sort of implies that you think that #Integer could be a list. That is not possible.
The most common way to do this is with coalesce or nullif. Like this:
WHERE coalesce(#integer,tb_Table_Integer) = tb_Table_Integer
According to the Peoplebook here, CreateRowset function has the parameters {FIELD.fieldname, RECORD.recname} which is used to specify the related display record.
I had tried to use it like the following (just for example):
&rs1 = CreateRowset(Record.User, Field.UserId, Record.UserName);
&rs1.Fill();
For &k = 1 To &rs1.ActiveRowCount
MessageBox(0, "", 999999, 99999, &rs1(&k).UserName.Name.Value);
End-for;
(Record.User contains only UserId(key), Password.
Record.UserName contains UserId(key), Name.)
I cannot get the Value of UserName.Name, do I misunderstand the usage of this parameter?
Fill is the problem. From the doco:
Note: Fill reads only the primary database record. It does not read
any related records, nor any subordinate rowset records.
Having said that, it is the only way I know to bulk-populate a standalone rowset from the database, so I can't easily see a use for the field in the rowset.
Simplest solution is just to create a view, but that gets old very soon if you have to do it a lot. Alternative is to just loop through the rowset yourself loading the related fields. Something like:
For &k = 1 To &rs1.ActiveRowCount
&rs1(&k).UserName.UserId.value = &rs1(&k).User.UserId.value;
&rs1(&k).UserName.SelectByKey();
End-for;
I am trying to understand a behaviour of Rails ActiveRecord with limit.
Let's say I have a model Car with only one attribute name.
Now in the console (rails console), if I type:
Car.limit(0).where(name: 'foo')
I get
SELECT "cars".* FROM "cars" WHERE "cars"."name" = 'foo' LIMIT 0
which is correct, but:
Car.limit(0).find_by_id(1)
gives
SELECT "cars".* FROM "cars" WHERE "cars"."id" = 1 LIMIT 1
Why is the limit option ignored?
Note that
Car.where(name:'foo').find_by_id(1)
gives
SELECT "cars".* FROM "cars" WHERE "cars"."name" = 'foo' AND "cars"."id" = 1 LIMIT 1
So find_by_id(or find) ignores limit but accepts where? How do you explain that?
Sidenote
I know that these queries don't make sense. I have an edge case in a project which executes Car.limit(0).find_by_id(1), the expected result was to get a nil object. I am trying to understand why find_by_id or find ignores limit.
find and find_by_ are methods used to retrieve a single instance. The result is either one object or nil if there are no objects to be found.
Because the method is supposed to return only one object it sets the limit to 1 regardless of what limit you specify.
If you want to specify a limit, use where as per your example.
I need count rows in table. So I use reg. exp. extractor. But response assertion ends with error and tried to find exactly rows:${ROWS_matchnr}.
I tried google, but I only find a few non-functional recommendations.
Thread Group
Http Cookie Manager
Http Request
Regular Expression Extractor(ROWS, row-(.*), $1$, 0, )
Response Assertion(rows:${ROWS_matchnr})
Change the value you have in the Match No field from 0 to -1. As documented in the, ahem, useless official help:
If the match number is set to a negative number, then all the possible matches in the sampler data are processed. The variables are set as follows:
refName_matchNr - the number of matches found; could be 0
refName_n, where n = 1,2,3 etc - the strings as generated by the template
refName_n_gm, where m=0,1,2 - the groups for match n
refName - always set to the default value
refName_gn - not set
Then change ${ROWS_matchnr} to ${ROWS_matchNr} (capital N) and it should work.
If you still have issues then use a Debug Sampler to see what is getting returned from the regex.