Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-07

Problem with TSQLScript

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Paul

Hello,

I have problem with TSQLScript (?)
Script looks like that

SET TERM ^ ;
CREATE PROCEDURE GET_USER_PRIVILEGES (
USER_ACCOUNT VARCHAR(10))
RETURNS (
RESULT CHAR(1))
AS
BEGIN
FOR
SELECT DISTINCT RDB$PRIVILEGE
FROM RDB$USER_PRIVILEGES
WHERE (RDB$USER = :USER_ACCOUNT)
INTO :RESULT
DO

      BEGIN
           SUSPEND;
      END

END
^
SET TERM ; ^

and the error message looks like that
{...}PrepareStatement
-Dynamic SQL Error
-SQL Error Code = -104
Token unknown - line 11, column 11
-?

line 11 -> INTO :RESULT
column 11-> :

FlameRobin does not have any problems with this piece of code

Any hints ?
Paul

I use Lazarus 1.0.10, Firebird 2.5 on Ubuntu 32bit -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130718/9e688dee/attachment-0001.html>

Reply by email

Reinier Olislagers
to Paul
Paul wrote 39 lines
I have problem with TSQLScript (?) Script looks like that SET TERM ^ ; CREATE PROCEDURE GET_USER_PRIVILEGES ( USER_ACCOUNT VARCHAR(10)) RETURNS ( RESULT CHAR(1)) AS BEGIN FOR SELECT DISTINCT RDB$PRIVILEGE FROM RDB$USER_PRIVILEGES WHERE (RDB$USER = :USER_ACCOUNT) INTO :RESULT DO BEGIN SUSPEND; END END ^ SET TERM ; ^ and the error message looks like that {...}PrepareStatement -Dynamic SQL Error -SQL Error Code = -104 Token unknown - line 11, column 11 -? line 11 -> INTO :RESULT column 11-> : FlameRobin does not have any problems with this piece of code Any hints ? Paul I use Lazarus 1.0.10, Firebird 2.5 on Ubuntu 32bit

Not really, except it's a Firebird error and it would be interested to know what actually gets passed to the Firebird engine (to verify if that runs in FlameRobin).
Perhaps sqldb logging [1] would work for that?

[1]
http://wiki.lazarus.freepascal.org/SqlDBHowto#Troubleshooting:_TSQLConnection_logging

Reply by email

Ludo Brands
to Paul: I have problem with TSQLScript (?) Script looks like that SET TERM ^ ; CREATE PROCEDURE…
Paul wrote 38 lines
Hello, I have problem with TSQLScript (?) Script looks like that SET TERM ^ ; CREATE PROCEDURE GET_USER_PRIVILEGES ( USER_ACCOUNT VARCHAR(10)) RETURNS ( RESULT CHAR(1)) AS BEGIN FOR SELECT DISTINCT RDB$PRIVILEGE FROM RDB$USER_PRIVILEGES WHERE (RDB$USER = :USER_ACCOUNT) INTO :RESULT DO BEGIN SUSPEND; END END ^ SET TERM ; ^ and the error message looks like that {...}PrepareStatement -Dynamic SQL Error -SQL Error Code = -104 Token unknown - line 11, column 11 -? line 11 -> INTO :RESULT column 11-> : FlameRobin does not have any problems with this piece of code Any hints ?

I think you have to set TSQLScript.UseSetTerm:=true. TSQLScript is parsing the script and executes queries one by one and needs to know what the "real" terminator is.
http://www.freepascal.org/docs-html/fcl/sqldb/tsqlscript.usesetterm.html

Ludo

Reply by email

Paul
to Ludo Brands

W dniu 19.07.2013 10:48, Ludo Brands pisze:

Show quoted text 53 lines
On 07/18/2013 05:40 PM, Paul wrote: > Hello, > > I have problem with TSQLScript (?) > Script looks like that > > SET TERM ^ ; > CREATE PROCEDURE GET_USER_PRIVILEGES ( > USER_ACCOUNT VARCHAR(10)) > RETURNS ( > RESULT CHAR(1)) > AS > BEGIN > FOR > SELECT DISTINCT RDB$PRIVILEGE > FROM RDB$USER_PRIVILEGES > WHERE (RDB$USER = :USER_ACCOUNT) > INTO :RESULT > DO > BEGIN > SUSPEND; > END > END > ^ > SET TERM ; ^ > > and the error message looks like that > {...}PrepareStatement > -Dynamic SQL Error > -SQL Error Code = -104 > Token unknown - line 11, column 11 > -? > > line 11 -> INTO :RESULT > column 11-> : > > FlameRobin does not have any problems with this piece of code > > Any hints ? I think you have to set TSQLScript.UseSetTerm:=true. TSQLScript is parsing the script and executes queries one by one and needs to know what the "real" terminator is. http://www.freepascal.org/docs-html/fcl/sqldb/tsqlscript.usesetterm.html Ludo -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

UseSetTerm is set to TRUE and Terminator to ";"
Without "SET TERM" directive in the script and terminator set to ^ result is the same :(

I tested other similar procedures, every time problem is somewhere around "INTO :VARIABLE"
in the procedure code.

Paul

Reply by email

Paul
to Reinier Olislagers: Not really, except it's a Firebird error and it would be interested to know what actually…

W dniu 19.07.2013 09:38, Reinier Olislagers pisze:

Show quoted text 55 lines
On 18/07/2013 17:40, Paul wrote: > I have problem with TSQLScript (?) > Script looks like that > > SET TERM ^ ; > CREATE PROCEDURE GET_USER_PRIVILEGES ( > USER_ACCOUNT VARCHAR(10)) > RETURNS ( > RESULT CHAR(1)) > AS > BEGIN > FOR > SELECT DISTINCT RDB$PRIVILEGE > FROM RDB$USER_PRIVILEGES > WHERE (RDB$USER = :USER_ACCOUNT) > INTO :RESULT > DO > BEGIN > SUSPEND; > END > END > ^ > SET TERM ; ^ > > and the error message looks like that > {...}PrepareStatement > -Dynamic SQL Error > -SQL Error Code = -104 > Token unknown - line 11, column 11 > -? > > line 11 -> INTO :RESULT > column 11-> : > > FlameRobin does not have any problems with this piece of code > > Any hints ? > Paul > > I use Lazarus 1.0.10, Firebird 2.5 on Ubuntu 32bit Not really, except it's a Firebird error and it would be interested to know what actually gets passed to the Firebird engine (to verify if that runs in FlameRobin). Perhaps sqldb logging [1] would work for that? [1] http://wiki.lazarus.freepascal.org/SqlDBHowto#Troubleshooting:_TSQLConnection_logging -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Only TSQLScript.OnException is triggered with error message as above I don't know why but TIBConnection.OnLog event isn't triggered at all (even when TSQLScript.OnException is not assigned)

Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130719/16365200/attachment.html>

Reply by email

Paul
to Ludo Brands: I think you have to set TSQLScript.UseSetTerm:=true. TSQLScript is parsing the script and…

W dniu 19.07.2013 10:48, Ludo Brands pisze:

Show quoted text 47 lines
On 07/18/2013 05:40 PM, Paul wrote: > Hello, > > I have problem with TSQLScript (?) > Script looks like that > > SET TERM ^ ; > CREATE PROCEDURE GET_USER_PRIVILEGES ( > USER_ACCOUNT VARCHAR(10)) > RETURNS ( > RESULT CHAR(1)) > AS > BEGIN > FOR > SELECT DISTINCT RDB$PRIVILEGE > FROM RDB$USER_PRIVILEGES > WHERE (RDB$USER = :USER_ACCOUNT) > INTO :RESULT > DO > BEGIN > SUSPEND; > END > END > ^ > SET TERM ; ^ > > and the error message looks like that > {...}PrepareStatement > -Dynamic SQL Error > -SQL Error Code = -104 > Token unknown - line 11, column 11 > -? > > line 11 -> INTO :RESULT > column 11-> : > > FlameRobin does not have any problems with this piece of code > > Any hints ? I think you have to set TSQLScript.UseSetTerm:=true. TSQLScript is parsing the script and executes queries one by one and needs to know what the "real" terminator is. http://www.freepascal.org/docs-html/fcl/sqldb/tsqlscript.usesetterm.html Ludo

TSQLScript.OnException
Exception.Message shows statement to run like this (without any terminator)

CREATE PROCEDURE GET_USER_PRIVILEGES (
USER_ACCOUNT VARCHAR(10))
RETURNS (
RESULT CHAR(1))
AS
BEGIN
FOR
SELECT DISTINCT RDB$PRIVILEGE
FROM RDB$USER_PRIVILEGES
WHERE (RDB$USER = :USER_ACCOUNT)
INTO :RESULT
DO

      BEGIN
           SUSPEND;
      END

END

Paul

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130719/d990fd6b/attachment-0001.html>

Reply by email