Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: Error during table's edition
Error during table's edition
Posted: 2002/06/17 05:19
 
I need to append & edit rows in Oracle table.
It's a part of code:

form1.datasource1.dataset.insert;
form1.datasource1.dataset.fieldbyName('column').AsInteger:=value;
form1.datasource1.dataset.post;

Datasource1.dataset is a TOCIQuery component.
This code is correct. For edition table I try to usr next code:

form1.datasource1.dataset.insert;
form1.datasource1.dataset.fieldbyName('column').AsInteger:=value;
form1.datasource1.dataset.post;

But I have error NOE129/Q - Can't execute query, undefined key fields.
How I can to correct my problem ?

Thanx. Max.
RE: Error during table's edition
Posted: 2002/06/17 05:44
 
Oh, it's from FAQ ! I'm sorry.
But question #2:
how I can send variable's value in Query
(clause WHERE) ?

RE: Error during table's edition
Posted: 2002/06/18 23:38
 
Query.SQL.Text := 'select col2 from tab1 where col1=aram';
Query.Prepare; // this creates Query.Params
Query.ParamByName('param').Value := 123;
Query.Open;

You can assign sql text at design time and then set Prepared property to True and then back to False. This will create parameter at design time and at runtime you will be able to omit first two lines
RE: Error during table's edition
Posted: 2002/07/02 23:17
 
I did next:

form1.OCIQuery2.text:='select col1 from tab1 wrere col2:=param';

and recieved this error:

[Error] Import_.pas(139): Cannot assign to a read-only property

Where did i do mistake ?
RE: Error during table's edition
Posted: 2002/07/07 23:28
 
Be more attentive!
form1.OCIQuery2.SQL.text:='select col1 from tab1 wrere col2:=param';
^^^
RE: Error during table's edition
Posted: 2002/08/12 09:18
 
OK, this error fixed. Now I have next code:

FORM1.OCIQuery1.SQL.Text:='select col1 from tab1 where col1:=param';
form1.OCIQuery1.Prepare;
form1.OCIQuery1.ParamByName('param').Value:=8;
form1.OCIQuery1.Open;

and next error:
Project MyProj.exe raised exception class EOCINativeError with message
'OCI_ERROR ORA-00920: invalid relational opereator'. Process stopped.
Use Step or Run to continue.

About ORA-00920:
ORA-00920 invalid relational operator
Cause: A search condition was entered with an invalid or missing relational
operator.
Action: Include a valid relational operator such as =, !=, ^=, <>, >, <, >=,
<=, ALL, ANY, [NOT] BETWEEN, EXISTS, [NOT] IN, IS [NOT] NULL, or [NOT]
LIKE in the condition.

Where was my search condition is invalid ?
Col1 is Primary Key, NUMBER.
In SQL/Plus next string:
SELECT col1 FROM tab1 WHERE col1=8
is correct.
RE: Error during table's edition
Posted: 2002/08/12 10:14
 
FORM1.OCIQuery1.SQL.Text:='select col1 from tab1 where col1:=param';
replace := with =
In fact it's not issue for this forum.