foreign key constraint

Ruslan Zasukhin ruslan_zasukhin at valentina-db.com
Mon Jan 25 13:32:35 CST 2010


On 1/25/10 8:43 PM, "Bernard Devlin" <bdrunrev at gmail.com> wrote:

Hi Bernard,

> Ivan, I think we may be at cross-purposes here.
> 
> On Mon, Jan 25, 2010 at 3:41 PM, Ivan Smahin
> <ivan_smahin at paradigmasoft.com> wrote:
>> Hello Bernard,
>> 
>> Monday, January 25, 2010, 1:48:55 PM, you wrote:
>> 
>>> ALTER TABLE Phone(
>>>     ADD CONSTRAINT 'link_Person_Phone'
>>>         FOREIGN KEY (PersonPtr) REFERENCES Person(ID)
>>>         ON DELETE SET NULL
>>>         ON UPDATE SET NULL )
>> 
>>> The above is from the Valentina wiki.  Is that right?  When I try to
>>> use the SQL Editor in VStudio, it complains about unexpected tokens.
>> 
>> CREATE TABLE t1 ( id long unique );
>> CREATE TABLE t2 ( ptr long indexed );
>> 
>> ALTER  TABLE  t2  ADD CONSTRAINT FK_t2_t1 FOREIGN KEY (t2.ptr) REFERENCES
>> t1(id)  ON DELETE SET NULL ON UPDATE SET NULL;
>> 
>> Really, get a syntax error...
>> 
>> but it works for ...FOREIGN KEY (ptr)...
>> Ok - will be fixed.
> 
> I think you are saying that this does work:
> FOREIGN KEY (ptr) REFERENCES
> but this does not work:
> FOREIGN KEY (t2.ptr) REFERENCES
> 
> I was questioning the correctness of the example from the wiki.

In case you see some WIKI example do not works (it looks ou have found
second SQL such) the best place to check is SQL GRAMMAR page

<http://valentina-db.com/dokuwiki/doku.php?id=valentina:vcomponents:vsql:ref
erence:sqlgrammar>

This page is the most up to date, and follow to our C++ sources of SQL
parser.

> There
> seem to be various things wrong with the example I cited: the whole
> ALTER TABLE statement cannot be bracketed, and the constraint cannot
> have quotation marks in it.

quotation marks ?

You mean for SQL binding?

That is right. Question marks (as well as :1, :2, ...) can be used only in
places where you see in the grammar EXPR rule.

Only EXPRs can be replaced for binding.

 
> http://valentina-db.com/dokuwiki/doku.php?id=valentina:vcomponents:vkernel:vli
> nk:foreign_key&s[]=foreign&s[]=key

-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list