Well - yes - you will need the Id of the row with that vendor id. The problem with vendor ids is, that you don't have much influence on them.

Of course you can write your new row into the child table without first "fetching" the parent id. Like in:

insert into child (parentid, vendorid, column1, ...)
select id, vendorid, 'Value', ...
from parent where vendorid = 'theVendorId';

This does it all in one statement. If you receive a sqlcode=100 then, the vendor id doesn't exist in the parent table.

Well, you can also use the vendor id in the child table as a direkt foreign key to the parent table - as long as the vendor id of the parent table is a unique key.

I wouldn't consider this as best practice - but technically it's possible.

HTH
Daniel


Am 11.02.2025 um 15:25 schrieb DEnglander--- via MIDRANGE-L <midrange-l@xxxxxxxxxxxxxxxxxx>:

Thank you.

That is what I thought.

The reason I asked is this: I have a table that I would like to have
function as the Parent. I want to possibly have other tables have
referential integrity with it. If I have an Identity number as the key [as
opposed to a Vendor Number for example], then how would I set something
like: A Child table's Vendor Number column must have a value that exists
in the Parent's Vendor Number column. Unless I'm missing something, it's
not as easy using Identity columns only, since you first have to get the
Identity column of the Vendor whose associated row you want to write in
the Child table. Sounds like extra steps to me, but maybe it's worth it?

Thanks again,

Doug



"CONFIDENTIALITY NOTICE: This e-mail transmission (and/or the attachments accompanying it) contain confidential information belonging to the sender. The information is intended only for the use of the intended recipient. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on the contents of the information is strictly prohibited. Any unauthorized interception of this transmission is illegal under the law. If you have received this transmission in error, please promptly notify the sender by reply e-mail, and then destroy all copies of the transmission."
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.