TOraReference

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Alexandre de Souza

TOraReference

Post by Alexandre de Souza » Sat 18 Mar 2006 13:47

How to use the Type TOraReference or Type ref for post in Query?

Alex
Posts: 655
Joined: Mon 08 Nov 2004 08:39

Post by Alex » Mon 20 Mar 2006 14:42

Please pay attention to our Refs demo project. If some questions remain open please describe them more detailed or, if it is possible, send us small demo project with scripts to create server side objects. Also specify your Oracle client/server versions and ODAC version.
Send a message to our ODAC support e-mail address.

Alexandre de Souza

TOraReferenceField

Post by Alexandre de Souza » Fri 24 Mar 2006 16:28

Hi, my problem is: I have 2 tables, 1 with the reference of other.
Exemple:
create type course_t as object
(
course_name varchar(20)
...
);
create table tb_course of course_t;

Create type peoble as object
(
cod Integer,
name varchar(20),
course ref course_t
);

create table tb_peoble of peoble;


I need to record the field type course with the reference.

My Code.

...
querypeoblecourse :TOrareferencefield;
...

query.sql.text := 'select ref(a) from tb_course where course_name = ''...'''

querypeoblecourse.assign(query.fields[0]);
querypeoble.post;

but it generates an error

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Thu 06 Apr 2006 08:39

You can't modify REF fields in SELECT query. To assing value to REF field you can write INSERT or UPDATE query with parameter of type 'Reference'.
To get value from REF field you can use GetRef(FieldName) method of TOraDataSet.

Examle:
query.sql.text := 'select ref(a) REF_A from tb_course where course_name = ''...''';
query.open;

OraSQLUpdate.SQL.Text :=
'UPDATE tb_peoble SET COURSE = :COURSE WHERE COD = :COD';

OraSQLUpdate.ParamByName('cod').AsInteger := 1;
OraSQLUpdate.ParamByName('COURSE').AsRef := query.GetRef('REF_A');
OraSQLUpdate.Execute;

Alexandre de Souza

REF

Post by Alexandre de Souza » Sun 16 Apr 2006 17:23

Tks challenger!! you it helped me sufficiently.

Post Reply