473,379 Members | 1,544 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Testing Inserts, Deletes and Updates before execution ...

Dear list,

i am looking for a way to check, whether an DML-statement can be
performed on a current database. That means, that i want to check, if
e.g. an INSERT is possible or not (due to existing constraints), without
executing it.

Any ideas?

Hagen

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

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

Nov 23 '05 #1
1 1526
Hagen Hoepfner wrote:
i am looking for a way to check, whether an DML-statement can be
performed on a current database. That means, that i want to check, if
e.g. an INSERT is possible or not (due to existing constraints), without
executing it.


I think this could be the easiest way: try it and rollback.

BEGIN;
SET CONSTRAINTS ALL IMMEDIATE; -- if you have deferred foreign key, e.g.
INSERT .... -- check if it works
ROLLBACK;

That should do what you want, IMHO.
In PostgreSQL 8.0 you would not need your own transaction here...

BEGIN;
-- do some work

SAVEPOINT check_dml;
INSERT ... -- check if it works
ROLLBACK TO check_dml;

-- do some more work
COMMIT;

Could this be what you want?

Best Regards,
Michael Paesold

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

Nov 23 '05 #2

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

Similar topics

3
by: kerri | last post by:
Hi, I need to do a mysqldump of specific inserts, updates & deletes. I read in the docs that I can use -w or --where. Can I do a join? Could someone provide an example? Is there another...
3
by: Viswanatha Thalakola | last post by:
Hello, Can someone point me to getting the total number of inserts and updates on a table over a period of time? I just want to measure the insert and update activity on the tables. Thanks....
11
by: Durai | last post by:
Hi All, I tested "concurrent testing" in MySQL. It works fine. But I couldn't do in PostgreSQL 7.3.4 on HPUX IPF. I got deadlock problem. I used the PHP script to update table( one script...
1
by: peter | last post by:
Hi All, a quick question. I haven't used DB2 on mainframe since 1995 so my memory is fading a bit. But I seem to recall DB2/MVS having the ability to perform unlogged deletes. Situation is I...
0
by: Steve - DND | last post by:
Is there a way to perform multiple inserts and updates to SQL Server with stored procedures and the Command object's named parameters all at once? The only way to do this that I'm gathering so far...
3
by: R.A.M. | last post by:
Please help. I have a table with single row. I need to allow only UPDATEs of the table, forbid INSERTs and DELETEs. How to achieve it? Thank you for information /RAM/
3
by: Rob | last post by:
Hi all, I have a bit of a complicated question, hope we have an SQL guru out there that can help us solve this killer problem. Due to the size of SQL Database we have (largest in the US), we...
0
by: Benzine | last post by:
I recently rolled out replication on our production server (MS SQL 2000 SP4) and every time a subscriber tries to sync the following always appears in the Merge Agent History: "Downloaded 100...
2
by: MihirShah | last post by:
If I insert rows in a table with no index, is select guaranteed to return the rows in the order it was inserted. Note: I am not doing any updates, deletes - pure inserts. In my small test...
0
by: Dimitris Milonas | last post by:
Hello to all, I have a DetailView on a page with Insert/Update enable and Paging enable. I would like to have on the same page two buttons ("Submit" and "Cancel") where with the first ("Submit")...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.