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

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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 6th, 2004, 11:40 AM
moonlight moonlight is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Goiânia,GO,Brazil
Posts: 17 moonlight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to moonlight
Error in procedure

I'm getting the following error on a procedure.

Arithmetic overflow or division by zero has occurred.
arithmetic exception, numeric overflow, or string truncation.

I tried to find the error but I just couldn`t. Could anybody help me? thanks

Code:
CREATE OR ALTER PROCEDURE VLR_CLASSE(P_REF_ANOMES NUMERIC(04),P_CDG_ORGAO NUMERIC(03),  
      P_CLASSE VARCHAR(02))
RETURNS(R_VALOR NUMERIC(13,2)) 

AS
  
BEGIN
   R_VALOR = 0;


   SELECT 
       C.VLR_CLASSE
     FROM 
       TBCLASSE C
     WHERE (C.CDG_ORGAO = :P_CDG_ORGAO)
       AND (RTRIM(C.CLASSE) = RTRIM(:P_CLASSE))
       AND (C.DTA_INI_CLASSE = (SELECT MAX(C2.DTA_INI_CLASSE) 
                               FROM TBCLASSE C2 
                               WHERE (CAST(CAST(EXTRACT(YEAR FROM C2.DTA_INI_CLASSE) || LPAD(EXTRACT(MONTH FROM C2.DTA_INI_CLASSE),2,'0') AS VARCHAR(10))AS NUMERIC(10)) <= :P_REF_ANOMES)
                                 AND C2.CDG_ORGAO = C.CDG_ORGAO 
                                 AND C2.CLASSE = C.CLASSE))
    INTO :R_VALOR; 

  IF (R_VALOR IS NOT NULL) THEN 
     BEGIN
      R_VALOR = COALESCE(R_VALOR,0);       
     END

  
   SUSPEND;
END;


Thank you, bjos

Reply With Quote
  #2  
Old January 6th, 2004, 02:12 PM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 249 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 8 h 23 m 12 sec
Reputation Power: 13
Hard to tell what the problem is with only this little info...

Can you run the SELECT statement by itself?
__________________
Martijn Tonies
Database Workbench: developer IDE for Firebird, MySQL, InterBase, MSSQL Server and Oracle
Upscene Productions
http://www.upscene.com

Reply With Quote
  #3  
Old January 7th, 2004, 10:00 AM
moonlight moonlight is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Goiânia,GO,Brazil
Posts: 17 moonlight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to moonlight
Only the "Select.." yeah I can. But outside the procedure. If I put it inside it again (and for it I have to add the "into..." part), taking out every other code of the procedure and try to execute the procedure again.. it gives me the same error

Reply With Quote
  #4  
Old January 7th, 2004, 10:04 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 249 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 8 h 23 m 12 sec
Reputation Power: 13
And you're sure the result fits in variable "R_VALOR"?

Reply With Quote
  #5  
Old January 7th, 2004, 10:13 AM
moonlight moonlight is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Goiânia,GO,Brazil
Posts: 17 moonlight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to moonlight
VLR_CLASSE and R_VALOR are the same type! NUMERIC(13,2)

What I`m thinking now is... my procedure is called VLR_CLASSE, and so is the table field I`m getting the value. Could that be a problem?

Reply With Quote
  #6  
Old January 7th, 2004, 10:18 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 249 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 8 h 23 m 12 sec
Reputation Power: 13
No, that can't be it.

Care to send me a backup of your database so that I can take a closer look at it?

What version of Firebird are you using?

If you like to send me a copy, send it to m.tonies @ upscene.com

Reply With Quote
  #7  
Old January 7th, 2004, 10:37 AM
moonlight moonlight is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Goiânia,GO,Brazil
Posts: 17 moonlight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to moonlight
Just sent you a copy. Thank you very much.

Reply With Quote
  #8  
Old January 7th, 2004, 11:16 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 249 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 8 h 23 m 12 sec
Reputation Power: 13
Hi,

What values do you use for the input parameters?

I think it might be related to parameter "P_REF_ANOMES".

Can you explain what value has to go into that parameter?

Reply With Quote
  #9  
Old January 7th, 2004, 11:21 AM
moonlight moonlight is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Goiânia,GO,Brazil
Posts: 17 moonlight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to moonlight
OOPS
i changed it from NUMERIC(04) to NUMERIC(06) (because it has to fit the value 200312, argh, what an asshole i am). Anyways.. it keeps giving the same error. Perhaps because both fit into the SMALLINT description...

Reply With Quote
  #10  
Old January 7th, 2004, 11:27 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 249 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 8 h 23 m 12 sec
Reputation Power: 13
Hi,

It works fine here, with a NUMERIC(6) for that particular parameter.

Make sure you disconnect all connections after modifying the procedure, re-connect and try again. Sometimes, Firebird keeps a procedure in it's cache if anyone else is connected and has run the procedure.

Reply With Quote
  #11  
Old January 7th, 2004, 11:30 AM
moonlight moonlight is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Goiânia,GO,Brazil
Posts: 17 moonlight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to moonlight
:S I'll kill myself

Thank you upscene
sorry :S

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Error in procedure

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap