dbTalk Databases Forums  

ADD FOREIGN KEY that alows null in the child table

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss ADD FOREIGN KEY that alows null in the child table in the sybase.public.sqlanywhere.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mike Marston
 
Posts: n/a

Default ADD FOREIGN KEY that alows null in the child table - 08-28-2009 , 11:19 AM






We can use Sybase Central to easily setup a foreigh key on a child table
whose column value is null.
Howerer we cannot seem to do this with systax. The following statement
results in an error...

ALTER TABLE "dba"."sfdc_tran"
ADD FOREIGN KEY "fk_wrk_machine" ("company_code", "wrk_code",
"wrk_mach_code")
REFERENCES "DBA"."wrk_machine" ("company_code", "wrk_code",
"wrk_mach_code")
ON UPDATE CASCADE

The error is: No primary key value for foreign key 'fk_wrk_machine' in table
'sfdc_tran'

With the Sybase Central FK wizzard we just check the "Allow null values"
checkbox and the fk is created with no errors. How do we duiplicaate this
using syntax?

* None of the columns in either table have a "Unique" constraint.
ASA 8.02

TIA
Mike

Reply With Quote
  #2  
Old   
tduemesnil
 
Posts: n/a

Default Re: ADD FOREIGN KEY that alows null in the child table - 08-29-2009 , 02:36 AM






I would try to copy and paste the FKey from Sybase Central into you
Text Editor.

HTH
Thomas

Reply With Quote
  #3  
Old   
Mike Marston
 
Posts: n/a

Default Re: ADD FOREIGN KEY that alows null in the child table - 08-31-2009 , 08:11 AM



Thomas,
I don't find any way to view the syntax of the Foreign Key in Sybase
Central, much less copy it. The graphical representation is there, but no
textual syntax. Am I missing something?

TIA,
Mike

"tduemesnil" <tduemesnil (AT) googlemail (DOT) com> wrote

Quote:
I would try to copy and paste the FKey from Sybase Central into you
Text Editor.

HTH
Thomas

Reply With Quote
  #4  
Old   
FalseDawn
 
Posts: n/a

Default Re: ADD FOREIGN KEY that alows null in the child table - 09-03-2009 , 10:14 AM



AFAIK, a null in the child field automatically satisfies a FK
constraint, you don't need to specify "Allow Nulls" in the script.

It's only if you don't want Nulls that you add "NOT NULL"

I don't think it's the Nulls causing the problem, but some other
Not-Null fields that aren't matching and Sybase Central is not
catching.

FYI, if you can perform an "Unload Database", you will be able to see
the script that Sybase creates to re-create your database - this
should show you the appropriate script to create the FK.




On 31 Aug 2009 06:11:22 -0700, "Mike Marston" <mikem (AT) ksitech (DOT) com>
wrote:

Quote:
Thomas,
I don't find any way to view the syntax of the Foreign Key in Sybase
Central, much less copy it. The graphical representation is there, but no
textual syntax. Am I missing something?

TIA,
Mike

"tduemesnil" <tduemesnil (AT) googlemail (DOT) com> wrote in message
news:0496a975-22f4-4994-b82e-24e473c18a3c (AT) p36g2000vbn (DOT) googlegroups.com...
I would try to copy and paste the FKey from Sybase Central into you
Text Editor.

HTH
Thomas

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.