Is there a way to enforce the use of sequences

is there a way to stop someone from inserting an id without using the sequence?
CREATE SEQUENCE id_seq
   START WITH 1;
CREATE TABLE test_table (id_seq NUMBER (4) PRIMARY KEY);
INSERT INTO test_table
     VALUES (id_seq.NEXTVAL);
INSERT INTO test_table
     VALUES (2);
INSERT INTO test_table
     VALUES (id_seq.NEXTVAL);gives us
ORA-00001: unique constraint (DSAMSTRC.SYS_C0091648) violated
as it should
however is there a check constraint of some ilk that ensures that the user is using the sequence when doing inserts?
so that the second insert
INSERT INTO test_table
     VALUES (2);gives me some sort of check constraint violation that I'm not using the id_seq.NEXTVAL ?

Justin:
One minor problem with your trigger. If the "bad" insert is the first thing done in the session you get:
SQL> insert into test_table values(25);
insert into test_table values(25)
ERROR at line 1:
ORA-08002: sequence ID_SEQ.CURRVAL is not yet defined in this session
ORA-06512: at "OPS$ORACLE.TRG_TEST_TABLE", line 4
ORA-04088: error during execution of trigger 'OPS$ORACLE.TRG_TEST_TABLE'If you want to raise an exception instead of just silently using the sequence as Frank suggests you need something more like:
create trigger trg_test_table
   before insert on test_table
   for each row
declare
   l_currval integer;
   no_currval exception;
   PRAGMA EXCEPTION_INIT (no_currval, -8002);
begin
   select id_seq.currval
   into l_currval
   from dual;
   if( l_currval != :new.id_seq ) then
      raise_application_error( -20001, 'Hey!  Use the sequence' );
   end if;
exception
   when no_currval then
      raise_application_error( -20001, 'Hey!  Use the sequence' );
end;John

Similar Messages

  • Is there any way to track the use of an IMEI on a stolen iPhone 5?

    I've had an iPhone 5 stolen.
    Battery was dead so 'Find My iPhone' was no use -so far.
    Problem is... my SIM-PIN is disabled so I need to deactivate the SIM in order to prevent fraudulent use of my contract account (if someone transferred the nano-SIM into another handset) -and to get services back.
    Once I do this, the phone will have zero network coverage and shall be unable to receive "Find My iPhone" messages or transmit its position.
    So, the difficulty here is that, in order to protect use of my phone account, I have to give up on any possibility of recovering my phone.
    Also, the handset's PIN is enabled so a well-intentioned person who might find my phone would be unable to connect the phone, even to their WiFi, to provide it with coverage in order to receive my 'Find My iPhone' message.
    I'm trying to figure out how I might use the IMEI to be made aware of the phone coming back up on a network somewhere at some future date? If so, I could contact the relevant network and track the calls and recover the phone.
    I assume that as there is a handset PIN in use on the phone -some jailbreaking or similar shall be required to hack the phone and reset it?
    If someone is going to that effort then clearly, the phone has been stolen rather than 'found'.
    Any ideas?
    Regards,
    EUPREMIER

    Apple, as I'm sure you know, now manage official phone 'unlocks' directly rather than the Newtork doing so.
    When a GSM Network Provider buys a consignment of iPhone's they are locked to that carrier and may only be officially unlocked if said carrier requests it. If so, it is Apple who do this, via iTunes.
    I am therefore inclined to think that part of the any generic iTunes syncing process involves the transmission of key hardware data, including IMEI, to Apple whenever the handset is synced.
    If this is the case and, as each iTunes account is linked to a credit card, were Apple to maintain a database of genuinely stolen phones (ones reported to Police) they could advise said Police force when a stolen phone stuck its metaphorical head over the parapets once again? They would be able to identify the name & address of the new user.
    I have spoken to the Police here in Ireland today and they regularly engage with Apple on such matters.
    This may not be tracking as we know it Jim, (not using GSM Triangulation or GPS) but it's arguably even more targetted and leaves an indelible fingerprint of guilt on the thief.
    The laws here are simple in this regard, if you are in possession of stolen property, knowlingly or otherwise, you forfeit the goods once the Police show up. Whether you get prosecuted depends on whether you stole the goods or were duped into purchasing them.

  • Is there any way to disable the use of the "Delete" key to delete an email message?

    It's very frustrating when I hit the delete key and iCloud automatically erases the selected email message.  I receive some HTML formatted emails that include a text box that I can utilize to directly reply to something.  If I don't make any mistakes at all, I can utilize this box and post a reply.  But if I mess up and need to delete text, instead of deleting text iCloud deletes the email message.  Is there any way to disable this?
    Thanks for your help.

    I don't believe it's possible to disable the delete key, but could be wrong. However, if you delete an email in error, you can restore it by pressing cmd + Z to undo the deletion.

  • Is there any way to undo the "Use this Mailbox for" action besides the undo action

    My Gmail account in Mac mail was confusing me so I set the Gmail folders to be used for certain things (i.e. Drafts, Sent, Junk, Trash), but now I'd like to set it back. I can't use undo because it was a while ago. How should I go about doing this?

    This is the action that I'm talking about. I set certain Gmail folders to be used for these 4 options. I would like to release those folders from their respective duties.

  • Is there a way to have what used to be called "Macros" (a small blurb that you type repeatedly over and over)?

    Is there a way to have the use of what we used to call "Macros" which would be a key you could hit where you have installed a word, phrase, etc that you type repeatedly? By this I mean if, while on line, you repeatedly type out the phrase "Thank you very much for your attention to this matter"....you could hit a key (like maybe F5 or something similar) that would automatically type this phrase out so you don't have to type it over and over and over again.

    You can also look at Clippings.
    *Clippings: https://addons.mozilla.org/firefox/addon/clippings/

  • Is there a way to automatically hide used clips??

    is there a way to hide the used clips??
    iMovie 10.0.4

    You can capture the complete clip and then apply Mark > DV Start/Stop Detect over the captured clip. You could get the best of two worlds so: smooth capture and clips creation.

  • While use of IL01, is there a way to enforce entry of characters?

    When creating a new functional location using IL01,  is there a way to enforce entry of a character in each space?, to ensure there are NO blank spaces?
    I have a new FLoc Structure created.
    NNNNA-XXXXXX-XXXXXX-XXXXXX-XXXXXX
    The business is asking if there a way to enforce entry of a character in each space?, to ensure there are NO blank spaces?
    Can anyone know of way to enforce entry or has done this before?
    Thanks,,
    David.

    Hi David,
                  There isnt any standard solution for your requirement because for Blank Spaces also the system considers to be a Character.
    Regards,
    Yawar Khan

  • Is there a way to open the mic using apple remote desktop

    Is there a way to open the mircophone channel using Apple Remote Desktop so I can listen on anything thats happening at my computer at home? If not is there another software that would work?
    Also is there a way to use apple's software to control and watch a PC?

    Is there a way to open the mircophone channel using Apple Remote Desktop so I can listen on anything thats happening at my computer at home? If not is there another software that would work?
    You would have to launch software that would accept audio from the microphone and transmit it to you in some fashion. ARD does not transmit audio itself. Another remote control solution such as Timbuktu might transmit audio, so you could look into that, perhaps.
    Also is there a way to use apple's software to control and watch a PC?
    You can install a VNC server on the PC and ARD can then take control of the system. It can be tricky to find a VNC system that will work with ARD, though, so search this forum for "VNC" for possible options. One of the applications that support Microsoft's remote desktop architecture such as their own Remote Desktop Connection Client for Mac or iTap Mobile RDP will probably work better, though.
    Regards.

  • Is there a way to open the notification pane using magic mouse?

    Is there a way to open the notification pane using magic mouse? i mean it would be great if i could two finger swipe to the right for the notification pane (two finger swipe left opens dashboard)
    I have Magic Prefs if it helps

    It doesn't seem like this is possible in 10.9.1.  Can someone at Apple confirm or provide a solution?

  • I scanned an image and want to use the image trace tool, but it doesn't pick up all the lines.  Is there a way to darken the lines before using the image trace tool?

    I scanned an image and want to use the image trace tool, but it doesn't pick up all the lines.  Is there a way to darken the lines before using the image trace tool?  Help!

    If the scan is in B&W, then play with the Threshold setting here
    If it's in Color, then you will have to open the scan in a Raster editing software (like Photoshop) and play with the Brightness/Contrast settings to make the lines bolder.

  • I want to play music from my playlist when I am using slideshow of my pictures in Ipad,  but I can only choose ONE SINGLE song, and it continuously repeates itself.  Is there a way to play the complete playlist while showing my pictures?

    I want to play music from my playlist when I am using slideshow of my pictures in Ipad,  but I can only choose ONE SINGLE song, and it continuously repeates itself.  Is there a way to play the complete playlist while showing my pictures?

    You can start the playlist playing in the iPod app and then switch into the Photos app and start your (non-music) slideshow - as you've found out you can currently only select a single track in the Photos app. Whether that will change in iOS 5 I don't know, but you could try leaving feedback for Apple : http://www.apple.com/feedback/ipad.html

  • Is there a way to delete the Apple ID on one device (IPhone 5) and replace the ID on that device with an existing ID used on three other devices?

    Is there a way to delete the Apple ID used on one device (IPhone5) and replace it with another ID that is being used on three other devices?

    If you have turned on Settings > iCloud > Find My you will have to start by turning that off - requires entering the Apple ID password.  Then remove the Apple ID from all places it is used, i.e., Messages, FaceTime, and so on.  Go to the App Store and then Sign Out.  Now you can enter the desired Apple ID and password in all of those places.

  • Is there a way to change the Apple ID you're using on your iPhone?

    I recently got an iPhone 3 and I am using my brothers ID to download apps but he won't tell me his password and its really inconvenient having to ask him to put it in every time, so I was wondering if theres a way to change the one your using as I have another on I can now use instead. Please if you have any thoughts on how to do this please tell me. Thanks

    Hi,
    try
    Settings->Store
    click on the existing appleId (your brothers), click 'sign out'. You should then be able to sign-in, but this time select 'Create New Apple ID'

  • My husband and I have the same Apple ID number so that we can both have access to an app we use.  I don't like the fact that our calendar, notes and email is also shared.  Is there a way to separate the things we want separate yet keep access to the cloud

    My husband and I share the same Apple ID number because we both need access to an app that has a subscription and would be expensive for us to do separately.  We don't like that this shared ID number means we also share our calendar, note pages, email, etc....Is there a way to separate the things we don't want to share?

    That would be my suggestion.  Just keep using the common one for purchases in the stores.  Then each get another AppleID using a free gmail, AOL, hotmail, MS Live or whatever email account.
    Delete your current iCloud account and login with the new AppleID, and logout of Messaging and then backin with the new AppleID.  Now you have a shared iTunes/App store account, but completely separate, independent iCloud and iMessage accounts.
    You can still share calendars if you wish to, even across separate accounts - http://support.apple.com/kb/ph2690

  • My husband and I both have iPads and somehow when they were setup the both we're setup using the same email I'd address. When I go to delete and rename one iPad it says all info and pictures will be erased from my iPad. Is there a way to keep the info iPa

    My husband and I both have iPads and somehow when they were setup the both we're setup using the same email I'd address. When I go to delete and rename one iPad it says all info and pictures will be erased from my iPad. Is there a way to keep the info IPad when doing this?

    You can go to Settings/iCloud and delete the account, then create a new iCloud account.  You can still use the same account for the app store though.

Maybe you are looking for

  • $0.99 Weekend Movie Rental

    Rented *Breakfast At Tiffany's* a week ago at $2.99 but it's at $0.99 for this weekend only. Ouch! Anyhow, I think it's a weekly promo thingy from iTunes Store. Guess I shall do my rentals over weekends from now on. :P Also, I think it's better to re

  • Supressing repeated values in hierarchy.

    Hi, this is what i wanna do. I have a hierarchy in query in my rows and another char also in the rows. When i run the query, the hierarchy node shows along with the other char in rows and the required KF's in columns. So far so good. But when i expan

  • SAP TAX TEMPLATE FOR BAHARAIN

    HI All, Please inform a if a standard template for gathering the data from business exists for the implemenation of SAP FI -TAX Configuration for a new country. The implementation is for Baharain. Also what level of TAX complexity exists and if the G

  • Pls help me to find the smartform name for RMA REQUEST(RMA)

    Hi Experts, Pls Tell me how too find the smartform name for RMA REQUEST(RMA) Pls help Thanks and regards Jaya

  • Archive link for Incomming Invoice

    Hi All, I have a requirement to link my incomming Invoce with Image of Invoce....which is stored in another server (not SAP) called Basware. we should be able to clik on link of image from Invoice document and Image should be open from Basware server