SHARE
TWEET

Untitled

a guest Feb 21st, 2020 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. --SQL script to convert from json to regular table
  3. CREATE TABLE fisaip as (
  4.         select
  5. --json_each(c_json->'declaratieFisaIP') ,
  6. (c_json->'declaratieFisaIP'->>'@an')::bigint as an,
  7. (c_json->'declaratieFisaIP'->>'@luna')::bigint as luna,
  8. (c_json->'declaratieFisaIP'->>'@totalPlata_A')::bigint as totalPlata_A,
  9. (c_json->'declaratieFisaIP'->>'@d_rec')::bigint as d_rec,
  10. (c_json->'declaratieFisaIP'->>'@tip_actiune')::bigint as tip_actiune,
  11. c_json->'declaratieFisaIP'->>'@nume_ip' as nume_ip,
  12. c_json->'declaratieFisaIP'->>'@nume_scurt_ip' as nume_scurt_ip,
  13. (c_json->'declaratieFisaIP'->>'@cif')::bigint as cif,
  14. (c_json->'declaratieFisaIP'->>'@cod_nom_categ_emit')::bigint as cod_nom_categ_emit,
  15. c_json->'declaratieFisaIP'->>'@nume_emitent' as nume_emitent,
  16. (c_json->'declaratieFisaIP'->>'@cod_nom_categ_act')::bigint as cod_nom_categ_act,
  17. c_json->'declaratieFisaIP'->>'@nume_act_emit' as nume_act_emit,
  18. c_json->'declaratieFisaIP'->>'@data_inf' as data_inf,
  19. (c_json->'declaratieFisaIP'->>'@cod_uat')::bigint as cod_uat,
  20. (c_json->'declaratieFisaIP'->>'@cui_uat')::bigint as cui_uat,
  21. (c_json->'declaratieFisaIP'->>'@cod_jud_uat')::bigint as cod_jud_uat,
  22. (c_json->'declaratieFisaIP'->>'@cod_tip_uat')::bigint as cod_tip_uat,
  23. c_json->'declaratieFisaIP'->>'@den_trez' as den_trez,
  24. c_json->'declaratieFisaIP'->>'@cod_trez' as cod_trez,
  25. c_json->'declaratieFisaIP'->>'@cod_trez_fiscal' as cod_trez_fiscal,
  26. c_json->'declaratieFisaIP'->>'@mail_pub' as mail_pub,
  27. c_json->'declaratieFisaIP'->>'@mail_coresp_1' as mail_coresp_1,
  28. c_json->'declaratieFisaIP'->>'@mail_coresp_2' as mail_coresp_2,
  29. (c_json->'declaratieFisaIP'->>'@tip_act')::bigint as tip_act,
  30. c_json->'declaratieFisaIP'->>'@sect_spe' as sect_spe,
  31. --- aSoc ----
  32. c_json->'declaratieFisaIP'->'aSoc'->>'@nume_jud' as aSoc_nume_jud,
  33. c_json->'declaratieFisaIP'->'aSoc'->>'@cod_jud' as aSoc_cod_jud,
  34. c_json->'declaratieFisaIP'->'aSoc'->>'@den_loc' as aSoc_den_loc,
  35. c_json->'declaratieFisaIP'->'aSoc'->>'@tip_a' as aSoc_tip_a,
  36. c_json->'declaratieFisaIP'->'aSoc'->>'@den_a' as aSoc_den_a,
  37. c_json->'declaratieFisaIP'->'aSoc'->>'@nr' as aSoc_nr,
  38. c_json->'declaratieFisaIP'->'aSoc'->>'@bl' as aSoc_bl,
  39. c_json->'declaratieFisaIP'->'aSoc'->>'@cp' as aSoc_cp,
  40. c_json->'declaratieFisaIP'->'aSoc'->>'@tel' as aSoc_tel,
  41. c_json->'declaratieFisaIP'->'aSoc'->>'@fax' as aSoc_fax,
  42. -- aFis ---
  43. c_json->'declaratieFisaIP'->'aFis'->>'@nume_jud' as aFis_nume_jud,
  44. c_json->'declaratieFisaIP'->'aFis'->>'@cod_jud' as aFis_cod_jud,
  45. c_json->'declaratieFisaIP'->'aFis'->>'@den_loc' as aFis_den_loc,
  46. c_json->'declaratieFisaIP'->'aFis'->>'@tip_a' as aFis_tip_a,
  47. c_json->'declaratieFisaIP'->'aFis'->>'@den_a' as aFis_den_a,
  48. c_json->'declaratieFisaIP'->'aFis'->>'@nr' as aFis_nr,
  49. c_json->'declaratieFisaIP'->'aFis'->>'@bl' as aFis_bl,
  50. c_json->'declaratieFisaIP'->'aFis'->>'@cp' as aFis_cp,
  51. c_json->'declaratieFisaIP'->'aFis'->>'@tel' as aFis_tel,
  52. c_json->'declaratieFisaIP'->'aFis'->>'@fax' as aFis_fax,
  53. --- aCoresp ----
  54. c_json->'declaratieFisaIP'->'aCoresp'->>'@nume_jud' as aCoresp_nume_jud,
  55. c_json->'declaratieFisaIP'->'aCoresp'->>'@cod_jud' as aCoresp_cod_jud,
  56. c_json->'declaratieFisaIP'->'aCoresp'->>'@den_loc' as aCoresp_den_loc,
  57. c_json->'declaratieFisaIP'->'aCoresp'->>'@tip_a' as aCoresp_tip_a,
  58. c_json->'declaratieFisaIP'->'aCoresp'->>'@den_a' as aCoresp_den_a,
  59. c_json->'declaratieFisaIP'->'aCoresp'->>'@nr' as aCoresp_nr,
  60. c_json->'declaratieFisaIP'->'aCoresp'->>'@bl' as aCoresp_bl,
  61. c_json->'declaratieFisaIP'->'aCoresp'->>'@cp' as aCoresp_cp,
  62. c_json->'declaratieFisaIP'->'aCoresp'->>'@tel' as aCoresp_tel,
  63. c_json->'declaratieFisaIP'->'aCoresp'->>'@fax' as aCoresp_fax,
  64.  
  65. c_json->'declaratieFisaIP'->'activFinProp' as activFinProp,
  66. c_json->'declaratieFisaIP'->'sectorBugetar' as sectorBugetar
  67.  
  68. from fisaep_t_json limit 20000
  69. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top