amidamaru
asked on
Problem to write in an Oracle Database
I am using Delphi 5 with an ODBC alias to access an Oracle database. I have no problem to read the informations in a table but the problem is when I want write a number and a name(by parameters), Delphi makes me a DBEngineError. Any ideas?
My Code :
QueryNouvelIntervenant.SQL .Text :=
'INSERT INTO intervenant VALUES(' +':param_num'+ ',' +':param_nom' + ')';
QueryNouvelIntervenant.Par amByName(' param_num' ).AsIntege r := StrToInt(edt_num.Text);
QueryNouvelIntervenant.Par amByName(' param_nom' ).AsString := Edt_nom.Text;
My Code :
QueryNouvelIntervenant.SQL
'INSERT INTO intervenant VALUES(' +':param_num'+ ',' +':param_nom' + ')';
QueryNouvelIntervenant.Par
QueryNouvelIntervenant.Par
Would you please announce some detailed info? such as table structure, detailed error message, etc.
After setting parameters you must use QueryNouvelIntervenant.Exe cSQL not QueryNouvelIntervenant.Ope n?
Ivan
P.S. I am only checking. :-)
Ivan
P.S. I am only checking. :-)
nice check, ivan, and true ;-)
ASKER
@kretzschmar : I also tested as you say but that does not change anything
@merry_prince :
Table intervenant :
Num NUMBER(9)
Nom VARCHAR2(20)
I try to translate from French
Error Message : The project AcceBd.exe makes an exception classes EDBEngineError with message 'Nonapplicable operation '.
@IPCH : I use a
QueryNouvelIntervenant.Pre pare and after a
QueryNouvelIntervenant.Exe cSQL
The exception come from the execsql
it is as if it did not accept the string from the parameter, when I write
'INSERT INTO intervenant VALUES(:param_num,''test'' )';
he can write in the table without problems
It's a nightmare
@merry_prince :
Table intervenant :
Num NUMBER(9)
Nom VARCHAR2(20)
I try to translate from French
Error Message : The project AcceBd.exe makes an exception classes EDBEngineError with message 'Nonapplicable operation '.
@IPCH : I use a
QueryNouvelIntervenant.Pre
QueryNouvelIntervenant.Exe
The exception come from the execsql
it is as if it did not accept the string from the parameter, when I write
'INSERT INTO intervenant VALUES(:param_num,''test''
he can write in the table without problems
It's a nightmare
well, ok,
you must define the paramtype of youe second
parameter to a stringtype, guessing the type
is currently unknown.
meikl ;-)
you must define the paramtype of youe second
parameter to a stringtype, guessing the type
is currently unknown.
meikl ;-)
ASKER
@kretzschmar :
QueryNouvelIntervenant.SQL .Text :=
'INSERT INTO intervenant VALUES (:param_num, :param_nom)';
QueryNouvelIntervenant.Par ams[0].Dat aType := ftInteger;
QueryNouvelIntervenant.Par ams[1].Dat aType := ftString;
I try this but no change always this ****** exception
it makes me crazy ^_^
QueryNouvelIntervenant.SQL
'INSERT INTO intervenant VALUES (:param_num, :param_nom)';
QueryNouvelIntervenant.Par
QueryNouvelIntervenant.Par
I try this but no change always this ****** exception
it makes me crazy ^_^
Can you use another param name instead of param_nom? Please try it.
If still mistake, would you please list the source codes related to database operations?
If still mistake, would you please list the source codes related to database operations?
ASKER
@kretzschmar :
QueryNouvelIntervenant.SQL .Text :=
'INSERT INTO intervenant VALUES (:param_num, :param_nom)';
QueryNouvelIntervenant.Par ams[0].Dat aType := ftInteger;
QueryNouvelIntervenant.Par ams[1].Dat aType := ftString;
I try this but no change always this ****** exception
it makes me crazy ^_^
QueryNouvelIntervenant.SQL
'INSERT INTO intervenant VALUES (:param_num, :param_nom)';
QueryNouvelIntervenant.Par
QueryNouvelIntervenant.Par
I try this but no change always this ****** exception
it makes me crazy ^_^
ASKER
Sorry i make a mistake and resend my old message oops !
procedure TForm1.FormCreate(Sender: TObject);
begin
basename := 'BaseOracle';
Database1.DatabaseName := basename;
Database1.Open;
//requête affichant tous les intervenants
QueryAfficheIntervenants.D atabaseNam e := basename;
QueryAfficheIntervenants.S QL.Text :=
'SELECT num AS "Numéro",nom FROM intervenant ORDER
BY num';
QueryNouvelIntervenant.Dat abaseName := basename;
QueryNouvelIntervenant.SQL .Text :=
'INSERT INTO intervenant VALUES (:param_num, :p_nom)';
QueryNouvelIntervenant.Par ams[0].Dat aType := ftInteger;
QueryNouvelIntervenant.Par ams[1].Dat aType := ftString;
procedure TForm1.Bt_AjoutClick(Sende r: TObject);
begin
QueryNouvelIntervenant.Par amByName ('param_num').AsInteger := StrToInt(edt_num.Text);
QueryNouvelIntervenant.Par amByName(' p_nom').As String := Edt_nom.Text;
QueryNouvelIntervenant.Pre pare;
QueryNouvelIntervenant.Exe cSQL;
//this quey
QueryAfficheIntervenants.C lose;
QueryAfficheIntervenants.O pen;
procedure TForm1.FormCreate(Sender: TObject);
begin
basename := 'BaseOracle';
Database1.DatabaseName := basename;
Database1.Open;
//requête affichant tous les intervenants
QueryAfficheIntervenants.D
QueryAfficheIntervenants.S
'SELECT num AS "Numéro",nom FROM intervenant ORDER
BY num';
QueryNouvelIntervenant.Dat
QueryNouvelIntervenant.SQL
'INSERT INTO intervenant VALUES (:param_num, :p_nom)';
QueryNouvelIntervenant.Par
QueryNouvelIntervenant.Par
procedure TForm1.Bt_AjoutClick(Sende
begin
QueryNouvelIntervenant.Par
QueryNouvelIntervenant.Par
QueryNouvelIntervenant.Pre
QueryNouvelIntervenant.Exe
//this quey
QueryAfficheIntervenants.C
QueryAfficheIntervenants.O
ASKER
Can it be possible that the driver odbc is not correct ?
I use Microsoft ODBC for Oracle
I use Microsoft ODBC for Oracle
Please create an ODBC db alias which driver is Oracle ODBC Driver. OK?
ASKER
Wonderfull, it ok, thank you very much ^_^
But I don't understand why it does not work with the driver from microsoft ? It's not normal that they make driver and they don't work !!!
But I don't understand why it does not work with the driver from microsoft ? It's not normal that they make driver and they don't work !!!
do you know any app from microsoft,
which works properly?
glad you got it work,
never gueesed that there is the problem.
merry_prince should be graded,
good work
meikl ;-)
which works properly?
glad you got it work,
never gueesed that there is the problem.
merry_prince should be graded,
good work
meikl ;-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If my memory isn't wrong. It maybe cause by the old ODBC driver type not support your oracle client program. Microsoft ODBC for Oracle only can support the version less than Oracle8.1.5. If want to support the version high than oracle 8.1.6, you should use Oracle ODBC Driver.
Just suggest you should format the code as below. It's benefit for reading.
procedure TForm1.FormCreate(Sender: TObject);
begin
basename := 'BaseOracle';
Database1.DatabaseName := basename;
Database1.Open;
//requjte affichant tous les intervenants
with QueryAfficheIntervenants, SQL do begin
DatabaseName := basename;
Add('SELECT num AS "Numiro",nom FROM intervenant ORDER BY num');
end; {with}
with QueryNouvelIntervenant, SQL do begin
DatabaseName := basename;
Add('INSERT INTO intervenant VALUES (:param_num, :p_nom)');
end; {with}
procedure TForm1.Bt_AjoutClick(Sende r: TObject);
begin
with QueryNouvelIntervenant do begin
ParamByName ('param_num').AsInteger := StrToInt(edt_num.Text);
ParamByName('p_nom').AsStr ing := Edt_nom.Text;
ExecSQL;
end; {with}
//this quey
with QueryAfficheIntervenants do begin
Close;
Open;
end; {with}
Just suggest you should format the code as below. It's benefit for reading.
procedure TForm1.FormCreate(Sender: TObject);
begin
basename := 'BaseOracle';
Database1.DatabaseName := basename;
Database1.Open;
//requjte affichant tous les intervenants
with QueryAfficheIntervenants, SQL do begin
DatabaseName := basename;
Add('SELECT num AS "Numiro",nom FROM intervenant ORDER BY num');
end; {with}
with QueryNouvelIntervenant, SQL do begin
DatabaseName := basename;
Add('INSERT INTO intervenant VALUES (:param_num, :p_nom)');
end; {with}
procedure TForm1.Bt_AjoutClick(Sende
begin
with QueryNouvelIntervenant do begin
ParamByName ('param_num').AsInteger := StrToInt(edt_num.Text);
ParamByName('p_nom').AsStr
ExecSQL;
end; {with}
//this quey
with QueryAfficheIntervenants do begin
Close;
Open;
end; {with}
ASKER
Thank you very much for answer so quickly ^_^
'INSERT INTO intervenant VALUES(:param_num,:param_n
best would be also to qualify the correspondending fields
like
'INSERT INTO intervenant (FieldName1, FieldName2) VALUES(:param_num,:param_n
whereas fieldnameX must be replaced with your real fieldnames
meikl ;-)