How to extract all rows, for which row a particular criteria is met? Details in description - etl

I am trying to load a set of policy numbers in my Target based on below criteria using Informatica PowerCenter.
I want to select all those rows of policy numbers, for which policy the Rider = 0
This is my source: -
Policy Rider Plan
1234 0 1000
1234 1 1010
1234 2 3000
9090 0 2000
9090 2 2545
4321 3 2000
4321 1 2000
Target should look like this: -
Policy Rider Plan
1234 0 1000
1234 1 1010
1234 2 3000
9090 0 2000
9090 2 2545
The policy number 4321 would not be loaded.
If I use filter as Rider = 0, then I miss out on below rows: -
1234 1 1010
1234 2 3000
9090 0 2000
9090 2 2545
What would be ideal way to load this kind of data using PowerCenter Designer?

Take the same source in one more qualifier in same mapping, use a filter as Rider=0 to get list of unique policy numbers that has Rider=0, then use a joiner with your regular source on policy number. This should work.
Another method, sort your data based on policy and Rider, and use variable ports with condition similar to below.
v_validflag=IIF(v_policy_prev!=policy, IIF(Rider=0, 'valid','invalid'), v_validflag)
v_policy_prev=policy
Then filter valid records.

There are many options. Here are two...
First:
It'll look like:
// AGGREGATOR \\
SOURCE >> SOURCE QUALIFIER >> SORTER << >> JOINER >> TARGET
\\============//
Connect all ports from Source Qualifier (SQ) to SORTER transformation (or sort in SQ itself) and define sorting Key for ‘Policy’ and ‘Rider’. After that split stream into two pipelines:
- Connect ‘Policy’ and ‘Rider’ to FILTER transformation and filter records by ‘Rider’ = 0. - After that link ‘Policy’ (only) to AGGREGATOR and set Group By to ‘YES’ for ‘Policy’. - Add a new port with FIRST or MAX function for ‘Policy’ port. This is to remove duplicate ‘Policy’-es.- Indicate ‘Sorted Input’ in the AGGREGATOR properties.- After that link ‘Policy’ from AGR to JOINER as Master in Port tab.
2.- Second stream, from SORTER, directly link to above JOINER (with aggregated ‘Policy’) as Detail. - Indicate ‘Sorted Input’ in the JOINER properties. - Set Join Type as ‘Normal Join’ and Join Condition as POLICY(master)=POLICY(detail) in JOINER properties.
... Target
Second option:
Just Override SQL in Source Qualifier...
WITH PLC as (
select POLICY
from SRC_TBL
where RIDER=0)
select s.POLICY, s.RIDER, s.PLAN
from PLC p left JOIN SRC_TBL s on s.POLICY = p.POLICY;
may vary depend on your source table constructions...

Related

ORACLE Program code to use filter and pivot table

IN EXCEL SHEET FOR THE BELOW INPUT, I HAVE TO USE FILTER TO “NET” FIRST WHERE NET=APB AND NEED TO FILTER “CODE VALUES” AS WDL, LRTF & NEED TO USE “PIVOT TABLE” TO GET OUTPUT WITH COUNT AS:
BUT I NEED CODE IN ORACLE TO RUN FOR THE FOLLOWING OUTPUT:-
INPUT:
STTID
AMOUNT
NET
CODE
SVPC12309A
5000
NFS
SOP
SVPC12309A
10000
NFS
WDL
000DHP11291
2500
APB
WDL
SVPC12309A
3000
CMV
LRTF
SVPC12309A
3000
CMV
WDL
DHP12341
4500
APB
LRTF
DHP23451
9500
APB
LRTF
DHP12341
5500
APB
LRTF
OUTPUT AS:
STTID
LRTF
WDL
TOTAL
000DHP11291
0
1
1
DHP12341
2
0
2
DHP23451
1
0
1
It appears you want something like
select sttid,
sum( case when code = 'LRTF' then 1 else 0 end ) ltrf,
sum( case when code = 'WDL' then 1 else 0 end ) wdl,
sum( case when code in ('WDL', 'LTRF') then 1 else 0 end) total
from your_table_name
group by sttid

Generate random sequence in Oracle

I am trying to generate random numbers into 2 columns where the first column is from_number and second column in to_number.
My query looks as following
select to_char(5001 + (level-1)),
to_char(5005 + (level-1))
from dual
connect by level <= 100;
My output is for the above query is:
5001 5005
5002 5006
5003 5007
5004 5008
5005 5009
and so on...
But my output should be like following:
5001 5005
5006 5010
5011 5015
5016 5020
and so on...
The second-row 'from_number' should be the first-row 'to_number'+1
How can achieve this?
Thanks in advance.
Note that what you are using here is not a random sequence. It is a fixed sequence. To know how to generate random number read this
Now coming back to your question, you can do it by playing a little with level. Note I reduced the <=100 to <=20 as we are using a multiplier of 5 so the maximum value you will get is 5005 + 20*5 - 5 = 6000. Change it back to <=100 if you want total of 100 rows.
select
to_char(5001 + (level*5) - 5 ),
to_char(5005 + (level*5) - 5)
from dual
connect by level <= 20;

Query field keys in regex-using Springboot and Influxdb

Spring-Boot has a Metrics look like
metrics_counter.status.200.hello 20
metrics_counter.status.200.jolokia.star-star 1
metrics_counter.status.200.metrics 2
metrics_counter.status.200.star-star.favicon.ico 4
metrics_counter.status.304.star-star 3
metrics_counter.status.404.star-star 1
it is dynamic by url ; for this example /hello have http status 200 for 20 time .
in influxdb the fields look like this
> show field keys
name: jolokia
fieldKey fieldType
-------- ---------
metrics_counter.status.200.jolokia.star-star float
metrics_counter.status.200.metrics float
metrics_counter.status.200.persons float
metrics_counter.status.200.star-star float
metrics_counter.status.200.star-star.favicon.ico float
metrics_counter.status.304.star-star float
metrics_counter.status.404.star-star float
if I query by regex , the result is
> SELECT mean(/status.200.*/) FROM jolokia
name: jolokia
time mean_metrics_counter.status.200.hello mean_metrics_counter.status.200.jolokia.star-star mean_metrics_counter.status.200.metrics mean_metrics_counter.status.200.persons mean_metrics_counter.status.200.star-star mean_metrics_counter.status.200.star-star.favicon.ico
---- ------------------------------------- ------------------------------------------------- --------------------------------------- --------------------------------------- ----------------------------------------- -----------------------------------------------------
0 3.8686440677966103 112.582995951417 8.935643564356436 651.429718875502 1 7.7923728813559325
how can I sum all http status like
200 27
304 3
404 1
by dynamic field keys query?
You'll have to modify your schema a bit, but it should be possible.
Instead of inserting data that looks like graphite format
jolokia metrics_counter.status.200.jolokia.star-star=100 <timestamp>
Use tags
jolokia,type=metrics_counter,status=200 star-star=100 <timestamp>
In fact, I would actually recommend that you structure your data like so
metrics_counter,status=200,app=jolokia star-star=100
metrics_counter,status=200,app=jolokia star-star.favicon=100
metrics_counter,status=304,app=jolokia star-star=100
metrics_counter,status=400,app=jolokia star-star.favicon=100
Then you can issue a query like
SELECT mean(*) FROM metrics_counter GROUP BY status

Read Security Audit Log static and dynamic filters using RFC

I am trying to read SAP Audit Log static and dynamic filters setting (sm19) using RFC connection.
For static filters i figured out they are stored in table rsauprof:
Field Key Data Element Type Offset Leng Decimals Check Table Text
PROFNAME X RSAUPNAME CHAR 0 8 0 SecAudit: Audit profile name (of the configuration)
SLOTNO X RSAUSLOTNO NUMC 8 4 0 Audit log: Number of the recording parameter (slot)
CURRPROF RSAUCPROF CHAR 12 8 0 Security Audit: Name of the current audit profile
CLASSES RSAUCLASID INT4 20 10 0 System audit log: Audit event classification indicator
SEVERITY RSAUSEVERI INT4 24 10 0 System audit log: Security levels
CLIENT MANDT CLNT 28 3 0 T000 Client
UNAME XUBNAME CHAR 31 12 0 USR02 User Name in User Master Record
STATUS RSAUSTATUS CHAR 43 1 0 Audit activity indicator (slot)
CUNAME RSAUCUNAME CHAR 44 12 0 USR02 Security audit: SAP name of person who changed the profile
CDATE RSAUCDATE DATS 56 8 0 Security Audit: Date when the audit profile was changed
SELVAR RSAUSELVAR RAW 64 1 0 Security audit: determining selection variant
MSGVECT RSAUMSGVEC CHAR 65 1 0 Security audit: selection vector of audit events
Field of interests is MSGVECT, but I have problems to interpret that value because it looks like a bitvector. How to convert that value into human-readable form?
For dynamic filters i didn't find any place to look for stored filter settings.
So the question is: how to read dynamic and static sap audit log filter settings from SAP?
You can check RSAU_CONFIG_SHOW report which had been introduced with 750 and API it uses.
Method GET_MSGVECT_FROM_ALV of class CL_SAL_CONFIG is probably what you seek.

price filter problem in magento

In magento sidebar basically how the price filter option is working, i went through all the templte and block files under my custom design.
I am getting this ranges by default.
1. $0.00 - $10,000.00 (1027)
2. $10,000.00 - $20,000.00 (3)
3. $20,000.00 - $30,000.00 (1)
These limits are automatically taken but i want give my own ranges, but they are using only one template file called filter.phtml if i touch that then all other filter options are having problem. How can i customize this price filter as per my own set of ranges?
I need something like this
# $40.00 - $60.00 (155)
# $60.00 - $80.00 (150)
# $80.00 - $100.00 (153)
# $100.00 - $200.00 (248)
# $200.00 - $300.00 (100)
# $300.00 - $400.00 (43)
# $400.00 - $500.00 (20)
# $500.00 - $600.00 (6)
# $600.00 - $700.00 (6)
# $700.00 - $800.00 (2)
If you look in filter.phtml, you will see that it is using the block Mage_Catalog_Block_Layer_Filter_xxx where xxx is the attribute type. Which in turn leads you to the model: Mage_Catalog_Model_Layer_Filter_Price.
Inside app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php, you will see the method getPriceRange() which calculates the price breaks.
You can override that model by copying it into app/code/local/Mage/Catalog/Model/Layer/Filter and adjusting that method so that it calculates the ranges per your requirements.
Good luck.
JD

Resources