473,773 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

figuring out if there was a transaction in this connection already

Hi,
I would like to be able to figure out if a table has
been updated in this connection from within a C
trigger.

I have already tried to the use a query with currval
on the autoincremented primary key but that exits the
trigger with

table.currval is not yet defined in this session

Is there a way to trap / ignore this error? Or a way
to check if there was a transaction in this connection
before.

Thanks for any input.

Best wishes,

M

_______________ _______________ _______________ _____
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #1
3 1198
On Sat, Sep 25, 2004 at 07:16:19AM -0700, Kundham Saare wrote:
I would like to be able to figure out if a table has
been updated in this connection from within a C
trigger.

I have already tried to the use a query with currval
on the autoincremented primary key but that exits the
trigger with

table.currval is not yet defined in this session
Checking currval() isn't a valid test for inserts because an insert
might have been rolled back, but the sequence would still have been
incremented:

test=> SELECT currval('person _id_seq');
ERROR: currval of sequence "person_id_ seq" is not yet defined in this session
test=> BEGIN;
BEGIN
test=> INSERT INTO person (name) VALUES ('John Doe');
INSERT 30437 1
test=> ROLLBACK;
ROLLBACK
test=> SELECT currval('person _id_seq');
currval
---------
12

Checking currval() also wouldn't tell you whether any rows in a
table had been updated.
Is there a way to trap / ignore this error? Or a way
to check if there was a transaction in this connection
before.


Why do you need to know this? What are you trying to do?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 23 '05 #2
> Checking currval() also wouldn't tell you whether
any rows in a
table had been updated.


I only need to know if there a row has been inserted.
I am trying to extend dbmirror so that I can easily
replicate all the transaction from a query even if
there it contains multiple update statements within
it.

Currently, this will insert multiple rows into a
pending table with different ID's.

Alternatively, is there some way to figure out what
the pid of the current connection is from the C
trigger function?

Best wishes,

M

_______________ _______________ ____
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 23 '05 #3
On Sat, Sep 25, 2004 at 08:44:18AM -0700, Kundham Saare wrote:
Alternatively, is there some way to figure out what
the pid of the current connection is from the C
trigger function?


getpid() should work.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1278
by: faktujaa | last post by:
Hi, I receive the above error in my code when in debug mode but im not using serviced components instead im making use of sql server transaction. In short, I have defined a transaction class that is derived from connection class. In the constructor, i open a connection if one not already present and then start the transaction by using BeginTransaction method of connection object. In the destructor, i have called the Dispose method that...
7
6668
by: Abdul-Wahid Paterson | last post by:
Hi, I have had a site working for the last 2 years and have had no problems until at the weekend I replace my database server with a newer one. The database migration went like a dream and I had the whole db changed over in 1 hour. Since the upgrade I have been getting the following error message sporadically.
1
10385
by: Jason Huang | last post by:
Hi, I am just wondering how do we test the transaction's Commit and Rollback? How do we simulate a situation to let the transaction fail then Rollback? Thanks for help. Jason
2
2637
by: Dano | last post by:
Hi all! Perhaps a wise soul can help me here. I have an insert routine for an ASP.Net application and it works fine, but I decided to test the transaction rollback capabilities by stopping the SQL server when it was just about to insert the record (I use a breakpoint and then stop the server). What should have happened is that the transaction is rolled back and my catch block response.writes the error which would be something about the...
9
1911
by: Chance Hopkins | last post by:
When using the sqlclient dotnet class and sql server. is it faster when doing a single (not multiple) insert to: 1- just do a simple connection and command object, then execute a nonquery 2-use a transaction, connection and command object to execute a nonquery and then commit the transaction Thanks
4
4154
by: Rahul Anand | last post by:
Getting SQL Exception when trying to implement Connection based Trasaction using SQL Helper class. I am using the follwing function to execute my stored procs: -=-=-=- ExecuteScalar(ByVal transaction As SqlTransaction, _ ByVal spName As String, _ ByVal ParamArray parameterValues() As Object)
1
1798
by: Jake Smythe | last post by:
Hello, I have a dataset that is being passed to a webservice. It has about 5 records. I call a stored proc that inserts for the first record but errors out for the others as the connection is already open. I am wanting to have a sql trans open for all so if one of the records fails all are rolled back. Could someone provide me with a simple way to do this? Below is my code. I think I need a main transaction with little ones inside but I...
1
18866
by: Mana | last post by:
Hi, I want to implement nested transactions in C#. When I write BEGIN TRANSACTION inside another BEGIN TRANSACTION in an SQL Script it works fine. But when I call BeginTransaction() inside another BeginTransaction() in a c# code on same connection object it throws exception as "SQLConnection doesnot support parallel transaction". Following is the code snippet that i have written.
6
5637
by: BobRoyAce | last post by:
Let's say that I am performing a bunch of insert/update queries within a transaction that is created as follows: Dim cnn As New SqlClient.SqlConnection(My.Settings.GRPConnectionString) cnn.Open() Dim trx As SqlClient.SqlTransaction = cnn.BeginTransaction() Further suppose that, in the middle of all of the insert/update queries, I want to execute a SELECT query against one of the tables
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.