Why would an XMLListCollection get corrupted by addItamAt function in Flash Builder 4.6 - flash-builder

The XMLListCollection in question is called studentsAll and looks like this after being created...
<details>
<name>Baughman, John D (#hawaii.rr.com at Pearl City H. S.)</name>
<id>2693</id>
<emailpw>johnbdh#hawaii.rr.com</emailpw>
<pw/>
</details>
<details>
<name>Benoit, Sandra (#gmail.com at Pearl City H. S.)</name>
<id>2694</id>
<emailpw>sandra#gmail.com</emailpw>
<pw/>
</details>
I am then runniing...
studentsList = new XMLListCollection;
studentsIDs = new XMLListCollection;
for (var _index:int=0; _index < studentsAll.length; _index++) {
studentsList.addItemAt(studentsAll[_index].name, studentsList.length);
studentsIDs.addItemAt(studentsAll[_index].id, studentsIDs.length);
}
Wehn that finishes the XMLListCollection studentsAll looks like this...
<details>
<name>Baughman, John D (#hawaii.rr.com at Pearl City H. S.)</name>
<name>Benoit, Sandra (#gmail.com at Pearl City H. S.)</name>
<id>2693</id>
<id>2694</id>
<emailpw>johnbdh#hawaii.rr.com</emailpw>
<pw/>
</details>
<details>
<name>Benoit, Sandra (#gmail.com at Pearl City H. S.)</name>
<id>2694</id>
<emailpw>sandra#gmail.com</emailpw>
<pw/>
</details>
Notice how the tags in the second index have been duplicated in the first.
Is this a bug?
Thanks,
John

IMHO this is caused by a SDK bug: https://issues.apache.org/jira/browse/FLEX-33913
A pretty nasty bug; personally, I now don't trust XMLListCollection at all.
Workarounds:
Use XMLList, Array or ArrayCollection instead of XMLListCollection or run the for loop on a cloned collection - use .copy()

Related

How can I use SQL to break comma-separeted values into new rows

I have the following dataset example:
Name:
Qualities:
Adam
Authentic,Cool,Young
Bob
Serious,Old,Authentic
Carl
Cool,Athletic,Hardworker
And I need to use SQL to turn this dataset into the following:
Name:
Qualities:
Adam
Authentic
Adam
Cool
Adam
Young
Bob
Serious
Bob
Old
Bob
Authentic
Carl
Cool
Carl
Athletic
Carl
Hardworker
Can someone give me a hand on that? I have no clue how can I get this done.
Hope to find it out soon!
Cheers!
SELECT Name, value AS Quality FROM <dataset>
CROSS APPLY STRING_SPLIT(Qualities, ',')
You can used STRING_SPLIT for string values.
Please see more informaton.
https://www.sqlservertutorial.net/sql-server-string-functions/sql-server-string_split-function/
SELECT
Name,
value Quality
FROM
<TABLE NAME>
CROSS APPLY STRING_SPLIT(Qualities, ',');

Oracle SQL to extraction of human names like Nltk

Is there a SQL/Regex or some advance function where we can extract human names for a columns that has around 2 million rows? some thing like NLTK
below is my sample. In the below I wanted to extract only human names (i.e.) filter companies **. Like these I have 2 million mixed with real companies and human names
KAREN STRAUSS
KASEY NEMELKA
KATHLEEN MCMAHON
KATHRYN HOCKADAY
KATHRYN HOLAHAN
KATIE NELSON
**KATHERINE KACENA CONSULTING**
KATHY ATKINS
KATRINA GRANT
KATY DYER
KATY G TACKES
**KAUFFMAN S TRANSPORT LLC**
KATHERINE MAGPANTAY
KATHERINE VENTURA
KATHRYN RUANO
JORGE DANIEL MUSCIA
JOSE MANUEL ROSALES SANTEROS
JOSE MANUEL VILAS CARR
JOSEPH H WILNER
This is too long for a comment. Human names are too variable. After all, is "John Deere" the name of a company. Or is it the name of a person? Or both?
You can construct special purpose logic for your data. It will take time to develop but something like this:
regexp(lower(name), '\s(consult|llc)')

How to find a specific word within a phrase?

I wish to know how to find a specific word within a phrase. I am trying to find the word "Pizza" within a set of keywords, however there is no keyword that only has "Pizza". There are keywords such as "Pizza Delivery" and "Pizza Delivery Boy", however they won't show up! How can I do this?
Desired output:
MOVIE KEYWORD
----------------------------------- ----------------------------------
Drive Angry Waitress
Taken France
Saving Private Ryan France
30 Minutes or Less Pizza Delivery
30 Minutes or Less Pizza Delivery Boy
My script:
SELECT MovieTitle AS "MOVIE", KEYWORDDESC AS "KEYWORD"
FROM TBLMOVIE
JOIN TBLKEYWORDDETAIL ON TBLMOVIE.MOVIEID = TBLKEYWORDDETAIL.MOVIEID
JOIN TBLKEYWORD ON TBLKEYWORDDETAIL.KEYWORDID = TBLKEYWORD.KEYWORDID
WHERE TBLKEYWORD.KEYWORDDESC IN ('France', 'Waitress', 'Pizza');
My output:
MOVIE KEYWORD
----------------------------------- ----------------------------------
Drive Angry Waitress
Taken France
Saving Private Ryan France
One method uses LIKE:
WHERE TBLKEYWORD.KEYWORDDESC LIKE '%France%' OR
TBLKEYWORD.KEYWORDDESC LIKE '%Waitress%' OR
TBLKEYWORD.KEYWORDDESC LIKE '%Pizza%'
Another method uses REGEXP_LIKE():
WHERE REGEXP_LIKE(TBLKEYWORD.KEYWORDDESC, 'France|Waitress|Pizza')
If you use REGEXP_LIKE() you should spend a little bit of time learning about regular expressions and how to use them.

How to display database records with <details> and <summary>

I am trying use the HTML5 <details> and <summary> features to display records from my database. Example:
CATEGORY | TITLE
Fruit | Apple
Cars | Chevrolet
Actors | Tom Hanks
....
I would like to display the data like this:
Cars
Chevrolet
Ford
Vauxhall
Actors
Tom Hanks
Harrison Ford
Meryl Streep
Selina Gomez
How should the query and the display in HTML be constructed? I tried this query:
SELECT DISTINCT CATEGORY, TITLE
FROM TEST
GROUP BY CATEGORY
However, all I got from my works is something like this:
Actors
Tom Hanks
Actors
Harrison Ford
Do I need another query?
We use the cfquery, cfoutput containers to achieve this.
And the group parameter on cfoutput
And this is how it works:
<cfquery name='dataPuller' datasource='whateverYourDataSourceIs'>
SELECT DISTINCT CATEGORY, TITLE
FROM TEST
GROUP BY CATEGORY
ORDER BY CATEGORY
</cfquery>
<cfoutput query='dataPuller' group='category'>
<strong>#dataPuller.CATEGORY#</strong>
<br>
<li>
<cfoutput>
<ul>#dataPuller.TITLE#</ul>
</cfoutput>
</li>
</cfoutput>
Note the group parameter
Note the nested cfoutput
Hope this helps :)

Getting the absolute position of a node using sql

I have an xml document of the bible
as
<bookcoll>
<book>
<bktshort>Matthew</bktshort>
<chapter><chtitle>Chapter 1</chtitle>
<v>The book of the generation of Jesus Christ, the son of David, the son of Abraham.
</v>
<v>Abraham begat Isaac; and Isaac begat Jacob; and Jacob begat Judas and his brethren;
</v>
..
</chapter>
<chapter><chtitle>Chapter 2</chtitle>
<v>Now when Jesus was born in Bethlehem of Judaea in the days of Herod the king, behold, there came wise men from the east to Jerusalem,
</v>
I would like to keep a row number of the total nuber of <v> nodes.
This statement resets the number for each Chapter node
select
Chapter.value('../../bktshort[1]', 'varchar(200)'),
Replace(Chapter.value('../chtitle[1]', 'varchar(200)'),'Chapter ', ''),
p.number,
Chapter.value('.','varchar(max)')
from
master..spt_values p
CROSS APPLY
#xml.nodes('/bookcoll/book/chapter/v[position()=sql:column("number")]') T(Chapter)
--where p.type = 'p'
order by
Chapter.value('../../bktshort[1]', 'varchar(200)'),
Replace(Chapter.value('../chtitle[1]', 'varchar(200)'),'Chapter ', ''),
p.number
so instead of
Matthew 1 23 Behold, a virgin shall be with child, and shall bring forth a son, and they shall call his name Emmanuel, which being interpreted is, God with us.
Matthew 1 24 Then Joseph being raised from sleep did as the angel of the Lord had bidden him, and took unto him his wife:
Matthew 1 25 And knew her not till she had brought forth her firstborn son: and he called his name JESUS.
Matthew 2 1 Now when Jesus was born in Bethlehem of Judaea in the days of Herod the king, behold, there came wise men from the east to Jerusalem,
Matthew 2 2 Saying, Where is he that is born King of the Jews? for we have seen his star in the east, and are come to worship him.
I would want
Matthew 1 23 Behold, a virgin shall be with child, and shall bring forth a son, and they shall call his name Emmanuel, which being interpreted is, God with us.
Matthew 1 24 Then Joseph being raised from sleep did as the angel of the Lord had bidden him, and took unto him his wife:
Matthew 1 25 And knew her not till she had brought forth her firstborn son: and he called his name JESUS.
Matthew 2 <b>26</b> Now when Jesus was born in Bethlehem of Judaea in the days of Herod the king, behold, there came wise men from the east to Jerusalem,
Matthew 2 <b>27</b> Saying, Where is he that is born King of the Jews? for we have seen his star in the east, and are come to worship him.
Side note I know that spt_values table is not big enough and would have to use a local table.
Maybe this will spur some ideas?
DECLARE #xml XML = '<bookcoll>
<book>
<bktshort>Matthew</bktshort>
<chapter>
<chtitle>Chapter 1</chtitle>
<v>The book of the generation of Jesus Christ, the son of David, the son of Abraham. </v>
<v>Abraham begat Isaac; and Isaac begat Jacob; and Jacob begat Judas and his brethren; </v>
</chapter>
<chapter>
<chtitle>Chapter 2</chtitle>
<v>Now when Jesus was born in Bethlehem of Judaea in the days of Herod the king, behold, there came wise men from the east to Jerusalem, </v>
</chapter>
</book>
<book>
<bktshort>Mark</bktshort>
<chapter>
<chtitle>Chapter 1</chtitle>
<v>The beginning of the good news about Jesus the Messiah,[a] the Son of God,</v>
</chapter>
</book>
</bookcoll>
'
SELECT BookTitle = Chapter.value('../../bktshort[1]', 'varchar(200)')
, Chapter = REPLACE(Chapter.value('../chtitle[1]', 'varchar(200)'), 'Chapter ', '')
, RunningVerse = ROW_NUMBER() OVER ( PARTITION BY Chapter.value('../../bktshort[1]', 'varchar(200)') ORDER BY Chapter.value('../../bktshort[1]',
'varchar(200)') )
, Scripture = Chapter.value('.', 'varchar(max)')
FROM #xml.nodes('/bookcoll/book/chapter/v') T ( chapter )
MY First solution is
SELECT
BQ.BookName
, BQ.BookNumber
, CQ.ChapterTitle
, CQ.ChapterNumber
, VQ.VerseText
, VQ.VerseNumber
, ROW_NUMBER() OVER (ORDER BY BQ.BookNumber, CQ.ChapterNumber,VQ.VerseNumber)
FROM
(SELECT Books.value('bktshort[1]', 'varchar(200)') as BookName,
p.number as BookNumber
FROM master..spt_values p
CROSS APPLY
#xml.nodes('/bookcoll/book[position()=sql:column("number")]') B(Books)
WHERE p.type='p'
) BQ
INNER JOIN
(SELECT C.Chapter.value('../bktshort[1]', 'varchar(200)') as BookName,
C.Chapter.value('chtitle[1]', 'varchar(200)') as ChapterTitle,
p.number as ChapterNumber
FROM master..spt_values p
CROSS APPLY
#xml.nodes('/bookcoll/book/chapter[position()=sql:column("number")]') C(Chapter)
WHERE p.type='p'
) CQ
on BQ.BookName = CQ.BookName
INNER JOIN
(SELECT V.Verses.value('../../bktshort[1]', 'varchar(200)') as BookName,
V.Verses.value('../chtitle[1]', 'varchar(200)') as ChapterTitle,
V.Verses.value('.', 'varchar(max)') as VerseText,
p.number as VerseNumber
FROM master..spt_values p
CROSS APPLY
#xml.nodes('/bookcoll/book/chapter/v[position()=sql:column("number")]') V(Verses)
WHERE p.type='p'
) VQ
on CQ.BookName = VQ.BookName
and CQ.ChapterTitle = VQ.ChapterTitle
but this takes two minutes to run so I am still taking suggestions