Using combination of insert into and select to create a new record in the table

Hello:
I'm trying to write a stored procedure that receives a record locator parameter
and then uses this parameter to locate the record and then copy this record
into the table with a few columns changed.
I'll use a sample to clarify my question a bit further
-- Create New Amendment
function create_amendment(p_mipr_number in mipr.mipr_number%TYPE, p_new_amendment_number in mipr.amendment_number%TYPE)
return integer is
new_mipr_id integer;
begin
THIS is causing me grief See comments after this block of code
insert into mipr
(select mipr_id from mipr where mipr_number=p_mipr_number),
(select fsc from mipr where mipr_number=p_mipr_number),
45,
(select price from mipr where mipr_number=p_mipr_number),
practical,
(select part_number from mipr where mipr_number=p_mipr_number);
THe above will work if I say the following
insert into mipr
(select * from mipr where mipr_number=p_mipr_number);
BUt, Of course this isn't what I want to do... I want to duplicate a record and change about 3 or 4 fields .
How do I use a combination of more than one select and hard coded values to insert a new record into the table.
/** Ignore below this is fine... I just put a snippet of a function in here ** The above insert statement is what I need help with
select (mipr_id) into new_mipr_id from mipr where mipr_number=p_mipr_number + amendment_number=(select max(amendment_number) + 1);
return new_mipr_id;
end;
THANK YOU IN ADVANCE!
KT

function create_amendment(p_mipr_number in mipr.mipr_number%TYPE)
return integer is
new_mipr_id integer;
tmp_number number;
tmp_mipr_id integer;
begin
tmp_number :=(select max(amendment_number) from mipr where mipr_number=p_mipr_number);
Question:
tmp_number :=1; works..
tmp_number doesn't work with the select statement?
Obviously I'm a novice! I can't find anything in my book regarding tmp variables... What should I look under is tmp_number a
variable or what? In my Oracle book, variable means something different.
Thanks!
KT
I have the following code in my stored procedure:
Good luck,
Eric Kamradt

Similar Messages

  • What is the shortcut key instead of using right-click on the link and selecting "Open Link in New Tab" from the context menu?

    I want to use from keyboard(to hold this for example T)and left-click on the link to open the link.Exactly my question is about "Opening links in a new tab".I prefer to use LEFT-click.thank you so so much.

    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    You can use "Disable all add-ons" on the ''Safe mode'' start window.
    You have to close and restart Firefox after each change via "File > Exit" (on Mac: "Firefox > Quit")

  • TS4124 I have around 1000 songs manually downloaded from my CD's to iTunes in my iPhone before an operating system change on my computer deleted my iTunes and had to create a new one.  The music won't transfer to my new iTunes!  How do I get it back?

    I can't figure out how to get my music back onto a new iTunes from my iPhone.  I had to replace my iTunes after an update to my operating system on my MacBook Pro was reversed (found Mountain Lion to be incompatible with many existing programs and couldn't use it).  I had alraedy manually loaded about a 1,000 songs from my CD's and now no matter what I've tried I can't get them back onto my new iTunes!  How can I fix this without re-loading all of these songs?

    Some of the information below has subsequently appeared in a document by turingtest2: Recovering your iTunes library from your iPod or iOS device - https://discussions.apple.com/docs/DOC-3991
    Your i-device was not designed for unique storage of your media. It is not a backup device and media transfer was planned with you maintaining a master copy of your media on a computer which is itself properly backed up against loss. Syncing is one way, computer to device, updating the device content to the content on the computer, not updating or restoring content on a computer. The exception is iTunes Store purchases which can be transferred to a computer.
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer - http://support.apple.com/kb/HT1848 - only purchases from iTunes Store
    For transferring other items from an i-device to a computer you will have to use third party commercial software. Examples (check the web for others; this is not an exhaustive listing, nor do I have any idea if they are any good):
    - Expod (free) - http://www.headlightsoft.com/expod/ - Mac, universal for 104.+ (newer machines try de-Tune)
    - deTune (free) - http://www.headlightsoft.com/detune/ - Mac, 10.5+
    - Senuti - http://www.fadingred.com/senuti/
    - Phoneview - http://www.ecamm.com/mac/phoneview/
    - MusicRescue - http://www.kennettnet.co.uk/products/musicrescue/
    - Sharepod (free) - http://download.cnet.com/SharePod/3000-2141_4-10794489.html?tag=mncol;2 - Windows
    - Snowfox/iMedia - http://www.mac-videoconverter.com/imedia-transfer-mac.html - Mac & PC
    - iexplorer (free) - http://www.macroplant.com/iexplorer/ - Mac&PC
    - Yamipod (free) - http://www.yamipod.com/main/modules/downloads/ - PC, Linux, Mac [Still updated for use on newer devices? No edits to site since 2010.]
    - 2010 Post by Zevoneer: iPod media recovery options - https://discussions.apple.com/message/11624224 - this is an older post and many of the links are also for old posts, so bear this in mind when reading them.
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive - https://discussions.apple.com/docs/DOC-3141 - dates from 2008 and some outdated information now.
    Copying Content from your iPod to your Computer - The Definitive Guide - http://www.ilounge.com/index.php/articles/comments/copying-music-from-ipod-to-co mputer/ - Information about use in disk mode pertains only to older model iPods.
    Get Your Music Off of Your iPod - http://howto.wired.com/wiki/Get_Your_Music_Off_of_Your_iPod - I am not sure but this may only work with some models and not newer Touch, iPhone, or iPad.
    Additional information here https://discussions.apple.com/message/18324797

  • Cannot delete messages i now have over 30000 messages in box if I cancel the acount will it delete all messages?  And if i create a new account with the same address will they all come back?

    Cannot delete message they come back imediately, I now 30,111 messages in inbox

    Try logging into your email provider's web interface on a computer. Mark some of those emails as spam - this will vary based on provider, and I do not know how Videotron does it.
    Delete the others. Hopefully, they have some spam filter and will begin to learn those emails are just junk.

  • How to create a new record using a custom method?

    Hi I want to create Jdev 11 a new record using the contructor following in the footsteps of http://www.oracle.com/webapps/online-help/jdeveloper/10.1.3/state/content/navId.4/navSetId._/vtAnchor.CACCIJAG/vtTopicFile.adfdevguide%7Cweb_adv~htm/.
    My problem is the following.
    Messages for this page are listed below.
    Error
    JBO-29000: Unexpected exception caught: javax.ejb.EJBException, msg=java.lang.IllegalArgumentException: Object: null is not a known entity type.; nested exception is: java.lang.IllegalArgumentException: Object: null is not a known entity type.
    Error
    java.lang.IllegalArgumentException: Object: null is not a known entity type.; nested exception is: java.lang.IllegalArgumentException: Object: null is not a known entity type.
    Error
    Object: null is not a known entity type.
    Someone can help me?
    Cristian.

    Hello Frank, this tutorial make it and was successful but, what I am trying to do is add a new record in the table departments. The steps undertaken are suguientes
    drag over page the contructor department, with a submit, this will drag on the button, the method presistencia, set binding action with "$ (bindings.Departments.result)", and when running the application gives me the error
    Nov 2, 2007 10:06:22 PM oracle.adf.controller.faces.lifecycle.FacesPageLifecycle addMessage
    WARNING: ADFc: JBO-29000: Unexpected exception caught: javax.ejb.EJBException, msg=java.lang.IllegalArgumentException: Object: null is not a known entity type.; nested exception is: java.lang.IllegalArgumentException: Object: null is not a known entity type.
    oracle.jbo.JboException: JBO-29000: Unexpected exception caught: javax.ejb.EJBException, msg=java.lang.IllegalArgumentException: Object: null is not a known entity type.; nested exception is: java.lang.IllegalArgumentException: Object: null is not a known entity type.
    I need to know if what I am doing is right, because I followed the steps of the tutorials and it is not functioning the insertion of a new record.
    Thank you thank you.

  • SELECT * cannot be used in an INSERT INTO query when the source or destination table contains a multivalued field

    Hi,
    I am using Access 2013 and I have the following VBA code, 
    strSQL = "INSERT INTO Master SELECT * from Master WHERE ID = 1"
     DoCmd.RunSQL (strSQL)
    when the SQL statement is run, I got this error.
    SELECT * cannot be used in an INSERT INTO query when the source or destination table contains a multivalued field
    Any suggestion on how to get around this?
    Please advice and your help would be greatly appreciated!

    Rather than modelling the many-to-many relationship type by means of a multi-valued field, do so by the conventional means of modelling the relationship type by a table which resolves it into two one-to-many relationship types.  You give no indication
    of what is being modelled here, so let's assume a generic model where there is a many-to-many relationship type between Masters and Slaves, for which you'd have the following tables:
    Masters
    ....MasterID  (PK)
    ....Master
    Slaves
    ....SlaveID  (PK)
    ....Slave
    and to model the relationship type:
    SlaveMastership
    ....SlaveID  (FK)
    ....MasterID  (FK)
    The primary key of the last is a composite one of the two foreign keys SlaveID and MasterID.
    You appear to be trying to insert duplicates of a subset of rows from the same table.  With the above structure, to do this you would firstly have to insert rows into the referenced table Masters for all columns bar the key, which, presuming this to be
    an autonumber column, would be assigned new values automatically.  To map these new rows to the same rows in Slaves as the original subset you would then need to insert rows into SlaveMastership with the same SlaveID values as those in Slaves referenced
    by those rows in Slavemastership which referenced the keys of the original subset of rows from Masters, and the MasterID values of the rows inserted in the first insert operation.  This would require joins to be made between the original and the new subsets
    of rows in two instances of Masters on other columns which constitute a candidate key of Masters, so that the rows from SlaveMastership can be identified.
    You'll find examples of these sort of insert operations in DecomposerDemo.zip in my public databases folder at:
    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
    If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.
    In this little demo file non-normalized data from Excel is decomposed into a set of normalized tables.  Unlike your situation this does not involve duplication of rows into the same table, but the methodology for the insertion of rows into a table which
    models a many-to-many relationship type is broadly the same.
    The fact that you have this requirement to duplicate a subset of rows into the same table, however, does make me wonder about the validity of the underlying logical model.  I think it would help us if you could describe in detail just what in real world
    terms is being modelled by this table, and the purpose of the insert operation which you are attempting.
    Ken Sheridan, Stafford, England

  • What mechanism Oracle 10g use for write (Insert/ Update) and Read (Select)?

    Hi
    What mechanism Oracle 10g use for write (Insert/ Update) and Read (Select)?
    Thank you

    Aren't the answers given in PL/SQL forum sufficient enough?Well, as the first answer in that forum directed the OP to this forum you can hardly blame them for the repost.
    There is some high-level stuff in the Concepts Guide. If that is insufficient the OP will need to tell us what more details they need to know (and perhaps why).
    Cheers, APC

  • INSERT INTO with SELECT invalid column name error

    I have a problem where I wish to update a table with only records that have changed or insert into a table with only new records. The Source table is queried using OPENQUERY as we have no staging db for this.
    I have the following code (adapted from a working example):
    INSERT INTO dbo.Contact
    SELECT contactID, lastUpdatedDateTime
    FROM
    MERGE INTO dbo.Contact AS DT
    USING (SELECT * FROM OPENQUERY(LINKED_SERVER,'SELECT contactID, lastUpdatedDateTime FROM Contact')) AS DS
    ON (DT.ContactID = DS.ContactID)
    WHEN NOT MATCHED THEN
    INSERT VALUES (DS.contactID, DS.lastUpdatedDateTime)
    WHEN MATCHED AND (DT.lastUpdatedDateTime <> DS.lastUpdatedDateTime) THEN
    UPDATE SET DT.contactID = DS.contactID, DT.lastUpdatedDateTime = DS.lastUpdatedDateTime
    OUTPUT $Action Action_Out
    AS MERGE_OUT
    WHERE MERGE_OUT.Action_Out = 'UPDATE';
    GO
    When I run this query I am getting the following errors referring to the columns in the SELECT:
    Msg 207, Level 16, State 1, Line 2
    Invalid column name 'contactID'.
    Msg 207, Level 16, State 1, Line 2
    Invalid column name 'lastUpdatedDateTime'.
    Am I missing something obvious as I can't quite work out why? The Target and source definitely exist with the specified columns present in both...

    Hello,
    The issue is because you are not outputting those values from the inner merge statement. All you are currently outputting is the action, so the error is correct as those columns do not exist.
    Change your output portion to be:
    OUTPUT inserted.contactID, inserted.lastUpdatedDateTime, $Action Action_Out
    Then it should work.
    Sean Gallardy | Blog | Microsoft Certified Master

  • I built an ad using layers saved it and then converted it to a jpeg. Now when I go into elements 11 to do anything else it will not allow to copy and paste to create a new layer. What am I missing?

    I built an ad using layers saved it and then converted it to a jpeg. Now when I go into elements 11 to do anything else it will not allow to copy and paste to create a new layer. What am I missing?

    You know that you lost the layers when you saved it as a jpeg, right? But you're saying you can't add layers to the jpeg now when it's open in the editor? Go to Image>mode and be sure it's RGB, for starters. Are all the commands in the Layer menu grayed out?

  • How do I create a new calendar for the current year, using last years calendar's birthday's/photos and comments from the lower pages?

    Each year for the past 5 years I make a family calendar and send copies to all he family members around the globe.  I hate that I have to recreate all the birthdays and special occasions from scratch, and re-drag all the photos onto these dates, in the lower half of the page of each month on the new calendar.  How can I create a new calendar for the current year and port all of these photos/comments into the new calendar from last years calendar, to save having to redo all this work!!  I am not talking about the upper half page of the photos only...I am referring to the calendar page of each month.
    Thanks in advance. 
    Colin

    Welcome to the Apple Discussions. Open iWeb so you see your original site in the left hand pane. Use the File->New Site menu option to create a new site. Give it the name you want.
    Now select a page in your original site and type Command+D. That will duplicate the page. Drag the duplicate page down to the new site and rename it as needed. Do that for the other pages you need in the original site.
    OT

  • I cant use facetime. but my sister can. we share the same account for itunes.but when i go to face itme and click on create a new account a blank screen pops up. what do i do?when i go to make a new facetime account nothing comes up

    i cant use facetime. but my sister can. we share the same account for itunes.but when i go to facetime on my ipod touch and click on create a new account a blank screen pops up and the only thing it says is cancel and account.  what do i do?

    Please follow these directions to delete the Mail "sandbox" folder.
    Back up all data.
    Triple-click the line below to select it:
    ~/Library/Containers/com.apple.mail
    Right-click or control-click the highlighted line and select
    Services ▹ Reveal
    from the contextual menu.* A Finder window should open with a folder named "com.apple.mail" selected. If it does, move the selected folder — not just its contents — to the Desktop. Leave the Finder window open for now.
    Quit and relaunch Mail, and test. If the problem is resolved, you may have to recreate some of your Mail settings. You can then delete the folder you moved and close the Finder window. If you still have the problem, quit Mail again and put the folder back where it was, overwriting the one that may have been created in its place. Post your results.
    Caution: If you change any of the contents of the sandbox, but leave the folder itself in place, Mail may crash or not launch at all. Deleting the whole sandbox will cause it to be rebuilt automatically.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard (command-C). In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar, paste into the box that opens (command-V). You won't see what you pasted because a line break is included. Press return.

  • How do I set upmy Imac to allow using both my computer speakers and a Bose SoundLink system as outputs at the same time.  I can use one or the other, but not both.

    how do I set up my Imac to allow using both my computer speakers and a Bose SoundLink system as outputs at the same time.  I can use one or the other, but not both.  From systems Preferences I must select one or the other.  I want both to work all the time.

    Hi,
    I would recommend you to use 0FI_AP_4 rather using both, particularly for many reasons -
    1. DS: 0FI_AP_4  replaces DataSource 0FI_AP_3 and still uses the same extraction structure. For more details refer to the OSS note 410797.
    2. You can run the 0FI_AP_4 independent of any other FI datasources like 0FI_AR_4 and 0FI_GL_4 or even 0FI_GL_14. For more details refer to the OSS note: 551044.
    3. Map the 0FI_AP_4 to DSO: 0FIAP_O03 (or create a Z one as per your requirement).
    4. Load the same to a InfoCube (0FIAP_C03).
    Hope this helps.
    Thanks.
    Nazeer

  • I have a MacBook Pro, I want to copy Itunes files to an SD card to play in my car, the SD Card doesn't appear in Itunes when I insert it, and I don't know how to convert the files to the correct format, can anyone help?

    I have a MacBook Pro, I want to copy Itunes files to an SD card to play in my car, the SD Card doesn't appear in Itunes when I insert it, and I don't know how to convert the files to the correct format, can anyone help?
    Thank you

    So it seems from reading the COMMAND manual that my first issue is that I used a 16GB SD card, and the manual says it will only recogize up to a 2GB SD card. I did use my MB Air's SD card slot and crated a folder and dragged the music files to it, then to the card. So I am going to get a 2GB card and try that next. Otherwise just stick with the iPOD connected. At least that is 8GB

  • I'm using FF 3.5.18 and I do not want newer versions because : using in the Open in New Tab page opens the near tab and not as a FF 3.5.18 or is it possible to do that open in new tabs would be the end. of the new FF version

    I'm using FF 3.5.18 and I do not want newer versions because : using in the Open in New Tab page opens the near tab and not as a FF 3.5.18 or is it possible to do that open in new tabs would be the end. of the new FF version

    You can change a preference to make tabs open
    # at the end of all open tabs
    # immediately after the current tab.
    See: http://kb.mozillazine.org/About:config
    *Type '''about:config''' in the URL bar and press the Enter key.
    *If you see the warning, accept it (promise to be careful).
    *Filter = browser.tabs.insertRelatedAfterCurrent
    *Look at the "Value" column ('''false'''=open at end, '''true'''=open after current tab); Value = true is the default.
    *Double-click that preference to toggle the value from true to false, or false to true
    *Restart Firefox (File > Restart Firefox)
    See: http://www.mydigitallife.info/2010/02/01/change-firefox-to-open-new-tab-at-far-right-end-of-tabbar-disable-insert-next-to-current-active-tab/

  • I recently bought a used iPod touch generation 5 and reset it (erased everything from it because the previous owner left a passcode on it) and I had to enter my language,wi-fi stuff, and then it said "Activate iPod" I don't know the owners info! Help?

    I recently bought a used iPod touch generation 5 and reset it (erased everything from it because the previous owner left a passcode on it) and I had to enter my language,wi-fi stuff, and then it said "Activate iPod" This iPod is currently linked to an Apple ID (c*****@k*****.net). Sign in with the Apple ID that was used to set up this iPod. The man who sold it to me said he bought it from another guy and sold it to me..So, I don't know what to do! I searched it up and it said you could go to iCloud and iTunes, but It's not working for me. Please help!!

    A little more information:
    You are running against the Activation Lock
    iCloud: Find My iPhone Activation Lock in iOS 7
    If you can't get this done
    Find My iPhone Activation Lock: Removing a device from a previous owner’s account
    you have a thin brick. I suspect your iPod was stolen or lost. I would turn it into the police since it is worthless to you if you can't get the previous owner to remove from their account

Maybe you are looking for

  • Change selected tab color theme

    I'm trying to make a small adjustment to my color theme. If you have used X-Chat Aqua, you'll notice that in the Blue OS X color theme, highlighted tabs are in blue, and easily identified. However, when the color scheme is grey, highlighted tabs are

  • Sony Hard disk error. Warranty services ?

    Recently I bought a hard disk E-1 1TB and now it doesn't show up when I connect. I tried in other laptops also. I have invoice bill is it enough to avail warranty services or warranty card is also required? If I dont have warranty card how can I get

  • Why am I no longer getting the student creative cloud rate?

    Up to August of 2014 I was paying the student creative cloud rate of 19.99/month. When I renewed, I began getting charged 29.99/month and I am still a student. Why is this? And I know to some it's only 10.00 but that is a lot for me right now.

  • Problems with the header

    Hello, I have followed the tutorial using my own Photos but now I have a problem. I have taken a screenshot to shot how the header "involves" with the next line. I don't know how to solve this problem? Isabella

  • Dialtone when trying to turn my Sennheiser headset on. Also doesn't let me switch back to telephone

    I have a Sennheiser OfficeRunner headset using the HeadSetup software and the automatic handset lifter. For the past 6 months it's worked FLAWLESSLY: When I would remove the headset from the base, the headset would be in PC Audio mode. When not on th