-2

What is wrong with that command I'm trying to use? Why is it not working? I could rage endlessly with hSQL... in combination with openoffice_base (because my employer is a cheap son of a) one day it'll kill me..

Explanation:

  • Table Suppliers -> Supp
  • Table ContactPerson -> Con
  • Table IT_Con_Supp

I want to have a intermediate table because one company can have 0 or many contact-persons and 0 or many contact-persons can belong to one company.

for the love of god - I found this page http://www.w3schools.com/sql/sql_foreignkey.asp

https://i.stack.imgur.com/1i59x.png

but not a single command is working in base - I assume it's coz base is hsqldb and not sql?

Please help me...

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

0

with the SQL statement add in:

USE 'DATABASE_NAME'

then the rest of your query. It might be that you do not have the proper database specifically specified so the query is trying to run against a sys database.

Zi0n1
  • 594
  • 2
  • 5
  • 16
  • Thanks for ur suggestions. – user6718396 Aug 15 '16 at 19:02
  • Thanks for ur suggestions. Zion1 - I didint quite catch what you mean.. PS: Zion, it's not a query think more of a create table command. like: "CREATE TABLE Orders ( O_Id int NOT NULL, OrderNo int NOT NULL, P_Id int, PRIMARY KEY (O_Id), FOREIGN KEY (P_Id) REFERENCES Persons(P_Id) )" But for some reason I cant get it to work :( – user6718396 Aug 15 '16 at 19:05
  • Not sure if it is possible but can you go into tools > SQL > command to execute box write the script except using the additional "USE" statement. Open Office is a both awesome and finicky at times. – Zi0n1 Aug 15 '16 at 19:25
0

Try

ALTER TABLE "IT_Con_Supp"
ADD FOREIGN KEY("FK_SUPP") REFERENCES "Supp"("ID")

I haven't used Office Base much but I believe it works a bit like Postgres in terms of case sensitivity.

  • it didnt work out. If I copy/paste ur command I get this message: "1: Column not found: FK_SUPP in statement [ALTER TABLE "IT_Con_Supp" ADD FOREIGN KEY("FK_SUPP")]" I'm really frustrated with that issue... – user6718396 Aug 15 '16 at 19:11
  • You will have to type the field name exactly as the case is in the table. I could not know how it was spelt. I just copied your code. –  Aug 15 '16 at 19:54