TOraReference
TOraReference
How to use the Type TOraReference or Type ref for post in Query?
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.
Send a message to our ODAC support e-mail address.
TOraReferenceField
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
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
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53
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;
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;