How to use recursive with dates in Teradata? - teradata

I have the following table for people running a marathon
person start end
mike 2-Jun-14 2-Jul-14
nike 3-Jul-14 9-Aug-14
mini 1-Aug-14 3-Sep-14
sara 25-Jun-14 27-Jun-14
steve 12-Jun-14 3-Jul-14
stan 2-Jun-14 2-Aug-14
pete 3-Jul-14 9-Aug-14
tara 5-Jul-14 5-Sep-14
I need to create a table that shows if a person was in the process of running at the beginning of every month
On Jul 1, 2014 there were 3 people running the marathon: mike,
steve, stan
On Aug 1,2014 there were 5 people: nike, mini, stan,
pete,tara
On Sep 1,2014 there were 2 people: mini, tara
etc . .
The desired table should look like this
person running on
mike 1-Jul-14
nike 1-Aug-14
mini 1-Aug-14
mini 1-Sep-14
steve 1-Jul-14
stan 1-Jul-14
stan 1-Aug-14
pete 1-Aug-14
tara 1-Aug-14
tara 1-Sep-14
Right now, to do this I am running a separate query for each month. This is very tedious I suspect that i should be usingrecursive, but I do not know how to implement it here.
PS: I have Teradata 14 with all functions, except I cannot write my own udfs and procedures. How can I get the final table using Teradata sql ?

There's no need for recursion or a procedure, this is done using some proprietary Teradata SQL extension:
SELECT person, BEGIN(pd)
FROM vt
EXPAND ON PERIOD(start, end) AS pd BY ANCHOR MONTH_BEGIN

Related

typeorm mariadb ER_PARSE_ERROR, no idea whats wrong

i am trying to save data using typeorm with mariadb driver. But I got this error:
error: Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' 'In 1972, a popular student in Yomiyama North Middle School\'s class 3-3 named ' at line 1
at Packet.asError (D:\kiramanga_fetch\node_modules\mysql2\lib\packets\packet.js:722:17)
at Query.execute (D:\kiramanga_fetch\node_modules\mysql2\lib\commands\command.js:28:26)
at PoolConnection.handlePacket (D:\kiramanga_fetch\node_modules\mysql2\lib\connection.js:456:32)
at PacketParser.onPacket (D:\kiramanga_fetch\node_modules\mysql2\lib\connection.js:85:12)
at PacketParser.executeStart (D:\kiramanga_fetch\node_modules\mysql2\lib\packet_parser.js:75:16)
at Socket.<anonymous> (D:\kiramanga_fetch\node_modules\mysql2\lib\connection.js:92:25)
at Socket.emit (events.js:375:28)
at addChunk (internal/streams/readable.js:290:12)
at readableAddChunk (internal/streams/readable.js:265:9)
at Socket.Readable.push (internal/streams/readable.js:204:10) {
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlState: '42000',
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use
near ' 'In 1972, a popular student in Yomiyama North Middle School\\'s class 3-3 named ' at line 1",
sql: 'INSERT INTO `Anime`(`id`, `anf_id`, `original`, `title`, `en_title`, `synonyms`, `synopsis`, `background`, `related`, `featured`, `url`, `show_type`, `status`, `source`, `episodes`, `songs`, `trailer`, `airing`, `airing_now`, `duration`, `rating`, `rate`, `update_time`, `seasonId`) VALUES (DEFAULT, \'11111\', \'アナザー\', \'Another\', \'Another\', , \'In 1972, a popular student in Yomiyama North Middle School\\\'s class 3-3 named Misaki passed away during the school year. Since then, the town of Yomiyama has been shrouded by a fearful atmosphere, from the dark secrets
hidden deep within. Twenty-six years later, 15-year-old Kouichi Sakakibara transfers into class 3-3 of Yomiyama North and soon after discovers that a strange, gloomy mood seems to hang over all the students. He also finds himself drawn to the mysterious, eyepatch-wearing student Mei Misaki;
however, the rest of the class and the teachers seem to treat her like she doesn\\\'t exist. Paying no heed to warnings from everyone including Mei herself, Kouichi begins to get closer not only to her, but also to the truth behind the gruesome phenomenon plaguing class 3-3 of Yomiyama North. Another follows Kouichi, Mei, and their classmates as they are pulled into the enigma surrounding a series of inevitable, tragic events—but unraveling the horror of Yomiyama may just cost them the ultimate price. [Written by MAL Rewrite]\', \'In 1972, a popular student in Yomiyama North Middle School\\\'s class 3-3 named Misaki passed away during the school year. Since then, the town of Yomiyama has been shrouded by a fearful atmosphere, from the dark secrets hidden deep within.Twenty-six years later, 15-year-old Kouichi Sakakibara transfers into class 3-3 of Yomiyama North and soon after discovers that a strange, gloomy mood seems to hang over all the students. He also finds himself drawn to the mysterious, eyepatch-wearing student Mei Misaki; however, the rest of the class and the teachers seem to treat her like she doesn\\\'t exist. Paying no heed to warnings from everyone including Mei herself, Kouichi begins to get closer not only to her, but also to the truth behind the gruesome phenomenon plaguing
class 3-3 of Yomiyama North.Another follows Kouichi, Mei, and their classmates as they are pulled into the enigma surrounding a series of inevitable, tragic events—but unraveling the horror of Yomiyama may just cost them the ultimate price.[Written by MAL Rewrite]Pre-screening on 26 December 2011. The regular TV airing started on 09 January 2012.\', \'{\\"prequel\\":[{\\"anf_id\\":11701,\\"title\\":\\"Another: The Other - Inga\\",\\"url\\":\\"/anime/11701/another-the-other-inga\\"}],\\"adaptation\\":[{\\"anf_id\\":29699,\\"title\\":\\"Another\\",\\"url\\":\\"/manga/29699/another\\"}],\\"other\\":[{\\"anf_id\\":20365,\\"title\\":\\"Another: Misaki Mei - Shizukani\\",\\"url\\":\\"/anime/20365/another-misaki-mei-shizukani\\"}]}\', \'https://ik.imagekit.io/feedani/another\', \'/anime/11111/another\', \'TV\', \'Finished Airing\', \'Light novel\', 12, \'{\\"opening\\":[\\"\\\\\\"Kyoumu Densen (凶夢伝染)\\\\\\" by ALI PROJECT\\"],\\"ending\\":[\\"\\\\\\"anamnesis\\\\\\" by Annabel\\"]}\', \'https://www.youtube.com/embed/UGoAl3L13bc?enablejsapi=1&wmode=opaque&autoplay=1\', \'{\\"from\\":\\"2012-01-10T00:00:00+00:00\\",\\"to\\":\\"2012-03-27T00:00:00+00:00\\",\\"details\\":{\\"from\\":{\\"day\\":10,\\"month\\":1,\\"year\\":2012},\\"to\\":{\\"day\\":27,\\"month\\":3,\\"year\\":2012}},\\"data\\":\\"Jan 10, 2012 to Mar 27, 2012\\"}\', false, \'24 min per ep\', \'R - 17+ (violence & profanity)\', 7.51, 1631599252606, 2)'
}
but I don't know what's wrong, so i ask here. Thanks. I'll provide other info if needed.
stupid of me, i forgot to convert the arrays into string, so the query messed up. if somebody have similar issue with this, i recommend to check your data before inserting, if any of the data is array make sure to convert it to string.

Why Oracle DataDump creates N-1 files if parallelism is set to N?

What am I doing wrong?
I set PARALLEL=4 but number of files created are 3.
time expdp data DIRECTORY=EXT_DIR TABLES=DATA.ST_EURKMORDER:P108 LOGFILE=log.txt CONTENT=DATA_ONLY COMPRESSION=DATA_ONLY DUMPFILE=DATA.ST_EURKMORDER_P108_compr_%U_out_of_4.dmp PARALLEL=4
Expected 4 files, but got 3:
ls -alh /data/DATA.ST_EURKMORDER_P108_compr_1*
-rw-r----- 1 oracle oinstall 170M Apr 11 13:38 /data/DATA.ST_EURKMORDER_P108_compr_01_out_of_4.dmp
-rw-r----- 1 oracle oinstall 159M Apr 11 13:38 /data/DATA.ST_EURKMORDER_P108_compr_02_out_of_4.dmp
-rw-r----- 1 oracle oinstall 151M Apr 11 13:38 /data/DATA.ST_EURKMORDER_P108_compr_03_out_of_4.dmp
According to the documentation, the PARALLEL setting (emphasis added):
Specifies the maximum number of processes of active execution operating on behalf of the export job.
It also shows an example similar to yours with PARALLEL set to four, which it says results in an export
... in which up to four files could be created ...
There are various other examples that refer to 'up to' as well. So, this is the expected behaviour. It could create four files, it could create fewer than that.

Extract relevant text from a .txt file in R

I am still on a basic beginner level with r. I am currently working on some natural language stuff and I use the ProQuest Newsstand database. Even though the database allows to download txt files, I don't need everything they provide. The files you can download there look like this:
###############################################################################
____________________________________________________________
Report Information from ProQuest 16 July 2016 09:58
____________________________________________________________
____________________________________________________________
Inhaltsverzeichnis
1. Savills cracks Granite deal to establish US presence ; COMMERCIAL PROPERTY
____________________________________________________________
Dokument 1 von 1
Savills cracks Granite deal to establish US presence ; COMMERCIAL PROPERTY
http:...
Kurzfassung: Savills said that as part of its plans to build...
Links: ...
Volltext: Property agency Savills yesterday snapped up US real estate banking firm Granite Partners...
Unternehmen/Organisation: Name: Granite Partners LP; NAICS: 525910
Titel: Savills cracks Granite deal to establish US presence; COMMERCIAL PROPERTY:   [FIRST Edition]
Autor: Steve Pain Commercial Property Editor
Titel der Publikation: Birmingham Post
Seiten: 30
Seitenanzahl: 0
Erscheinungsjahr: 2007
Publikationsdatum: Aug 2, 2007
Jahr: 2007
Bereich: Business
Herausgeber: Mirror Regional Newspapers
Verlagsort: Birmingham (UK)
Publikationsland: United Kingdom
Publikationsthema: General Interest Periodicals--Great Britain
Quellentyp: Newspapers
Publikationssprache: English
Dokumententyp: NEWSPAPER
ProQuest-Dokument-ID: 324215031
Dokument-URL: ...
Copyright: (Copyright 2007 Birmingham Post and Mail Ltd.)
Zuletzt aktualisiert: 2010-06-19
Datenbank: UK Newsstand
____________________________________________________________
Kontaktieren Sie uns unter: http... Copyright © 2016 ProQuest LLC. Alle Rechte vorbehalten. Allgemeine Geschäftsbedingungen: ...
###############################################################################
What I need is a way to extract only the full text to a csv file. The reason is, when I download hundreds of articles within one file it is quite difficult to copy and paste them manually and I think the file is quite structured. However, the length of text varies. Nevertheless, one could use the next header after the full text as a stop sign (I guess).
Is there any way to do this?
I really would appreciate some help.
Kind regards,
Steffen
Lets say you have all publication information in a single text file make a copy of your file for reset first. Using Notepad++ and RegEx you'd go through following steps:
Ctrl+F
Choose the Mark tab.
Search mode: Regular expression
Find what: ^Volltext:\s
Alt+M to check Bookmark line (if unchecked only)
Click on Mark All
From the main menu go to: Search > Bookmark > Remove Unmarked Lines
In a third step go through following steps:
Ctrl+H
Search mode: Regular expression
Find what: ^Volltext:\s (choose from dropdown)
Replace with: NOTHING (clear text field)
Click on Replace All
Done ...
Try this out:
con <- file("./R/sample text.txt")
content <- paste(readLines(con),collapse="\n")
content <- gsub(pattern = "\\n\\n", replacement = "\n", x = content)
close(con)
content.filtered <- sub(pattern = "(.*)(Volltext:.*?)(_{10,}.*)",
replacement = "\\2", x=content)
Results:
> cat(content.filtered)
Volltext: Property agency Savills yesterday snapped up US real estate banking firm Granite Partners...
Unternehmen/Organisation: Name: Granite Partners LP; NAICS: 525910
Titel: Savills cracks Granite deal to establish US presence; COMMERCIAL PROPERTY: [FIRST Edition]
Autor: Steve Pain Commercial Property Editor
Titel der Publikation: Birmingham Post
Seiten: 30
Seitenanzahl: 0
Erscheinungsjahr: 2007
Publikationsdatum: Aug 2, 2007
Jahr: 2007
Bereich: Business
Herausgeber: Mirror Regional Newspapers
Verlagsort: Birmingham (UK)
Publikationsland: United Kingdom
Publikationsthema: General Interest Periodicals--Great Britain
Quellentyp: Newspapers
Publikationssprache: English
Dokumententyp: NEWSPAPER
ProQuest-Dokument-ID: 324215031
Dokument-URL: ...
Copyright: (Copyright 2007 Birmingham Post and Mail Ltd.)
Zuletzt aktualisiert: 2010-06-19
Datenbank: UK Newsstand

ps utility does not show the year a process was started

I am doing some work on a fairly old system and need to know when a couple of processes started. When I use "ps -ef" one says October 18 and the other March 23. We haven't got to October 18 this year so I'm not sure if this is October 18 last year or the previous year. The uptime command is showing 2419 days (6.6 years!) so it's possible the Oct 18 is from earlier than 2012. This is a HP-UX system. I have done a bit of googling and none of the answers I came across worked, eg ps -o, looking in the /proc dir.
cfgmgr 9947 9943 3 Mar 23 ? 6831:32 /home/cfgmgr/bin/snmpagt
root 24338 1 0 Oct 18 ? 2628:13 /usr/sbin/snmpdm -tcplocal
PS can only show the date because as per PS documentation at MAN page
'Only the year will be displayed if the process was not started the same year ps was invoked, or "mmmdd" if it was not started the same day, or "HH:MM" otherwise.'

showing column data as header in telerik radgrid

I have a table in dataset like:
-------------------
id class name sub
------------------------
1 mca aditya network
2 mca abhishek daa
3 mca akhilesh algorithm
4 btech ram cs
5 btech shyam ds
6 btech anand client/server
7 mba furqan os
8 mba arvind marketing
9 mba aayush hr
I want a result set in telerik rad grid like the following:
----------------
class name sub
------------------------
mca aditya network
abhishek daa
akhilesh algorithm
btech ram cs
shyam ds
anand client/server
mba furqan os
arvind marketing
aayush hr
John DeVight has written an extension to the Telerik MVC grid. He has a function called hideGroupColumns that hides columns that are grouped. The syntax looks like this:
$('#grid').data('tGrid').hideGroupColumns()
The Telerik community forums has some discussion of this extension.

Resources