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.

Similar Messages

  • 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>

  • How to insert huge XML in CLOB using insert command in sql*plus....

    How to upload huge XML into a CLOB column of a normal table using a script?
    A simple insert statement does not seem to work.
    Thanks & regards.

    In SQL *Plus i'm trying to insert directly into the table.
    My insert statement is like below :
    Insert into ui_templates
    (TEMPLATE_ID, TEMPLATE_NAME, CUSTOMER_ID, DESCRIPTION, XML_CONTENT)
    Values
    (1, 'Default', 1, 'Main Default Template', '<?xml version="1.0" encoding="utf-8"?><xoraLayout:Layout name="MyLayout" version="1.0" ................<3357> chars long');
    COMMIT;
    Message was edited by:
    DKar

  • Getting syntax error when i using INSERT command

    Hi,
    i am using MS Access DB. Table name is "Timesheet". the table has the following Fields,
    uname - Text
    date - Text
    intime - Text
    outtime - Text
    duration - Text
    desc - Text
    i am using preparedStatment,
    String accessDBURLPrefix = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
    String accessDBURLSuffix = ";DriverID=22;READONLY=false}";
    String filename="D:\\TimeSheet\\TimeDB.mdb"
    String databaseURL = accessDBURLPrefix + filename + accessDBURLSuffix;
    Connection con = DriverManager.getConnection(databaseURL);
    PreparedStatment st = con.prepareStatement("INSERT INTO (uname, date, intime) TimeSheet VALUES (?,?,?)");
    st.setString(1,user);
    st.setString(2,date);
    st.setString(3,intime);
    st.executeUpdate();
    }if i am going to compile this code i will get SQLException
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
         at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
         at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:3150)
         at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedStatement.java:214)
         at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(JdbcOdbcPreparedStatement.java:136)
         at TimeSheetDemo.writeToDB(TimeSheetDemo.java:84)
         at TimeSheetDemo.main(TimeSheetDemo.java:37)
    Really i have tired to figure out this problem. please help me anyone.
    thank you

    Thank you. it was my careless mistake. i changed that mistake. but still it is not working, get same exception.
    st = con.prepareStatement("INSERT INTO  TimeSheet (uname, date, intime) VALUES (?,?,?)");suppose, if i will give values for all fields, it will work fine, example
    st = con.prepareStatement("INSERT INTO  TimeSheet  VALUES (?,?,?,?,?,?)");
    st.setString(1,user);
    st.setString(2,date);
    st.setString(3,intime);
    st.setString(4,outtime);
    st.setString(5,duration);
    st.setString(6,descrip);
    st.executeUpdate();But my problem is i want to insert the values for only 3 fields.
    give me the solution for inserting values for specified fields

  • Using Insert command

    Hi Experts
    I need to insert values in a oracle database could u please give me the EJB code for it

    hi
    good
    check this code,
    // Insert1.java:  Demonstrates how to INSERT data into an SQL
    //               database using Java JDBC.
    // Copyright 1998 Developer's Daily (http://www.DevDaily.com). All rights reserved.
    import java.sql.*;
    class Insert1 {
        public static void main (String[] args) {
            try {
                String url = "jdbc:msql://200.210.220.1:1114/Demo";
                Connection conn = DriverManager.getConnection(url,"","");
                Statement st = conn.createStatement();
                st.executeUpdate("INSERT INTO Customers " +
                    "VALUES (1001, 'Simpson', 'Mr.', 'Springfield', 2001)");
                st.executeUpdate("INSERT INTO Customers " +
                    "VALUES (1002, 'McBeal', 'Ms.', 'Boston', 2004)");
                st.executeUpdate("INSERT INTO Customers " +
                    "VALUES (1003, 'Flinstone', 'Mr.', 'Bedrock', 2003)");
                st.executeUpdate("INSERT INTO Customers " +
                    "VALUES (1004, 'Cramden', 'Mr.', 'New York', 2001)");
                conn.close();
            } catch (Exception e) {
                System.err.println("Got an exception! ");
                System.err.println(e.getMessage());
    http://www.devdaily.com/java/edu/pj/jdbc/jdbc0002/
    reward point if helpful.
    thanks
    mrutyun^

  • Using SET DATEFIRST inside a function to call into a view

    Hi,
    I need to use the statement SET DATEFIRST inside a function. This operation is not available, but I need to use this command into a function to call inside a view.
    How can I solve this issue?
    Thanks

    Eventually you will learn 2 very important things.  First, the term "working day" has no absolute definition and varies by country, organization, culture, etc.  Second is that circumstances will occur that change what should be considered a working
    day to a non-working day (or vice versa).  While you might attempt to create logic that "forecasts" whether a given date in the future is a working day, you cannot apply that logic to past dates.  The best solution is to create a calendar table for
    this purpose - some forum/internet searching will find many different variations.

  • How to use Insert for mulit-values

    Can anyone help, I try to insert mulit-values using insert command. but keep getting error. here is the code.
    INSERT INTO PRODUCTS
    VALUES (
    'C','CABLE',39.95,
    'D','DSL',29.95,
    'U','DIALUP_56K',19.95);
    Thank you!

    The SQL you posted isn't valid, assuming that there are only three columns in your table. The type of insert statement you posted can only insert 1 row at a time.
    You could look into loading data into collections and using the bulk insert syntax to insert multiple values in a single statement. Please post to the PL/SQL forum if you need more assistance on this.
    Justin

  • How to overcome Dump during Insert Command

    Hi Abappers,
    When I am trying to upload the text file into the Database,
    I am using Insert command using internal table.
    When the record exist, it gives dump saying duplicate records.
    How to convert that dump into the error message?
    Please Reply.
    Regards,
    Rahul

    Rahul,
    Insert FROM TABLE itab [ACCEPTING DUPLICATE KEYS]
    Effect
    If you specify an internal table itab, several rows are created from its content for insertion in the database table. A row for insertion into the table is taken from each row of the internal table according to the same rules as for a single work area Einfügenwa. The line type of the internal table has to meet the prerequisites for use in Open-SQL statements.
    If a row witht he same primary key or a same unique secondary index does not already exist in the database table for any of the rows to be inserted, all rows are inserted and sy-subrc is set to 0. If the internal table is empty, sy-subrc is also set to 0. The system field sy-dbcnt is always set to the number of rows that were actually inserted.
    If a row with the same primary key or a same unique secondary index already exists in the database table for one or more of the rows to be inserted, these rows cannot be inserted. In this situation, there are three possibilities:
    Use of ACCEPTING DUPLICATE KEYS
    If the addition ACCEPTING DUPLICATE KEYS is specified, all rows are inserted for which this is possible. The remaining rows are rejected and sy-subrc is set to 4. The system field sy-dbcnt is set to the number of lines that are inserted.
    Handling an exception
    If the addition ACCEPTING DUPLICATE KEYS is not specified, a treatable exception occurs CX_SY_OPEN_SQL_DB (it always occurs since Release 6.10). Rows are inserted until the exception occurs. The number of rows that are inserted is not defined. The system fields sy-subrc and sy-dbcnt retain their previous value.
    Runtime error
    If the addition ACCEPTING DUPLICATE KEYS is not specified and if the exception is not handled, then a runtime error occurs (it always occurs prior to Release 6.10). This executes a database rollback that reverses all changes to the current database LUW. This applies in particular to rows that were inserted before a double entry occurred.
    i would also suggest you to see SAP help by pressing F1 because some time may we miss but SAP never.
    Amit.

  • To check a record for existence in dbtable before using insert

    Hi Experts:
    My problem is that i have defined a foreign key in the Z database table and if i create entries directly through SE11, the check executes finely, but is i use insert command through module pool, all the entries are saved and the foreign key check is not executed.
    Eg I want to check the plant entry in T001w, if it is there, only then that record should be saved, otherwise error message that please check your entry,
    Is there any possiblity without using internal table.
    Can we read through dbtable as we can in case of internal table?
    Best Regards, Neetu

    You could do a select single from T001W before you Insert into your Z table to see if the entry exists.  However, if you are doing multiple inserts it is more efficient to do a single load of the T001W records into an internal table, sort it and da a read using binary search.
    I think T001W is fully buffered (a lot of these type of tables are) so the select is going to be reasonably efficient.
    Andrew

  • Need Help Can i use Merge command along with exist function in oracle?

    I am using Merge command to update the destination table and updating the rows which are already in the destination table.
    But what i want is to delete the existing rows from the destination table and insert fresh rows instead of updating the existing rows in the destination table.
    So can we use exist function to check the existing rows and delete them and use merge command to insert the rows in the table.

    You definitely need to do a DELETE then INSERT since MERGE will not delete rows, although I'm not really sure what that gets you since the net effect would be the same as a MERGE over the same pair of tables.
    If you really want to do it this way, then I would likely do something like:
    DELETE FROM target_table
    WHERE (columns_you_would_match_on) IN (SELECT columns_you_would_match_on
                                           FROM source_table
                                           WHERE predicate_you_would_use_in_using);
    INSERT INTO target_table (column_list)
    SELECT column_list
    FROM source_table
    WHERE predicate_you_would_use_in_using;John

  • Binding problem when using NVL function

    Hello.
    I have a problem with my ADF application (11.1.2.1).
    I use VO with a query (database view) - pivot table.
    If i use where clause like table.attr = :p_attr, everything works ok.
    If i use where clause like table.attr = NVL (:p_attr, table.attr) and put a value in :p_attr (executeWithParam) , query executes as if there is a null value.
    Debug console shows:
    Binding null of type 12 for "p_attr".
    Query with NVL works ok in sqldeveloper.
    But in jdev, as if the table attribute isn't bind to bind variable.
    If a just remove NVL function, it works.
    Any idea?
    Thanks.
    Regards
    Edited by: DejanH on Oct 6, 2011 1:32 PM

    Hello.
    I enter 50 in p_depart parameter and click "ExecuteWithParams". Query is executed and shows records (pivot table).
    But if i look at the log window i see that an empty query was executed first.
    <OracleSQLBuilderImpl> <bindParamValue> [427] Binding null of type 12 for "p_depart"
    <OracleSQLBuilderImpl> <bindParamValue> [428] Binding null of type 12 for "p_job"
    <OracleSQLBuilderImpl> <bindParamValue> [429] Binding null of type 12 for "p_hire_od"
    <OracleSQLBuilderImpl> <bindParamValue> [430] Binding null of type 12 for "p_hire_do"
    Then, it is autoexecuted for the second time with parameter set to the value i inserted.
    <OracleSQLBuilderImpl> <bindParamValue> [470] Binding param "p_depart": 50
    <OracleSQLBuilderImpl> <bindParamValue> [471] Binding null of type 12 for "p_job"
    <OracleSQLBuilderImpl> <bindParamValue> [472] Binding null of type 12 for "p_hire_od"
    <OracleSQLBuilderImpl> <bindParamValue> [473] Binding null of type 12 for "p_hire_do"
    The same happens in our query. But ours is much more complex and it takes a lot of time to first execute "empty" query and then with inserted parameter.
    We cannot use it.
    It looks like bug.
    Regards
    Edited by: DejanH on Oct 11, 2011 6:52 AM

  • How to use NVL Function

    hi,
    i want to use nvl Function in that Quary
    select f_words(SUM(a.AMOUNT)+sum(a.vat_amount) +
    nvl( (select sum(b.LABOUR_AMT)+sum(b.service_tax_amt)
    from LAB_WORK_DTL b
    where a.bill_no =b.bill_no), 0)
    )) as t
    from TRANSACTION_DETAILS a
    where a.bill_no =:P42_bill_no
    group by a.BILL_NO;
    i am using NVL in that Quary Like This
    select f_words*(nvl(S*UM(a.AMOUNT)+sum(a.vat_amount) +
    nvl( (select sum(b.LABOUR_AMT)+sum(b.service_tax_amt)
    from LAB_WORK_DTL b
    where a.bill_no =b.bill_no), 0)
    )) as t
    from TRANSACTION_DETAILS a
    where a.bill_no =:P42_bill_no
    group by a.BILL_NO;
    I want to use NVL Function In BOLD
    How Can I use NVL Functiion.
    Thanks
    Edited by: Manoj Kaushik on Mar 25, 2010 5:55 AM

    hi,
    select f_wordsl(SUM(a.AMOUNT)+sum(a.vat_amount) +
    nvl( (select sum(b.LABOUR_AMT)+sum(b.service_tax_amt)
    from LAB_WORK_DTL b
    where a.bill_no =b.bill_no), 0)
    )) as t
    from TRANSACTION_DETAILS a
    where a.bill_no =:P42_bill_no
    group by a.BILL_NO;
    i have two tables Bill no is comman field in both tables if i have not enter value in any one of the table .
    so how can i show Total amount in words if Bill NO are not in any one table.
    Thanks

  • Insert query using fn-bea:execute-sql() function

    Hi ,
    How to use sql insert query in Xquery function fn-bea:execute-sql().
    Could you please anyone help me on this.
    Regards
    Rajesh.

    Hi
    Can i use stored procedure in that function to include insert query?
    could you please suggest me on this.
    Please provide some links or tutorial on that.
    Regards
    Rajesh

  • Using textboxes in insert command

    Sir,
    I had a doubt about insert command while I was trying to give the content of the swing text boxes as the arguments to the insert command.Is it possible?.How can i give values to the fields of a table through GUI components.

    Hi,
    I meant using text boxes in insert statement.because all time we should not give literals.we should have got inputs from swing panel from which we have to
    insert data into tables.So I asked how can i give variables or input GUI Components as arguments of insert statement. Also I gave the code below
    //CRM Sections Campaign
    //package marketing;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    public class CRM_Marketing_1B extends JFrame implements ActionListener
    JOptionPane joptMessage;
    JButton jbtnSave;
    JButton jbtnClear;
    JButton jbtnExit=new JButton("Exit");
    public CRM_Marketing_1B(String title)
    Container conMarketingPane=getContentPane();
    conMarketingPane.setLayout(new FlowLayout());
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel lblCustomer_Id=new JLabel("Customer ID");
    JLabel lblCustomer_Name=new JLabel("Customer Name");
    JLabel lblCompany_Name=new JLabel("Company Name");
    JLabel lblDesignation=new JLabel("Designation");
    JLabel lblAddress1=new JLabel("Address1");
    JLabel lblAddress2=new JLabel("Address2");
    JLabel lblQuantity=new JLabel("Quantity");
    JLabel lblUnit_Price=new JLabel("Unit Price");
    JLabel lblInterest_Level=new JLabel("Interest Level");
    JLabel lblContact_No=new JLabel("Contact No");
    JLabel lblMobile_No=new JLabel("Mobile No");
    JLabel lblEmail=new JLabel("Email Address");
    JLabel lblEmployee_Id=new JLabel("Employee ID");
    JLabel lblCampaign_Date=new JLabel("Campaign Date");
    JLabel lblNext_Appointment=new JLabel("Next Appointment");
    JLabel lblCampaign_Id=new JLabel("Campaign ID");
    JLabel lblTeam_Id=new JLabel("Team ID");
    JLabel lblOrder_No=new JLabel("Order No");
    JLabel lblResult=new JLabel("Result");
    JTextField txfCustomer_Id=new JTextField(30);
    JTextField txfCustomer_Name=new JTextField(30);
    JTextField txfCompany_Name=new JTextField(30);
    JTextField txfDesignation=new JTextField(30);
    JTextField txfAddress1=new JTextField(30);
    JTextField txfAddress2=new JTextField(30);
    JTextField txfQuantity=new JTextField(30);
    JTextField txfUnit_Price=new JTextField(30);
    JTextField txfInterest_Level=new JTextField(30);
    JTextField txfContact_No=new JTextField(30);
    JTextField txfMobile_No=new JTextField(30);
    JTextField txfEmail=new JTextField(30);
    JTextField txfEmployee_Id=new JTextField(30);
    JTextField txfCampaign_Date=new JTextField(30);
    JTextField txfNext_Appointment=new JTextField(30);
    JTextField txfCampaign_Id=new JTextField(30);
    JTextField txfTeam_Id=new JTextField(30);
    JTextField txfOrder_No=new JTextField(30);
    JTextField txfResult=new JTextField(30);
    JButton jbtnSave=new JButton("Save");
    JButton jbtnClear=new JButton("Clear");
    JButton jbtnExit=new JButton("Exit");
    conMarketingPane.add(lblCustomer_Id);
    conMarketingPane.add(lblCustomer_Name);
    conMarketingPane.add(lblCompany_Name);
    conMarketingPane.add(lblDesignation);
    conMarketingPane.add(lblAddress1);
    conMarketingPane.add(lblAddress2);
    conMarketingPane.add(lblQuantity);
    conMarketingPane.add(lblUnit_Price);
    conMarketingPane.add(lblInterest_Level);
    conMarketingPane.add(lblContact_No);
    conMarketingPane.add(lblMobile_No);
    conMarketingPane.add(lblEmail);
    conMarketingPane.add(lblEmployee_Id);
    conMarketingPane.add(lblCampaign_Date);
    conMarketingPane.add(lblNext_Appointment);
    conMarketingPane.add(lblCampaign_Id);
    conMarketingPane.add(lblTeam_Id);
    conMarketingPane.add(lblOrder_No);
    conMarketingPane.add(lblResult);
    conMarketingPane.add(txfCustomer_Id);
    conMarketingPane.add(txfCustomer_Name);
    conMarketingPane.add(txfCompany_Name);
    conMarketingPane.add(txfDesignation);
    conMarketingPane.add(txfAddress1);
    conMarketingPane.add(txfAddress2);
    conMarketingPane.add(txfQuantity);
    conMarketingPane.add(txfUnit_Price);
    conMarketingPane.add(txfInterest_Level);
    conMarketingPane.add(txfContact_No);
    conMarketingPane.add(txfMobile_No);
    conMarketingPane.add(txfEmail);
    conMarketingPane.add(txfEmployee_Id);
    conMarketingPane.add(txfCampaign_Date);
    conMarketingPane.add(txfNext_Appointment);
    conMarketingPane.add(txfCampaign_Id);
    conMarketingPane.add(txfTeam_Id);
    conMarketingPane.add(txfOrder_No);
    conMarketingPane.add(txfResult);
    conMarketingPane.add(jbtnSave);
    conMarketingPane.add(jbtnClear);
    conMarketingPane.add(jbtnExit);
    setSize(900,900);
    setVisible(true);
    lblCustomer_Id.setLocation(50,50);
    lblCustomer_Name.setLocation(50,70);
    lblCompany_Name.setLocation(50,90);
    lblDesignation.setLocation(50,110);
    lblAddress1.setLocation(50,130);
    lblAddress2.setLocation(50,150);
    lblQuantity.setLocation(50,170);
    lblUnit_Price.setLocation(50,190);
    lblInterest_Level.setLocation(50,210);
    lblContact_No.setLocation(50,230);
    lblMobile_No.setLocation(50,250);
    lblEmail.setLocation(50,270);
    lblEmployee_Id.setLocation(50,290);
    lblCampaign_Date.setLocation(50,310);
    lblNext_Appointment.setLocation(50,330);
    lblCampaign_Id.setLocation(50,350);
    lblTeam_Id.setLocation(50,370);
    lblOrder_No.setLocation(50,390);
    lblResult.setLocation(50,410);
    txfCustomer_Id.setLocation(250,50);
    txfCustomer_Name.setLocation(250,70);
    txfCompany_Name.setLocation(250,90);
    txfDesignation.setLocation(250,110);
    txfAddress1.setLocation(250,130);
    txfAddress2.setLocation(250,150);
    txfQuantity.setLocation(250,170);
    txfUnit_Price.setLocation(250,190);
    txfInterest_Level.setLocation(250,210);
    txfContact_No.setLocation(250,230);
    txfMobile_No.setLocation(250,250);
    txfEmail.setLocation(250,270);
    txfEmployee_Id.setLocation(250,290);
    txfCampaign_Date.setLocation(250,310);
    txfNext_Appointment.setLocation(250,330);
    txfCampaign_Id.setLocation(250,350);
    txfTeam_Id.setLocation(250,370);
    txfOrder_No.setLocation(250,390);
    txfResult.setLocation(250,410);
    jbtnSave.setLocation(250,450);
    jbtnClear.setLocation(350,450);
    jbtnExit.setLocation(450,450);
    txfCustomer_Id.setRequestFocusEnabled(true);
    txfCustomer_Id.requestFocus();
    jbtnSave.addActionListener(this);
    jbtnClear.addActionListener(this);
    jbtnExit.addActionListener(this);
    public void actionPerformed(ActionEvent ae)
    if(ae.getSource().equals(jbtnSave))
    //' &txfAddress1& ',' &txfAddress2& ',' &txfQuantity& ',
    //' &txfUnit_Price& ',' &txfInterest_Level& ',' &txfContact_No& ',
    //' &txfMobile_No& ',' &txfEmail& ',' &txfEmployee_Id& ',' &txfCampaign_Date& ',
    //' &txfNext_Appointment& ',' &txfCampaign_Id& ',' &txfTeam_Id& ',' &txfOrder_No& ',' &txfResult& '
    try
    Class.forName("jdbc.odbc.JdbcOdbcDriver");
    Connection connCampaign=DriverManager.getConnection("jdbc:odbc:CRMSource");
    Statement stmtCampaign=connCampaign.createStatement();
    /* stmt.executeUpdate("insert into Campaign values('" &jtxfCustomer_ID& "',&jtxfCustomer_Name&,
    ' &jtxfCustomer_ID& ',' &txfCompany_Name& ',' &txfDesignation& ',' &txfAddress1& ',' &txfAddress2& ',
    ' &txfQuantity& ',' &txfUnit_Price& ',' &txfInterest_Level& ',' &txfContact_No& ',
    ' &txfMobile_No& ',' &txfEmail& ',' &txfEmployee_Id& ',' &txfCampaign_Date& ',
    ' &txfNext_Appointment& ',' &txfCampaign_Id& ',' &txfTeam_Id& ',' &txfOrder_No& ',' &txfResult& ')");*/
    JOptionPane.showMessageDialog(this,"Statement was saved");
    catch(Exception ex)
    ex.printStackTrace();
    I got "unclosed character literal" error when i tried to execute the above java source file .
    help me to get the required result.

  • Compilation problems using NVL function in Pro*C subselect

    I have come across a weird oracle problem. When I execute the following query in SQLPlus it works but when
    I include it in Pro*C code in a EXEC SQL statement it gives syntax errors and fails to compile. Any idea what I am doing wrong.
    SELECT DISTINCT
         A.ID_PERSON,
         C.ID_STAGE_PERSON_LINK ,
         A.NM_PERSON_FULL,
         A.NBR_PERSON_AGE,
         A.ADDR_PERSON_ST_LN_1,
         A.ADDR_PERSON_CITY,
         A.ADDR_PERSON_ZIP,
         A.CD_PERSON_STATE,
         A.CD_PERSON_COUNTY,
         A.NBR_PERSON_PHONE,
         C.CD_STAGE_PERS_REL_INT
         FROM
              PERSON A,
              STAGE_PERSON_LINK C
         WHERE
         C.ID_CASE = 88776721
         AND          A.IND_INVALID_PERS IS NULL
         AND          C.CD_STAGE_PERS_TYPE = 'PRN'
         AND          C.ID_PERSON = A.ID_PERSON
         AND C.ID_STAGE_PERSON_LINK =
    NVL (
                   (SELECT MAX(F.ID_STAGE_PERSON_LINK)
                   FROM STAGE_PERSON_LINK F
                   WHERE F.ID_PERSON=C.ID_PERSON
                   AND F.ID_CASE = C.ID_CASE
                        AND F.CD_STAGE_PERS_TYPE = 'PRN'
                        AND F.CD_STAGE_PERS_REL_INT IS NOT NULL)
                   (SELECT MAX(G.ID_STAGE_PERSON_LINK)
                   FROM STAGE_PERSON_LINK G
                   WHERE G.ID_PERSON=C.ID_PERSON
                   AND G.ID_CASE = C.ID_CASE
                        AND G.CD_STAGE_PERS_TYPE = 'PRN')
    AND A.ID_PERSON NOT IN
    SELECT S.ID_PERSON
    FROM STAGE_PERSON_LINK S,STAGE T
    WHERE S.ID_CASE = C.ID_CASE
    AND S.ID_CASE = T.ID_CASE
    AND S.ID_STAGE = T.ID_STAGE
    AND T.CD_STAGE &lt;&gt; 'INT'
    MINUS
    SELECT H.ID_PERSON
    FROM STAGE_PERSON_LINK H, STAGE F
    WHERE H.ID_CASE = F.ID_CASE
    AND H.ID_STAGE = F.ID_STAGE
    AND H.ID_CASE = C.ID_CASE
    AND H.CD_STAGE_PERS_ROLE &lt;&gt; 'XE'
    AND F.CD_STAGE &lt;&gt; 'INT'
    This query returns data when run in sqlplus.When used in a Pro*C C program and compiled the precompiler complains with syntax errors when used with EXEC SQL DECLARE CLSS82D_CURSOR CURSOR FOR &lt; query above &gt;.However removing the NVL function and retaining the subselect clause compiles but that is not what I want to do.
    Syntax error at line 262, column 20, file clss82d.pc:
    Error at line 262, column 20 in file clss82d.pc
    SELECT MAX( F.ID_STAGE_PERSON_LINK )
    ...................1
    PCC-S-02201, Encountered the symbol "MAX" when expecting one of the following:
    ( ) * + - / . @ | at, day, hour, minute, month, second, year,
    The symbol "(" was substituted for "MAX" to continue.
    Syntax error at line 263, column 10, file clss82d.pc:
    Error at line 263, column 10 in file clss82d.pc
    FROM STAGE_PERSON_LINK F
    .........1
    PCC-S-02201, Encountered the symbol "FROM" when expecting one of the following:
    , ) * + - / | at, day, hour, minute, month, second, year,

    Pro*C works bit differently tha sqlplus. try removing the blank line after
    SELECT MAX(G.ID_STAGE_PERSON_LINK)
    FROM STAGE_PERSON_LINK G
    WHERE G.ID_PERSON=C.ID_PERSON
    AND G.ID_CASE = C.ID_CASE
    AND G.CD_STAGE_PERS_TYPE = 'PRN')
    good luck,
    Gauranga

Maybe you are looking for

  • I am no longer able to download new messages, and Thunderbird indicates that it is not responding.

    I am receiving some emails on my iPad, but not all of them.

  • New iMac on the way

    Hi everyone, I ordered a new iMac two days ago, my first Mac of any kind. The operating system and everything will be very new to me and my wife. I really didn't know which model or options but ended up choosing the 24" 2.93GHz with a GT 130 video ca

  • Field value retrieve from sql query

    Hi, Is there any way to code sql query into form field in rtf template ?. I have converted an oracle report to BI publisher (e-business suite R12) but I have a form field that contain a sql query that retrieve a value from database. I don't know how

  • Fade in fade out pics in flash

    Hi there ive just downloaded the flash catalyst cs5 trial version and am trying to create a fade in fade out effect with my pictures so i can upload to my website. Ive been on it for two days now and am getting no where anybody have any suggestions o

  • Sata Raid with spare drive not booting?

    Hi Peeps, Been reading throught this forum and founds loads of good tips already, however, I still can't find the answer to my problem. Just setup 2 new Maxtor (250gb) drives as Raid 0, made them bootable and installed Windows XP SP2. All works fine