Recent

Author Topic: ORA-00933 SQL command not specifically terminated. Zeos or SQLdb + Oracle  (Read 1351 times)

babycode

  • New Member
  • *
  • Posts: 38
Good afternoon sirs,

I have a Data Module with ZConnection and a ZQuery with SQL:

Code: Pascal  [Select][+][-]
  1. select * from COMPANY.clients;

When I activate the query at design or run time I receive the error: "ORA-00933 SQL command not specifically terminated."

I ran the query creating the objects at run time and the problem does not occur:

Code: Pascal  [Select][+][-]
  1. procedure TfrmPrincipal.Button1Click(Sender: TObject);
  2. var
  3.   Connection: TZConnection;
  4.   Query: TZQuery;
  5. begin
  6.   Connection := TZConnection.Create(nil);
  7.   try
  8.     Connection.Protocol := 'oracle';
  9.     Connection.HostName := 'LOCALHOST';
  10.     Connection.Database := 'DATABASE_COMPANY_A';
  11.     Connection.User := 'USER';
  12.     Connection.Password := 'masterpass';
  13.     Connection.LibraryLocation:='oci.dll';
  14.     Connection.Connected := True;
  15.  
  16.     Query := TZQuery.Create(nil);
  17.     try
  18.       Query.Connection := Connection;
  19.       Query.SQL.Text := 'SELECT * FROM COMPANY.clients WHERE CODCLI = 123456';
  20.       Query.Open;
  21.  
  22.       // Processar os dados
  23.       while not Query.EOF do
  24.       begin
  25.         ShowMessage(Query.FieldByName('NAME').AsString);
  26.         Query.Next;
  27.       end;
  28.     finally
  29.       Query.Free;
  30.     end;
  31.  
  32.   finally
  33.     Connection.Free;
  34.   end;
  35. end;  


The problem occurs with both Zeos and SQLdb

dseligo

  • Hero Member
  • *****
  • Posts: 1412
Try without semicolon at the end. In your 2nd example (which works) you don't have semicolon.

babycode

  • New Member
  • *
  • Posts: 38
Hello, thanks for responding. I tried without the semicolon.

dseligo

  • Hero Member
  • *****
  • Posts: 1412
And what if you (in runtime) try:
Code: Pascal  [Select][+][-]
  1. Query.SQL.Text := 'SELECT * FROM COMPANY.clients WHERE CODCLI = 123456';
  2. Query.Open;

Also, try to make one component in runtime, and other one at design time (i.e. create TZConnection at runtime, and put your TZQuery in Datamodule).

Then at runtime (without creating TZQuery):
Code: Pascal  [Select][+][-]
  1.       Query.Connection := Connection;
  2.       Query.SQL.Text := 'SELECT * FROM COMPANY.clients WHERE CODCLI = 123456';
  3.       Query.Open;

If it works when you all create at runtime, I bet the error is somewhere in your code or component setup.

Did you set Connected of TZConnection to false before running application?

Zvoni

  • Hero Member
  • *****
  • Posts: 2744
Errr...... isn't the delimiter to separate schema/namespace from table a colon in Oracle?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

babycode

  • New Member
  • *
  • Posts: 38
It worked without semicolons. I entered the schema before the table name.

jcmontherock

  • Sr. Member
  • ****
  • Posts: 272
In mySQL you should write:

Code: Pascal  [Select][+][-]
  1. Query.SQL.Text := 'SELECT * FROM COMPANY.clients WHERE CODCLI = 123456;';

';' is the default script delimiter.
Windows 11 UTF8-64 - Lazarus 4RC1-64 - FPC 3.2.2

Zvoni

  • Hero Member
  • *****
  • Posts: 2744
In mySQL you should write:

Code: Pascal  [Select][+][-]
  1. Query.SQL.Text := 'SELECT * FROM COMPANY.clients WHERE CODCLI = 123456;';

';' is the default script delimiter.
What's got MySQL to do with the Problem?

There is a saying in Germany: If you can read, you have an advantage.....
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

jcmontherock

  • Sr. Member
  • ****
  • Posts: 272
SQL is a normalized language... and Mysql is by Oracle edited !
Windows 11 UTF8-64 - Lazarus 4RC1-64 - FPC 3.2.2

Zvoni

  • Hero Member
  • *****
  • Posts: 2744
SQL is a normalized language...
Yes... for the core part of SQL. The moment you go into the extended part, that statement becomes useless

Quote
and Mysql is by Oracle edited !
Try to execute the following in MySQL
Code: SQL  [Select][+][-]
  1. SELECT * FROM SomeTable FETCH FIRST 10 ROWS ONLY
  2.  
That SQL will execute in Oracle but not in MySQL

Just because Oracle bought MySQL, doesn't mean a Solution for MySQL will work in Oracle and vice versa
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

jcmontherock

  • Sr. Member
  • ****
  • Posts: 272
Yes, but you can try it...
« Last Edit: July 17, 2024, 11:33:02 am by jcmontherock »
Windows 11 UTF8-64 - Lazarus 4RC1-64 - FPC 3.2.2

 

TinyPortal © 2005-2018