Need help with trigger/new at pl/sql

I would appreciate any help as I am new to PL/SQL and have run out of ideas.
I am trying to write a trigger that when a user inserts a row into a table that records an ID, a clinic, and user initials, a second table is updated with that ID in the next available "slot" for that clinic.
I wrote a procedure that does execute successfully with ID, user initials, and clinic hardcoded. I cannot create a trigger using the fields from the 1st table instead of the hardcoded values that compiles without errors.
The tables in question are in another schema, but I have all priviledges on that schema.
I have tried referencing the fields from table 1 in every way I can think of:
1) :new.<field from table 1> and got:
ORA-04082: NEW or OLD references not allowed in table level triggers
2) :<field from table 1> and got
PLS-00049: bad bind variable '<field name>'
3) <field from table 1> , <table>.<field from table 1>, <schema>.<table>.<field from table> and got
5/38 PL/SQL: ORA-00904: "N106CLINIC": invalid identifier
14/44 PL/SQL: ORA-00904: "N106CLINIC": invalid identifier
and
5/38 PL/SQL: ORA-00904: "N106"."N106CLINIC": invalid identifier
14/44 PL/SQL: ORA-00904: "N106"."N106CLINIC": invalid identifier
and
5/38 PL/SQL: ORA-00904: "CCRN"."N106"."N106CLINIC": invalid identifier
14/44 PL/SQL: ORA-00904: "CCRN"."N106"."N106CLINIC": invalid identifier
in addition to "SQL statement ignored".
It does complain only about n106clinic, even though other fields referenced from the first table are n106id and n106init; n106clinic IS a valid field name in the n106 table...maybe this is just a compiler peculiarity.
Here is the code for the trigger. N106 is the table where the user inserts a row and RAMBCYL is the table to be updated. CCRN is the schema that owns the two tables.
create or replace trigger ccrn.aocylrand
after insert
on ccrn.n106
declare l_accno number;
begin
select rambcyl.accno into l_accno
from ccrn.rambcyl rambcyl
where rambcyl.clinic=n106clinic and
rambcyl.accno = (select min(r.accno)
from ccrn.rambcyl r
where r.id is null
and r.clinic = n106clinic);
update ccrn.rambcyl set id =n106id,
randdt = sysdate,
staff=n106init
where ccrn.rambcyl.accno = l_accno and
ccrn.rambcyl.clinic = n106clinic;
end aocylrand;
Thanks, Helen

You cannot refer to the :old or :new column values in a statement level trigger, only in row-level triggers. I would suggest the following which does the update in a single statement:
create or replace trigger ccrn.aocylrand
  after insert
  on ccrn.n106
  for each row  -- specifies a row-level trigger
begin
  update ccrn.rambcyl r1
     set id = :new.n106id,
         randdt = sysdate,
         staff = :new.n106init
   where clinic = :new.n106clinic
     and accno = (select min(r2.accno)
                    from ccrn.rambcyl r2
                   where r2.id is null
                     and r2.clinic = r1.clinic);
end aocylrand;

Similar Messages

  • I need help with my new ipod on windows me

    I bought myself an ipod in the states (usa) i was told it was universal & can be used in the uk! i have windows ME & was also told this would be compatible with this computer but once i tried to download my software of the cd & put in my details of the ipod it came up with the following error message:ERROR 1904.MODULEC:\PROGRAM FILES\IPOD\IPOD UPDATER 2005-02-07\IPOD UPDATER EXT.Dll FAIIED TO REGISTER .HRESULT-2147220473 CONTACT YOUR SUPPORT PERSONELL.
    can any one help????
    aslo i was told once downloaded onto my p.c i then cant use my ipod on another p.c this does not make any sense say if you upgrade your p.c does this mean you then cant use your ipod anymore ??? please help me ???

    Hello Andrew,
    Was the reply I gave you in the other post you made of no help?
    I explained that Windows ME is not compatible, but you can get it work with a little messing around, and once again, here's a link on how to do it.
    Guide to iPod and Windows ME.
    As I said previously though, you won't be able to use iTunes.
    See my other answer to you here.
    Jeff Bryan, "Need help with my iPod." #4, 06:13am Aug 8, 2005 CDT

  • Need help with trigger for whitespace and caps validation

    I need to create a table trigger that will generate an error whenever a specific column does not contain all caps or has whitespace when records are either inserted or updated. I'm new to writing SQL, so any help is appreciated!

    In 10g
    SQL> create or replace trigger trigg_sample
      2  before update or insert on sample
      3  for each row
      4  declare
      5  lv_pos number;
      6  begin
      7  select regexp_instr(:new.col1,'[a-z|( )]') into lv_pos from dual;
      8  if lv_pos > 0 then
      9  raise_application_error(20000,'The column contains lowercase or white space characters');
    10  end if;
    11  end;
    12  /
    Trigger created.
    SQL> desc sample;
    Name                                      Null?    Type
    COL1                                               VARCHAR2(20)
    SQL> insert into sample values('DFD') ;
    1 row created.
    SQL> insert into sample values('dfdfd') ;
    insert into sample values('dfdfd')
    ERROR at line 1:
    ORA-21000: error number argument to raise_application_error of 20000 is out of
    range
    ORA-06512: at "XLS_ADMIN.TRIGG_SAMPLE", line 6
    ORA-04088: error during execution of trigger 'XLS_ADMIN.TRIGG_SAMPLE'
    SQL> insert into sample values('DFDF ') ;
    insert into sample values('DFDF ')
    ERROR at line 1:
    ORA-21000: error number argument to raise_application_error of 20000 is out of
    range
    ORA-06512: at "XLS_ADMIN.TRIGG_SAMPLE", line 6
    ORA-04088: error during execution of trigger 'XLS_ADMIN.TRIGG_SAMPLE'
    SQL>

  • I need help with my new LG G2. I dial *611 but it will not recognize my phone number

    I am having trouble setting up my new LG G2. When I dial *611, it will not recognize my number, and the 800 number refers me back to the *611 number. There is no live chat available on the website, so I am lost. Is this any way to run customer support?

    It seems I am about the only G2 customer support you'll fund unfortunately.  Chat is available on the support site after logging in to My Verizon on the web, but you have to click on Contact Us at the top right of the page then choose Live Chat and then Help with My device and then look to the right and wait for the red dot to turn green.  *611 will take you to a screen where you can launch My Verizon or Click to Call which dials the customer support number. Unfortunately chat is about as useless as waiting for a rep to respond in the forums.  Calling is the only way to get started and work your way up the chain.  Going to a store is a hassle.  What exactly is the problem you're having?  You can't activate the phone or set up your Google accounts or what?

  • I need help with my new iPod video!!!!!

    i got an iPod video and i am trying to get some songs onto it. i plugged my iPod into my computer and opened up iTunes. i was told that an iPod icon is supposed to pop up. when i plugged my iPod in, the icon did not show up. what do i do?!
    signed,
    I NEED HELP DESPERATELY!!!!!!!!!
    Dell Inspiron   Windows 2000  

    Make sure you have the latest version of iTunes (iTunes 7.0.2.16). To find the version of iTunes you have open iTunes, click Help, then About iTunes. If this does not work then follow the following instructions:
    For iTunes Technical support please call 1-800-APL-CARE
    or
    Another problem might be that your service pack of Windows 2000 is not the latest version (Windows 2000 Service Pack 4).
    I would recogmend getting Windows XP, many advantages over Windows 2000. Especially security and looks wise.

  • Hey I need help with my new Video Ipod haha

    Hey whats up.. i need help.. i want to put some movies on my ipod from my computer.. but they wont go into itunes.. i need to find a converter to convert some divx movies and vlc what converter should i download???

    you've posted in the wrong section of this board..
    for support of iPod users on Windows, please ask the experts here:
    http://discussions.apple.com/forum.jspa?forumID=807
    iMovie is the video edit app, that comes free and exclusively on every Mac...

  • Need help with using new ipod as hard drive. please!

    Hi. Has anyone had any problems using the ipod as a hard drive between two systems? I have an old 4th generation ipod which I used on my PC. That ipod worked great between macs and pcs as a hard drive. But recently it is completely screwed up. Anyway, I got a new Mac book pro and a 5th generation 60gb ipod.
    Now, I'm trying to get some stuff off my pc and transfer it into my mac. In my pc it comes up in "my computer" but keeps asking me to format the hard drive whenever I do the drag and drop of files into it. I've already formatted it for my mac, but haven't put anything on it yet. So I guess I could just do that for the transfer and reformat it for the mac and then put my music on it.
    I just want to know, it worked so well between mac and pc as a hard drive when originally formatted for my pc. will it not work the other way around? Will I have to keep reformatting it for the pc every time and then lose any information and all my music if I want to use it in that way? Or is there something I'm doing wrong? I would really appreciate any help at all that anyone could give me. Who really needs a 60gb anyway, if not to be able to transfer files back and forth between home and work, right?
    Dell Dimension 4400/MacBook Pro   Mac OS X (10.4.9)   Windows XP on the PC

    Thank you for your reply. It cleared up a lot of confusion for me. But I have one more question.
    See, I looked both of those software applications up, and it seems those are to be installed on the windows operating system. My plan is to eventually stop using my PC and give it away to goodwill, however, for work purposes- which is freelance- I'd need to use the ipod as a nice small portable hard drive- I'm a photographer, and work with big files, so I need the larger space that a flash drive can't give me.
    So, is there any type of mac formatting on the ipod that can also be read by the pc? Or is there a 3rd party software that can be installed on the ipod that will enable it to be read on the pc and mac while retaining its mac formatting?
    If not I guess I'll just have to go back to the old and extremely inconvenient way of doing things. I really wish mac would have mentioned these things before in all their descriptions.

  • Hard Drive Crash - need help with choosing new drive and installation

    My hard drive seems to have crashed. My computer froze, and when I tried to reboot, it got stuck at the startup screen. I started from the system CD, ran the disk repair utility, and it said it could not repair the disk. I ran Tech Tool Pro and it could not repair the disk. I tried to start up in Target disk mode while connected to my older G4 iMac (that I'm using now as my backup), and the disk would not mount. So I need some expert advice - I am assuming the hard drive is toast. I wish I could at least mount it in target disk mode to transfer files, but I haven't been able to do that. I was going to take it in for repair (or possibly buy a new computer), but after reading some of the posts here, I am thinking I could just replace the internal hard drive with a 3.5" SATA drive.
    What I need to know is am I correct about this? And is this the right kind of drive for my iMac? Are there any specifications I need to be aware of when ordering a new drive? I downloaded the manual explaining how to replace the drive and it looks doable. I would appreciate any guidance as to choosing the new drive (specific brand names/models would be great), installing the drive, and tips for formatting, etc. Thanks in advance for your help!

    Welcome to Discussions - any 3 1/2" SATA drive will be fine, go to [macsales.com] or [smalldog.com] or [newegg.com] and choose whichever drive fits your wallet. Most of them are reliable, I have heard of problems with Seagate and Hitachi, but there are always some failures with any brand. Make sure to get a good warranty.Instructions will come with the drive, but you can download them from [Apple|http://www.apple.com/support/manuals/imac> as well.

  • Need help with workflow: New iMac with SSD & HDD and Pegasus Promise

    Hello everyone! I've decided to upgrade my iMac and ordered an i7 with the SSD and HDD drive configuration as well as the Pegasus Promise 12TB drive. I've been researching as to what's the best way to manage both the SSD and HDD drives and I really haven't seen an end-all answer. Now with the purchase of the Pegasus Promise, I'm more confused as to what's the best approach to take. Here are my thoughts:
    1. Use the SSD as the boot and application drive and the HDD for the users folder.
    2. Use the SSD as the boot and application drive, the HDD for the users folder, and photos and pics onto the Pegasus.
    3. Use the SSD as the boot and application drive, the Pegasus for the users folder, and the HDD for ???
    4. Just use the Pegasus drive as the boot drive and use it for everything. (being that it's a RAID drive, then all my files are backed-up already)
    Majority of my space-filling files are my iTunes folder, tons of pictures from using Aperture, and iMovie for videos.
    Thanks in advance for everyone's input and help!

    I'm working on a similar premise.  i7, SSD, HDD, Promise raid, etc.
    I'm nowhere near as savvy as a lot of the people here, but after a lot of research I decided that focusing on how the Pegasus gets configured is the most important for me.  My concerns are for a business in photography, btw.
    I can't budget the 12TB unit so I'm trying to make the most of either the R4-8tb or th R6-6tb.
    I'm planning to launch the applications from the SSD.  I will use the Mac HDD for typical non-photographic files, iTunes (mine's not so big), and standard fair.  This is all backed up via Time Machine to a 3TB Western Digital MyBook for the time being. 
    As for the Pegasus, I believe I've settled on: taking an R6-6tb unit, placing the 6th drive in my firesafe from the moment I get it.  Configuring the remaining 5 drives in a level 5 setup.  Leaves me 4TB to get started and buys me a few succesful quarters to plan on daisy chaining another unit when memory is needed.  This way, I may not have maximum possible drive space, but I've got a replacement drive on the ready should I experience a drive-failure.  Then, I'm not sitting on pins and needles while I await a replacement; they'll simply be shipping me a new "spare".
    I still need to actually speak to someone @ Promise to make sure this will work, as I stated: I"m learning as I go here.  If this is an acceptable Raid setup, you would have 8TB available to you.
    Personally, I am far more comfortable running systems in series and building the size as I go (to a point) than putting so much data in a single array.
    [Edit] The raid bay is mainly for the Lightroom catalog, and I use standard external drives to store redundant backups off-site (1TB at a time).

  • Need Help With My New 30-inch Diplay

    I just got myself the 30-inch display couple days ago... but now I am having a VERY hard time fiding a video card for it. I have one of the first generation G5's (Dual 2.0Ghz) I believe it has the 9600 64MB in it right now (what it came with) I have found a few cards that claim to work (NVIDIA 6800 Ultra and Radeon 9600 Pro) Will these work? I also found a Radeon 9650 but I saw that one website claimed it needed Mac OS X 10.4.. is this true? I'm running 10.3.9. The Radeon 9650 also seems MUCH cheaper so I would prefer that too. Any suggestions and help would be great, thanks!!!
    Dual 2.0 G5   Mac OS X (10.3.9)  

    sammx1234,
    have you tried creating a second new partition where the deleted partition used to be, and then deleting the first new partition, and then stretching the second new partition to use the space of the deleted first new partition?

  • Need help with my new n97

    Hello, I've been lucky enough to get my hands on a new N97.
    It's been working great (a bit glitchy right now but that's to be expected).
    Maps were working fine until I uploaded all the stuff from my N96 to my N97 using the pc suite backup programme.
    Now maps don't work.
    On my N96 I was using maps 3.0 beta and I guess that has something to do with the malfunction.
    The message that comes up when I boot the maps application after 30% download is this...
    Cannot install application. Install latest version from Nokia/maps.com
    I have tried downloading maps 2.0 from the site. It says my phone isn't supported. So I just say it's an n96 and download. This isn't helping. Exactly the same result.
    I have restored factory settings twice now. But to no avail.
    My n97 simply wont run the maps 2.0 application.
    Does anyone know if this has anything to do with the dump from my n96 which had maps 3.0 on it?
    And if so, why is it still not working after I reverted to factory settings.
    Most grateful for any help and advice.

    also if you need any assistance in the future, we have a whole maps section on these boards
     /discussions/board?board.id=navigation
    here is the link, be well rad.  
    You know what I love about you the most, the fact that you are not me ! In love with technology and all that it can offer. Join me in discovery....

  • I need help with the new update

    I am at a complete loss on what to do. I have been trying to install the new update but it keeps bringing up an error. I have searched on here for some solutions and I believe I am not doing this right. I have uninstalled all the items everyone has suggested (ex. Bonjour...) and rebooted. I went and downloaded iTunes again but two things keep happening:
    1. While the iTunes Setup is installing and pop-up box says "Object already exists" and this pops up multiple times
    and
    2. After those messages go away another pop up says "iTunes Installer completed - Errorc occurred during installation before iTunes could be configured. Your system has not been modified. To complete the installation, run the installer again."
    What am I doing wrong here? Can someone please help me? I have a Windows 7 laptop.

    For "Object already exists" or "Access denied" errors when installing try opening Control Panel > Programs and Features > View installed updates then checking for Security Update for Microsoft Windows (KB2918614). Uninstall if you have it, then reboot, and try installing iTunes again.
    For general advice see Troubleshooting issues with iTunes for Windows updates.
    tt2

  • Need help with the new Multi-cam feature in CC

    Hi,
    I'm trying to use the Multi-cam feature in CC and have a few questions, so would be happy with help/advice for any of the issues below. The platform is Windows 7 Pro 64bit.
    The first question is what am I doing wrong? This question relates to the fact I'm trying to use Multi-cam and encountering a lot of frustrating glitches, as sometimes it seems to work and at others it doesn't.
    The video I'm trying to edit comes from a dance show so I created a sequence called Act 1. I then highlighted the six clips of Act 1 with Cam 01 at the top, as I wanted the audio from this clip and made a Multi-cam feature using the audio synch. I dragged it to the sequence, set the prog window to Multi-cam and was amazed at how well it had synchronised all clips, as I could see all six clips with great audio synch from Cam 01. So far so good and after thinking how brilliant it was, things went downhill from there
    I started by using ripple delete to drag to the start of Act one and then tried editing with Multi-cam. That's where I encountered the first problem, as sometimes it seemed to toggle between cams but didn't put edit points in and the selected cam had a yellow border and not a red one. At other times it inserted edit points when I changed cams and the selected cam has a red border. I can't work out what I'm doing, or not doing for this to happen. Can anyone help please?
    The second question is how do I cut audio and video at exactly the same point, as I want to edit out pauses in between the different elements of the actual dance show. When I use the razor tool in Multi-cam it only cuts the video. I tried highliting audio and video using shift, but to no effect. If it matters audio and video are shown as linked when I right click. I thought I might get it to work if I revealed all original clips within the MC nest using the technique shown in "Adobe Learn." This was Ctrl double click, but it resulted in the third problem.
    When I tried Ctrl double click I ended up with only Cam 02 showing in the V2 track and after some frustrating attempts at resolving this issue I decided to start all over again. I deleted the PP project and created a new one, importing everything again. I followed exactly the same procedure as I originally did to create a Multi-cam nest, but when I dragged it to the new sequence I saw Cam 02 in V2 of the sequence, which is the same as it was before I deleted the original project. Premiere Pro seems to have annoyingly remembered the actions that went wrong, so please can anyone tell me how to tell Premiere Pro not to do this?
    Thanks if anyone can help me on any of the issues.

    In Premiere Pro, multi-camera is accomplished by nesting a sequence.  There's a new, more automated way of doing this in CC.  View the steps here: http://blogs.adobe.com/premierepro/2013/04/a-quick-walkthrough-of-editing-a-multi-camera-s equence-with-clips-synchronized-by-audio.html
    HOWEVER, you must be warned that multi-cam in CC is currently broken.  A patch is in the works, but until it is released you should not use multi-cam in CC.

  • Need help with trigger comp err

    i'm new to forms and triggers. I am trying to do a simple "select into" from the "previous" record so I can see what was the value of a column was and bump it up by one. The code for a post_text_item trigger is:
    select
    anum
    from
    x
    where
    x.pageid = :pageid;
    the gist of the error is that the compile acts like it never heard of table "x", even though the form is built on table "x"! the err is - PDE-PSD001 - Could not resolve ref to unk program unit while loading block ...
    any thoughts??
    thanks in advance,
    Burt
    null

    Sudha -
    actually -
    if the table I mention in the trigger contains an Ordsys.Ordimage column, the trigger blows. I guess the little procedure builder guy cant deal with the intermedia stuff too well/at all. I created a view from the table with the image, but didn't include the image in the view. I referenced the view in the trigger and everything went just fine.
    thanks for your input
    burt
    null

  • I need help with my new tablet please !

    hi there
    i cant logon the appworld in my tablet
    iam from Saudia arabia
    it says " the app world not available in my country "
    how can i install app if i cant conect from my tablet
    is there any way to use my laptop for help
    iam using MACBOOK computer
    in case if there is any programme need to download
    so i can work with my tablet
    sorry for my bad english
    with all respect
    Nawaf

    Dear friend, by the moment Blackberry playbook is just for USA/Canada users, in a very short time RIM will announce the release of the product for the rest of countries.
    Be patient when you can use it at 100%, you will be amazed!

Maybe you are looking for

  • Vendor field should not display when GI is done in MB1A?

    Hi  guys , i have  a  report programe here i am pulling  all the material data  and purhasing order info  in the background using the BADIO MB_DOCUMENT BADI.  here i am writing my logic. this BADI is triggering  once material Documnet is created  in

  • EIM v902 - Best practice for ActiveDB to ArchiveDB

    Hi all, In EIM there's a function to move activities from ActiveDB to ArchiveDB. Docs mention once ActiveDB hits 20GB it will be a good time to turn this on. However, the attachment will not move to the ArchiveDB. In my environment, the top 4 tables

  • How Good are the Graphics?

    Hello, I am looking to buy a new computer and I'm looking for one that will be able to run modern games such as Grand Theft Auto V (GTA V), H1Z1, Battlefield Hardline, maybe Garry's Mod (Gmod), and any other games to be released in the future that se

  • Query about  Webi Rich client Install through Infoview in XI 3.1

    When we Install Webi Rich client through Infoview on a client box ,It Install all language  packages . Is this a default behavior (So that we can log it in Enhancement request) or It is Potential bug with Product. If this is a default behavior ?Is th

  • How to use NODIM func with out it's values being rounded

    I created a new calculated key figure in Query Designer 3.x, and used the function NODIM() - Value with out dimensions. When I use this function, the values are rounding off to the nearest value. For example, I have a value 0.000075 US$, when I use N