Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Delphi MySQL- SQL-Script funktioniert nicht in Firebird (https://www.delphipraxis.net/118720-mysql-sql-script-funktioniert-nicht-firebird.html)

juergen 13. Aug 2008 14:34

Datenbank: Firebird • Version: 2.1 • Zugriff über: IBExpert

MySQL- SQL-Script funktioniert nicht in Firebird
 
Hallo zusammen,

ich beschäftige mich momentan "etwas" mit DB...
Dazu habe ich ein Projekt aufgegriffen (opengeodb).

Nun habe ich mich damit schon etwas länger befasst (und will auch weitermachen), finde aber nichts, warum folgender MySQL-Sript als Firebird-SQL-Script ab der 3. Zeile nicht funktioniert:
SQL-Code:
create table geodb_hierarchies (
  loc_id              integer not null references geodb_locations,
  level               integer not null check (level>0 and level<=9),
  id_lvl1              integer not null,
  id_lvl2              integer,
  id_lvl3              integer,
  id_lvl4              integer,
  id_lvl5              integer,
  id_lvl6              integer,
  id_lvl7              integer,
  id_lvl8              integer,
  id_lvl9              integer,
  valid_since         date,
  date_type_since     integer,
  valid_until         date not null,
  date_type_until     integer not null
  check (
    (
      (level = 1 and /* loc_id = id_lvl1 and */
                     id_lvl2 is null and id_lvl3 is null and
                     id_lvl4 is null and id_lvl5 is null and
                     id_lvl6 is null and id_lvl7 is null and
                     id_lvl8 is null and id_lvl9 is null) or
      (level = 2 and /* loc_id = id_lvl2 and */
                     id_lvl1 is not null and id_lvl3 is null and
                     id_lvl4 is null and id_lvl5 is null and
                     id_lvl6 is null and id_lvl7 is null and
                     id_lvl8 is null and id_lvl9 is null) or
      (level = 3 and /* loc_id = id_lvl3 and */
                     id_lvl1 is not null and id_lvl2 is not null and
                     id_lvl4 is null and id_lvl5 is null and
                     id_lvl6 is null and id_lvl7 is null and
                     id_lvl8 is null and id_lvl9 is null) or
      (level = 4 and /* loc_id = id_lvl4 and */
                     id_lvl1 is not null and id_lvl2 is not null and
                     id_lvl3 is not null and id_lvl5 is null and
                     id_lvl6 is null and id_lvl7 is null and
                     id_lvl8 is null and id_lvl9 is null) or
      (level = 5 and /* loc_id = id_lvl5 and */
                     id_lvl1 is not null and id_lvl2 is not null and
                     id_lvl3 is not null and id_lvl4 is not null and
                     id_lvl6 is null and id_lvl7 is null and
                     id_lvl8 is null and id_lvl9 is null) or
      (level = 6 and /* loc_id = id_lvl6 and */
                     id_lvl1 is not null and id_lvl2 is not null and
                     id_lvl3 is not null and id_lvl4 is not null and
                     id_lvl5 is not null and id_lvl7 is null and
                     id_lvl8 is null and id_lvl9 is null) or
      (level = 7 and /* loc_id = id_lvl7 and */
                     id_lvl1 is not null and id_lvl2 is not null and
                     id_lvl3 is not null and id_lvl4 is not null and
                     id_lvl5 is not null and id_lvl6 is not null and
                     id_lvl8 is null and id_lvl9 is null) or
      (level = 8 and /* loc_id = id_lvl8 and */
                     id_lvl1 is not null and id_lvl2 is not null and
                     id_lvl3 is not null and id_lvl4 is not null and
                     id_lvl5 is not null and id_lvl6 is not null and
                     id_lvl7 is not null and id_lvl9 is null) or
      (level = 9 and /* loc_id = id_lvl9 and */
                     id_lvl1 is not null and id_lvl2 is not null and
                     id_lvl3 is not null and id_lvl4 is not null and
                     id_lvl5 is not null and id_lvl6 is not null and
                     id_lvl7 is not null and id_lvl8 is not null)
      ) and
      (
        (valid_since is null and date_type_since is null) or
        (valid_since is not null and date_type_since is not null)
      )
  )
)
Es kommt folgende Fehlermeldung:
Zitat:

The next statement causes the following error:
Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 3, column 3.
level.
Ich habe da nun schon etliches gelesen und gesucht, finde aber nicht heraus, wo hier das Problem liegt.
Ich denke hier ist eine Anpassung an die Firebird Syntax notwendig.

Völlig unklar ist mir, was "level" zu besagen hat und der Zusammenahng zu "check"... :gruebel:

Über Hilfe würde ich mich freuen.
Und habt bitte Nachsehen, ich stehe erst gaaanz am Anfang... :oops:

mkinzler 13. Aug 2008 14:39

Re: MySQL- SQL-Script funktioniert nicht in Firebird
 
Er scheint die 2. Zeile nicht so zu nehmen. Definiere die Constraints mal extra

DeddyH 13. Aug 2008 14:41

Re: MySQL- SQL-Script funktioniert nicht in Firebird
 
Außerdem ist level wohl ein reserviertes Wort.

mkinzler 13. Aug 2008 14:42

Re: MySQL- SQL-Script funktioniert nicht in Firebird
 
Zitat:

Zitat von DeddyH
Außerdem ist level wohl ein reserviertes Wort.

was man durch Quoten umgehen könnte, besser ab ändern

DeddyH 13. Aug 2008 14:46

Re: MySQL- SQL-Script funktioniert nicht in Firebird
 
Ich würde auch id_level daraus machen, das ist IMHO besser als quoten.

juergen 13. Aug 2008 14:53

Re: MySQL- SQL-Script funktioniert nicht in Firebird
 
Hallo,
Bingo, "Level" ist in FB ein reserviertes Wort! :thumb:
Ich hatte das auch schon geändert, hatte dann aber noch weitere Fehler, so dass ich auf diesen Schluss nicht gekommen bin.

Danke Euch beiden!


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:02 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz