Subject | Re: [IBO] Two or more tables... |
---|---|
Author | Marcelo Machado |
Post date | 2005-12-04T23:16:19Z |
Dear Helen,
Helen Borrie <helebor@...> wrote:
1) What are the two SQL statements?
SET SQL DIALECT 3;
SET NAMES WIN1252;
/// Table PACIENTE
CREATE GENERATOR GEN_PACIENTE_ID;
CREATE TABLE PACIENTE (
CODIGO INTEGER NOT NULL,
NOME VARCHAR (50),
END VARCHAR (50),
FONE INTEGER);
/// Primary Keys
ALTER TABLE PACIENTE ADD PRIMARY KEY (CODIGO);
/// Triggers
CREATE TRIGGER PACIENTE_BI FOR PACIENTE
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.CODIGO IS NULL) THEN
NEW.CODIGO = GEN_ID(GEN_PACIENTE_ID,1);
END
^
SET TERM ; ^
(This works well)
-------------------------------------------------------
SET SQL DIALECT 3;
SET NAMES WIN1252;
/// Table PATOLOGIA
CREATE GENERATOR GEN_PATOLOGIA_ID;
CREATE TABLE PATOLOGIA (
PATOCHAVE INTEGER NOT NULL,
TRAUMA VARCHAR(50),
ESCOLIOSE VARCHAR(50),
CODIGO INTEGER);
/// Primary Keys
ALTER TABLE PATOLOGIA ADD PRIMARY KEY (PATOCHAVE);
/// Foreign Keys
ALTER TABLE PATOLOGIA ADD CONSTRAINT CODIGO FOREIGN KEY (CODIGO) REFERENCES PACIENTE (CODIGO);
/// Triggers
/* Trigger: PATOLOGIA_BI */
CREATE TRIGGER PATOLOGIA_BI FOR PATOLOGIA
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.PATOCHAVE IS NULL) THEN
NEW.PATOCHAVE = GEN_ID(GEN_PATOLOGIA_ID,1);
END
^
SET TERM ; ^
2) What are the Keylinks of the two sets?
/// keylink for PACIENTE
PACIENTE.CODIGO
/// keylink for PATOLOGIA
PATOLOGIA.PATOCHAVE
/// masterlink for PATOLOGIA
PATOLOGIA.CODIGO=PACIENTE.CODIGO
3) Do you open the datasets in your code?
( I didn't understand )
Marcelo
---------------------------------
Yahoo! Personals
Let fate take it's course directly to your email.
See who's waiting for you Yahoo! Personals
[Non-text portions of this message have been removed]
Helen Borrie <helebor@...> wrote:
1) What are the two SQL statements?
SET SQL DIALECT 3;
SET NAMES WIN1252;
/// Table PACIENTE
CREATE GENERATOR GEN_PACIENTE_ID;
CREATE TABLE PACIENTE (
CODIGO INTEGER NOT NULL,
NOME VARCHAR (50),
END VARCHAR (50),
FONE INTEGER);
/// Primary Keys
ALTER TABLE PACIENTE ADD PRIMARY KEY (CODIGO);
/// Triggers
CREATE TRIGGER PACIENTE_BI FOR PACIENTE
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.CODIGO IS NULL) THEN
NEW.CODIGO = GEN_ID(GEN_PACIENTE_ID,1);
END
^
SET TERM ; ^
(This works well)
-------------------------------------------------------
SET SQL DIALECT 3;
SET NAMES WIN1252;
/// Table PATOLOGIA
CREATE GENERATOR GEN_PATOLOGIA_ID;
CREATE TABLE PATOLOGIA (
PATOCHAVE INTEGER NOT NULL,
TRAUMA VARCHAR(50),
ESCOLIOSE VARCHAR(50),
CODIGO INTEGER);
/// Primary Keys
ALTER TABLE PATOLOGIA ADD PRIMARY KEY (PATOCHAVE);
/// Foreign Keys
ALTER TABLE PATOLOGIA ADD CONSTRAINT CODIGO FOREIGN KEY (CODIGO) REFERENCES PACIENTE (CODIGO);
/// Triggers
/* Trigger: PATOLOGIA_BI */
CREATE TRIGGER PATOLOGIA_BI FOR PATOLOGIA
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.PATOCHAVE IS NULL) THEN
NEW.PATOCHAVE = GEN_ID(GEN_PATOLOGIA_ID,1);
END
^
SET TERM ; ^
2) What are the Keylinks of the two sets?
/// keylink for PACIENTE
PACIENTE.CODIGO
/// keylink for PATOLOGIA
PATOLOGIA.PATOCHAVE
/// masterlink for PATOLOGIA
PATOLOGIA.CODIGO=PACIENTE.CODIGO
3) Do you open the datasets in your code?
( I didn't understand )
Marcelo
---------------------------------
Yahoo! Personals
Let fate take it's course directly to your email.
See who's waiting for you Yahoo! Personals
[Non-text portions of this message have been removed]