473,398 Members | 2,393 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,398 software developers and data experts.

how to make undeleted record

Hi all,

I want to have some of records in table to be undeleted?
how can i do that?
for instance, keep first 20 records of table undeleted or read only for
outside access
but DBA or users who have DBA or higher level rights can do delete or
change operations.

Many thanks!

Dec 1 '05 #1
8 1431
I am not sure what you mean by undelete.

However, if you only want to let some people do a DELETE operation, and
others not, only GRANT DELETE to the users that require it.

If you want to allow some records to be DELETEable by everyone, and
others to only be DELETEable by some, CREATE two TABLEs, one for each
set, and GRANT DELETE to all users on one, and to only some users on
the second one. Then, CREATE a VIEW that is a UNION ALL on both TABLEs,
and have the users access the view rather than the individual TABLEs.

B.

Dec 1 '05 #2
Brian Tkatch wrote:
I am not sure what you mean by undelete.

However, if you only want to let some people do a DELETE operation, and
others not, only GRANT DELETE to the users that require it.

If you want to allow some records to be DELETEable by everyone, and
others to only be DELETEable by some, CREATE two TABLEs, one for each
set, and GRANT DELETE to all users on one, and to only some users on
the second one. Then, CREATE a VIEW that is a UNION ALL on both TABLEs,
and have the users access the view rather than the individual TABLEs.


Or you can use a view including the WITH CHECK OPTION. Deleting against the
view ensures that at least 20 records remain in the table.

Or you stick with triggers.
--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Dec 1 '05 #3
> Or you can use a view including the WITH CHECK OPTION. Deleting against the
view ensures that at least 20 records remain in the table.
How would you do that?
Or you stick with triggers.


A TRIGGER would definitely of service here.

....but...IMNHSO, i don't like the use of TRIGGERs for major things. If
the second TABLE was populated with DELETEs, but the second TABLE was
not used by the system, a TRIGGER makes a lot of sense as it is more
data management. But to have two TABLEs, and have a TRIGGER keep them
in sync for actual use (through a view), the application or stored
PROCEDURE should handle it. Otherwise it tends to get real messy.

IOW, the actual data model should not use TRIGGERs, only management
features like an non-natural Id COLUMN or a history TABLE (for "just in
case" purposes) or rights that cannot be otherwise implemented, or
auditing, etc should use TRIGGERs.

But that's just my opinion. :)

Based on the ugliness i've seen when people begin to rely on TRIGGERs
to populate other TABLEs, and then have to code around them.

B.

Dec 1 '05 #4
Brian Tkatch wrote:
Or you can use a view including the WITH CHECK OPTION. Deleting against
the view ensures that at least 20 records remain in the table.


How would you do that?


Create the view in such a way that the underlying table must have at least
those 20 records. And if that's not the case, the view does not show
anything. So deleting the 20th row would result in no rows shown in the
view and, thus, the check option being violated.

Granted, that's a rather strange way but it should work. After all, that's
just usual SQL stuff. ;-)

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Dec 2 '05 #5
>Create the view in such a way that the underlying table must have at least those 20 records.

OK. Could you provide a quick example. I am curious how a view
guarantees a certain amount of rows.
Granted, that's a rather strange way but it should work. After all, that's just usual SQL stuff. ;-)


:)

Although, a good design (usually) removes the "usual" SQL stuff, so
things can be a bit more stright forward.

B.

Dec 2 '05 #6
Brian Tkatch wrote:
Create the view in such a way that the underlying table must have at least
those 20 records.


OK. Could you provide a quick example. I am curious how a view
guarantees a certain amount of rows.


SELECT ...
FROM <tab>
WHERE ... AND
( SELECT COUNT(*)
FROM <tab> ) >= 20

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Dec 2 '05 #7
Oh, i see. That's easy, i guess i never thought of that. :)

Hmm.. This doesn't use any order though. IOW, it'll keep *any* twenty
records.

B.

Dec 2 '05 #8
Brian Tkatch wrote:
Oh, i see. That's easy, i guess i never thought of that. :)

Hmm.. This doesn't use any order though. IOW, it'll keep *any* twenty
records.


That's right. I don't know if the OP had any special tuples in mind.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Dec 2 '05 #9

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

Similar topics

2
by: EricRobineau | last post by:
hello I have a DB with many inter-related tables (MySQL) My main table called "content" has almost only foreign keys (integers) some have a 3 level relation (ex: content->city->region->country) ...
5
by: yvan | last post by:
Approximately once a month, a client of ours sends us a bunch of comma-delimited text files which I have to clean up and then import into their MS SQL database. All last week, I was using a Cold...
0
by: Gianfranco | last post by:
Hi I got a problem with 2 tables. I have a table, say A, with x records, coming from a make table query and a table, say B, with y records, coming from another make table query. I need to join...
3
by: Phil | last post by:
I am looking to set up a hyperlink control on a form to retrieve letters that correspond to a record on a form. That is, there may be 100 form records, and I would like each of those form records...
1
by: PCB | last post by:
Hi all, Not sure if this is possible, but can I change the controls of a command button on a per record bases in a subform. In my case, I would like to make a command button visible only if...
15
by: Hi5 | last post by:
Hi, I am designing a database for a client in which It has a client table including the followings: 1-Table Client 2-Table lookupcategory 3-Table Ctegory
1
by: Landon | last post by:
Ver: Access 2003 Hi everyone and thanks in advance, General Issue: I want to make a table whose data polls from two other tables and will update (add new records) if additions are made to...
4
by: banderson | last post by:
Hello, I am having a problem getting a new record in a subform to append to the underlying table. When I add a new record to the main form, the subform is blank, except for the ID field, which is...
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.