Formula Language: Select all child documents - lotus-notes

id
itemId
correlationId
1
A
2
B
A
3
A
4
C
B
5
D
B
6
E
D
Hello, I have a Notes database with a similar structure like the table above. This table contains a unique id for each document. It also contains an itemId, which is not unique, and a correlationId which creates a relation to another item (itemId).
I want to select all documents, which have a specific itemId (in this example A) and every document which is correlated to this itemId (directly or indirectly). The result should look similar to my table.
I was wondering if I need to write multiple requests or if it is possible to write only one formula.
SELECT #Contains(itemId; "A");
SELECT #Contains(correlationId;"A") => retrieve itemId: B ==>SELECT #Contains(correlationId;"B") => retrieve itemId: C, D ==> SELECT #Contains(correlationId;"C") (no result) and SELECT #Contains(correlationId;"D")

Related

generate a inventory item coding in excel

Can you support me in the following I need to create coding for inventory items
I built the structure ( 4 letters, and 4 digits)
(Warehouse Type, Warehouse Group, Family, Sub-Family) after that add a sequence 4 numbers
if the item in Warehouse Type ( A ), Warehouse Group (B ), Family(C), Sub-Family(D),
I need to generate a code ABCD0001, the following item if it from the same warehouse, group,family, and sub-family take generate code (ABCD0002),
BUT if the item has any different thing in structure starting from 0001
like if the item:
Warehouse Type ( B ), Warehouse Group (B ), Family(C), Sub-Family(D)
the code should be BBCD0001
what should I do to achieve this, I have almost 1200 items and I need to add a code for all of them
Create 4 lookup tables (for sample I have made two for Warehouse Type & Group seen on the left). Then apply the mapping you wish to have for each Type, Group, Etc.
In your raw data (on the right) create two helper columns: one to create your warehouse string and another to count the instances of those strings i.e. your sequence number
The formulas are below. Add them to first row of raw data and drag down to create the full list of unique keys
I2 = VLOOKUP(G2,$A$1:$B$6,2,0) & VLOOKUP(H2,$D$1:$E$6,2,0)
J2 = I2 & TEXT(COUNTIF(I$2:I2,I2),"0000")
In cell I2 you will need to combine 4 VLOOKUPS so just copy the method shown here. One for Type, Group, Family, & Sub-Family.

Would comparing two long strings using ora_hash faster than direct comparison in Oracle

I have two tables Table A and Table B. Both table have million rows and a column - column C where data type is "varchar2(3000)".
Following is the schema:
Create Table TableA
ID number(20),
C Varchar2(3000)
Create Table TableB
ID number(20),
C Varchar2(3000),
C_HARSH Varchar2(100)
I only have read access to Table A. However, I am the owner and have full access to table B. Both tables have million rows
I need to make a comparison on the column C from both table.
Would it be faster if I firstly add a new column to Table B to store the hash value of the column C from table and compare the hash value of column C from Table A than simply compare long strings?
IE
Would
B.C_Harsh = ora_hash(A.C,99,5)
Faster than
B.C = A.C
In my scenario?
-------------- Added example as requested --------------------
Following is one of the sample data in Column C
Small Changes
Big Changes

create database from with 2 distinct database according to customer name in python

Table A: Product Attributes
This table contains two columns; the first one is a unique product ID represented by an integer, the second is a string containing a collection of attributes assigned to that product.
product tags
100 chocolate, sprinkles
101 chocolate, sprinkles
102 glazed
Table B: Customer Attributes
The second table contains two columns as well; the first one is a string that contains a customer name, the second is an integer that contains a product number. The product IDs from column two are the same as the product IDs from column one of Table A.
customer product
A 100
A 101
B 101
C 100
C 102
B 101
A 100
C 102
Generated Table
I want to create a table matching this format, where the contents of the cells represent the count of occurrences of product attribute by customer.
customer chocolate sprinkles glazed
A ? ? ?
B ? ? ?
C ? ? ?
I want count instead of ?.
And I want to do this in python.
One more question: If the two starting tables were in a relational database or Hadoop cluster and each had 100 million rows, how might my approach change?

Cassandra list type conflicts

If I have a List field in Cassandra and two people write to it at the same time, is it a simple last write wins or will it merge the writes?
For example: [a, b, c, d]
User1 -> [b, a, c, d] (move b to index 0)
User2 -> [a, b, d, c] (move c to index 3)
Will Cassandra merge the results and end up with [b, a, d, c] or will it use last write wins to the microsecond?
You will get the merge result
Every write data to cassandra, a timestamp associated with each column is also inserted. when you execute read query, timestamps are used to pick a "winning" update within a single column or collection element.
What if I have a truly concurrent write with the same time stamp? In the unlikely case that you precisely end up with two time stamps that match in its microsecond, you might end up with a bad version but Cassandra ensures that ties are consistently broken by comparing the byte values.
Cassandra store list (collection) different than normal column.
Example :
CREATE TABLE friendlists (
user text PRIMARY KEY,
friends list <text>
);
If we insert some dummy data :
user | friends
----------+-------------------------
john | [doug, patricia, scott]
patricia | [john, lucifer]
The internal representation:
RowKey: john
=> (column=, value=, timestamp=1374687324950000)
=> (column=friends:26017c10f48711e2801fdf9895e5d0f8, value='doug', timestamp=1374687206993000)
=> (column=friends:26017c11f48711e2801fdf9895e5d0f8, value='patricia', timestamp=1374687206993000)
=> (column=friends:26017c12f48711e2801fdf9895e5d0f8, value='scott', timestamp=1374687206993000)
=> (column=friends:6c504b60f48711e2801fdf9895e5d0f8, value='matt', timestamp=1374687324950000)
=> (column=friends:6c504b61f48711e2801fdf9895e5d0f8, value='eric', timestamp=1374687324950000)
-------------------
RowKey: patricia
=> (column=, value=, timestamp=1374687352290000)
=> (column=friends:3b817b80f48711e2801fdf9895e5d0f8, value='john', timestamp=1374687243064000)
Here the internal column name is more complicated because a UUID is appended to the name of the CQL field "friends". This is used to keep track of the order of items in the list.
Every time you insert data cassandra with below query :
INSERT INTO friendlists (user , friends ) VALUES ( 'patricia', ['john', 'lucifer']);
//or
UPDATE friendlists SET friends = ['john', 'lucifer'] where user = 'patricia';
Will create a tombstone with a less timestamp than current, it tells that the previous data has been deleted. So if concurrent insert happened with the same exact timestamp both data are ahead of tombstone so both data will live.
Source :
http://mighty-titan.blogspot.com/2012/06/understanding-cassandras-consistency.html
http://opensourceconnections.com/blog/2013/07/24/understanding-how-cql3-maps-to-cassandras-internal-data-structure-sets-lists-and-maps/

How can I fetch 'distinct' data keeping row ID in the lookup view?

Assume I have an entity with the following structure:
ID (it would be the GUID of the record, I'll use number in this example for easier read)
Name
Product (lookup to product)
Price List (custom lookup to standard price list)
I now need to build a lookup view in this fashion:
(Sample data)
ID Name Product PriceList
-----------------------------------
1 Rec1 P1 PL1
2 Rec1 P1 PL2
3 Rec1 P1 PL3
4 Rec2 P2 PL1
5 Rec2 P2 PL2
(Desired result in lookup view)
ID Name
-----------------------------------
1 Rec1
4 Rec2
To explain the requirement in plain english, it is:
In the lookup view I only want one row per Name: Product and Price List don't matter.
Here's what I'd do if I could use straight T-SQL:
;WITH cte AS
(
SELECT ROW_NUMBER()
OVER (PARTITION BY Name ORDER BY Name ASC) AS RowNo, ID, Name
FROM FilteredEntity
)
SELECT ID, Name FROM cte WHERE RowNo = 1
But I can't figure out how to achieve the same result set in a FetchXML query.
The only way I can think of to do this would go like this:
In JS on your form, determine the unique names (Rec1 and Rec2 from your example), and store the ids of two records that reference Rec1 and Rec2 (let's call these ids Id1 and Id2)
Generate a fetch query that returns only those two records. Your fetch query would specifically say show me records where id is Id1 or Id2.
Filter the lookup using addCustomFilter and addPreSearch (link).
I can see two approaches here, neither of which are pure FetchXML queries.
Use distinct, (I'm not 100% on this but worth giving a go). This will then hopefully get you a record for every name, and you just grab the first record of each in code.
<attribute name='name' distinct='true'/>
Perform the filtering client side using Linq.

Resources