Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE FUNCTION FUNCTION1 (a DECIMAL(12,2), h DECIMAL (12,2) )
- RETURNS DECIMAL(12,2)
- NO EXTERNAL ACTION
- F1: BEGIN ATOMIC
- -- ######################################################################
- -- # Returns count of all tables created by DB2ADMIN and VARNAME
- -- ######################################################################
- RETURN a*h/2;
- END
- SELECT FUNCTION1(1.2356,1) FROM SYSibm.SYSDUMMY1;
- CREATE OR REPLACE FUNCTION FUNCTION2 (urodziny VARCHAR(128), koszt_poczatkowy DECIMAL (8,2))
- RETURNS DECIMAL(8,2)
- NO EXTERNAL ACTION
- F2: BEGIN ATOMIC
- -- koszt = poczatkowy (1 + (nominalna_stopa / liczba_kapitalizacji) ) ^ (liczba_kapitalizacji * czas_trwania)
- -- koszt = 7.00*( 1 + ( 0.05 / 365.25 ) ) ^ (365.25 * (2017-1995)
- DECLARE daysto INTEGER;
- DECLARE ctr INTEGER;
- DECLARE ret DECIMAL(16,5);
- DECLARE per DECIMAL(16,10);
- DECLARE odsetR DECIMAL(8,2);
- SET odsetR=5.0;
- SET per = (odsetR/365)/100;
- SET daysto = (days(CURRENT DATE) - days(DATE(urodziny)));
- SET ctr = 0;
- SET ret = 0;
- WHILE ctr < daysto DO
- SET ctr = ctr+1;
- SET ret = (ret + koszt_poczatkowy) + (ret + koszt_poczatkowy)*per;
- END WHILE;
- RETURN ret;
- END
- XQUERY
- db2-fn:xmlcolumn('CUSTOMER.INFO')/customerinfo[addr/city='Toronto']/name;
- XQUERY
- db2-fn:xmlcolumn('CUSTOMER.INFO')/customerinfo/addr[city='Toronto']/../name/text();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement