AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken Delphi Problem mit "NOT NULL - Feld"
Thema durchsuchen
Ansicht
Themen-Optionen

Problem mit "NOT NULL - Feld"

Ein Thema von Angel4585 · begonnen am 10. Mai 2006 · letzter Beitrag vom 12. Mai 2006
Antwort Antwort
Seite 2 von 2     12   
Benutzerbild von Kedariodakon
Kedariodakon

Registriert seit: 10. Sep 2004
Ort: Mönchengladbach
833 Beiträge
 
Delphi 7 Enterprise
 
#11

Re: Problem mit "NOT NULL - Feld"

  Alt 10. Mai 2006, 23:46
hmm das weiß ich nicht, teste es doch einfach
Reponse wär dann nicht schlecht, falls mal wer ein ähnliches Problem hat...

Bye Keda
Christian
  Mit Zitat antworten Zitat
Hansa

Registriert seit: 9. Jun 2002
Ort: Saarland
7.554 Beiträge
 
Delphi 8 Professional
 
#12

Re: Problem mit "NOT NULL - Feld"

  Alt 10. Mai 2006, 23:58
So ungefähr geht das :

http://www.ibexpert.info/documentati...raint/738.html
Gruß
Hansa
  Mit Zitat antworten Zitat
Angel4585

Registriert seit: 4. Okt 2005
Ort: i.d.N.v. Freiburg im Breisgau
2.199 Beiträge
 
Delphi 2010 Professional
 
#13

Re: Problem mit "NOT NULL - Feld"

  Alt 11. Mai 2006, 05:04
Also ich habe jetzt mit INSERT was eingefügt was durchb das CHECK eigentlich ausgeschlossen werden sollte und es wurde trotzdem in die Tabelle geschrieben. Muss ich das anders reinschreiben oder funktioniert das vllt einfach nur nicht mit MySQL?

Hansa dein Beispiel bezieht sich ja auf Firebird aber was ist mit MySQL?
Martin Weber
Ich bin ein Rüsselmops
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#14

Re: Problem mit "NOT NULL - Feld"

  Alt 11. Mai 2006, 05:22
Ich glaube die Firma MySql hat auch ne Homepage, auf der sie ihren Systax erklären.
Markus Kinzler
  Mit Zitat antworten Zitat
Angel4585

Registriert seit: 4. Okt 2005
Ort: i.d.N.v. Freiburg im Breisgau
2.199 Beiträge
 
Delphi 2010 Professional
 
#15

Re: Problem mit "NOT NULL - Feld"

  Alt 12. Mai 2006, 07:11
Zitat von Bill K. von MySQL.com:
MySQL accepts CHECK constraint syntax in the CREATE TABLE statement, and gives no error. But MySQL does not store any information for the constraint, and does not enforce the constraint.

Similarly for foreign key constraints when using MyISAM tables.

IMHO, this is a bad decision on the part of the makers of MySQL. They did it so that users could import schema definitions from other RDBMS that make use of these features, without editing their DDL scripts. But it causes users to have a false impression that a given constraint has been defined in the schema.

As an alternative, if you use MySQL 5.0 you can write a trigger that changes your Field1 to NULL if someone attempts to insert a value of "". That way, the NOT NULL constraint on that column will be violated and the operation will be aborted.

CREATE TRIGGER noblank_field1 BEFORE INSERT ON Tablename
FOR EACH ROW BEGIN
IF NEW.Field1 = "" THEN
SET NEW.Field1 = NULL;
END IF;
END

(Also make a similar trigger BEFORE UPDATE.)

If you use a version of MySQL earlier than 5.0, triggers are not implemented. You would have to enforce the rule in application code.

--
Regards,
Bill K.
Martin Weber
Ich bin ein Rüsselmops
  Mit Zitat antworten Zitat
Alt 12. Mai 2006, 11:19     Erstellt von Hansa
Dieser Beitrag wurde von Sharky gelöscht. - Grund: Es hat nichts mit der Frage zu tun und ist einfach nur \"unnötig\". Darum blende ich diesen Beitrag aus.
Alt 12. Mai 2006, 13:00     Erstellt von Angel4585
Dieser Beitrag wurde von Sharky gelöscht. - Grund: Da der \"Original\" Beitrag ohne Sinn war blende ich auch die Antwort aus ;-)
Antwort Antwort
Seite 2 von 2     12   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:30 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz