Advertisement
Guest User

truiz

a guest
Apr 27th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. --select * from document
  2. --where id = 144722
  3.  
  4. SELECT --*
  5. document.documentum_id,
  6. 'ARXEION',
  7. document.archive_id,
  8. to_char(document.data_creation, 'YYYY') as ANNO,
  9. to_char(document.data_creation, 'MONTH') as MESE,
  10. document.document_guid,
  11. document.file_name,
  12. document.document_version,
  13. document.current_version,
  14. NULL AS ATTACHMENTS,
  15. NULL AS attachment_file_name
  16. -- archive_name,
  17. -- archive_location
  18. FROM
  19. archive INNER JOIN document ON archive.id = document.archive_id
  20. --LEFT OUTER JOIN document_in_attachment ON document.id = document_in_attachment.document_id
  21. --LEFT OUTER JOIN attachment ON attachment.id = document_in_attachment.attachment_id
  22. where document_guid = '96a63ffd-62f6-4a9e-8fda-d523ce31ca47'
  23.  
  24. UNION
  25.  
  26. SELECT --*
  27. document.documentum_id,
  28. 'ARXEION',
  29. document.archive_id,
  30. to_char(document.data_creation, 'YYYY') as ANNO,
  31. to_char(document.data_creation, 'MONTH') as MESE,
  32. document.document_guid,
  33. document.file_name,
  34. document.document_version,
  35. document.current_version,
  36. CASE WHEN attachment.attachment_file_name IS NULL THEN NULL ELSE 'ATTACHMENTS' END AS ATTACHMENTS,
  37. attachment.attachment_file_name
  38. -- archive_name,
  39. -- archive_location
  40. FROM
  41. archive INNER JOIN document ON archive.id = document.archive_id
  42. LEFT OUTER JOIN document_in_attachment ON document.id = document_in_attachment.document_id
  43. LEFT OUTER JOIN attachment ON attachment.id = document_in_attachment.attachment_id
  44. where document_guid = '96a63ffd-62f6-4a9e-8fda-d523ce31ca47'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement