Wiki Home

Set Skip


Namespace: People
Set Skip is used when a relationship between tables exists. A relationship must be established before issuing the Set Skip statement followed by the aliases of the child tables.
Set Skip synchronizes the parent records as you navigate child records.
Set Skip returns unexpected results when the data is tied to a grid in VFP 6 SP3 and should be avoided for now.
A browse or grid on a parent table with a set skip in effect will show virtual parent records for each child record beyond the first child. These virtual parent records will show *'s for all parent table fields. The * records are not real parent records, they are place holders to allow all of the children to be processed. It makes no difference if there are any child recrods in the grid or browse or not.
According to the Hackers Guide:
(SET SKIP) turns a relation into a one-to-many relation. It indicates that issuing SKIP in the parent should proceed to the next record in the child and not go on to the next parent record until there are no more child records for this parent. This allows you to process all the children for a given parent. SET SKIP TO by itself changes the relation back to one-to-one.

According to the Microsoft Knowledge Base:
ID: Q158240 Offsite link to http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q158240

3.00 3.00b 5.00 WINDOWS kbprg kbprb

The information in this article applies to:

Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 6.0

SYMPTOMS
Issuing the SET RELATION TO command repeated times within a program causes inconsistent results to appear in Browse windows and in Grids. While cycling through the program, some iterations do not show the proper one-to- many relationships between records in the Browse window or Grid object. The placeholder characters (asterisks) in the child record appear in different columns when you repeatedly executes the program.

STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.

create database Test
create table Clients;
  ( iClKey i not null primary key, ;
  cClId c(10) not null unique, ;
  cClNam c(20) )

create table Orders;
  ( iOdKey i not null primary key, ;
  iOdClKey i references Clients, ;
  cOdId c(10) not null unique, ;
  cOdDsc c(40) )

insert into clients values (1, "ABC", "ABC Broadcasting")
insert into clients values (2, "BAU", "Bananns are us" )
insert into clients values (3, "GCI", "Garbage Cans Inc.")
insert into clients values (4, "LCM", "Three funny guys")
insert into clients values (5, "MB", "Five funny guys")
* clients

insert into orders values( 1, 1, "001", "Modem" )
insert into orders values( 2, 1, "002", "Cable" )
insert into orders values( 3, 2, "003", "Monitor" )
insert into orders values( 4, 2, "004", "Keyboard" )
insert into orders values( 5, 2, "005", "Cpu" )
insert into orders values( 6, 4, "006", "Mouse" )
insert into orders values( 7, 4, "007", "Ram" ) select clients
set order to iOdClKey in orders
set relation to iClKey into orders


? "A. Without SET SKIP:"
list cClId, cClNam, orders.cOdId, orders.cOdDsc ? "B. With SET SKIP:"
set skip to Orders
list cClId, cClNam, orders.cOdId, orders.cOdDsc ? "C. SQL using left join:"
select cClId, cClNam, cOdId, cOdDsc ;
from clients ;
left join orders on iClKey = iOdClKey ;
into cursor sqlc
list ? "D. SQL using inner join:"
select cClId, cClNam, cOdId, cOdDsc ;
from clients ;
join orders on iClKey = iOdClKey ;
into cursor sqld
list return

Contributors: Kendra Wien Steven Black Carl Karsten John Koziol
Category Code Samples
( Topic last updated: 1999.11.19 03:46:04 AM )