Tuesday, December 29, 2020

NFL Fantasy Championship 2020

The last NFL fantasy week is coming and as the league No.1, hopefully I will win the final week, and I believe so:)))

Here is my championship team to be:)






Wednesday, September 4, 2019

ORCL - MATCH_RECOGNIZE

From time to time, collages ask me about doing max consecutive count, let's say we want to know a donor most continuous donation year total, we used to do the hard way* until we tried using the match_recognize ().

Courtesy to https://oracle-base.com/articles/12c/pattern-matching-in-oracle-database-12cr1, my favorite Oracle knowledge website.

"Introduced in Oracle 8i, Analytic Functions, also known as windowing functions, allow developers to perform tasks in SQL that were previously confined to procedural languages. Oracle 12c has added the MATCH_RECOGNIZE clause into the analytic function syntax to make pattern matching from SQL simpler. This article gives a flavour of what can be done using the MATCH_RECOGNIZE clause, but you will need to refer to the documentation to understand the true level of complexity possible."

So here is the new baby:))

select max(runs)
from
(select *  
from   (select distinct g.gift_donor_id, g.gift_year_of_giving from gift g where g.gift_donor_id = '00000xxxxx')
match_recognize ( 
  order by gift_year_of_giving 
  measures  
    first(gift_year_of_giving) as first_run, 
    last(gift_year_of_giving) as last_run, 
    count(*) as runs, 
    match_number() as grp 
  pattern ( strt consecutive* ) 
  define  
    consecutive as gift_year_of_giving = ( prev (gift_year_of_giving ) + 1 ) 
))

From Oracle:
What does this query do? The following explains each line in the MATCH_RECOGNIZE clause:

  • PARTITION BY divides the data from the Ticker table into logical groups where each group contains one stock symbol.
  • ORDER BY orders the data within each logical group by tstamp.
  • MEASURES defines three measures: the timestamp at the beginning of a V-shape (start_tstamp), the timestamp at the bottom of a V-shape (bottom_tstamp), and the timestamp at the end of the a V-shape (end_tstamp). The bottom_tstamp and end_tstamp measures use the LAST() function to ensure that the values retrieved are the final value of the timestamp within each pattern match.
  • ONE ROW PER MATCH means that for every pattern match found, there will be one row of output.
  • AFTER MATCH SKIP TO LAST UP means that whenever you find a match you restart your search at the row that is the last row of the UP pattern variable. A pattern variable is a variable used in a MATCH_RECOGNIZE statement, and is defined in the DEFINE clause.
  • PATTERN (STRT DOWN+ UP+) says that the pattern you are searching for has three pattern variables: STRT, DOWN, and UP. The plus sign (+) after DOWN and UP means that at least one row must be mapped to each of them. The pattern defines a regular expression, which is a highly expressive way to search for patterns.
  • DEFINE gives us the conditions that must be met for a row to map to your row pattern variables STRT, DOWN, and UP. Because there is no condition for STRT, any row can be mapped to STRT. Why have a pattern variable with no condition? You use it as a starting point for testing for matches. Both DOWN and UP take advantage of the PREV() function, which lets them compare the price in the current row to the price in the prior row. DOWN is matched when a row has a lower price than the row that preceded it, so it defines the downward (left) leg of our V-shape. A row can be mapped to UP if the row has a higher price than the row that preceded it.
*Hard way:):

with years as
(
select distinct g.id, g.giving_year
from gift, allocation a
where g.gift_associated_allocation = a.allocation_code and a.athletics_ind = 'Y'--upper(a.short_name) like '%ATHLETICS%'
order by g.id, g.gift_year
)
select id,   ayear from_yr, byear to_year, yearcon
from
(
  select
    a.id,
    a.year ayear,
    b.year byear,
    (b.year - a.year)+1 yearcon,
    dense_rank() over (partition by a.id order by (b.year - a.year) desc) rank
  from
    years a
    join years b on a.id = b.id and b.year > a.year
  where
    b.year - a.year =
      (select count(*)-1
         from years a1
        where a.id = a1.id
             and a1.year between a.year and b.year)
)
where rank = 1 and yearcon>=10
order by 4 desc

Come on, Google!

Personally I have great feeling about Google technology until today!:((

As an outdoor person, I love to blog my travel, hiking and often post a lot of images.

Due to some unpleasant reason I need to remove some images from my blog, I thought all my uploaded images should be easily managed by me, so I removed some images form my blog and google photo, but the images still exist with the link like:
https://1.bp.blogspot.com/-7T5MQDsXSVE/XVbUdA38OvI/AAAAAAAAR7I/Qr4UsMF6FBEXlKtmQIgtMZbFDMGLuaj1gCLcBGAs/s1600/IMG_20190731_123441.jpg

So I spent about two hours to figure out how to remove the images, then I found out that you have to request removal of images such as in:
https://www.google.com/webmasters/tools/removals?pli=1

Well, I have to say that sucks! Just want to mark it for any future use or anyone have same experience with me.


After an image is removed from a website, it may still appear in search results for a little while.
To remove these images from search results, follow these steps:
  1. Search on images.google.com for the image you want to find.
  2. Select the image link by right clicking on the image thumbnail and choosing  Copy link address.
    Note: Different browsers may have different names for copying link location.
  3. Go to the Remove outdated content page.
  4. In the box next to "Request removal," paste the URL.
  5. Click Request removal.
    • If you see the message "We think the image or web page you're trying to remove hasn't been removed by the site owner," follow the steps on the screen to give us more information.
    • If you see the message "This content is no longer live on the website," click Request removal.

      Why Google doesn’t remove most images

      Most images that show up in Google’s search results are from websites that aren’t owned by Google. Since we aren’t the owners of these sites, we can’t remove the images from the web.
      Even if we delete the image from Google’s search results, the image still exists and can be found on other search engines, or if people visit the URL directly.
      This is why your best option is to contact the site's webmaster who can remove the page entirely.

Tuesday, May 5, 2015

ORCL - CONTINUEIF

About 17 years ago, my 1st IT job is maintaining a sql load program for hospital medical records at Alberta Health. Today we have an imodule routine to fetch the records and load into database.

My colleague had some trouble with the data with embedded line breaks before ending the recordes, and ask me if I could help. I could not help to jump on my "first love" :)) special feeling about sqlloader:))

sqlloader offer two possibilities :  - courtesy to http://gerardnico.com/wiki/!
  • if you have a special character at the end of each line: the stream record format
Using the STR attribute, we can specify a new end-of-line character (or sequence of characters). This allows us to create an input data file that has some special character at the end of each line. The newline is no longer special.
  • if you don't have a special character at the end of each line: the CONTINUEIF statement.
Here is the sample data for us:

"100045678","address is
super street
18999 Edmonton Alberta
T6R4Y3" ............................................
"2","the degree is MBA
UT
1998" ............................................
 
The each field inside data looks enclosed with double quotes "xxx", so we could simple add the CONTINUEIF to control the end of records.
 
From Oracle:

Using CONTINUEIF to Assemble Logical Records

Use CONTINUEIF if the number of physical records to be combined varies. The CONTINUEIF clause is followed by a condition that is evaluated for each physical record, as it is read. For example, two records might be combined if a pound sign (#) were in byte position 80 of the first record. If any other character were there, the second record would not be added to the first.
The full syntax for CONTINUEIF adds even more flexibility:
Table 8-2 describes the parameters for the CONTINUEIF clause.

Therefore we ask the loader to continue the record if see a break line not followed by a double quote, which means it's not the end of records!

LOAD DATA
INFILE 'giftdata.dat'
CONTINUEIF LAST != '"'
INTO TABLE conversion
APPEND
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(
"ID",
"DESCRIPTION" CHAR(500)
)

Cheers!

Wednesday, October 22, 2014

Drupal - Rotating Banners

Playing website is my hobby since year 2000 when we set up an IT company. It's interesting to try to stay current while my daily job is mainly database stuff:). So I keep revamping my website from WordPress, Joomla, now Drupal, just to learning some new stuff.

Imaging 2000 until now, how the technology changed. It only takes 10 minutes to have a good, professional looking website and so many free themes you could choose. I had some popular Drupal themes, but I had problem to make the rotating banners working....

Documentation! Documentation! I had to be patient to read carefully on the documentation. Sometimes I was just lazy to read :(((. I missed whole bunch modules and now I would like to share those steps from Drupal site(https://www.drupal.org/node/1786134).

"Rotating Banners requires two other modules and a pair of scripts to function.
The dependent modules are Media, http://drupal.org/project/media, and Styles, http://drupal.org/project/styles.
The two server scripts are jquery.cycle.all.min.js and jquery.easing.1.3.js.
The first script can be downloaded here: http://jquery.malsup.com/cycle/download.html.
Once you download it, rename it to jquery.cycle.js.
The second can be downloaded here: http://gsgd.co.uk/sandbox/jquery/easing/
Once you download it, rename it to jquery.easing.js.
Install rotating Banners through the Administration/Modules page.
Then copy both scripts to the following directory: …/sites/all/modules/rotating_banner/includes/.
This will create an interface in the Admin/Structure/Blocks menu."

Basically we need media, style, and 2 jQuery scripts, and media needs Ctools module! I totally missed Requirement section! I am thinking I am close to retirement:(

The weird thing I found after installing Rotating Banners/Ctools, some modules got unchecked such as Toolbar, Locale etc., so I had to enable them again.

Friday, May 2, 2014

Tuesday, February 4, 2014

ORCL - REGEXP_REPLACE

I really like the listagg function, but it can not be used with distinct.

Sometimes I want remove the duplicate values return form listagg function and I don't like to use subquery, etc.

Finally I found a great solution using regular expression! really cool and I thought maybe useful to someone:))


select '1223-1223-1223-1345' t1, rtrim( REGEXP_REPLACE('1223-1223-1223-1345', '([^-]*)(-\1)+($|-)', '\1\3'), '-') t2

from dual;

1223-1223-1223-1345 will be 1223-1345, but be sure the list is order by the item!

Here is a example for me:

select regexp_replace( (listagg(a.short_name, ',' ) within group (order by a.short_name)), '([^,]*)(,\1)+($|,)','\1\3')

from gift g, allocation a where g.gift_donor_id = l.gift_donor_id and g.gift_associated_allocation = a.allocation_code and a.alloc_school = 'LS') distinct_allocs      

Explanation is following: Courtesy to Srinivasan - bean farmer 

http://srinisqlwork.blogspot.com/2016/12/sql-remove-duplicates-in-listagg-result.html

Understanding the solution with example:
select
REGEXP_REPLACE( 'English,English,English,Hindi,Hindi,Kannada,Kannada,Kannada,Tamil,Tamil,Telugu,Telugu','([^,]*)(,\1)+($|,)'   ,'\1\3')
from dual
1. Understanding regExMatch expression: '([^,]*)(,\1)+($|,)'
There are three groups in above expression
group 1: ([^,]*) : match all or no characters till comma   
match Result: English
group 2: (,\1)+ : \1 - stands for first group which is Kannada, so it becomes (,English)+, meaning match one or more occurrences of  ',English'.
match Result: ,English,English
group 3: ($|,) : $ stands for 'end of string', | stands or. So it says match either end of string or a comma
match Result: ,    (this is comma which is following group2 match: ,English,English)
2. Understanding regExReplace expression '\1\3':
\1\3 represent the group number which are used in regExMatch expression.
replace Result: English,

REGEXP_REPLACE

Syntax
Description of regexp_replace.gif follows
Description of the illustration regexp_replace.gif

Purpose
REGEXP_REPLACE extends the functionality of the REPLACE function by letting you search a string for a regular expression pattern. By default, the function returns source_char with every occurrence of the regular expression pattern replaced with replace_string. The string returned is in the same character set as source_char. The function returns VARCHAR2 if the first argument is not a LOB and returns CLOB if the first argument is a LOB.
This function complies with the POSIX regular expression standard and the Unicode Regular Expression Guidelines. For more information, please refer to Appendix C, "Oracle Regular Expression Support".
  • source_char is a character expression that serves as the search value. It is commonly a character column and can be of any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB or NCLOB.
  • pattern is the regular expression. It is usually a text literal and can be of any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2. It can contain up to 512 bytes. If the datatype of pattern is different from the datatype of source_char, Oracle Database converts pattern to the datatype of source_char. For a listing of the operators you can specify in pattern, please refer to Appendix C, "Oracle Regular Expression Support".
  • replace_string can be of any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. If replace_string is a CLOB or NCLOB, then Oracle truncates replace_string to 32K. The replace_string can contain up to 500 backreferences to subexpressions in the form \n, where n is a number from 1 to 9. If n is the backslash character in replace_string, then you must precede it with the escape character (\\). For more information on backreference expressions, please refer to the notes to "Oracle Regular Expression Support", Table C-1.
  • position is a positive integer indicating the character of source_char where Oracle should begin the search. The default is 1, meaning that Oracle begins the search at the first character of source_char.
  • occurrence is a nonnegative integer indicating the occurrence of the replace operation:
    • If you specify 0, then Oracle replaces all occurrences of the match.
    • If you specify a positive integer n, then Oracle replaces the nth occurrence.
  • match_parameter is a text literal that lets you change the default matching behavior of the function. This argument affects only the matching process and has no effect on replace_string. You can specify one or more of the following values for match_parameter:
    • 'i' specifies case-insensitive matching.
    • 'c' specifies case-sensitive matching.
    • 'n' allows the period (.), which is the match-any-character character, to match the newline character. If you omit this parameter, the period does not match the newline character.
    • 'm' treats the source string as multiple lines. Oracle interprets ^ and $ as the start and end, respectively, of any line anywhere in the source string, rather than only at the start or end of the entire source string. If you omit this parameter, Oracle treats the source string as a single line.
    • 'x' ignores whitespace characters. By default, whitespace characters match themselves.
    If you specify multiple contradictory values, Oracle uses the last value. For example, if you specify 'ic', then Oracle uses case-sensitive matching. If you specify a character other than those shown above, then Oracle returns an error.
    If you omit match_parameter, then:
    • The default case sensitivity is determined by the value of the NLS_SORT parameter.
    • A period (.) does not match the newline character.
    • The source string is treated as a single line.

Tuesday, November 12, 2013

How are you, Air Canada?!

About 20 years ago, my 1st flight with Air Canada, I still remember that's Dec 8, a very cold winter day, ground covered with all snow. I arrived in Edmonton, but I lost one of my bag with bottles of expensive Chinese Mao Tai if you know some liquor from China:). That time my spoken English and listening are so limited, but I had to communicate with Air Canada to get my bag back. After a few weeks my bag was dragged to my apartment and finally I got it back even though the Mao Tai was opened, I guess it was checked by some officer:(

1996 I went to my home town through Shanghai with Air Canada, my home town is about 6 hours bus from Shanghai at that time without highway yet. Again I lost one new luggage, which I just bought for this trip. I left my home town contact information and went home; a few days later my new luggage came dirty on crowded bus, mot much complained, I felt fortune to get it back in just a few days.


2005 I visited China with whole family by Air Canada and again we missed one luggage on the way back to Canada! After a few month registering case on Air Canada website and talking to agents, I almost had no hope to get my luggage back (only compensation by Air Canada is $100!). Well, it was finally located and sent it back to me. When I opened my out-of-shape luggage, most gift/stuff was squeezed. Well, what can I say, it came back after a few month travelling around world, I wish I could did this free travelling!

Until now such losing luggage experience gave me a big stress every time I travel with checked luggage, I was so worried and always triple check to make sure I keep those luggage receipts in case any luggage gets lost. Recently I travel to China a lot to visit my parents and I believe Air Canada improved the process about the checked luggage, but unfortunately I encounter some new headache about cancelled and delayed air flights.

This Summer (2013) we booked tickets with Air Canada and we were stuck at Vancouver! That evening all passenger were on board and airplane is driving out and ready to take off, after 30 minutes waiting Captain told us there were some air-conditioning issue to fix before taking off. So we were patiently waiting and then were told that airplane had to go back for checking, shortly after reaching the dock we were notified to get off and wait inside. Soon it announced that the flight cancelled.

What a chaos and we had some miscommunication and finally whole family ran to some hotel outside airport in the Vancouver city at 2am in the morning and had to get back airport for re-check-in for another airplane departing at next day 9am. A lot of passenger were mad, especially those with connection flights, one of lady was so upset and ask all of us refuse to aboard, but nobody listened to her, since everyone was so tired and wanted to leave as soon as we could and got over with this. I was pretty sad to see that lady was screaming and kicking the coupon paper which Air Canada offers for this chaos, it's 15% off next purchase, come on, I don't think that lady will take Air Canada again:(




We were glad to take off next day and arrived safely in Beijing even it's was 12 hours delay, I have sympathy for those who missed next connecting flight, train or bus. When coming back the flight was delay again! We were late at Vancouver, and could not catch the booked flight to Edmonton. This time we were experienced with no panic and we were staying in the Fairmount hotel inside Vancouver airport, not bad, my daughters were excited to stay this nice hotel for a few hours.

That's my stories with Air Canada, I just want to say Air Canada, how are you doing? I wish you getting better and I heard news doing well. Do I ride with Air Canada again?

Yes, I think so, there are many reasons, just to speak a couple :))
1. I am a Canadian, hohoho
2. I just know a high school classmate, working at Air Canada Montreal office, Mr Yu, hahaha
......

Do I choose Air Canada if there is other option? I don't know honestly....

Monday, October 7, 2013

UTF-8 without BOM

I promise this post will be good:)

A while ago set up a group forum using phpbb, overall phpbb3 is not bad even though it lacks of some popular features and you need some module for some popular features.

As more and more posts on our forum, I thought it might be a good idea to mark those posts with over a certain number of views. I checked and phpbb3 comes with popular topic based on posts, I want to have popular posts based on views.

Thanks and hates to http://startrekguide.com/mods, I found that some simple update of a few php files could get what I wanted:)) since I am so lazy and web stuff is just one of my hobbies. Why I hate? After I followed the instruction to update those files, I found the crazy warning about "Cannot modify header information - headers already sent by (output started t /includes/acp/acp_board.php:1)"!

What the heck? I changed file back (didn't save a copy since I was thinking those changes are so simple:(). Still same error pops up, double checked the space, commas, etc, still same error! It gets me frustrated, so I decided to change configure php file (even it says don't touch this file:( ) to uncomment the debug mode line to see what's really going on. Damn, even worse, whole phpbb forum is not running!

Thanks to the Internet search, sounds like I was having some encoding type issue, I edited those files in notepad to make sure same as UTF-8, but still same thing! Searched again, I was educated that I need to save as UTF-8 without BOM, the notepad doesn't have this option so called BOM:(

After downloaded notepad++ and edit the files and applied the changes according to http://startrekguide.com/mods, now I havd to say thanks. After that everything was working properly:)

I thought I should write this out and again LONG LIVE INTERNET SEARCH! (mostly google or baidu?:))

Byte order mark

From Wikipedia, the free encyclopedia
      
The byte order mark (BOM) is a Unicode character used to signal the endianness (byte order) of a text file or stream. It is encoded at U+FEFF byte order mark (BOM). BOM use is optional, and, if used, should appear at the start of the text stream. Beyond its specific use as a byte-order indicator, the BOM character may also indicate which of the several Unicode representations the text is encoded in.[1]

Thursday, August 29, 2013

ORCL - FORMAT_ERROR_BACKTRACE

Having a few packages to send email around, often I find exception error is hard to trace since I was just using SQLerrm function in exception, which only shows the error without telling the source.
1st I thought I could look for ways to find where exactly the error occurs, such as showing function/procedure name, then after a little online search, I found dbms_utility package has a nice function: FORMAT_ERROR_BACKTRACE, which displays the error line number, better than function/procedure name!
 
This procedure displays the call stack at the point where an exception was raised, even if the procedure is called from an exception handler in an outer scope. The output is similar to the output of the SQLERRM function, but not subject to the same size limitation.
Syntax
DBMS_UTILITY.FORMAT_ERROR_BACKTRACE 
  RETURN VARCHAR2;
Return value
 
NICE! Also if you want to look at full error stack, check FORMAT_ERROR_STACK function.
 
To use, just simply add such line (red) as the below:
 
EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line (dbms_utility.FORMAT_ERROR_BACKTRACE);
      V_MSG_SUB_ERROR := V_MSG_SUB_ERROR;
      V_MSG_ERROR     := V_MSG_ERROR || SQLERRM || '
' || dbms_utility.FORMAT_ERROR_BACKTRACE || V_MSG_SIG;
      UTL_MAIL.SEND(SENDER     => EMAIL_FROM,
                    RECIPIENTS => EMAIL_ERROR_TO,
                    CC         => EMAIL_BCC,
                    SUBJECT    => V_MSG_SUB_ERROR,
                    MESSAGE    => V_MSG_ERROR,
                    MIME_TYPE  => 'text/html');
  END;

"In a real-world application, the error backtrace could be very long. Generally, debuggers and support people don't really want to have to deal with the entire stack; they are mostly going to be interested in that top-most entry. The developer of the application might even like to display that critical information to the users so that they can immediately and accurately report the problem to the support staff. In this case, it is necessary to parse the backtrace string and retrieve just the top-most entry." - by Steven Feuerstein 
 

Friday, April 19, 2013

Home 2 routers with 2 ssids

We had the Cisco Linksys router at home for quite time, maybe 2,3 years. Since we moved into the current house, the upstairs wireless singal is kind of weak, especaily for Dell/HP laptops. So I decided buy a new router.

After some homework, I bought WestDigital Mynet N750, was thinking about N900 with DLNA support and 7 ports, but the comments on N750 looks better than N900. Anyway, I may check out N900 later some time, so far N750 singal is pretty good.

With 2 routers I have now I decided to setup 2 routers with 2 ssids, one is for N, one is for mixed B/G since I am still using 1st Gen iPod (ancient, isn't it?) and a HP mini laptop (very slow).  Even though my network skill is very rusty, but I thought it should be easy to set up.

Pretty easy to set up and the old iPod is connected to the 2nd router, obtaining right IP address, just could not get into Internet complainting about DNS problem, then set the DNS to the 1st router default gateway. Then it is all working:). This reminds me of old days when I was taking Network Specialist courses.

Some key points I could think of:

Any router had external and internal IP address, internal IP is easy and most time is just DHCP, external IP is what ever the IP talking outside the own network, for 2nd router the external IP is the IP within 1st router range, and for 1st router is the IP with my Internet Service Provider network range.

DNS is just like chain pass from internal to external, from router 2 go to router 1, then router to ISP DNS server to find real route to the web pages you want to see.

And also dont forget the 2 routers are in different subnets (1.1 and 0.1, you can do whatever number you want, just keep 192.168 or if you prefer the other private network start with 10 and 172).

Here is the diagram of my home network of 2 routers with 2 ssids:)

Next I will talk a bit about the hot DLNA topic.



Tuesday, March 19, 2013

Joomla or Wordpress

Doing some web site revamp recently, and amazed by the easiness and friendless of making website and there are so many nice templates you could choose, too many choice.

Looks Word press is very popular and I did get one for one of my clients, and will make it ready for themselves to update the content. For Joomla, was working with it before, and seems more complicated and powerful than Word press.

For my next project, I would like to choose Joomla if I could get the template I like. Now start to clean our hosting site stuff, so many blog/forum when I was testing. I would like to have one good forum package well support multiple languages such as English and Chinese.

Over all, here is a nice way to decide if you have difficult to choose which one:
(picture from http://www.sitepoint.com/ and thanks!)

Just now working on 2 templates, one is WordPress, one is Joomla, WordPress is OK to apply the dump.sql, but Joomla is a pain when dealing with different version. If I have time, I will definitely create my own template instead of buying. The version compatibility of Joomla is sure a pain.

Thursday, March 14, 2013

Confucius and Confusion

Sounds really funny, since I was very young I am a confused boy, very puzzled and bewildered, but never lost for what I want.

I am confused by the life, the meaning of life, and think the world is full of confusion. That's why I picked confusion as my nick. Then I tried to find the adjective for confusion and I don't like confusional(?), so I decided to use confusious(even though no such word), then people are thinking I was wrong and should be confucius. Well, should I change this to the famous ancient great Master Kong? Let me know your answer:)

Confucius Says (子曰)is so profound, and let's review the Top 10 quotes from Master Kong (so many and I just pick what I like:):

Just a thought: I have to say sorry to Master Kong, since in the end he was confused and failed. The Only savior is Our Lord! Don't you agree?!

1. “Never impose on others what you would not choose for yourself.”

己所不欲,勿施于人。

2. “Real knowledge is to know the extent of one’s ignorance.”

知之为知之,不知为不知,是知也。

3. “Keep what you say and carry out what you do.”
言必信,行必果。

4. “A gentleman sets strict demands on himself while a petty man set strict demands on others.”

君子求诸己,小人求诸人。

5. “The Superior Man is aware of Righteousness, the inferior man is aware of advantage.”

君子喻於义,小人喻於利。

6. “The gentleman wishes to be slow in speech but quick in action.”
君子欲讷于言而敏于行。

7. “When I walk along with two others, they may serve me as my teachers.”

三人行,必有我师焉。

8. “He who learns but does not think, is lost. He who thinks but does not learn is in great danger.”

学而不思则罔,思而不学则殆。

9. “He that would perfect his work must first sharpen his tools.”

工欲善其事,必先利其器。

10. “If you look into your own heart, and you find nothing wrong there, what is there to worry about? What is there to fear?”

君子坦荡荡,小人长戚戚。

太多啦,加一个:有朋自远方来,不亦乐乎?
Is it not delightful to have friends coming from distant quarters?

Friday, March 1, 2013

ORCL - LISTAGG

Very handy Listagg Function
 
During my daily routine, I constantly need to display multiple values for single row, I have to write a few lines of code until the LISTAGG function!
 
Description of listagg.gif follows
 
 
Examples from oracle
 
The following single-set aggregate example lists all of the employees in Department 30 in the hr.employees table, ordered by hire date and last name:
 
SELECT LISTAGG(last_name, '; ') WITHIN GROUP (ORDER BY hire_date, last_name) "Emp_list",
    MIN(hire_date) "Earliest"
    FROM employees
    WHERE department_id = 30;

Emp_list                                                     Earliest
------------------------------------------------------------ ---------
Raphaely; Khoo; Tobias; Baida; Himuro; Colmenares            07-DEC-02