Subject Re: [firebird-support] Re: I can't find the error in this very short SP
Author Mark Deibert
So the "rule" is put a semicolon at the end of every line of SQL but no
where else. I saw an example somewhere using the SET TERM statement. Is this
common practice? It does make sense. Some of my data may contain semicolons.
There should never be a duplicate player name.
In TSQL "First" equals "Top". Thats good info to have.
I'll be headed to Borders this weekend to pick up a PSQL book. Do you have
any favorite authors or titles I should look for?
Thank you everyone for the replies. You saved me :-)

On 7/23/05, Adam <s3057043@...> wrote:
>
> Mark,
>
> I am glad you have found a solution / work around to the issue, but I
> think what IBEasy would have been complaining about is the SQL
> termintator character (default ';') being found within a statement.
>
> In other words it finds a semi colon and tries to run this as a query
>
> CREATE PROCEDURE SP_PLAYERFIND ( PLAYERNAME VARCHAR(16) )
> RETURNS ( PLAYERKEY NUMERIC(15,0) )
> AS
> BEGIN
> SELECT PKEY FROM PLAYERS WHERE PLAYERNAME=:PLAYERNAME
> INTO :PLAYERKEY;
>
> If you were a database engine and got fed this you to would kick up a
> fuss.
>
> The easiest solution is to do something like this.
>
> -- Change terminator to something else
> SET TERM ^;
>
> CREATE PROCEDURE SP_PLAYERFIND ( PLAYERNAME VARCHAR(16) )
> RETURNS ( PLAYERKEY NUMERIC(15,0) )
> AS
> BEGIN
> SELECT PKEY FROM PLAYERS WHERE PLAYERNAME=:PLAYERNAME
> INTO :PLAYERKEY;
> SUSPEND;
> END
> ^
>
> -- Change the terminator back
> SET TERM ;
> ^
>
> By the way, if you have multiple players with the same name, you can
> change your procedure slightly to return them all.
>
> CREATE PROCEDURE SP_PLAYERFIND ( PLAYERNAME VARCHAR(16) )
> RETURNS ( PLAYERKEY NUMERIC(15,0) )
> AS
> BEGIN
> FOR SELECT PKEY FROM PLAYERS WHERE PLAYERNAME=:PLAYERNAME
> INTO :PLAYERKEY
> DO
> BEGIN
> SUSPEND;
> END
> END
> ^
>
> Then you could run
>
> Select PlayerKey
> from SP_PlayerFind('John Brown');
>
> and it would return something like
>
> PlayerKey
> =========
> 2323
> 8472721
>
> etc
>
> Otherwise with your first syntax, you should use the first syntax to
> be confident you don't get duplicates and hence a SQL error as Helen
> pointed out.
>
> ie:
>
> SELECT FIRST 1 PKEY FROM PLAYERS WHERE PLAYERNAME=:PLAYERNAME
> INTO :PLAYERKEY;
>
> Adam
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
>
> ------------------------------
> YAHOO! GROUPS LINKS
>
>
> - Visit your group "firebird-support<http://groups.yahoo.com/group/firebird-support>"
> on the web.
> - To unsubscribe from this group, send an email to:
> firebird-support-unsubscribe@yahoogroups.com<firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>
> - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------
>



--

L8R,

Mark:-Deibert
> SELECT * FROM Users WHERE Clue> 0
> 0 records returned


[Non-text portions of this message have been removed]