Is there a way to make the mapping dynamic loop between the XML scheme? - bloomberg

Setuing a fix engine for Bloomberg FXGO for FX Derivatives.
Although using an XML scheme (DataDictionary=FIX_BBG.xml) for the mapping of the FIX message, I receive an error of
*FIX Message": "8=FIX.4.4|9=156|35=3|34=1770|49=MAP|52=20220118-14:39:48.607|56=MAP_BBG_BETA|145=FX|45=1783|**58=Out of order repeating group members, field=602|371=602|372=8|373=15|10=180"***
This due to the fact that the tags sequence is repeating across different type of transactions;
For the above tag 602 is coming in normal sequence and then repeats itself after tag 675.
Is there a way to make the mapping dynamic loop between the XML scheme?
Tried to add the tag 602 in multiple location in XML scheme or changing the order but still receiving the same error
Adding a sample FIX msg, 602 tag to 1074 in the sequence is repeating twice, whereas in the XML schema is once and in arithmetic order from 1 to 20,XXX tag. and this is resulting to rejection.
8=FIX.4.4|9=2317|35=8|49=MAP_BLP_BETA|56=MAP_BETA|34=1933|144=FX|52=20220708-15:01:49|30=XOFF|60=20220708-14:55:49.210|120=USD|150=F|31=1.203294|151=0|32=240003|64=20220719|6=1.203294|1056=288794.17|37=3-2-XXXXXXXXXXX-0-0|1057=Y|38=240003|218=0|39=2|40=G|460=4|1300=XOFF|1390=0|11=3-2-XXXXXXXXXXX-0-0|14=240003|194=1.2032|854=0|15=GBP|75=20220708|195=0.000593|17=3-2-XXXXXXXXXXX-0-0|167=FXSWAP|797=Y|22277=0|48=TGBYHN1234|528=P|22280=2|22=4|54=B|55=GBP/USD|119=288794.17|2489=FX_CASH_RFQ_815676229|78=2|79=TESTVENUE|80=240003|79=TESTVENUE|80=240003|555=2|**600=GBP/USD|****1788=1|602=TGBYHN1234|603=4****|607=4|609=FXFWD|624=1|556=GBP|687=240003|654=1|587=6|588=20220719|675=USD|637=1.203294|1073=0.000094|1074=288794.17|****600=GBP/USD|1788=2|602=EZBCKS7MP4D1|603=4|607=4|609=FXFWD|624=2|556=GBP|687=240003|654=2|587=6|588=20220812|675=USD|637=1.203887|1073=0.000687|1074=288936.49|**10009=6|10010=VENUE1|10011=1.203334|22161=1.203927|22162=0.000593|22163=0.000687|22485=1.20324|22486=0|22545=0|10010=VENUE2|10011=1.203304|22161=1.203897|22162=0.000593|22163=0.000687|22485=1.20321|22486=0|22545=0|10010=VENUE3|10011=1.203324|22161=1.203917|22162=0.000593|22163=0.000687|22485=1.20323|22486=0|22545=0|10010=VENUE5|10011=0|22161=0|22162=0|22163=0|22485=0|22486=0|22545=0|10010=MidRate|10011=1.20324|22161=1.203845|22162=0.000605|22163=0.000695|22485=1.2032|22486=0|22545=0|10010=RefRate|10011=1.203294|22161=1.203887|22162=0.000593|22163=0.000687|22485=1.2032|22486=0|22545=0|22078=1|22079=1.203294|22080=20|22081=12|453=7|448=XOFF|447=G|452=64|802=1|523=TESTUIT12345678|803=4025|448=BGTB|447=D|452=13|802=5|523=Pricer Test USER4|803=1|523=24876081|803=2|523=USER1|803=9|523=12345QAZWSX|803=4025|523=Y|803=4047|448=125698745|447=P|452=12|2376=24|802=1|523=Y|803=4047|448=125698745|447=P|452=122|2376=24|802=1|523=Y|803=4047|448=VENUE2|447=D|452=1|802=5|523=Pricer BGAU|803=1|523=27391323|803=2|523=TESTUSER|803=9|523=12345QAZWSX|803=4025|523=Y|803=4046|448=PRODUCT TYPE|447=D|452=16|802=1|523=Dealing (RFQ)|803=4|448=24876081|447=D|452=11|1907=2|1903=TESTUTI2333333|1905=1234QWERT|1904=0|1906=5|2411=1|1903=TESTID12345667789|1905=1234QWERT|1904=0|1906=5|2411=2|768=2|769=20220708-14:55:49.210|770=1|769=20220708-14:55:40.000|770=10|2668=2|2669=0|2670=4|2669=1|2670=7|10=243|

Related

SonarQube considering SQL DML entries to have duplicate values

I have the below code in my Github respository:
INSERT INTO lookup_tables.view_da_status_lookup(status_id, object_type, status_name, status_type, ui_dropdown_flag, last_updt_ts)
VALUES
(1,'View','Validation success','Maker Validation',true,CURRENT_TIMESTAMP),
(2,'View','Validation Failed','Maker Validation',true,CURRENT_TIMESTAMP),
(3,'View','Approved','Checker Validation',true,CURRENT_TIMESTAMP);
Maker Validation is repeated in the DML and it expects us to use a variable and have the command in a PL-SQL construct.
This is the error I get:
Define a constant instead of duplicating this literal 1 times.
However, we do not have to implement PL-SQL. Is there a way to tell it to ignore the error?
On the following link, you can find:
Exclude specific rules from specific files
Analysis Scope > D. Issue > Exclusions > Ignore Issues on Multiple Criteria
You can prevent specific rules from being applied to specific files by
combining one or more pairs of strings consisting of a** rule key
pattern and a **file path pattern.
The key for this parameter is sonar.issue.ignore.multicriteria.
However, because it is a multi-value property, we recommend that only
be set through the UI.
For example, if you use Maven, the setting should look like this:
<properties>
<sonar.issue.ignore.multicriteria>e1,e2</sonar.issue.ignore.multicriteria>
<sonar.issue.ignore.multicriteria.e1.ruleKey>squid:S00100</sonar.issue.ignore.multicriteria.e1.ruleKey>
<sonar.issue.ignore.multicriteria.e1.resourceKey>**/*Steps.java</sonar.issue.ignore.multicriteria.e1.resourceKey>
<sonar.issue.ignore.multicriteria.e2.ruleKey>squid:S1118</sonar.issue.ignore.multicriteria.e2.ruleKey>
<sonar.issue.ignore.multicriteria.e2.resourceKey>**/PropertyPlaceholderConfig.java</sonar.issue.ignore.multicriteria.e2.resourceKey>
</properties>
where e1 and e2 are local rule names, e1.ruleKey is sonarqube rule id and e1.resourceKey is path to file.

Understanding the "Not found: Dataset ### was not found in location US" error

I know this topic has come up many times but still here I am. Data processing location seems consistent (dataset, US; query: US) and I am using backticks & long format in the FROM clause
Below are two sequences of code. The first one works perfectly:
SELECT station_id
FROM `bigquery-public-data.austin_bikeshare.bikeshare_stations`
Whereas the following returns an error message:
SELECT bikeshare_stations.station_id
FROM `bigquery-public-data.austin_bikeshare`
Not found: Dataset glassy-droplet-347618:bigquery-public-data was not found in location US
My question, thus, is why do the first lines of text work while the second doesn't?
You need to understand the different parts of the backticks:
bigquery-public-data is the name of the project;
austin_bikeshare is the name of the schema (aka dataset in BQ); and
bikeshare_stations is the name of the table/view.
Therefore, the shorter format you are looking for is: austin_bikeshare.bikeshare_stations (instead of bigquery-public-data.austin_bikeshare).
Using bigquery-public-data.austin_bikeshare means that you have a schema called bigquery-public-data that contains a table called austin_bikeshare , when this is not true.

Find XML tag which is present several times

I am working with an Oracle database 19c.
I have a table with the blob field "MSG_BODY". This field contains XML's like that:
<Body xmlns = "http://www.finnova.ch/ZV/EHF/021">
<Auftrag>
<Auftragsinformation>
<Auftragsidentifikation>
<AUF_LNR>987987987987</AUF_LNR>
<APPL_ID>9999</APPL_ID>
</Auftragsidentifikation>
<Auftragsreferenz>
<EXT_REF>TEST-2020082109574181</EXT_REF>
<EXT_AUF_REF>BA18081508D86B28</EXT_AUF_REF>
<KD_LNR_ERF>901</KD_LNR_ERF>
</Auftragsreferenz>
</Auftragsinformation>
<Zahlungsliste>
<Zahlung>
<Identifikation>
<ZV_ZLG_SYS_LNR>987987987987</ZV_ZLG_SYS_LNR>
<ZV_ZLG_LNR>1</ZV_ZLG_LNR>
</Identifikation>
<Referenz>
<EXT_REF>ABCD654654654</EXT_REF>
<EXT_REF_AUF>XX-XXX 230/99999/1</EXT_REF_AUF>
<EXT_REF_AUF_IB>BA9999988888</EXT_REF_AUF_IB>
<ZLG_INSTR_ID>BA999988886666</ZLG_INSTR_ID>
<MeldungsRef>
<MSG_TX_ID>123123123123</MSG_TX_ID>
<CS_ZLG_TRACK_ID>d8047b9f-a8c7-4d74-b5c7-470510240b60</CS_ZLG_TRACK_ID>
<CS_SWIFTGPI_SVC_ID>001</CS_SWIFTGPI_SVC_ID>
</MeldungsRef>
<MeldungsRef>
<MSG_TX_ID_DECK>xxxxxxxxxx</MSG_TX_ID_DECK>
</MeldungsRef>
</Referenz>
<Mitteilung>
<MIT_BEGxxx</MIT_BEG>
<MIT_BEG_XML>
<Ustrd>xxx</Ustrd>
</MIT_BEG_XML>
<PURP_CD>SALA</PURP_CD>
</Mitteilung>
</Zahlung>
</Zahlungsliste>
</Auftrag>
The tag "Zahlung" can exist multiple times and that's OK, but into the the tag "Zahlung" is the
tag "MeldungsRef". This tag should exist zero or one time for every tag "Zahlung". That's a fault shown in the XML above. I now need a query to select all rows in the table, which contains an XML, where the tag "MeldungsRef" is multiple times there. How can I do that?
Thanks for helping me!
Regards,
mablaser
You're looking for a second appearance of the MeldungsRef node within a Zahlung node, so you can look directly for that. This query shows you the first and second instances of the node, using xmlquery() and specifying the appearance to find with [1] or [2]:
select id,
xmlquery(
'declare default element namespace "http://www.finnova.ch/ZV/EHF/021"; (: :)
/Body/Auftrag/Zahlungsliste/Zahlung/Referenz/MeldungsRef[1]'
passing xmltype(msg_body)
returning content
) as first,
xmlquery(
'declare default element namespace "http://www.finnova.ch/ZV/EHF/021"; (: :)
/Body/Auftrag/Zahlungsliste/Zahlung/Referenz/MeldungsRef[2]'
passing xmltype(msg_body)
returning content
) as second
from your_table;
You could look for the second being not-null, but it's easier to use the same XPath with xmlexists() to test whether a second child node exists:
select id
from your_table
where xmlexists(
'declare default element namespace "http://www.finnova.ch/ZV/EHF/021"; (: :)
/Body/Auftrag/Zahlungsliste/Zahlung/Referenz/MeldungsRef[2]'
passing xmltype(msg_body)
);
db<>fiddle with one good (single node) and one bad (multiple node) row.
i receive the following error: ORA-32512: type 'xquery external variable'
As your base column is a BLOB you need to tell it which character set it's it, e.g.:
passing xmltype(msg_body, nls_charset_id('UTF8'))
db<>fiddle.

Xquery transformation on text data in response

I want to get a xquery transformation drafted for below data.. here as part of service response fault, I am getting below payload and need to capture the data in ErrorCode element.
challenge that I am having here is, this is not part of a XML structure, its coming as part of CDATA tags.
Could you please suggest how I can get this value in a variable same.
Say I am getting this structure as part of $Fault and now need to assign ErrorCode in a new variable $FaultCode
$FaultCode = $Fault/con:details/con1:ErrorResponseDetail/con1:detail/ ********
I am not sure how I can capture this further detail element
<con:fault xmlns:con="http://www.bea.com/wli/sb/context">
<con:errorCode>382502</con:errorCode>
<con:reason>eceived an error response</con:reason>
<con:details>
<con1:ErrorResponseDetail xmlns:con1="http://www.bea.com/wli/sb/stages/transform/config">
<con1:detail>
<![CDATA[<Error xmlns="http://servic.abcd.net/V1">
<ErrorCode>DATA_AVAILABILITY</ErrorCode>
<ErrorDescription>{"description":"No Cdata for )"}</ErrorDescription>
</Error>]]></con1:detail>
<con1:http-response-code>404</con1:http-response-code>
</con1:ErrorResponseDetail>
</con:details>
<con:location>
<con:node>TestPPNode</con:node>
<con:pipeline>TestPPNode_request</con:pipeline>
<con:stage>Test Stage</con:stage>
<con:path>request-pipeline</con:path>
</con:location>
</con:fault>
Assuming XQuery 3.1 with the parse-xml function (https://www.w3.org/TR/xpath-functions/#func-parse-xml) you can use
declare namespace con="http://www.bea.com/wli/sb/context";
declare namespace con1="http://www.bea.com/wli/sb/stages/transform/config";
declare namespace V1 = "http://servic.abcd.net/V1";
/con:fault/con:details/con1:ErrorResponseDetail/con1:detail!parse-xml(.)/V1:Error/V1:ErrorCode/data()
to get the string value DATA_AVAILABILITY, see https://xqueryfiddle.liberty-development.net/6qM2e27 for demo.
With XQuery 1 there is not XML parsing which is needed to solve this properly but you can of course try to use string functions to extract the data e.g.
/con:fault/con:details/con1:ErrorResponseDetail/con1:detail/substring-before(substring-after(., '<ErrorCode>'), '</ErrorCode>')

SQL simulator on Prolog

i need to do a SQL simulator on Prolog. i need to simulate some functions like create_table, insert, delete, update_table, select_table, drop_table, show_table, etc. I am learning how to do asserts and retracts but im getting some errors in my first function create_table(N,A) where N is the name of the table and A a list with the atributtes
An example is create_table("student",["name","lastname","age"]). This will create my table named "student" with the atributes ["name","lastname","age"].
I was searching how to work with assert and i see i need to do dynamic before making assert, then my code is.
len([],0).
len([_|T],N) :- len(T,X), N is X+1.
create_table(_, []):-!.
create_table(N, Atributos):- len(Atributos, L), dynamic N/L, assert(N(Atributos)).
But i get this error :7: Syntax error: Operator expected on this line
create_table(N, Atributos):- len(Atributos, L), dynamic N/L, assert(N(Atributos)).
What im doing wrong? excuse me, i dont speak good english.
From the error message, seems you're using SWI-Prolog....
Your code could be (note that len/2 can be replaced by the builtin length/2)
create_table(N, Atributos):-
length(Atributos, L),
dynamic(N/L),
T =.. [N|Atributos], % this missing 'constructor' was the cause of the error message
assert(T). % this is problematic
There is an important 'design' problem: the CREATE TABLE SQL statement works at metadata level.
If you do, for instance,
?- assertz(student('Juan', 'Figueira', 20)).
pretending that the predicate student/3 holds table data, you're overlapping data and metadata
using dynamic/1 and assert is a tricky non-logical aspect of Prolog, and dynamically creating dynamic predicates is really unusual. Fundamentally you cannot have a Prolog query with the predicate name as a variable e.g.
query(N,X) :- N=student, N(X).
My suggestion is you remove a layer of complexity and have one dynamic predicate 'table', and assert your SQL tables as new 'table' clauses i.e.
:- dynamic table/2.
:- assertz(table(student,['Joe','Young',18])).
query(N,X) :- table(N,X).
:- query(student,[Name,Lastname,Age]).