[Gambas-user] Subject: Re: MULTIPLE ROW RESULT

admin at ...1080... admin at ...1080...
Tue Jan 22 10:11:09 CET 2008


Hi Nx GT-R BOY

Your Subquery
            (SELECT " & lookingfor & " FROM " & table & "
                where " & reference & " = '" & value & "')
return more then 1 row and that is not Okey for SQL (has nothing to do 
with Gambas).

There are two possibility's to correct it:

1) You can try with "LIMIT 1" for MySQl or "TOP 1" for MSSql (other Sql 
don't know).
2) Change the where-clause of the Subquery to get one unique row. I can 
help more here only if you tell more about whats in the variable 
"reference" and how are data in the table.

I would recommend the solution 2)

Regards, Werner


------------------------------

Message: 8
Date: Mon, 21 Jan 2008 16:40:40 -0800
From: "Nx GT-R BOY" <nxgtrturbo at ...626...>
Subject: Re: [Gambas-user] MULTIPLE ROW RESULT
To: gambas-user at lists.sourceforge.net
Message-ID:
<688afe140801211640u36e8835fl71635af3587ad9ae at ...627...>
Content-Type: text/plain; charset=ISO-8859-1

Sorry, I made a Mistake with the procedure I write, the right one is:

PUBLIC SUB tellmeposition(lookingfor AS String, table AS String, reference
AS String, value AS String)
myresult = conexion.Exec("SELECT count(*) AS position FROM " & table & "
where " & lookingfor & " < (SELECT " & lookingfor & " FROM " & table & "
where " & reference & " = '" & value & "')")
END

My program crash with the message:
"Query failed: Subquery return more than 1 row"

Did I make something wrong?

On Jan 21, 2008 3:50 PM, Nx GT-R BOY <nxgtrturbo at ...626...> wrote:
MULTIPLE ROW RESULT
>
>  Hi, I got a trouble with the "Result" data type @ gambas, I have a
>  function like this:
>
>  PUBLIC myresult AS Result
>
>  PUBLIC SUB search(lookingfor AS String, table AS String, reference AS
>  String, value AS String)
>  myresult = conexion.Exec("Select " & lookingfor & " from " & table & "
>  where " & reference & " = '" & value & "'")
>  END
>
>  Everything works perfect when the query returns ONLY ONE ROW, but what
>  about multiple row result?, I tried:
>
>  PUBLIC myresult AS Result[X]
>  and
>  PUBLIC myresult[X] AS Result
>
>  But that didn't work (the language doesn't allow that), Is there any
>  possible way to catch all the rows?
>
>
>
>
>  --





More information about the User mailing list