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 29th, 2011, 07:54 AM
mrtblt mrtblt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 14 mrtblt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 4 m 26 sec
Reputation Power: 0
Committing records inserted by Stored Procedure

I created the following Stored Procedure

Code:
SET TERM ^ ;  
CREATE OR ALTER PROCEDURE EDIT_FATURA (fat_id integer, mflag integer) as 
begin     
  update inv_lines set mflag = :mflag where fat_id = :fat_id;
  delete from inv_lines_temp where 1=1 ;     
  insert into inv_lines_temp select ID,CODE_ID,ADET,UNIT_PRICE,LINE_NET,LINE_VAT,KDV,LINE_GRAND,CRN 
from inv_lines where fat_id = :fat_id; 
end^  
SET TERM ; ^  
GRANT SELECT,UPDATE ON INV_LINES TO PROCEDURE EDIT_FATURA;  
GRANT SELECT,INSERT,DELETE ON INV_LINES_TEMP TO PROCEDURE EDIT_FATURA;  
GRANT EXECUTE ON PROCEDURE EDIT_FATURA TO SYSDBA;


And with the following code I call the stored procedure with my Delphi application

Code:
dm.q_genel.Close;     
dm.q_genel.SQL.Clear;     
dm.q_genel.SQL.Add('EXECUTE PROCEDURE EDIT_FATURA(:p1,:p2)');
dm.q_genel.ParamByName('p1').AsInteger := fid;
dm.q_genel.ParamByName('p1').AsInteger := sayi; 
dm.q_genel.execute;


As it is seen, some records inserted to a table by stored procedure called in my delphi application.

But since they are not committed after the execution of the stored procedure, I cannot access newly inserted records in my application.

How i can commit rows inserted by Stored Procedure so that i can access them in my application?

As far as i know, it is not allows "commit" within a Stored Procedure

Reply With Quote
  #2  
Old January 29th, 2011, 08:07 AM
shammat shammat is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Oct 2003
Location: Germany
Posts: 2,684 shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 3 Days 19 h 38 m
Reputation Power: 284
I don't know Delphi, but why don't you simply issue a commit after calling [i]dm.q_genel.execute;[/]?

There must be a way in Delphi to issue a commit in the current transaction.

Reply With Quote
  #3  
Old January 29th, 2011, 03:53 PM
mrtblt mrtblt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 14 mrtblt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 4 m 26 sec
Reputation Power: 0
Thanks shammat,

I resolved it. Mine was a programming error in Delphi side.

Reply With Quote
  #4  
Old January 31st, 2011, 05:11 AM
mIRCata mIRCata is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Location: Plovdiv. Bulgaria
Posts: 200 mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 6 h 50 m 4 sec
Reputation Power: 11
I don't know is this the real code but you set P1 twise
q_genel.ParamByName('p1').AsInteger := fid;
dm.q_genel.ParamByName('p1').AsInteger := sayi; - here must be P2

After
dm.q_genel.execute;
Use
dm.q_genel.Transaction.Commit;

Reply With Quote
  #5  
Old January 31st, 2011, 05:51 AM
mrtblt mrtblt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 14 mrtblt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 4 m 26 sec
Reputation Power: 0
Problem has been resolved. Thanks.

I was assigning a wrong fid value. Thats why i didnt get it

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Committing records inserted by Stored 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