is there a way to impose the use of sequences

is there a way to stop someone to insert 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 be

However is it a check constraint of some ilk who made sure the user uses the sequence during inserts?
then the second insert
INSERT INTO test_table
     VALUES (2);
gives me a sort of violation of check constraint that I do not use the id_seq. NEXTVAL?

Allows you to encode the audit in a trigger

SQL> ed
Wrote file afiedt.buf

  1  create trigger trg_test_table
  2    before insert on test_table
  3    for each row
  4  declare
  5    l_currval integer;
  6  begin
  7    select id_seq.currval
  8      into l_currval
  9      from dual;
 10    if( l_currval != :new.id_seq )
 11    then
 12      raise_application_error( -20001, 'Hey!  Use the sequence' );
 13    end if;
 14* end;
 15  /

Trigger created.

SQL> INSERT INTO test_table
  2       VALUES (id_seq.NEXTVAL);

1 row created.

SQL> INSERT INTO test_table
  2       VALUES (id_seq.NEXTVAL);

1 row created.

SQL> INSERT INTO test_table
  2       VALUES (25);
INSERT INTO test_table
            *
ERROR at line 1:
ORA-20001: Hey!  Use the sequence
ORA-06512: at "SCOTT.TRG_TEST_TABLE", line 9
ORA-04088: error during execution of trigger 'SCOTT.TRG_TEST_TABLE'

But at this point, you're probably better just to have the trigger complete the sequence column ignoring all that was passed in.

Justin

Tags: Database

Similar Questions

  • Are there possible ways to check the use of database applications on windows 8?

    Original title: use of data

    Are there possible ways to check the use of database applications on windows 8?

    SB

    If by data use you mean internet is used by desktop applications, you must install a 3rd party like net limiter tool.

  • Is there a way to track the use of Apple's music?

    I have the family plan and I would like to know how we as a family of broadcast music, primarily to determine whether to continue.

    To my knowledge there is no way to control the use of streaming music Apple. You can check the latest purchases in your iTunes account and you can check the iCloud data storage and its use but is not streaming its use. My guess is that Apple has this info somewhere so they can find a way to balance the load on their servers from Apple's music but I've never seen like the selection of menu item or a user of Apple's music.

  • Is there a way to recover the use of storage for a specific org through the vCloud API RESTful vdc?


    Hello - I hope someone can tell me how to recover the amount of storage used against an assignment given to a specific VCC in the goal.  I use storage profiles in my environment and when I retrieve the details of an org vDC by AGAINST... api / / admin/vdc / < OID >, I think the result is a block with hrefs VdcstorageProfiles I can do more gets against for details on provisioned storage profiles.  However the results of these becomes later contain just a 'Limit' tag in the XML file that indicates the amount of the allowance, but still no details on usage.  The initial GET against the vDC shows its use against the allocation of memory and cpu, and I was looking to find a similar result for storage.

    Thank you!

    Nevermind, I just have this one resolved, everything necessary for the query / api /? type = adminOrgVdcStorageProfile & filter = vdcName is XXXX

  • I use Origami as my screensaver and changing images quickly, is there a way to slow the progression from one slide to another?

    I use Origami as my screensaver and changing images quickly, is there a way to slow the progression from one slide to another?

    Check in system preferences > Desk Top & screensaver:

    Ciao.

  • I accidentally deleted files and even deleted from the Recycle Bin. Is there a way to retrieve them using MS DOS?

    I accidentally deleted files and even deleted from the Recycle Bin. Is there a way to retrieve them using MS DOS?

    Thank you both of you who tried to help. I just found out that Dropbox keeps deleted files images for 30 days. I just need to go in their undelete function, choose the files that I deleted and restore them. It has been easy.

    Thanks again

  • Recovery of the system using Backup automatic backup of XP program wants a disk is there a way to let him use a CD instead?

    Recovery of the system using Backup automatic backup of XP program wants a disk is there a way to let him use a CD instead?

    Name of the operating system Microsoft Windows XP Professional
    Version 5.1.2600 Service Pack 3 Build 2600
    Manufacturer of operating system Microsoft Corporation
    250GB_DRIVE system name
    System manufacturer HP Pavilion 061
    EG705AA-ABA M7265C system model
    System Type X 86-based PC
    Processor x 86 Family 15 Model 4 Stepping 4 GenuineIntel ~ 2800 Mhz
    Version/Date BIOS Phoenix Technologies, LTD 3.17, 20/04/2006
    SMBIOS Version 2.4
    Windows C:\WINDOWS directory
    System directory C:\WINDOWS\system32
    Boot Device \Device\HarddiskVolume2
    The local United States
    Hardware Abstraction Layer Version = "5.1.2600.5512 (xpsp.080413 - 2111).
    250GB_DRIVE\HP_Administrator user name
    Time zone Pacific Daylight Time
    Total physical memory 072,00 MB 3
    1.55 GB available physical memory
    Total virtual memory 2.00 GB
    Available virtual memory 1.96 GB
    Page file space 4.83 GB
    Paging file C:\pagefile.sys

    Hello

    The ASR (automated system recovery) tool must have a disk for restoration purposes. The best option, if you really want to use ASR, is a floppy of USB external as suggested by chrisamiller.

    You can also follow this procedure to create the ASR files without the floppy drive and then copy them to another location to create a floppy disk or, if you're lucky, your PC can boot from a USB key (I never tried to start ASR on a key, do not know if it will work or not, but it might be worth it) :

    "You can"trick"the ASR in the race without a floppy drive." When it gets to the point where he writes on the diskette to cancel it. He writes two files, which are used for recovery, in the Windows\Repair directory. After completing your ASR copy these two files (files asr.sif and asrpnp.sif) to a network location and then make the diskette also. Make sure you update your disk whenever you make a new ASR or your backup will be watered.

    Or, you can use a USB floppy drive. It is sometimes the only option, especially if you need to install SCSI or SATA drivers during the recovery. »

    a: when you start the backup, it may be in Wizard mode. Follow the link to the Advanced Mode.
    b. Backup tab.
    c. click on the box next to the drive you want to back up so that it has a blue box.
    d. backup media or file name: Browse.
    e. Select a new file name on your CD.
    f. start the backup.

  • Is there a way to recover the deleted files without using any software?

    Is there a way to recover the deleted files without using any software?

    Is there a way to recover the deleted files without using any software?

    # Software is necessary.

    First check the recylcl tray. If she isn't here, read the following:

    "Deleting" a file does not delete actually it brand just space be used. There are third-party programs that can sometimes recover deleted files. The problem is that the space used by the file is likely to be replaced very quickly, and this makes the unrecoverable file.

    So your chances of successfully recover this file are decent, if you try it again immediately after deleting it and quickly down. If you have used the computer since then (for example to read this answer and write that question), your chances may be very weak now.

    But if the file is large enough, it's still worth a try. Stop using the computer in question immediately, if you haven't done so already. Download an undelete program (in here is one: http://www3.telus.net/mikebike/RESTORATION.html but there are many other choice; do a search) on a friend's computer and bring it to you on a diskette, CD, or drive to the thumb.

    If that fails, your only recourse is to bring or send the drive to a professional file recovery company. This kind of service is very expensive and may or may not work in your case.

  • Is there a way to disable the fingerprint on my laptop reader? I don't want to use it.

    Is there a way to disable the fingerprint on my laptop reader?  I don't need or want that I'm the only one using my laptop.  In addition, in case of emergency, I would like someone else to access my laptopn.  It does not always first or second time and I find it annoying.

    I have a laptop DV7-6169NR model.

    Thanks for your help.

    Kathy

    Hello

    If you do not ever use fingerprint sensor, then you can uninstall it from the system for it - HP SimplePass software. Then you can disable the fingerprint sensor in the Device Manager. How to do?

    Reach:

    Control Panel-> device-> biometric devices Manager

    Right click of your fingerprint sensor fingerprint validity it and choose " disable ".

  • I put 240 photos in an InDesign document using mini bridge.  Is there a way to hide the photos I used after I have put in my document?

    I put 240 photos in an InDesign document using mini bridge.  Is there a way to hide the photos I used after I have put in my document?

    I think Willi, and I even read your question differently. I thought you wanted to hide the images in Mini Bridge once they have been placed in InDesign so that you could keep track of those who you have (if you put twice the same image). If you want to hide in InDesign (as Willi read the question), his suggestion is very good. Another alternative is to use the shortcut to hide (command 3 on Mac OS), after putting the images, but before you click next to deselect them.

    I do not use Mini Bridge, so I can't help you there. If you want to use the full version of the bridge, you can use a Move command to move the selected items to another folder (temp), where they will not appear in your current folder. You can move after that that they all were placed. A bit of a hack, but it could work.

  • Is there a way to replace the series I use?

    I was using a student permit until the last few days and now bought a lot. Is there a way to replace the serial and more key reinstall the plug-in?

    Thank you.

    With the plugin the first raise after deactivation takes you back to the mode of trial in silence.

    If you raise again if she must invite for a new SN.

    -Chris

  • Is there a way to hide the button of hamburger?

    Is there a way to hide the button of hamburger?

    http://userstyles.org/styles/101011/hide-Firefox-menu-button

    or using a userChrome.css file

    @namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
    
    #PanelUI-menu-button {display: none;}
  • After that you increase the size of the page with Ctrl plus, is there a way to keep the new setting?

    My new laptop has great features but a much smaller screen. Change the screen resolution in Windows makes it all look terrible. Using ctrl / + in Firefox to increase the page size solves the problem, but only until you go to a new page. Is there a way to keep the new setting until what reverse you it with ctrl/less?

    There are some add-ons that can be used to change the zoom level on all sites, for example:

  • Is there a way to remove the Favorites button in the menu bar?

    Is there a way to remove the Favorites button in the menu bar? I use the Google toolbar to organize my favorites because Google bookmarks can be accessed from any computer and my phone. By habit, I continue to go click on the Favorites button in the menu bar in Firefox, but there is nothing there. Can I remove it? I want to talk about real "Bookmarks" option in the menu bar across the top of the window: file | Change | View | History | BOOKMARKS | Tools | Help

    See http://kb.mozillazine.org/Editing_configuration#How_to_edit_configuration_files

    Add code to userChrome.css below @namespace.

    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
    
    #bookmarksMenu {display:none!important;}
    
  • Is there a way to make the safari opens a new page every time?

    Hello

    I'm kinda new here and I would like to ask a question. I now use an iPhone as a primary device, instead of Android. But is there a way to make the safari to remove all tabs when you close, and when you open it, it just opened a new page or a blank page? My phone is just laying around sometimes and I let my friends to use. But when I close safari after I order something or when I'm checking my bank account, they can all see when they open up safari...

    All I can think is to close all tabs before close Safari, or use it in private Mode:

    Enable or disable the navigation on your iPhone, iPad or iPod touch - Apple Support

Maybe you are looking for

  • Need to pass the iPhone 6 to iOS 10 before getting iP7?

    I have an iPhone 6s + running iOS 9 and I'm getitng a new iPhone 7 this Friday. Everything is backed up daily to iCloud. I have to spend my 6 s + iOS 10 and do a backup to restore from backup iPhone 7 - or that I can use my backup to iCloud iOS 9 and

  • SuSE 9.2 on an A30 614

    I tried to install suse 9.2 on my laptop.It works if I stop the PCMCIA device on the manual installation. En I did.SUSE is working now but my pcmcia device does not work.When I see the irq pcmcia and lancart are on IRQ11.I need the device pcmcia for

  • HP Solutions Center's does not open after Installation

    My used HP OfficeJet 6500 appeared to have successfully installed using the complete driver on the HP download site.  However, when I click on the HP Solution Center, I receive a message that the installation was incomplete and to insert the cd that

  • How to solve error 50103

    Dear all I'm trying to collect data from two sensors. The two sensors ouput is similar tension. My goal is to acquire data from two sensors can trace their waveforms, multiply the two waveforms and get the FFT. The error that is 50103. The image of t

  • Windows 7 Installing even update every time that I log out.

    Whenever I log out, I have an update to install - the same one - a security update for Microsoft XML Core Services 4.0 Service Pack 2 for x 64-based systems (KB954430).  What do need me to either prevent it or try to really recognize that the update