Hello list,
I'm a postgres-newbie with a maybe silly question.
I'm working on a SuSE-Linux 9.1 with PostgreSQL 7.4.6 with PostGIS 0.9.
My problem is, that I can't insert data into a table because I get the
error, that there is no corresponding value in the referenced field.
But when I query the referenced table with the value, I get a result.
Both fields are of the same type and length (varchar(10)).
1st Table:
CREATE TABLE "T_OEPNV_HS T"
(
"HST_ID" serial,
"HST_NR" varchar(10),
"HST_NAME" varchar(256),
"HST_COORD" public.geometry ,
CONSTRAINT "T_OEPNV_HST_pk ey" PRIMARY KEY ("HST_ID"),
CONSTRAINT "T_OEPNV_HST_un r" UNIQUE ("HST_NR"),
CONSTRAINT "enforce_geotyp e_HST_COORD" CHECK geometrytype("H ST_COORD")
= 'POINT'::text OR "HST_COORD" IS NULL,
CONSTRAINT "enforce_srid_H ST_COORD" CHECK srid("HST_COORD ") = 31467
) WITH OIDS;
2nd Table:
CREATE TABLE "T_OEPNV_HST_LI N" (
"HST_LIN_ID " serial primary key,
"HST_NR" varchar(10) references "T_OEPNV_HS T" on update cascade,
"LIN_U_NAME " varchar(255) references "T_OEPNV_UNTERN EHMEN" ("U_NAME")
on update cascade,
"LIN_KAT" varchar(50) NOT NULL,
"LIN_NAME_O " varchar(50) NOT NULL,
"LIN_NAME_I " varchar(50) NOT NULL
);
The problem is related to the fields "HST_NR" in the two tables.
For Example:
insert into "T_OEPNV_HST_LI N" ("HST_NR", "LIN_U_NAME ", "LIN_KAT",
"LIN_NAME_O ", "LIN_NAME_I ") values ('10001', 'Stadtwerke Marburg GmbH',
'Bus', 'C', '11103');
does not work while
select * from "T_OEPNV_HS T" where "HST_NR"='10001 ';
returns
HST_ID | HST_NR | HST_NAME | HST_COORD
--------+--------+----------+------------------------------------------
23555 | 10001 | Afföller | SRID=31467;POIN T(3483856.148 5632168.48)
(1 Zeile)
So, I can't understand, why I get the error, that I can't insert the
data into "T_OEPNV_HST_LI N" because there is no HAST_NR='10001' in
"T_OEPNV_HS T".
I hope, someone can help...
Cheers,
Bjoern
--
momatec GmbH www.momatec.de
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend 3 5242
On Thu, Nov 11, 2004 at 08:13:16AM +0100, Bjoern Platzen wrote: insert into "T_OEPNV_HST_LI N" ("HST_NR", "LIN_U_NAME ", "LIN_KAT", "LIN_NAME_O ", "LIN_NAME_I ") values ('10001', 'Stadtwerke Marburg GmbH', 'Bus', 'C', '11103'); does not work while select * from "T_OEPNV_HS T" where "HST_NR"='10001 '; returns HST_ID | HST_NR | HST_NAME | HST_COORD --------+--------+----------+------------------------------------------ 23555 | 10001 | Aff?ller | SRID=31467;POIN T(3483856.148 5632168.48) (1 Zeile)
The foreign key constraint on T_OEPNV_HST_LIN .HST_NR references the
wrong field in T_OEPNV_HST. Since you didn't specify a field, it's
referencing the primary key HST_ID instead of HST_NR.
--
Michael Fuhr http://www.fuhr.org/~mfuhr/
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
=?iso-8859-1?Q?Bj=F6rn_Pla tzen?= <bj************ @momatec.de> writes: CREATE TABLE "T_OEPNV_HS T" ( "HST_ID" serial, "HST_NR" varchar(10), ... CONSTRAINT "T_OEPNV_HST_pk ey" PRIMARY KEY ("HST_ID"), CONSTRAINT "T_OEPNV_HST_un r" UNIQUE ("HST_NR"), ... CREATE TABLE "T_OEPNV_HST_LI N" ( "HST_NR" varchar(10) references "T_OEPNV_HS T" on update cascade, );
So, I can't understand, why I get the error, that I can't insert the data into "T_OEPNV_HST_LI N" because there is no HST_NR='10001' in "T_OEPNV_HS T".
Since you wrote the REFERENCES clause without mentioning any particular
column name, it defaults to referencing the primary key of
"T_OEPNV_HS T", that is, "HST_ID".
When I try the example I get
ERROR: insert or update on table "T_OEPNV_HST_LI N" violates foreign key constraint "T_OEPNV_HST_LI N_HST_NR_fkey"
DETAIL: Key (HST_NR)=(10001 ) is not present in table "T_OEPNV_HS T".
The error message is mentioning the referencing column not the
referenced column. I recall that we decided this was less confusing
than the other choice, but I'm not sure why we thought that.
Particularly now that the FK constraint name includes the referencing
column name by default, I wonder if we ought to switch.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly
From: "Björn Platzen" <bj************ @momatec.de> "HST_NR" varchar(10) references "T_OEPNV_HS T" on update cascade,
try:
"HST_NR" varchar(10) references T_OEPNV_HST(HST _NR) on update cascade,
gnari
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Victor M. |
last post by:
Hello everyone.
I am a newbie to Oracle 8 so please be patient and thanks for your time.
The problem is the above mentioned error. I have two databases
successully created using SQL*Plus 8.03. They are as follows:
Create Table EMPLOYEES
(
FName VARCHAR(15) NOT NULL,
MINIT CHAR,
|
by: kungfukittens |
last post by:
Hi, question how do you insert from VB.net to a foxpro date field
eg insert into temp values('07/31/05', 2)
i keep getting a type mismatch error on the date field
temp table
date date
no integer :confused:
--
|
by: Chris |
last post by:
I think I already know that the answer is that this can't be done, but
I'll ask anyways.
Suppose you want to use an RDBMS to store messages for a threaded
message forum like usenet and then display the messages. A toy table
definition (that I've tried to make standards compliant) might look
like:
create table messages (
message_id integer,
|
by: mstery |
last post by:
I have a report generated via an ID selection made in a dropdown on a
form. The report filters by an on click event in a preview report
button on the form. Everything in the report, including subreports,
filters perfectly, with the exception of a running sum DLookup field on
the main report. This field looks up a value in a foreign table. I'm
not clear where I'm supposed to be filtering this field, since it
obviously isn't picking up the...
|
by: trint |
last post by:
I am trying to insert a record, but I have to get an automatically
created identity field at the same time to do this.
string strSQL2 = "INSERT INTO tblTravelDetail(MemberID, " +
" TravelEventID, " +
" CreatedDateTime, " +
" Operator) " +
"VALUES ('" + TxtMLV.Text.Trim() + "', " +
" '" + TxtEventID+ "', " +
" '" + TxtDATE.Text.Trim() + "', " +
| |
by: 4partee |
last post by:
I'm trying to import a csv file with a PHP procedure. However, some of the
lines in the csv file have missing values.
When this command is given to mysql:
insert tablex values
('2006-01-06','IHS',127,,,,,,,3.45,-0.33,12.82,,,,,,40.64,17.41,79.22,,,,,,3,3,3.00,15,0.51,0.40,0.38,3904,,,498.24,,,,,,71.03,,,,,,7.098505e-03,,,,,,2.87,,,,,,0.34,,,,,,1.01,1.07,,
)
Here is the error message:
|
by: weird0 |
last post by:
I have two tables accounts and ATM and i am trying to insert a tuple
in ATM with accountId as foreign key. But even this simple work,I
encounter the following error:
The INSERT statement conflicted with the FOREIGN KEY constraint
"FK_ATM_Accounts". The conflict occurred in database "G:\DOCUMENTS AND
SETTINGS\ADMINISTRATOR\DESKTOP\VERSION2\APP_DATA\BANKINGDB.MDF", table
"dbo.Accounts", column 'acc_Id'.
please sugggest how can i fix...
|
by: assgar |
last post by:
Hi
I am having problem with my loping.
I don't know if I have chosen the correct approach.
GOAL:
I need to insert into a table event types for a specific date range.
The calendar the event type is displayed on is divided into
15 minutes time intervals
|
by: jarea |
last post by:
I have read quite a bit about this error but I have yet to find the solution to my problem.
I am trying to execute the following mysql statement:
alter table line_items
add constraint fk_line_item_products
foreign key (product_id) references products(id)
I have also tried the following statement with the same result:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |