Can use INSERT in a FUNCTION

create or replace function insert_new_richesid_list(in_hard in number,in_productid in number)
return number
as
v_sql varchar2(1000);
v_result number;
err_num number;
err_msg varchar2(1000);
begin
v_sql:='insert into new_richesid_list(richesid,hard,productid,getdate) values (auto_richesid_list.nextval,'||in_hard||','||in_productid||',sysdate)';
execute immediate v_sql;
v_sql := 'select auto_richesid_list.currentval from dual';
execute immediate v_sql
into v_result;
return (v_result);
exception
when others then
err_num :=SQLCODE;
err_msg := SUBSTR(SQLERRM, 1, 1000);
insert into err_report(errno,errcode,errmsg,errdate,errsql) values (sq_err_report_errno.nextval,err_num,err_msg,sysdate(),'insert_new_richesid_list');
end;
run it ,tell me :
ERROR at line 1:
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "SPORTSCN.INSERT_NEW_RICHESID_LIST", line 19
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at line 1
why?

Just like the previous response I did not have any difficulty with
this FUNCTION. However, I have modified it slightly. Give it
a try and let me know if it works:
create or replace function insert_new_richesid_list
(in_hard in number,in_productid in number)
return number as
v_sql varchar2(1000);
v_result number;
err_num number;
err_msg varchar2(1000);
begin
v_sql:='insert into new_richesid_list(richesid,hard,productid,getdate) '||
'values (auto_richesid_list.nextval, :1, :2, :3 )';
execute immediate v_sql
USING in_hard, in_productid, sysdate;
v_sql := 'select auto_richesid_list.currentval from dual';
execute immediate v_sql
into v_result;
return (v_result);
exception
when others then
err_num :=SQLCODE;
err_msg := SUBSTR(SQLERRM, 1, 1000);
insert into err_report(errno,errcode,errmsg,errdate,errsql)
values (sq_err_report_errno.nextval,err_num,err_msg,sysdate,'insert_new_richesid_list');
RETURN('FAIL');
end;

Similar Messages

  • Is there a way I can use the iPhoto maps function within Keynote?

    Hi,
    I recently brought a Macbook Pro, and am having my first go at using Keynote. Having previously played with iPhoto, there is the map function built in, and I was wondering whether there is a way to use this in Keynote?
    I was hoping to avoid using a screenshot of google maps as its not interactive, and plus quite bland too.
    Any way this can be done?
    Thanks,

    Keynote can not interact with other applications other than launch a web browser, it cant display web content within a Keynote presentation.
    The only way Keynote can be used to display a "live" web content is to launch a browser at a specific webpage, Google Maps for example,
    To try this place a shape on the slide, select it then:
    Inspector > Hyperlink > Enable as Hyperlink > link to webpage;  type in the web address in the URL box

  • In File to File how we can use Oracle in-bulit functions like LPAD???

    Hi,
    I am performing file to file transformation using staging area different from target.
    My requirement is a)I have to implement LPAD or RPAD for each record in a file.
    b)which LKM ,i will use for loading data from souce
    Thanks.

    Hi,
    You can to use LKM File to SQL and IKM SQL to File Append (Read the description b4 using it).
    Also, make sure u "check" staging area different from target area and select any Oracle logical schema in the drop down.
    Eventually, u can see 3 boxes in flow tab whereas u need to select KMs for 1 st (LKM) and 3 rd (IKM) boxes only.
    So now, u can write ur oracle function for columns and execute that in "staging".
    P.S: Please close ur previous thread if they are answered. And plz bare in mind to assign points if u find the replies from expert are Helpful/Correct.
    Thanks,
    Guru

  • How can use java emulate ping function?

    When I type ping xxx.x.xx.x,it would send a icmp package.
    If the remote mechine has no echo,it would wait too long.
    So Making a runtime process to invoke ping command directly is not efficient.
    My single aim is showing the remote mechine exiting or not on web page.
    Any idea appreciate

    Runtime.exec,I know,but it's too long to wait if the mechine has no echo.
    The checked machine is not the pc,but the "set top box".
    Assume there are no firewall to block any port and any protocol.
    It can telnet to the STB by No.25 port.
    But when I use socket connection,it has no response.
    It's very weird.
    I have successfully to check the PC by this way.
    Anyway,this way also wait too long,although I have set the time out value.It has no use.
    BTW,I have search the forums again, some one write native C to emualte icmp.I still not test it and hope it not use that complex way.
    package TEST;
    import java.net.*;
    import java.io.*;
    * Useful to know if you can connect to a computer
    * Port 13 is the date time port
    * Port 7 is the echo port
    * Port 23 is the Telnet service port
    * Port 25 is the E-Mail port
    public class PING {
        public static void main (String [] args) {
            if(args.length !=2){
                System.out.println("Usage: java ping ");
                System.exit(0);
            String computer = args[0];
            int dayTimePort = 13; //each computer uses this port for date and time
            dayTimePort = Integer.parseInt(args[1]);
            BufferedReader in = null;
            Socket socketComputer = null;
            try{
                System.out.println(computer + ":" + dayTimePort);
                socketComputer = new Socket(computer,dayTimePort);
                socketComputer.setSoTimeout(1000);
                in = new BufferedReader( new InputStreamReader( socketComputer.getInputStream() ) );
                String timeStamp = in.readLine();
                System.out.println( computer + " is alive at " + timeStamp );
            }catch (UnknownHostException e) {
                System.err.println( "Don't know about host: " + computer );
                System.exit( 1 );
            }catch (IOException e) {
                System.err.println( "Couldn't get I/O for " + "the connection to: " + computer + e.getMessage());
                System.exit( 1 );
        } // end main
    } // end class ping.java

  • How do I put my bookmarks in alphabetical order? I can use the sort by function in the organize bookmarks tab but it does not save.

    When I open the bookmark tab my bookmarks are sorted in random order. I want to open the bookmark tab and have them in alphabetical order. How do I set this as the default for bookmarks?

    See http://kb.mozillazine.org/Sorting_and_rearranging_bookmarks_-_Firefox
    SortPlaces: https://addons.mozilla.org/firefox/addon/9275

  • How to use INSERT INTO ALL statement in jdbc prepared statement with beans

    Kindly give me some example that how we can use "INSERT INTO ALL STATEMENT" in jdbc prepared statement inside a jsf bean?
    Actually i want to take employee id's of present employees using single jsf page and using one textbox for each employee id.
    How can i use INSERT INTO ALL statement to achieve this?
    Following is my code snippet.
    AttendanceBean.java:
    public class AttendanceBean {
    private int atteid;
    private String attdname;
    private int attday;
    private int attmonth;
    private int attyear;
    public static Connection getAttConnection() throws Exception {
    String driver = "oracle.jdbc.driver.OracleDriver";
    String url = "jdbc:oracle:thin:@localhost:1521:globldb3";
    String username = "scott";
    String password = "tiger";
    Class.forName(driver);
    Connection conn = DriverManager.getConnection(url, username, password);
    return conn;
    public String addAttendance(){
    Connection conn = null;
    PreparedStatement pstmt = null;
    boolean committed = false;
    try {
    conn = getAttConnection();
    conn.setAutoCommit(false);
    String query = "INSERT ALL INTO attendance VALUES (?,?,?,?,?)";
    pstmt = conn.prepareStatement(query);
    pstmt.setInt(1,this.atteid);
    pstmt.setString(2,this.attdname);
    pstmt.setInt(3,this.attday);
    pstmt.setInt(4,this.attmonth);
    pstmt.setInt(5,this.attyear);
    pstmt.executeUpdate();
    conn.commit();
    conn.setAutoCommit(true);
    committed = true;
    return "home.xhtml";
    } catch (Exception e) {
    e.printStackTrace();
    return "CRM.xhtml";
    } finally {
    try{
    if (!committed) conn.rollback();
    if (pstmt != null) pstmt.close();
    if (conn != null) conn.close();
    }catch(Exception e){
    e.printStackTrace();
    }

    Check this program for some info on Push buttons:
    1-DEMO_DYNPRO_PUSH_BUTTON
    2-DEMO_DYNPRO_MODULE
    3-DEMO_DYNPRO_ON_CONDITION
    Suppose Your screen is 101
    Then in that screen create one push button and assign it a function code.
    Now in the PAI of the 101 screen
    Create Module for user command
    Inside that module checc the sy-ucomm if sy-ucomm eq <Function code of your push button>
    Insert the values in database.
    *& Module USER_COMMAND_0101 INPUT
    process after input for screen 0101 *
    MODULE USER_COMMAND_0101 INPUT.
    CASE OK_CODE.
    WHEN 'SAVE'.
    *Insert the values here
    WHEN 'DISP'.
    ENDCASE.
    CLEAR OK_CODE.
    ENDMODULE. " USER_COMMAND_0101 INPUT
    Regards
    Neha
    Edited by: Neha Shukla on Dec 3, 2008 1:02 AM
    Edited by: Neha Shukla on Dec 3, 2008 1:02 AM
    Edited by: Neha Shukla on Dec 3, 2008 1:06 AM

  • How to insert multiple rows in a single shot using insert command?

    Hi,
    If we insert one row, we can use "insert into" command. I want to insert multiple rows into the table in a single shot. Is there any SQL command for insert multiple rows into the table?
    Plese give the solution.
    Thanks,
    chelladurai

    If you would like to do it with SQL, this would be one of the ways to achive it:
    SQL*Plus: Release 10.2.0.4.0 - Production on Fri Sep 25 10:12:59 2009
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, Data Mining and Real Application Testing options
    SQL>
    SQL> desc leap
    Name                                      Null?    Type
    FIRST_PRICE                                        NUMBER(16,6)
    NEXT_PRICE                                         NUMBER(16,6)
    SQL>
    SQL> select * from leap;
    no rows selected
    SQL>
    SQL>
    SQL> !vi multirow_insert.sql
    SQL> !cat multirow_insert.sql
    insert into leap(first_price, next_price) values (1,2);
    insert into leap(first_price, next_price) values (3,4);
    insert into leap(first_price, next_price) values (5,6);
    SQL>
    SQL> @multirow_insert.sql
    1 row created.
    1 row created.
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL>
    SQL> select * from leap;
    FIRST_PRICE NEXT_PRICE
              1          2
              3          4
              5          6
    SQL>

  • Using XQilla XQuery Extension Functions in BDBXML

    Hello
    How i can use xqilla:parse-json function in BDBXML?
    http://xqilla.sourceforge.net/ExtensionFunctions
    Thx,
    Vitaliy

    Vitaliy,
    Because it's in XQilla you can just use it. If there are issues it is not available for Oracle-based support but those working on XQilla will likely investigate.
    Here's an example that just returns the XML mapping of some simple JSON:
    dbxml> query xqilla:parse-json('{"menu": {
    "id": "file",
    "value": "File",
    "popup": {
    "menuitem": [
    {"value": "New", "onclick": "CreateNewDoc()"},
    {"value": "Open", "onclick": "OpenDoc()"},
    {"value": "Close", "onclick": "CloseDoc()"}
    1 objects returned for eager expression 'xqilla:parse-json('{"menu": {
    "id": "file",
    "value": "File",
    "popup": {
    "menuitem": [
    {"value": "New", "onclick": "CreateNewDoc()"},
    {"value": "Open", "onclick": "OpenDoc()"},
    {"value": "Close", "onclick": "CloseDoc()"}
    dbxml> print
    <json type="object"><pair name="menu" type="object"><pair name="id" type="string">file</pair><pair name="value" type="string">File</pair><pair name="popup" type="object"><pair name="menuitem" type="array"><item type="object"><pair name="value" type="string">New</pair><pair name="onclick" type="string">CreateNewDoc()</pair></item><item type="object"><pair name="value" type="string">Open</pair><pair name="onclick" type="string">OpenDoc()</pair></item><item type="object"><pair name="value" type="string">Close</pair><pair name="onclick" type="string">CloseDoc()</pair></item></pair></pair></pair></json>
    Here's an example that queries the parsed JSON:
    dbxml> query xqilla:parse-json('{"menu": {
    "id": "file",
    "value": "File",
    "popup": {
    "menuitem": [
    {"value": "New", "onclick": "CreateNewDoc()"},
    {"value": "Open", "onclick": "OpenDoc()"},
    {"value": "Close", "onclick": "CloseDoc()"}
    }}')//pair[.="CreateNewDoc()"]
    1 objects returned for eager expression 'xqilla:parse-json('{"menu": {
    "id": "file",
    "value": "File",
    "popup": {
    "menuitem": [
    {"value": "New", "onclick": "CreateNewDoc()"},
    {"value": "Open", "onclick": "OpenDoc()"},
    {"value": "Close", "onclick": "CloseDoc()"}
    }}')//pair[.="CreateNewDoc()"]'
    dbxml> print
    <pair name="onclick" type="string">CreateNewDoc()</pair>
    Have fun -- it's quite experimental at this stage.
    Regards,
    George

  • Using insert command in NVL function

    How can we use insert command in a NVL function
    exapmle : INSERT INTO employee
    VALUES ( (NVL ( (SELECT emp_id
    FROM employee
    WHERE emp_name LIKE 'Test'),
    (insert into employee values((select max(emp_id)+1 from employee),'Test')))));
    I mean i will check for the record to exist in the table and if not exist i will add it to the table.

    998504 wrote:
    How can we use insert command in a NVL function
    exapmle : INSERT INTO employee
    VALUES ( (NVL ( (SELECT emp_id
    FROM employee
    WHERE emp_name LIKE 'Test'),
    (insert into employee values((select max(emp_id)+1 from employee),'Test')))));
    I mean i will check for the record to exist in the table and if not exist i will add it to the table.The first thing caught my eye is this
    max(emp_id) +1A real bad piece of code. Never do that. Ever thought about multi user environment? Use a SEQUENCE.
    If you want EMP_NAME to be unique (Which looks strange to me), then just add a UNIQUE constraint. You dont try to do what oracle already does really well.

  • Using iPad mail program I have a draft of an email. I attempted to "cancel" and "delete draft" but it is still on my screen even after shutting down and restarting. How do I exit so that I can use other mail functions?

    Using iPad mail program I have a draft of an email. I have attempted to "cancel" this and "delete draft" but the email stays on my screen. How can I exit this so that I can use other email functions?

    Try closing the Mail app completely and see if it works properly when you re-open the app : from the home screen (i.e. not with the Mail app 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the Mail app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    If that doesn't work also do a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • If we use DML statement in function then that function can be used inside s

    if we use DML statement in function then that function can be used inside select query or any DML query?

    select f from t2;I think you meant to query t1.
    It works if the function is an autonomous transaction:
    create or replace function f return number
    is
    PRAGMA AUTONOMOUS_TRANSACTION;
    begin
        update t1 set c=2;
        commit;
        return 1;
    end;
    select f from t1But as Billy said why would you want to do DML this way. And this is not the way autonomous procedures should be used either.
    An an answer to an interview question though nothing wrong with it.

  • How can I buy it on my Apple ID so I can use Recovery to put my MBP to function once again? Help D=

    My MBP just failed, bought it from a friend and dont have an Apple ID with Lion, Lion is no longer on the App Store so, how can I buy it on my Apple ID so I can use Recovery to put my MBP to function once again? Help D=
    Or what else could I do? I don´t have any USB to reinstall the OS and my DVD Unit is death, but it seems I can reinstall over Wi-Fi if Im able to link an OS X Lion license to my Apple ID

    You would need to call Apple Sales (USA 1-800-MY-APPLE) and purchase a redemption code for Lion.

  • How do I find out what year my MacBook Pro is?  I want to know if I can use the mirroring function with my Apple TV if I download Mountain Lion.

    I'm trying to find out if I can use the mirror function to look at large construction drawings using my Apple TV.  It says that my MacBook Pro has to be early 2011 or newer and I can't remember what it is.

    Mactracker - Get Info on any Mac

  • I have powerpoint for Mac on my imac.  I can't seem to get the active text box function to work like it did on my PC.  How can I insert an active textbox into a presentation that will allow me to type while presenting?

    I have powerpoint for Mac on my imac.  I can't seem to get the active text box function to work like it did on my PC.  How can I insert an active textbox into a presentation that will allow me to type while presenting?

    I've gotten a little further on this. The dynamic select is
    working fine. It's the "a href" code that isn't. I'm wondering if
    someone can look at this line and tell me if it's okay to build the
    query string this way. The storeid comes through fine but I'm still
    not getting the employeeid value to pass. Here's line that's not
    working:
    td><a href="registerStoreCust.php?storeid=<?php echo
    $row_storeRS['storeid']; echo "&employeeid="; echo
    $_GET['employeeLM']; ?>">Register
    Customer</a></td>

  • Every time I try to upload a video to youtube (or pictures to blog services like tumblr) using Firefox, I cannot upload them unless I use the "basic uploader" function. Why and what can be done?

    Every time I try to upload a video to youtube or a pictures to a blog service, such as tumblr, I am unable to do so with the default uploading options (usually something that allows multiple uploads, etc). Instead, I can upload these media using their "basic upload" functions. Why and what can be done?
    == URL of affected sites ==
    http://www.youtube.com; http://www.tumblr.com

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you turn on the computer, and again when you log in.
    Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a Fusion Drive or a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to start up and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal startup may also be somewhat slow.
    The login screen appears even if you usually login automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, restart as usual (not in safe mode) and verify that you still have the problem. Post the results of the test.

Maybe you are looking for