Subject Re: [IBO] Two or more tables...
Author Marcelo Machado
Helen,

in the PACIENTEtib_query i have:

SELECT * ///THE FIELD IS ENDP (Sorry)
FROM PACIENTE

____________________

PLAN (PACIENTE NATURAL)

_______________________

Keylink

PACIENTE.CODIGO

_______________________

in the PATOLOGIAtib_query i have:

SELECT *
FROM PATOLOGIA
FOR UPDATE
_______________________

PLAN (PATOLOGIA INDEX (CODIGO))

_______________________

Keylink

PATOLOGIA.PATOCHAVE

________________________

Masterlink

PATOLOGIA.CODIGO=PACIENTE.CODIGO


__________________________________________

and why the PACIENTE works and PATOLOGIA dont?


Marcelo






Helen Borrie <helebor@...> wrote:
Marcelo,

At 03:16 PM 4/12/2005 -0800, you wrote:
>Dear Helen,
>
>
>Helen Borrie <helebor@...> wrote:
>
>1) What are the two SQL statements?

There is total confusion here. Originally you said
"I´m using a tib_query for each table"

To use tib_query, you must have a SELECT statement in the SQL property, for
example:

select
CODIGO,
NOME,
END, <-------------------- see my note about this
FONE
from PACIENTE

The SELECT statement defines your dataset, i.e. the structure of each row
that is returned to the ib_query.

[[ Note about END: you should check this table to see whether the
identifier of this column is "END". The word END (without double quotes)
is not a legal word for an identifier in Firebird, because it is an SQL
keyword, reserved word. ]]

If you don't have a SELECT statement in your tib_query, then the query is
"nothing", undefined.


> 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

These would be OK if you actually had anything defined as contents of the
dataset!


>
> > 3) Do you open the datasets in your code?
>
> ( I didn't understand )


The method Open is used to activate the ib_query. Underneath, it causes a
lot of things to happen.

-- First it checks whether the database connection named in the ib_query's
IB_Connection property is connected.

-- If so, it then it checks whether the transaction named in the ib_query's
IB_Transaction property is started. If not, it attempts to start it.

-- Next, it checks whether the SELECT statement in the SQL property is
prepared. If not, it prepares the statement.

-- It does some more checks and, finally, it submits the statement to the
database.

You code needs to open the datasets if they are not active. Somewhere (in
an event related to what you want your application to do) you will need a
block of code similar to this:

with MyQuery do
begin
if not Active then Open;
...
end;

Helen


---------------------------------
Yahoo! DSL Something to write home about. Just $16.99/mo. or less

[Non-text portions of this message have been removed]