3liz / QgisCadastrePlugin

A QGIS plugin which helps users to import the french land registry ('cadastre') data into a database. It is meant to ease the use of the data in QGIS by providing search tools and appropriate layer symbology.
GNU General Public License v2.0
61 stars 41 forks source link

Cadastre-ERREUR: syntaxe en entrée invalide pour le type numeric : « » #118

Open zorgas2a opened 7 years ago

zorgas2a commented 7 years ago

Bonjour,

Après avoir télécharger le plugin cadastre sur le l’astre je trouve cette erreur en faisant un import sous PostGIS : comment puis je faire pour résoudre ceci?

ERREUR: syntaxe en entrée invalide pour le type numeric : « »

REQUETE


-- Traitement: pev
INSERT INTO "cadastre".pev
(
 pev, annee, ccodep, ccodir, ccocom, invar,
 dnupev,
 ccoaff, ccostb, dcapec, dcetlc,
 ccocac, dnutrf, dcfloc, dsupot, dvlper, dvlpera, gnexpl,
 ccthp, retimp, dnuref, gnidom,
 dvltpe,
 tpevtieom, ccortar, ccorvl, dtaurv, dcmloc, dcsplca, dcsglca, dcralca,
 local10, lot
 )
SELECT
  REPLACE('2017'||SUBSTRING(tmp,1,3)||SUBSTRING(tmp,7,10)||SUBSTRING(tmp,28,3),' ','0') AS pev,
  '2017',
  SUBSTRING(tmp,1,2) AS ccodep,
  SUBSTRING(tmp,3,1) AS ccodir,
  SUBSTRING(tmp,4,3) AS ccocom,
  SUBSTRING(tmp,7,10) AS invar,

  SUBSTRING(tmp,28,3) AS dnupev,

  CASE WHEN trim(SUBSTRING(tmp,36,1))='' THEN NULL ELSE trim(SUBSTRING(tmp,36,1)) END AS ccoaff,
  SUBSTRING(tmp,37,1) AS ccostb,
  SUBSTRING(tmp,38,2) AS dcapec,
  CASE WHEN trim(SUBSTRING(tmp,40,3))='' THEN NULL ELSE to_number(SUBSTRING(tmp,40,3),'999')/100 END AS dcetlc,

  SUBSTRING(tmp,46,4) AS ccocac,
  SUBSTRING(tmp,50,2) AS dnutrf,
  CASE WHEN trim(SUBSTRING(tmp,52,3))='' THEN NULL ELSE to_number(SUBSTRING(tmp,52,3),'999') END AS dcfloc,
  CASE WHEN trim(SUBSTRING(tmp,55,6))='' THEN NULL ELSE to_number(SUBSTRING(tmp,55,6),'999999') END AS dsupot,
  CASE WHEN trim(SUBSTRING(tmp,61,9))='' THEN NULL ELSE to_number(SUBSTRING(tmp,61,9),'999999999') END AS dvlper,
  CASE when trim(SUBSTRING(tmp,70,9))='' THEN NULL ELSE to_number(SUBSTRING(tmp,70,9),'999999999') END AS dvlpera,
  CASE WHEN trim(SUBSTRING(tmp,79,2))='' THEN NULL ELSE trim(SUBSTRING(tmp,79,2)) END AS gnexpl,

  SUBSTRING(tmp,111,1) AS ccthp,
  SUBSTRING(tmp,112,1) AS retimp,
  SUBSTRING(tmp,113,3) AS dnuref,
  SUBSTRING(tmp,116,1) AS gnidom,

  CASE when trim(SUBSTRING(tmp,130,9))='' THEN NULL ELSE to_number(SUBSTRING(tmp,130,9),'999999999') END AS dvltpe,

  CASE WHEN trim(SUBSTRING(tmp,144,1))='' THEN NULL ELSE to_number(SUBSTRING(tmp,144,1),'9') END  AS tpevtieom,

  CASE WHEN trim(SUBSTRING(tmp,145,3))='' THEN NULL ELSE to_number(SUBSTRING(tmp,145,3),'999') END  AS ccortar,
  SUBSTRING(tmp,148,2) AS ccorvl,
  CASE WHEN trim(SUBSTRING(tmp,150,3))='' THEN NULL ELSE to_number(SUBSTRING(tmp,150,3),'999') END  AS dtaurv,
  CASE WHEN trim(SUBSTRING(tmp,153,3))='' THEN NULL ELSE to_number(SUBSTRING(tmp,153,3),'999') END  AS dcmloc,
  SUBSTRING(tmp,156,5) AS dcsplca,
  SUBSTRING(tmp,161,5) AS dcsglca,
  SUBSTRING(tmp,166,5) AS dcralca,

  '2017'||SUBSTRING(tmp,1,3)||SUBSTRING(tmp,7,10) AS local10,
  'A' as lot
FROM "cadastre".bati WHERE SUBSTRING(tmp,31,2) ='21

cordialement, david

Christophe55 commented 6 years ago

Bonjour,

J'ai le même souci pour un import avec Postgis (avec les version 1.4.1 et 1.5.0 du plugin) erreur de valeur nulle pour le champ numeric

----------------------------------------------------------------------------------------------------
ERREUR:  syntaxe en entrée invalide pour le type numeric : «   »
----------------------------------------------------------------------------------------------------
commune, geo_commune, annee, ccodep, ccodir, ccocom, clerivili, libcom, typcom, ruract, carvoi, indpop, poprel, poppart, popfict, annul, dteannul, dtecreart, codvoi,
 typvoi, indldnbat, motclas, lot
)
SELECT
  REPLACE('2017'||SUBSTRING(tmp,1,6),' ', '0') AS commune,
  REPLACE('2017'||SUBSTRING(tmp,1,6),' ', '0') AS geo_commune,
  '2017',
  SUBSTRING(tmp,1,2) AS ccodep,
  SUBSTRING(tmp,3,1) AS ccodir,
  SUBSTRING(tmp,4,3) AS ccocom,
  SUBSTRING(tmp,11,1) AS clerivili,
  SUBSTRING(tmp,12,30) AS libcom,
  CASE WHEN trim(SUBSTRING(tmp,43,1))='' THEN NULL ELSE trim(SUBSTRING(tmp,43,1)) END AS typcom,
  SUBSTRING(tmp,46,1) AS ruract,
  SUBSTRING(tmp,49,1) AS carvoi,
  SUBSTRING(tmp,50,1) AS indpop,
  CASE WHEN trim(SUBSTRING(tmp,53,7))='' THEN NULL ELSE to_number(trim(SUBSTRING(tmp,53,7)),'0000000') END AS poprel,
  to_number(SUBSTRING(tmp,60,7),'9999999') AS poppart,
  to_number(SUBSTRING(tmp,67,7),'0000000') AS popfict,
  SUBSTRING(tmp,74,1) AS annul,
  SUBSTRING(tmp,75,7) AS dteannul,
  SUBSTRING(tmp,82,7) AS dtecreart,
  SUBSTRING(tmp,104,5) AS codvoi,
  SUBSTRING(tmp,109,1) AS typvoi,
  SUBSTRING(tmp,110,1) AS indldnbat,
  SUBSTRING(tmp,113,8) AS motclas,
  'AGGLO' as lot
FROM "cadastre".fanr WHERE SUBSTRING(tmp,4,3)  != ' ' AND 

 trim(SUBSTRING(tmp,7,4))=''
----------------------------------------------------------------------------------------------------

L'import fonctionne parfaitement avec ce jeux de données dans une base sqlite.

cordialement Christophe

mdouchin commented 6 years ago

Bonjour,

Pouvez vous préciser

Christophe55 commented 6 years ago

Bonjour, il s'agit de données millésime 2017, l'année précisée est 2017. Testé également avec version de format 2016 et données 2016, le problème reste identique.

Cordialement. Christophe.

Christophe55 commented 6 years ago

Suite au crash de l'import des données MAJIC, j'ai relancé, sans faire de DROP SCHEMA l'import des fichiers EDIGEO seuls, l'import a foncionné et je dispose de mes infos propriétaire sur mes parcelles, je n'ai pas pu vérifié pour le coup quels sont les données manquantes dans la base de données..

cordialement Christophe

MaelREBOUX commented 5 years ago

Bonjour @Christophe55

Votre problème analogue à #15 est-il toujours d'actualité ?

MaelREBOUX commented 3 years ago

Bonjour @Christophe55

Est-ce que vous rencontrez toujours ce problème avec la dernière version 1.10.2 ?

otoupin commented 2 years ago

Bonjour, je relance car je rencontre la même erreur pour les données 2021 L'environnement :

windows 10
postgresql 11
postgis 2.5.3
QGIS 3.10.14
plugin cadastre 1.13.5

Erreur SQL :

-- Traitement: commune
INSERT INTO "public".commune
(
 commune, geo_commune, annee, ccodep, ccodir, ccocom, clerivili, libcom, typcom, ruract, carvoi, indpop, poprel, poppart, popfict, annul, dteannul, dtecreart, codvoi,
 typvoi, indldnbat, motclas, lot
)
SELECT
  REPLACE(SUBSTRING(tmp,1,6),' ', '0') AS commune,
  REPLACE(SUBSTRING(tmp,1,6),' ', '0') AS geo_commune,
  '2021',
  SUBSTRING(tmp,1,2) AS ccodep,
  SUBSTRING(tmp,3,1) AS ccodir,
  SUBSTRING(tmp,4,3) AS ccocom,
  SUBSTRING(tmp,11,1) AS clerivili,
  SUBSTRING(tmp,12,30) AS libcom,
  CASE WHEN trim(SUBSTRING(tmp,43,1))='' THEN NULL ELSE trim(SUBSTRING(tmp,43,1)) END AS typcom,
  SUBSTRING(tmp,46,1) AS ruract,
  SUBSTRING(tmp,49,1) AS carvoi,
  SUBSTRING(tmp,50,1) AS indpop,
  CASE WHEN trim(SUBSTRING(tmp,53,7))='' THEN NULL ELSE to_number(trim(SUBSTRING(tmp,53,7)),'0000000') END AS poprel,
  to_number(SUBSTRING(tmp,60,7),'9999999') AS poppart,
  to_number(SUBSTRING(tmp,67,7),'0000000') AS popfict,
  SUBSTRING(tmp,74,1) AS annul,
  SUBSTRING(tmp,75,7) AS dteannul,
  SUBSTRING(tmp,82,7) AS dtecreart,
  SUBSTRING(tmp,104,5) AS codvoi,
  SUBSTRING(tmp,109,1) AS typvoi,
  SUBSTRING(tmp,110,1) AS indldnbat,
  SUBSTRING(tmp,113,8) AS motclas,
  '1' as lot
FROM "public".fanr WHERE SUBSTRING(tmp,4,3)  != ' ' AND trim(SUBSTRING(tmp,7,4))='' renvoyé 0 [ERREUR:  syntaxe en entrée invalide pour le type numeric : «   »
]

L'import fonctionne avec le même jeu de données dans une base sqlite.

Bien cordialement, Olivier