retrieve data from Oracle XMLType with multiple or matrix type text node values - oracle

I'm very new to XML and I don't know how to extract XMLType from Oracle. My task is loop through a table column with XMLType datatype (please see attached imaged file) and check the length of value of text node. However, one type of text node is different from the other. One has multiple values separated with ';' and another is by matrix with multiple items and multiple records. I cannot even go pass this simple SQL statement that returns null vale:
SELECT extract( xs.xs_xml, '/arg0/item/text()' )
FROM XML_Shield xs
WHERE xs_id = 521521;
Looking in the internet for solution similar to my task but none fits my requirement. Most of the examples I see are one value text nodes and not matrix. I must admit this is out of my deep.
Can you guys please help me? I appreciate your assistance regarding this matter.
thanks...

Related

Power Query - conditional replace/clear entire cell in multiple columns

I'm trying to clear the entire cell if it doesn't contain a given keyword.
I've managed to do this for one column:
Table.ReplaceValue(#"PrevStep",each [#"My Column"], each if Text.PositionOf([#"My Column"],"keyword")>-1 then [#"My Column"] else null,Replacer.ReplaceValue,{"My Column"})
The problem is I need to iterate/repeat that step for a number of columns... the number of columns may vary and column names also may be different every time. I can have all those column names put into a list but I'm not able to use it.
The solution I'm looking for may look like this
for each ColNam in MyColumnsList
Table.ReplaceValue(#"PrevStep",each [#"ColNam"], each if Text.PositionOf([#"ColNam"],"keyword")>-1 then [#"ColNam"] else null,Replacer.ReplaceValue,MyColumnsList)
next
but this is not the VBA code but Power Query M - and of course the problem is with #PrevStep as I would see it like a recursions... again... do not know how to process.
Is the path I follow correct or should it be done some other way
Thanks
Andrew
Unpivot your columns to turn all the columns into two columns. Apply your replacement to the single value column then pivot it back into the original format

Match part of the text and replace with another text in excel

I've data table with list of names which are having few differences. I am trying to change those text to similar name within data table as image in below.
If part of the text in cells in data table are matching with the "Abbreviations" list(Col-AK) then Data table text must replace with the text in "To be replaced" (Col-AL) into "Expected Return Table". I've tried using may different functions to accomplish my ultimate target, but none of them is giving perfect answer.
Can anybody help me with this problem.
I found an answer to my problem. I could do this using below formula.
Step 01:- I've used below static formula at first to identify the dynamic formula
=IF(LEFT(AC2,4)=$AK$2,$AL$2,AC2)
Step 02:- Then I've used Index function to return the first text in abbreviation list which is Iodine by only changing partial of the formula to return only single value avoiding others. Ex: Firstly I considered only about the Iodine in the list. This will only replace Iodine into the expected data table.
=IF(LEFT(AC2,4)=INDEX($AK$2:$AK$11,1),$AL$2,AC2)
Step 03:- Then row_num turned into dynamic and expanded the return text data into range($AL$2:$AL$11) from single($AL$2) using Match & Left function as below.
=IF(LEFT(AC2,4)=INDEX($AK$2:$AK$11,MATCH(LEFT(AC2,4),$AK$2:$AK$11,0)),INDEX($AL$2:$AL$11,MATCH(LEFT(AC2,4),$AK$2:$AK$11,0)),AC2)
Step 04:- Finaly ignore errors using IFERROR Function.
=IFERROR(IF(LEFT(AC2,4)=INDEX($AK$2:$AK$11,MATCH(LEFT(AC2,4),$AK$2:$AK$11,0)),INDEX($AL$2:$AL$11,MATCH(LEFT(AC2,4),$AK$2:$AK$11,0)),AC2),"")
Expected Return Data Table as shown below.

Storing and retrieving value inconsistency in a table in Oracle

I am facing a weird problem. I have a table (observation_measurement) in oracle DB and it has many fields. One field name is observation_name. this observation_name field stores different measurements with it's value from a text file.
For example, observation_name stores four measurements a,b,c,d (name of the measurements) and their corresponding values 1,2,3,4 (values of those measurements).
Later it is reading same text file. This time that text file has three measurements a,b,d (c is not there) and their values are 7,8,9 and then store in the table. So, if I need the latest values for all observation_names then I should get a=7,b=8,c=null,d=9. But it is giving me
a=7,b=8,c=3,d=9. I dont know why it is getting old data for c measurement.
Any ideas?
NULL has to be handled specially in Oracle, like IS NULL or IS NOT NULL.
Hope, your update logic involves some validation over the column and it leaves NULL values untreated.
Since, some validation fails because of NULL, the old value is retained in the table.
Can you please update your question with the Query used to UPDATE the table.

ORACLE SQLLOADER, referencing calculated values

hope you're having a nice day. I'm learning how to use functions on SQL-LOADER and i have a question about it, lets say i have this table
table a
--------------
code
name
dept
birthdate
secret
the data.csv file contains this data
name
dept
birthdate
and i'm using this code to load data to it with SQLLOADER
LOAD DATA
INFILE "data.csv"
APPEND INTO TABLE a;
FIELDS TERMINATED BY ',' optionally enclosed by '"'
TRAILING NULLCOLS
(code "getCode(:name,:dept)",name,dept,birthdate,secret "getSecret(getCode(:name,:dept),birthdate)")
so this works like a charm it gets the values from my getCode and getSecret functions, however, i would like to reference the previously calculated value (by getCode) so i don't have to nest functions on getSecret, like this:
getSecret(**getCode(:name,:dept)**,birthdate)
i've tried to do it like this:
getSecret(**:code**,birthdate)
but it gets the original value from the file (meaning null) and not the calculated by the function (guess because it does it on the fly), so my question is if there is a way to avoid these nest calls for previously calculated values, so i don't have to loose performance recalculating the same values over and over again (the real table i'm using it's like 10 times bigger and nests a lot of functions for these previously calculated values, so i guess that's reducing performance)
any help would be appreciated, Thanks!!
complement
Sorry, but i haven't used external tables before (kinda new here), how could i implement this using this tables? (considering all the calculated values i need to get from functions i developed, tried trigger (SQL Loader, Trigger saturation?), killed database...)
I'm not aware of a way of doing this.
If you switched to using external tables you'd have a lot more freedom for this sort of thing -- common table expressions, leveraging subquery caching, that sort of stuff.

How to create a table with lines and columns using Ireport?

I'am using JasperReport and ireport 4.0 , I want to know If their the possibility to create a table that can I fix lines and columns? Because the only the table that I have found allowed me just to fix columns !!
And
For the charts I have just an integer values but I dont know what the scale use float numbers!
Update:
what I mean that ireport allowed this format:
and I want the following format:
Thank you
Typically you have a varying number of rows, because the number of rows depend on the data from your database.
To have a known number of rows you either have to make sure that your data has the expected number of rows, or you design your detail section in a way that corresponds to your desired outcome. The height of the detail section is flexible, and you can put various text fields not only side by side, but also on top of each other.

Resources