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 August 4th, 2006, 06:24 AM
nagysz nagysz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 46 nagysz User rank is Corporal (100 - 500 Reputation Level)nagysz User rank is Corporal (100 - 500 Reputation Level)nagysz User rank is Corporal (100 - 500 Reputation Level)nagysz User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 10 h 4 m 43 sec
Reputation Power: 4
How can i debug my triggers & stored procedure?

another newbie question:

how can i debug my procedures?

i have a simle procedure like

Code:
CREATE PROCEDURE GENFACT (
    DB SMALLINT)
AS
DECLARE VARIABLE I SMALLINT;
begin
  i=0;
  while (i<db) do
  begin
    insert into van_facturi (nr, client)
    values(random()*1000000,1);
    i=i+1;
  end
end


the client field is a foreign key to the Clients table and clients table contains:

Clientid, Name
1, AAA
2, BBB
3. CCC

the procedure above gives an error that foreign key constraint violation (in spite of i specified the client code (=1) and it exists in the client table)

and when i give a backup/restore to the database it works a couple times, and then it starts giving the same message.

how can i test what values will the procedure insert into my table?

Reply With Quote
  #2  
Old August 7th, 2006, 12:57 AM
badukist badukist is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 62 badukist User rank is Corporal (100 - 500 Reputation Level)badukist User rank is Corporal (100 - 500 Reputation Level)badukist User rank is Corporal (100 - 500 Reputation Level)badukist User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 3 m 18 sec
Reputation Power: 7
Send a message via Yahoo to badukist
Quote:
Originally Posted by nagysz
another newbie question:

how can i debug my procedures?

i have a simle procedure like

Code:
CREATE PROCEDURE GENFACT (
    DB SMALLINT)
AS
DECLARE VARIABLE I SMALLINT;
begin
  i=0;
  while (i<db) do
  begin
    insert into van_facturi (nr, client)
    values(random()*1000000,1);
    i=i+1;
  end
end


the client field is a foreign key to the Clients table and clients table contains:

Clientid, Name
1, AAA
2, BBB
3. CCC

the procedure above gives an error that foreign key constraint violation (in spite of i specified the client code (=1) and it exists in the client table)

and when i give a backup/restore to the database it works a couple times, and then it starts giving the same message.

how can i test what values will the procedure insert into my table?


You can use IBExpertfull, Database Workbench or EMS SQL Manager for Firebird/Interbase. All have stored procedure debugger.

Or, for a quick and dirty solution, store values in variables, define an exception and then...

Code:
...
  while (i<db) do
  begin
    variable1 = random()*1000000 ;

    exception test 'Variable1:' || :variable1 ;

    insert into van_facturi (nr, client)
    values(:variable1,1);
    i=i+1;
  end
end


On the other side, why you do this?

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > How can i debug my triggers & stored procedure?


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
Stay green...Green IT