Advertisement
jets-

SQLPLXML

Jul 6th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.64 KB | None | 0 0
  1. --SQLPL
  2. --1
  3. --2
  4. SELECT DISTINCT deref(id_aviao).tipo
  5. FROM tb_plano_voo p
  6. WHERE deref(id_rota).destino LIKE '%John F. Kennedy';
  7. --3
  8. ALTER TYPE tp_Piloto REPLACE AS object (
  9.     cpf varchar2(15),
  10.         cadastro INTEGER,
  11.         nome varchar2(30),  
  12.         habilitacao varchar2(30),
  13.         cpf_comandante REF tp_Piloto,
  14.         constructor FUNCTION tp_Piloto(
  15.         x1 varchar2,
  16.         x2 varchar2,
  17.         x3 INTEGER,
  18.         x4 varchar2)
  19.     RETURN SELF AS RESULT
  20. );
  21. CREATE OR REPLACE TYPE body tp_Piloto AS
  22.     constructor FUNCTION tp_Piloto(
  23.         x1 varchar2,
  24.         x2 varchar2,
  25.         x3 INTEGER,
  26.         x4 varchar2)
  27.     RETURN SELF AS RESULT IS
  28.     BEGIN
  29.         cpf:=x1;
  30.         cadastro:=x3;
  31.         nome:=x2;
  32.         habilitacao:=x4;
  33.         cpf_comandante:=NULL;
  34.         RETURN;
  35.     END;
  36. END;
  37. /
  38. INSERT INTO tb_Piloto VALUES (tp_Piloto('12345678990','JETS','15','A1'));
  39.  
  40. --4
  41. SELECT p.nome, p.habilitacao
  42. FROM tb_Piloto p
  43. WHERE p.habilitacao='A2'
  44. AND REF(p) IS NOT dangling;
  45.  
  46. --5
  47. /*
  48. select r.id_pista.condicoes, r.id_pista.comprimento
  49. from tb_Pouso_Decolagem v, table(v.reservas) r
  50. where v.max_velocidade>'500';
  51. */
  52.  
  53. --6
  54. SELECT T.*
  55. FROM tb_fones_funcionario f, TABLE(f.lista_fone) T, tb_Pilota p
  56. WHERE p.cpf_piloto.cpf=f.cpf_piloto.cpf
  57. AND p.id_aviao.tipo LIKE 'Boeing 737-800';
  58.  
  59.  
  60.  
  61.  
  62. --XML
  63. --4
  64. SET serveroutput ON;
  65. DECLARE
  66. ctx dbms_xmlgen.ctxhandle;
  67. RESULT CLOB;
  68. BEGIN
  69.     ctx := dbms_xmlgen.newContext('select pilota.id_aviao.tipo from tb_Pilota pilota where pilota.cpf_piloto.nome=''Maria W. Griffith''');
  70.     DBMS_XMLGEN.setRowsetTag(ctx, 'AviΓ΅es');
  71.     DBMS_XMLGEN.setRowTag(ctx,'Tipos');
  72.     RESULT := dbms_xmlgen.getXML(ctx);
  73.     dbms_output.put_line(RESULT);
  74.     dbms_xmlgen.closeContext(ctx);
  75. END;
  76. /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement