Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tables not forming a relationship properly
Message
From
16/07/2003 11:13:15
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
16/07/2003 09:57:08
Brian Weber
Ohio Department of Development
Columbus, Ohio, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00810631
Message ID:
00810677
Views:
21
>I'm still a little new to FoxPro, and having issues linking tables together. I have two tables, set up with an appropriate automaticly defined primary key(numerical field, with a default value of "recno()" ), and FoxPro wont let me create any relationship between the two table except a one to one relationship, which is not what i want, and besides that it doesnt work right. I need a one to many relationship. On top of this, FoxPro is working just fine pulling data from the one table, yet will only pull one record from the other(its not updating the form at all), despite the query changing for both tables. Im not sure really how to explain it clearly, but thats the best way to describe it i can come up with. Any suggestions on how to fix this would be welcome
> Brian

The relationship is from index to index.

If you drag a PK index to another PK (or CK) index, you will get a one-to-one relationship.

If you drag a PK index to a regular index, you will get a one-to-many index.

Remember, always drag from the parent to the child.


I agree with Mark, that it is better not to use recno() as the PK.

I am adding my function, which gets a serial number from a table.

HTH,

Hilmar.
*************************************************************************
FUNCTION SerialNumber(tcSequenceName)
	* by Hilmar Zonneveld
	* Generate a serial number. Uses a table that you should create with:
	* open database <databasename>
	* create table serialnumber (sequence C(30) primary key, nextnum I)
	* local lnOldSelect
	* lnOldSelect = select()
	* select serialnumber
	* select (lnOldSelect)
	tcSequenceName = upper(tcSequenceName)
	local lnOldSelect
	lnOldSelect = select()
	if used("serialnumber")
		select serialnumber
	else
		select 0
		use serialnumber
	endif
	set order to sequence
	if not seek(padr(tcSequenceName, len(sequence)))
		append blank
		replace sequence with tcSequenceName, nextnum with 1
	endif
	local lnReturnValue
	if lock()
		lnReturnValue = nextnum
		replace nextnum with nextnum + 1
		unlock
	else
		lnReturnValue = -1
	endif
	select (lnOldSelect)
	return lnReturnValue
ENDFUNC
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform