Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Hi,

I am using sybase 11, Delphi XE with NativeDb components.

I can add a foreign key using sybase central. If I try and execute the same sql via NativeDB I get sql error

Error -300: Run time SQL error --  Person(40000):

the sql line is

alter table tablename add foreign key person (personid) references person

If I add an index onto tablename.personid, the sql will execute no problem.

foreign keys dont require indices, so why is the error generated.

asked 01 Jun '12, 11:54

Curlew's gravatar image

Curlew
16112
accept rate: 0%

edited 03 Jun '12, 08:53

Volker%20Barth's gravatar image

Volker Barth
40.2k361550822


This error is unexpected. We are unaware of any issues with the creation of foreign keys in v11 software.

Keep in mind that in SQL Anywhere all foreign keys are created with indexes to match.

Some follow-on questions:

1) what version/build of SQL Anywhere 11 are you running? 2) are the FK and PK columns for "personID" the identical data type? 3) does your database validate successfully?

permanent link

answered 01 Jun '12, 13:20

Glenn%20Paulley's gravatar image

Glenn Paulley
10.8k576106
accept rate: 43%

1) sql anywhere is version 11.0.1.2044 2) PK and FK are both char(20) 3) yes DB validates, tried that before posting error

Adding a foreign from within sybase central works. But I get the error from nativeDB.

Sql looks correct, but error message doesnt give any clues if I add an index eg

create index byperson on mytable (personid)

it works, but should have to do that.

(01 Jun '12, 13:36) Curlew
Replies hidden

No, you should not have to add the index beforehand. I am puzzled why you get the internal error but only when using Native DB. Would it be possible for you to move to a later build of 11.0.1? Build 2044 was the initial release build, and I know that a number of issues in the server have been implemented since the initial release.

(01 Jun '12, 14:09) Glenn Paulley

My technical director is off until Thursday, and I am sure there wont be an issue with me getting a local copy of 11.x.x.x

(01 Jun '12, 14:31) Curlew

Possibly you could use request logging of operations ("dbsrv11 -zr ...") to check if the syntax NativeDB is sending is different from that of other SQL clients?

(02 Jun '12, 06:21) Volker Barth
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×143
×95
×31
×9
×3

question asked: 01 Jun '12, 11:54

question was seen: 3,053 times

last updated: 03 Jun '12, 08:53