Welcome, Guest
Username: Password: Remember me
General discussions, feature requests for CodeTyphon Project and discussions that don't fit in any of the other specific CodeTyphon forum categories.
  • Page:
  • 1

TOPIC:

DatabaseError Cannot open a non-select statement 11 years 4 months ago #4139

  • Pierre Joubert
  • Pierre Joubert's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 13
  • Thank you received: 0
Hi

In a console application that uses MySQL, I get a "DatabaseError Cannot open a non-select statement" when I try to open a Select statement. I am using CodeTyphon 4.3.

Here is the console output:
Connected
stSelect

Here is a summary of the code:
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils, CustApp,
{ you can add units after this }
mimemess, mimepart, smtpsend, synachar, // Synapse
// ZConnection, ZDataset, Interfaces, // Zeosdbo - after adding pl_zeosdbocomp you have to add interfaces
mysql55conn, sqldb, // MySQL
pl_dcpcomp, DCPrijndael, dcpsha256;

var
cnMain : TMySQL55Connection;
QryGeneral : TSqlQuery;
QrySync : TSqlQuery;
T_Transact : TSQLTransaction;

cnMain := TMySQL55Connection.Create(nil);
T_Transact := TSQLTransaction.Create(nil);
QryGeneral := TSQLQuery.Create(nil);
QrySync := TSQLQuery.Create(nil);

Try
With cnMain Do
Begin
HostName := 'ipadres';
DatabaseName := 'dbname';
UserName := 'username';
Password := 'password';
End;


//Attempt connection
Try
cnMain.Open;
Except
On E: Exception Do
Begin
writeln('CONNECTION ERROR: Please verify your connection settings.');
Terminate;
End;
End;

if cnMain.Connected then
begin
writeln('Connected');
end;

cnMain.Transaction := T_Transact;

QryGeneral.DataBase := cnMain;
QrySync.DataBase := cnMain;

QryGeneral.Close;
QryGeneral.SQL.Clear;
QryGeneral.SQL.Add('Select COUNT(*) as SlaveThreads from information_schema.processlist where user = ''system user'' ');

QryGeneral.Prepare;
writeln(QryGeneral.StatementType);

QryGeneral.Open;


This code is based on a previous Zeos based application, the previous application worked without a problem.

Please help.

Please Log in or Create an account to join the conversation.

DatabaseError Cannot open a non-select statement 11 years 4 months ago #4140

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Please Sir
test this post
PilotLogic Architect and Core Programmer
The following user(s) said Thank You: Pierre Joubert

Please Log in or Create an account to join the conversation.

DatabaseError Cannot open a non-select statement 11 years 4 months ago #4146

  • Pierre Joubert
  • Pierre Joubert's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 13
  • Thank you received: 0
Hi Sternas

Thank you that helped, however the next problem cropped up.

The select
QryGeneral.SQL.Add('Select COUNT(*) as slaveshreads from information_schema.processlist where user = ''system user'' ');
runs and I can see it in the mysql.log.

However the debugger give the following message:
Field not found: "slaveshreads"
as response to:
If QryGeneral.FieldByName('slaveshreads').AsInteger <> 2 Then

Please Log in or Create an account to join the conversation.

DatabaseError Cannot open a non-select statement 11 years 4 months ago #4150

  • Pierre Joubert
  • Pierre Joubert's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 13
  • Thank you received: 0
Hi Sternas

The error
Field not found: "slaveshreads"
is also in CT4.2

I tried
QryGeneral.SQL.Add('Select COUNT(*) from information_schema.processlist where user = ''system user'' ');
And
If QryGeneral.Fields[0].AsInteger <> 2 Then
This produced the following error:
List index (0) out of bounds

Please Log in or Create an account to join the conversation.

DatabaseError Cannot open a non-select statement 11 years 4 months ago #4156

  • Pierre Joubert
  • Pierre Joubert's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 13
  • Thank you received: 0
Hi Sternas

Seems as if the
Field not found: "slaveshreads"
problem is coming from:
QryGeneral := TSQLQuery.Create(nil);
QrySync := TSQLQuery.Create(nil);

Please Log in or Create an account to join the conversation.

  • Page:
  • 1