You are currently browsing the archives for the SQL category.
- CSS (2)
- Javascript (3)
- LANSA (21)
- SQL (8)
- Twitter API (1)
- Uncategorized (25)
- 8. March 2010: American Express is Suing Me
- 28. January 2010: So frackin hard
- 1. September 2009: Twitter API STREAM Filter
- 15. June 2009: DOS Commands that work on Windows XP
- 14. April 2009: TWEATER CHEATER IS BORN
- 14. April 2009: Windows Keyboard Short Cuts - ALT F4 is my Favorite
- 11. April 2009: SELECT_SQL Examples
- 30. January 2009: My Recovery ID Idea
- 29. January 2009: Test Program to See what LANSA Services are Licensed
- 11. January 2009: glossary
Archive for the SQL Category
So frackin hard
28. January 2010 by admin.
CREATE TABLE EMPLOYEE3 AS
(SELECT PROJNO, PROJNAME, DEPTNO
FROM EMPLOYEE
WHERE DEPTNO = ‘D11′) WITH NO DATA
MUST USE "WITH NO DATA" at the end of statement - bullshit fibm
Posted in SQL | No Comments »
SELECT_SQL Examples
11. April 2009 by admin.
SELECT_SQL FIELDS((#W_COUNT ‘count(*)’)) FROM_FILES((REQUEST )) WH
ERE(’CLIENT_ID = :RITAID AND STATUS_CODE = 4 AND BA
TCH_SEQ_NUM = 0′)
ENDSELECT
SELECT_SQL FIELDS((#CRGUID ) (#CRTED ) (#CROBATCH ) (#CRBATCH ) (#
CRCCNO ) (#CREXPDT ) (#CRAMNT ) (#CRSWIPE ) (#CRQOVR )
(#CRRITAS ) (#CRRITAID ) (#CRTCN ) (#CRMUSR ) (#CRCCET
) (#CRORIG ) (#CRFAIR )) FROM_FILES((CRTRAN )) WHERE(’S
UBSTR(CROBATCH,1,2) = :XBFRGN AND CRSWIPE <> :WSWIPE AN
D (CRRITAS = 5 OR (CRRITAS = 200 AND CRAMNT < 0))’) ORD
ER_BY(’CROBATCH,CRBATCH’)
********** OK to Mark for Completion
SELECT_SQL FIELDS((#W_COUNT ‘count(*)’) (#W_SUM ‘SUM(INT(TRANS_AMO
UNT))’)) FROM_FILES((REQUEST )) WHERE(’CLIENT_ID = :RIT
AID AND STATUS_CODE = 4 AND BATCH_SEQ_NUM = 0 AND C
OMMAND =:COMMND’) IO_STATUS(#W_IOSTS) IO_ERROR(*NEXT)
ENDSELECT
********** put decimal place in amount
SUBROUTINE NAME(GETRITASTS)
**********
SELECT_SQL FIELDS((#INTRN0001 ‘INTRN_SEQ_NUM’) (#STATU0001 STATU00
001)) FROM_FILES((REQUEST )) WHERE(’ORIG_SEQ_NUM = :WRT
AID’) ORDER_BY(STATU00001) IO_ERROR(*NEXT)
LEAVE
ENDSELECT
**********
IF_NULL FIELD(#INTRN0001)
SELECT_SQL FIELDS((#INTRN0001 ‘INTRN_SEQ_NUM’) (#STATU0001 STATU00
001)) FROM_FILES((REQUEST )) WHERE(’INTRN_SEQ_NUM= :WRT
AID’) ORDER_BY(STATU00001) IO_ERROR(*NEXT)
LEAVE
ENDSELECT
SELECT_SQL FIELDS((#W_COUNT ‘count(*)’)) FROM_FILES((REQUEST )) WH
ERE(’CLIENT_ID = :WRITAI AND STATUS_CODE = :WRITAS AND
BATCH_SEQ_NUM = 0′)
ENDSELECT
Posted in SQL, LANSA | No Comments »
iseries SQL Help Functions and Commands
21. November 2008 by admin.
Iseries / AS400 SQL Built-In Functions
Basic Functions
Function Description
===============================
MAX Maximum value from a set of pre-defined values.
MIN Minimum value from a set of pre-defined values.
AVG Average value of a set of pre-defined values.
SUM Sum of a set of pre-defined values.
COUNT Number of elements in a set of pre-defined values.
Numeric Functions
Function Description
=======================================
ABS(N) Absolute value of N.
COS(A) / ACOS(A)
SIN(A) / ASIN(A)
TAN(A) / ATAN(A) Basic trigonometric functions.
CEILING(N)
FLOOR(N) Rounding of N to the unit
above/below.
DEGREES(R) Converts a value in radians to degrees.
RADIANS(D) Converts a value in degrees to radians.
LN(N)
LOG10(N) Natural logarithm / base 10 logarithm of N.
String Functions
Function Description
====================================
CHAR(N) The string representation of the number N.
CHAR_LENGTH(S) Length of a string.
CONCAT(S1, S2) Concatenates S1 with S2.
SUBSTR(S, I, L) Returns a substring of S, starting at index I of lenght L.
LOWER(S) Lowercase representation of S.
UPPER(S) Uppercase representation of S.
TRIM(S) Removes spaces from the beggining and and of S.
RTRIM(S) Removes spaces at the begging (right) of S.
LTRIM(S) Removes spaces at the begging (left) of S.
Date and Time Functions
Function Description
============================
CURDATE() System’s current date.
CURTIME() System’s current time.
DATE(D) Converts a string representation of a date into into a date value.
DATE(T) Converts a string representation of a time into into a time value.
DAY(D) Day(1-31) from the date D.
WEEK(D) Week (1-54) from the date D.
MONTH(D) Month (1-12) from the date D.
YEAR(D) Year from the date D.
DAYOFWEEK(D) Day (1-7) from the date D where 1 is Sunday.
DAYOFWEEK_ISO(D)Day (1-7) from the date D where 1 is Monday.
DAYOFYEAR(D) Number of the day, in a year (1-366).
HOUR(T) Hour (0-24) from the time T.
MINUTE(T) Minute from the time T.
SECOND(T) Second from the time T.
MICROSECOND(T) Microsecond from the time
Posted in SQL | No Comments »
whhoooo who - SQL UPDATE A PORTION OF FIELD FROM FIELD IN OTHER FILE
1. August 2008 by admin.
UPDATE prddtalib/crtran Set CROBATCH = (SELECT
substr(client_ID,4,2) FROM ritadb30/request where crtran.crritaid =
request.troutd) concat substr(crobatch,3,10)
WHERE crtran.crritaid IN (Select troutd FROM
ritadb30/request)
50 rows updated in CRTRAN in PRDDTALIB.
11:55 pm still got it
Posted in SQL | No Comments »
SQL STUFF I FORGET
1. August 2008 by admin.
String Functions
| Function | Description | CHAR(N) | Returns the the string representation of the number N. |
|---|---|
| CHAR_LENGTH(S) | Returns the length of a string. |
| CONCAT(S1, S2) | Concatenates S1 with S2. |
| SUBSTR(S, I, L) | Returns a substring of S, starting at index I of lenght L. |
| LOWER(S) | Returns the lowercase representation of S. |
| UPPER(S) | Returns the uppercase representation of S. |
| TRIM(S) | Removes spaces from the beggining and and of S. |
| RTRIM(S) LTRIM(S) |
Removes spaces at the begging (right) or end (left) of S. |
Date and Time Functions
| Function | Description | CURDATE() CURTIME() |
Returns the system’s current date/time. |
|---|---|
| DATE(D) DATE(T) |
Converts a string representation of a date/time into into a date/time value. |
| DAY(D) | Returns the day(1-31) from the date D. |
| WEEK(D) | Returns the week (1-54) from the date D. |
| MONTH(D) | Returns the month (1-12) from the date D. |
| YEAR(D) | Returns the year from the date D. |
| DAYOFWEEK(D) | Returns the week day (1-7) from the date D where 1 is Sunday. |
| DAYOFWEEK_ISO(D) | Returns the week day (1-7) from the date D where 1 is Monday. |
| DAYOFYEAR(D) | Returns the number of the day, in a year (1-366). |
| HOUR(T) | Returns the hour (0-24) from the time T. |
| MINUTE(T) | Returns the minute from the time T. |
| SECOND(T) | Returns the second from the time T. |
| MICROSECOND(T) | Returns the microsecond from the time |
Posted in SQL | No Comments »
Inserted records from file.a into file.b where not exists
5. June 2008 by admin.
Don’t you hate when your copy file with *ADD fails due to duplicate key? I used this sql to push the rest in.
INSERT INTO DVDTA/DWXP010
SELECT table1.* FROM masonm/xdwxp010 table1 left join dvdta/dwxp010
table2 on (table1.acctno = table2.acctno and table1.policy =
table2.policy and table1.effdte = table2.effdte and table1.edsno =
table2.edsno) WHERE table2.acctno is null
46 rows inserted in DWXP010 in DVDTA.
Posted in SQL | No Comments »
SQL LEFT JOIN (resembles not exist)
5. June 2008 by admin.
SELECT table1.* FROM masonm/xdwxp010 table1 left join dvdta/dwxp010
table2 on (table1.acctno = table2.acctno and table1.policy =
table2.policy and table1.effdte = table2.effdte and table1.edsno =
table2.edsno) WHERE table2.acctno is null
I prefer not exists
select * from table1
where not exists (select field2 from table2 where table2.field2 = table1.field1)
Posted in SQL | No Comments »
SQL INSERT INTO SELECT example
5. June 2008 by admin.
INSERT INTO MASONM/XDWXP010 (POLICY, EFFDTE, EDSNO, EDSDTE, ACTDTE,
COVEND, EXPDTE, CANDTE, CANPND, POLTRM, CANOPT, CANRSN, CANMTD,
CANSTE, NONPAY, INSNAM, INSAD1, INSAD2, INSAD3, INSCTY, INSST,
INSZIP, INSTEL, SERCH, CO, AGENT, SUBPRO, AGYTYP, AGYCOM, ACCTNO,
DIRASS, POLTYP, INSTYP, PROD, EDMNTS, PRVPOL, RELPOL, PRIPOL,
CLMOCC, POLPRT, REINST, NONREN, STATS1, STATS2, STATS3, STATS4,
STATS5, TRANS, TRDATE, TRTIME, IDADD, MAILDT, POLPRE, ASSRSK,
REINFL, NRWRSN, PRTF1, FLAGI1, FLAGI2, FLAGI3, REFQOT, UDDR,
UDDROD, UDDRDT, MVRHLD, RNIMAG, PAYPLN, FACTOR, APRP, INTCHG, COMM,
TOTDUE, TOTFAC, RTEFLG, AUDFRQ, AUDTYP, AUDEND, FINAUD, RETRTE,
INTRSK, PRDFLG, FIXFLD, SUBCAN, SUBEDS, NBRENTY, GLCLAS, ORPOYR,
RETDTE, TAIDTE, FLAGI4, FLAGI5, FLAGI6, POLCFG, FUTUR3, FUTUR4,
FUTUR5, ORGEFF, TRUEXP, FIELDA, FIELDB, FIELDC, FIELDD, FIELDE,
FIELDF, CMOVFG, CMOVPC, COUTRY, RTEMTD, CNVPOL, COMWOP, FACPRM,
DUPNAM, INDIC1, INDIC2, INDIC3, INDIC4, INDIC5, INDIC6, MINPRE,
FLD003, FLD004, NYFTCL, NYFTCD, FLD005, FLD006, AUDDTE, SICCDE,
INTPOL, FLD008, REDEPT, MAXLOS, FLD010, FLTPOL, GRPPGH, GRPDIS,
USELOC, PRGMID, TOTPRM, TYCVBS, NMADIN, BUSDSC, FINCCO, RWTFLG,
RWTPOL, PGMFLG, SHTRSN, UNDRWR, TYPBIZ, HAZGRP, FUTF11, FUTF12,
FUTF13, FUTF14, FUTF31, FUTF51, DSPRET, SIPFLG, EMPLPF, PCERTN,
POLPLI, WRAPUP, OLNINS, APYWAV, DIRHLD, BKTRAN, CLNTID, PREDST,
WAVAMT, RTEFDT, WAVPRM, REFOVR, RLPATP, PNDRFG, RLPCOM, FACRIN,
NXTRVW, REFLOS, TRECDT, AGNDDT, QTAGDT, QTFLDT, DCCLDT, QTFLAG,
SMSTCD, SMSTTX) SELECT xdwxp010.* FROM masonm/zdwxp010
xdwxp010,masonm/webfl100 WHERE XDWXP010.AGENT = WEBFL100.AGENT and
XDWXP010.ACCTNO = WEBFL100.ACCTNO and XDWXP010.POLICY =
WEBFL100.POLICY and XDWXP010.EFFDTE = WEBFL100.EFFDTE and
XDWXP010.EDSNO = WEBFL100.EDSNO
83 rows inserted in XDWXP010 in MASONM.
Posted in SQL | No Comments »