comparison flys-backend/contrib/shpimporter/dgm.py @ 5260:8f71fe38977c

fixed DEM-importer to work with Oracle (made by A. Heinecke)
author Tom Gottfried <tom@intevation.de>
date Tue, 12 Mar 2013 19:43:11 +0100
parents 3b86bf214d53
children 9245f4b434b3
comparison
equal deleted inserted replaced
5259:7a11271f5593 5260:8f71fe38977c
53 """ 53 """
54 SQL_INSERT_RANGE_ID_ORA = """ 54 SQL_INSERT_RANGE_ID_ORA = """
55 INSERT INTO ranges (id, river_id, a, b) VALUES (:s, :s, :s, :s) 55 INSERT INTO ranges (id, river_id, a, b) VALUES (:s, :s, :s, :s)
56 """ 56 """
57 SQL_NEXT_ID = "SELECT coalesce(max(id), -1) + 1 FROM %s" 57 SQL_NEXT_ID = "SELECT coalesce(max(id), -1) + 1 FROM %s"
58 SQL_NEXT_ID_ORA = "SELECT coalesce(max(id), -1) + 1 FROM :s"
59 58
60 59
61 NEXT_IDS = {} 60 NEXT_IDS = {}
62 def next_id(cur, relation, oracle): 61 def next_id(cur, relation, oracle):
63 idx = NEXT_IDS.get(relation) 62 idx = NEXT_IDS.get(relation)
64 if idx is None: 63 if idx is None:
65 if oracle:
66 cur.execute(SQL_NEXT_ID_ORA % relation)
67 else:
68 cur.execute(SQL_NEXT_ID % relation) 64 cur.execute(SQL_NEXT_ID % relation)
69 idx = cur.fetchone()[0] 65 idx = cur.fetchone()[0]
70 NEXT_IDS[relation] = idx + 1 66 NEXT_IDS[relation] = idx + 1
71 return idx 67 return idx
72 68

http://dive4elements.wald.intevation.org