IBM Connections: Dicas de Queries para o DB2

From Wiki
Revision as of 15:07, 5 July 2012 by Ebasso (talk | contribs) (New page: == Conexão ao DB2 == db2 catalog tcpip node DB2PRODUCAO remote <ip_do_servidor> server <porta> db2 catalog db PEOPLEDB as PEOPLEDB at node DB2PRODUCAO db2 connect to PEOPLEDB use...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Conexão ao DB2

db2 catalog tcpip node DB2PRODUCAO remote <ip_do_servidor> server <porta>

db2 catalog db PEOPLEDB as PEOPLEDB at node DB2PRODUCAO 

db2 connect to PEOPLEDB user LCUSER using <PASSWORD>

Gerando listagens

db2 "SELECT prof_source_uid||';'||prof_display_name||';'||prof_given_name||';'||prof_surname as listagem from empinst.employee" > resultado.txt

db2 "SELECT prof_key||';'||prof_given_name||';'||prof_surname as listagem from empinst.employee" > resultado.txt

db2 "SELECT 'UPDATE EMPINST.EMPLOYEE SET PROF_GIVEN_NAME=#'||prof_given_name||'#, PROF_SURNAME=#'||prof_surname||'# WHERE PROF_KEY=#'||prof_key||'#' as listagem from empinst.employee" > queryupdate.txt

db2 "SELECT 'UPDATE EMPINST.EMPLOYEE SET PROF_GIVEN_NAME=#'||prof_given_name||'#, PROF_SURNAME=#'||prof_surname||'# WHERE PROF_KEY=#'||prof_key||'#' as listagem from empinst.employee" > queryupdate.txt

db2 "SELECT prof_key||';'||prof_surname as listagem from empinst.surname" > resultadoSURNAMES.txt

db2 "SELECT 'UPDATE EMPINST.SURNAME SET PROF_SURNAME=#'||prof_surname||'# WHERE PROF_KEY=#'||prof_key||'#' as listagem from empinst.surname" > queryupdateSURNAME.txt

Exemplo

SELECT prof_key,prof_given_name,prof_surname,prof_last_update from empinst.employee where prof_uid='ebasso'

ec4130ce-f29b-4486-8550-a1c847889c8b Enio            Basso        2012-07-05 10:43:11.874


SELECT prof_surname from empinst.surname where prof_key='ec4130ce-f29b-4486-8550-a1c847889c8b'
 
basso
rubens basso