[Gambas-user] Doing query of Stored procedure with no related data crashes gambas
BB
adamnt42 at gmail.com
Sun Feb 19 11:32:12 CET 2023
On 19/2/23 8:47 pm, Christof Thalhofer wrote:
> Am 19.02.23 um 09:23 schrieb BB:
>
>> This is a gambas "bug" in one sense and not so in others.EXEC expects a
>> Result object to be returned, no matter whether the provided parameter
>> is a valid SQL sentence or not! In his case I believe it may have not
>> returned such. Further, his report of the Gambas error "Query failed:
>> Commands out of sync; you can't run this command now" indicates that
>> there could be a further and actual bug in the Gambas db component.
>
> In short: I cannot see a bug.
>
> I just created a stored procedure in PG which does nothing (except
> querying some stuff inside):
>
>> testdb=> CREATE PROCEDURE testcall()
>> testdb-> LANGUAGE SQL
>> testdb-> AS $$
>> testdb$> select test from tbtest;
>> testdb$> $$;
>> CREATE PROCEDURE
>
> Tested it inside PG:
>
>> testdb=> call testcall();
>> CALL
>
> Ok, it runs so far...
>
> So now let's execute it from Gambas:
>
> > ConTest.Exec("call testcall();")
> > Print "ok"
>
> Runs the statement 'call testcall();' and prints ok.
>
>> res = ConTest.Exec("call testcall();")
>> Print "ok"
>
> Also runs the statement 'call testcall();' and prints ok.
>
> The Result object ('res') is returned and is empty.
>
> A last test:
>
> > res = ConTest.Exec("glibberish thing") ' No valid SQL!
> > Print "ok"
>> Catch Print Error.Text
>
> Gambas throws an error which contains the error, the database threw:
>
> 'Query failed: ERROR: syntax error at or near "glibberish"'
>
> -----------------------------------------------------------------
>
> So Conection.Exec() does what it has to do:
>
> It sends a string to the DB and let the DB execute it.
>
> If there's a result it returns a Result object.
>
> If the result is empty it returns a Result object which is empty.
>
> If the DB reports an error, it throws an error.
>
> At least with Postgresql.
>
> Alles Gute
>
> Christof Thalhofer
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
You'll need to find the condition where the server interface returns
notices and no output result parameter.
It is possible, trust me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230219/55398e04/attachment.htm>
More information about the User
mailing list