Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 30th, 2005, 06:49 AM
JGeer JGeer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 14 JGeer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 9 m 57 sec
Reputation Power: 0
Question SELECT SP's newbie question

Hi, this is my first post here and I'm new with Firebird too.

I'm trying to migrate from MSDE to Firebird but I'm having some problems. I'm using EMS to create my database tables and stored procedures. I'm having problems with stored procedures that involve SELECT statements.

For example, this does not compile:

CREATE PROCEDURE S_CLIENTES (
P_CLIENTEID INTEGER
, P_CIF CHAR(9)
, P_RAZONSOCIAL VARCHAR(255)
)
AS
BEGIN
SELECT
CLIENTES.CLIENTEID
, CLIENTES.CIF
, CLIENTES.RAZONSOCIAL
, CLIENTES.DIRECION
, CLIENTES.CODIGOPOSTAL
, CLIENTES.POBLACION
, CLIENTES.TELEFONO
, CLIENTES.FAX
, CLIENTES.WEB
, CLIENTES.OBSERVACIONES
FROM CLIENTES
WHERE (( :P_CLIENTEID IS NULL) or (CLIENTEID = :P_CLIENTEID))
AND (( :P_CIF IS NULL) or (CIF = :P_CIF))
AND (( :P_RAZONSOCIAL IS NULL) or (RAZONSOCIAL LIKE '%' || :P_RAZONSOCIAL || '%'))
SUSPEND;
END

I think it's related to the SUSPEND word ¿how it works?
I've read in docs that this kind of stored procedures needs the RESULT block but, what I have to put there in this case?

Thanks in advance.

Reply With Quote
  #2  
Old February 1st, 2005, 10:11 AM
SilverDB's Avatar
SilverDB SilverDB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Romania
Posts: 173 SilverDB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 45 m 53 sec
Reputation Power: 4
Send a message via Yahoo to SilverDB
Can you post the error message that you receive while running this ?

Reply With Quote
  #3  
Old February 2nd, 2005, 01:27 PM
JGeer JGeer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 14 JGeer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 9 m 57 sec
Reputation Power: 0
Confused with firebird

Quote:
Originally Posted by SilverDB
Can you post the error message that you receive while running this ?

Ok, seems that the SELECTs must have this format:

CREATE PROCEDURE MYPROC
RETURNS ( ReturnField1 integer, ReturnField2 integer, ReturnField3 integer)
AS
FOR SELECT c1, c2, c3
FROM myTable
WHERE myCondition
INTO :ReturnField1, :ReturnField2, :ReturnField3
DO
BEGIN
SUSPEND;
END


Is that way?

What if my SELECT has 40 fields, I must declare 40 vars in the RETURNS section !!??

Reply With Quote
  #4  
Old February 2nd, 2005, 04:29 PM
Eternum Eternum is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 12 Eternum User rank is Private First Class (20 - 50 Reputation Level)Eternum User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 35 m 34 sec
Reputation Power: 0
Quote:
Originally Posted by JGeer
What if my SELECT has 40 fields, I must declare 40 vars in the RETURNS section !!??


Correct.

Reply With Quote
  #5  
Old February 3rd, 2005, 08:14 AM
fikret fikret is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Sarajevo, Bosnia
Posts: 111 fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 5 h 17 m 43 sec
Reputation Power: 8
Quote:
Originally Posted by JGeer

What if my SELECT has 40 fields, I must declare 40 vars in the RETURNS section !!??


Correct. Or use IBExpert, it will generate StoredProc for you

--
Best regards,
Fikret Hasovic http://fikret.fbtalk.net

FirebirdSQL Foundation member.
- Join today at http://www.firebirdsql.org/ff/foundation
JEDI VCS contributor
http://jedivcs.sourceforge.net/

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > SELECT SP's newbie question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway