Error inserting a row into a table with identity column using cfgrid on change

I got an error on trying to insert a row into a table with identity column using cfgrid on change see below
also i would like to use cfstoreproc instead of cfquery but which argument i need to pass and how to use it usually i use stored procedure
update table (xxx,xxx,xxx)
values (uu,uuu,uu)
     My component
<!--- Edit a Media Type  --->
    <cffunction name="cfn_MediaType_Update" access="remote">
        <cfargument name="gridaction" type="string" required="yes">
        <cfargument name="gridrow" type="struct" required="yes">
        <cfargument name="gridchanged" type="struct" required="yes">
        <!--- Local variables --->
        <cfset var colname="">
        <cfset var value="">
        <!--- Process gridaction --->
        <cfswitch expression="#ARGUMENTS.gridaction#">
            <!--- Process updates --->
            <cfcase value="U">
                <!--- Get column name and value --->
                <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                <cfset value=ARGUMENTS.gridchanged[colname]>
                <!--- Perform actual update --->
                <cfquery datasource="#application.dsn#">
                UPDATE SP.MediaType
                SET #colname# = '#value#'
                WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
                </cfquery>
            </cfcase>
            <!--- Process deletes --->
            <cfcase value="D">
                <!--- Perform actual delete --->
                <cfquery datasource="#application.dsn#">
                update SP.MediaType
                set Deleted=1
                WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
                </cfquery>
            </cfcase>
            <cfcase value="I">
                <!--- Get column name and value --->
                <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                <cfset value=ARGUMENTS.gridchanged[colname]>
                <!--- Perform actual update --->
               <cfquery datasource="#application.dsn#">
                insert into  SP.MediaType (#colname#)
                Values ('#value#')              
                </cfquery>
            </cfcase>
        </cfswitch>
    </cffunction>
my table
mediatype:
mediatypeid primary key,identity
mediatypename
my code is
<cfform method="post" name="GridExampleForm">
        <cfgrid format="html" name="grid_Tables2" pagesize="3"  selectmode="edit" width="800px" 
        delete="yes"
        insert="yes"
              bind="cfc:sp3.testing.MediaType.cfn_MediaType_All
                                                            ({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
              onchange="cfc:sp3.testing.MediaType.cfn_MediaType_Update({cfgridaction},
                                            {cfgridrow},
                                            {cfgridchanged})">
            <cfgridcolumn name="MediaTypeID" header="ID"  display="no"/>
            <cfgridcolumn name="MediaTypeName" header="Media Type" />
        </cfgrid>
</cfform>
on insert I get the following error message ajax logging error message
http: Error invoking xxxxxxx/MediaType.cfc : Element '' is undefined in a CFML structure referenced as part of an expression.
{"gridaction":"I","gridrow":{"MEDIATYPEID":"","MEDIATYPENAME":"uuuuuu","CFGRIDROWINDEX":4} ,"gridchanged":{}}
Thanks

Is this with the Travel database or another database?
If it's another database then make sure your columns
allow nulls. To check this in the Server Navigator, expand
your DataSource down to the column.
Select the column and view the Is Nullable property
in the Property Sheet
If still no luck, check out a tutorial, like Performing Inserts, ...
http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/index.jsp
John

Similar Messages

  • What is the best practice for inserting (unique) rows into a table containing key columns constraint where source may contain duplicate (already existing) rows?

    My final data table contains a two key columns unique key constraint.  I insert data into this table from a daily capture table (which also contains the two columns that make up the key in the final data table but are not constrained
    (not unique) in the daily capture table).  I don't want to insert rows from daily capture which already exists in final data table (based on the two key columns).  Currently, what I do is to select * into a #temp table from the join
    of daily capture and final data tables on these two key columns.  Then I delete the rows in the daily capture table which match the #temp table.  Then I insert the remaining rows from daily capture into the final data table. 
    Would it be possible to simplify this process by using an Instead Of trigger in the final table and just insert directly from the daily capture table?  How would this look?
    What is the best practice for inserting unique (new) rows and ignoring duplicate rows (rows that already exist in both the daily capture and final data tables) in my particular operation?
    Rich P

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> My final data table contains a two key columns unique key constraint. [unh? one two-column key or two one column keys? Sure wish you posted DDL] I insert data into this table from a daily capture table (which also contains the two columns that make
    up the key in the final data table but are not constrained (not unique) in the daily capture table). <<
    Then the "capture table" is not a table at all! Remember the fist day of your RDBMS class? A table has to have a key.  You need to fix this error. What ETL tool do you use? 
    >> I don't want to insert rows from daily capture which already exists in final data table (based on the two key columns). <<
    MERGE statement; Google it. And do not use temp tables. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Insert Multiple rows into the table from that table data

    Hi All,
    I have a requirement like to insert mulitple rows into the table from that table data only(I need to replicate the data).
    In this table primary key is composite primary key with all foreign keys.primary key also including the Date foreign key.I need to change that date at the of insertion.
    INSERT
    INTO myschema.Fact_page_performance
    time_sk ,
    batch_id ,
    delta_msec ,
    delta_user_msec,
    error_code_sk ,
    content_errs ,
    element_count ,
    page_bytes ,
    Available ,
    date_sk
    VALUES
    (SELECT time_sk ,
    batch_id ,
    delta_msec ,
    delta_user_msec,
    error_code_sk ,
    content_errs ,
    element_count ,
    page_bytes ,
    Available
    FROM myschema.FACT_PAGE_PERFORMANCE_BACKUP
    WHERE date_sk=20090509,20090510
    But it is giving the error like missing Expression.
    Could anyone please help to me.
    Thanks and Regards
    Swetha.

    You can have either VALUES or SELECT not both
    INSERT
    INTO myschema.Fact_page_performance
    time_sk ,
    batch_id ,
    delta_msec ,
    delta_user_msec,
    error_code_sk ,
    content_errs ,
    element_count ,
    page_bytes ,
    Available ,
    date_sk
    SELECT time_sk ,
    batch_id ,
    delta_msec ,
    delta_user_msec,
    error_code_sk ,
    content_errs ,
    element_count ,
    page_bytes ,
    Available
    FROM myschema.FACT_PAGE_PERFORMANCE_BACKUP
    WHERE date_sk=20090509,20090510;

  • Inserting multiples rows into a table using function or procedure..

    How do i insert multiples rows into a table using function or procedure?
    Please provide me query..

    Use FORALL bulk insert statement...
    eg:
    procedure generate_test_data as
    type cl_itab is table of integer index by pls_integer;
    v_cl_itab cl_itab;
    type cl_vtab is table of varchar2(25) index by pls_integer;
    v_cl_vtab cl_vtab;
    type cl_dtab is table of date index by pls_integer;
    v_cl_dtab cl_dtab;
    begin
    for i in 1.. 100 loop
              v_cl_itab(i):= dbms_random.value(1,1000);
              v_cl_vtab (i):=dbms_random.string('a',20);
              v_cl_dtab (i):=to_date(trunc(dbms_random.value(2453737, 2454101)),'j');          
         end loop;
         forall i in v_cl_itab.first .. v_cl_itab.last
              execute immediate 'insert into test_order values( :n, :str , :dt ) ' using v_cl_itab(i), v_cl_vtab (i), v_cl_dtab (i);          
         commit;
    end;

  • Query to insert a row in a table with same values except 1 field.

    Suppose I have a table with 100 columns(fields).
    I want to insert a row with 99 fileds being the same as previous ones except one fileld being different.
    The table doesn't have any constraints.
    Kindly suggest a query to solve the above purpose..

    And for much more lazy people, a desc of table is shorter to write. :-)
    Then copy & paste into any editor, then mode column to add a comma after every column name in one shot.Or have the system do it for you. Be lazy.
    SELECT Column_Name || ',' FROM User_Tab_Columns where Table_Name = '';
    Indeed, it can be converted to a script called desc(.sql)
    SELECT Column_Name || ',' FROM User_Tab_Columns where Table_Name = '&1' ORDER BY Column_Id;
    Then desc or @desc.

  • Inserting multiple rows into a table (using sequences)

    Hi!
    I want to insert multiple rows into a db table, but I don't know how.
    I know how to insert 1 row using a sequence:
    I put all the fields in the jsp form's page and in the submit page I put something like this:
    <jbo:Row id="myRow" datasource="ds" action="Update" rowkeyparam="MyRowKey" >
    <jbo:SetAttribute dataitem="*" />
    </jbo:Row>
    But how can I insert multiple rows like this:
    Id          Name
    1          ana
    2          monteiro
    3          maria
    Thanks!

    Hi Chris,
    I think this should give you what you need: Working with a Multiple Select List Item
    --Jennifer                                                                                                                                                                                                                                                                                                                                                                                                   

  • Inserting Multiple Rows into Database Table using JDBC Adapter - Efficiency

    I need to insert multiple rows into a database table using the JDBC adapter (receiver).
    I understand the traditional way of repeating the statement multiple times, each having its <access> element. However, I am just wondering whether this might be performance-inefficient, as it might insert records one by one.
    Is there a way to ensure that the records are inserted into the table as a block, rather than record-by-record?

    Hi Bhavesh/Kanwaljit,
    If we have multiple ACCESS tags then what happens is that the connection to the database is made only once. But the data is inserted row by row.
    Why i am saying this?
    If we add the following in JDBC Adapter..logSQLStatement = true. Then incase of multiple inserts we can see that there are multiple
    <i>Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','1000')
    Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','2000')</i>
    Doesnt this mean that rows are inserted one by one?
    Correct me if i am wrong.
    This does not mean that the transaction is not guaranted. Either all the rows will be inserted or rolled back.
    Regards,
    Sumit

  • Populating a table with two columns using a custom bean

    hello,
    Can someone provide me or give me a link to an example of populating a table (with two columns) with a custom bean?
    thank you
    fwu

    1)create a java class
    2)have a list as a class variable
    3) populate the list in the constructor..
    4) map the values in the af:table
    //Employee pojo
    public class Employee {
        public Employee() {
            super();
        private String empName;
        private String empManager;
        private String job;
        public void setEmpName(String empName) {
            this.empName = empName;
        public String getEmpName() {
            return empName;
        public void setEmpManager(String empManager) {
            this.empManager = empManager;
        public String getEmpManager() {
            return empManager;
        public void setJob(String job) {
            this.job = job;
        public String getJob() {
            return job;
    //maanged bean
    public class Bean {
    private List<Employee> employee;
        public Bean() {
            super();
            employee = new ArrayList<Employee>();
          Employee e1 = new Employee();
          e1.setEmpName("xxxxx");
          e1.setEmpManager("xxxxxxxx");
          e1.setJob("xxxxxxx");
          Employee e2 = new Employee();
          e2.setEmpName("yyyyyyy");
          e2.setEmpManager("yyyyyyy");
          e2.setJob("yyyyyyt");
          Employee e3 = new Employee();
          e3.setEmpName("zzzzzz");
          e3.setEmpManager("zzzzzzz");
          e3.setJob("zzzzzzzz");
          employee.add(e1);
          employee.add(e2);
          employee.add(e3);
          employee.add(e4);
        public void setEmployee(List<Employee> employee) {
            this.employee = employee;
        public List<Employee> getEmployee() {
            return employee;
        }in the table map like
    <af:table value="#{Bean.employee}" var="row" rowBandingInterval="0"
                        id="t1">
    <af:column headerText="Employee Name" id="c1">
                  <af:inputText value="#{row.empName}" id="it5"/>
                </af:column>
                <af:column headerText="Employee Manager" id="c2">
                  <af:inputText value="#{row.empManager}" id="it2"/>
                </af:column>
    </af:table>

  • Inserting Multiple Rows into a Table

    I am having problems insert multiple rows. I am using Table1.Row1.instanceManger.addInstance(1).
    I try adding another line using
    Table1.Row2.Cell2.value.#text= "TEST"
    and I get an error acessor is unknown. I assume this is an index issue. Can someone tell me if I am doing this wrong and discuss table indexes?

    The first thing I notice is that your variable, "num," isn't initialized in the FOR loop like I'm used to seeing.. The next thing I would try would be declaring my variables outside of the loop. Something like this maybe.
    String query = null;
    Statement stmt = null;
    int rowsUpdated = 0;
    for (int num = 0; num < 10; num++);     {
         query = "INSERT into apartment (apartmentID,blockID) VALUES ('"+num+"','"+aid+"')";
         stmt = con.createStatement();
         rowsUpdated += stmt.executeUpdate(query);
    }Let me know how it goes.
    -Aaron
    http://www.WeKnowErrors.com/ A free Wiki for error codes and computer problems.

  • Inserting multiple rows into a table using a multiple-select list

    I'm trying to figure out how to take the output of a multiple-select list (":" separated list of values) and use that to update a table by inserting multiple rows based on the values. Is there a straight-forward way to do that in APEX?
    Thanks.
    Chris

    Hi Chris,
    I think this should give you what you need: Working with a Multiple Select List Item
    --Jennifer                                                                                                                                                                                                                                                                                                                                                                                                   

  • Inserting multiple rows into database table

    hi
    I have a simple jsp/html page like this:
    <h1>Enter Comments</h1>
       <select name = "g1">
            <option>10</option>
            <option>20</option>
            <option>30</option>
            <option>40</option>
            <option>50</option>
            <option>60</option>
            <option>70</option>
            <option>80</option>
            <option>90</option>
            <option>100</option>
        </select> <input name = "comment1" type = "text" size = "60"><p>
         <select name = "g1">
            <option>10</option>
            <option>20</option>
            <option>30</option>
            <option>40</option>
            <option>50</option>
            <option>60</option>
            <option>70</option>
            <option>80</option>
            <option>90</option>
            <option>100</option>
        </select> <input name = "comment1" type = "text" size = "60"><p>but when i say : String fruit=request.getParameter("g1");
    String fruit=request.getParameter("comment1");
    only one gets written into the table. How would I write them both into seperate rows of the table? e.g.
    g1 comment1
    g1 comment1
    thank you all,

    change the name of the second select and second text element.
    You're only getting one because they're named the same, so the second one is overwriting the values of the first.
    HTH.

  • Not able to create rows in a table with dependent columns in an OAF page.

    We have a table in an OAF page which has the property "Records Displayed" set as "10". Hence pagination kicks in for more than 10 rows in the table. "Add rows" is enabled in this table. The table also has 'detail' component.
    In this table, we have created 2 new columns (dropdowns) using personalization. Dropdown 2 is dependent on the value selected in Dropdown1. Both are required fields.
    We are able to add new rows to the table. All the columns render properly. Dropdown 2 also renders properly depending on the values selected in Dropdown1. There is no issue until we add the 10th row (remember the number of displayed records in the tabble is 10). When we add the 10th row, the fields appear properly. Dropdown1 values are displayed as expected. But when we select a value in Dropdown1, Dropdown2 does not refresh and get populated with the expected values (depending on Dropdown1 values). Dropdown2 remains blank. But this happens only when the 10th row is added. Since Dropdown2 is a required field and since Dropdown2 is not refreshed with values depending on Dropdown1, the records cannot be saved.
    There seems to be a problem with refresh when the nth row is added to the table where 'n' is the Records displayed in the table (pagination).
    If we change the Records Displayed to say 15 then we have the above problem when adding the 15th row. 14 rows can added to the table without an issue.
    Can a workaround (other than increasing the number of displayed records) be provided for this issue?

    Hi,
    I suspect you have written a method having String return type but the method does not have return statement.
    Go to the Catalogue component->BPM Object->Right click on the BPM object and select New Method->Give the method name. Now the method window will be opened. Go to the propertied tab of the right most panel. Set the return type as string. In the method window editor write your business logic. The below mentioned code is for sample one.
    String msg = "Hello World";
    return msg;
    Bibhu

  • Insert data into a table without identity column

    Hi,
    I need to insert data into a table using data flow task. Unfortunately this table's priamry key column (integer column) is not identity column.  I am looking a way to get the primary key value for the new records. Please advice. Thanks

    Phil has a great post on generating surrogate keys in SSIS: http://www.ssistalk.com/2007/02/20/generating-surrogate-keys/

  • Migrating CMP EJB mapped to SQL Server table with identity column from WL

    Hi,
        I want to migrate an application from Weblogic to SAP Netweaver 2004s (7.0). We had successfully migrated this application to an earlier version of Netweaver. I have a number of CMP EJBs which are mapped to SQL Server tables with the PK as identity columns(autogenerated by SQL Server). I am having difficulty mapping the same in persistant.xml. This scenario works perfectly well in Weblogic and worked by using ejb-pk in an earlier version of Netweaver.
       Please let me know how to proceed.
    -Sekhar

    I suspect it is the security as specified in the message. E.g .your DBA set the ID columns so no user can override values in it.
    And I suggest you 1st put the data into a staging table, then push it to the destination, this does not resolve the issue, but ensures better processing.
    Arthur
    MyBlog
    Twitter

  • Error inserting CLOB data into xmltype table on Solaris 8 Oracle 9.2.0.1.0

    Hi all,
    I have a table t of type xmltype.
    I have a function getData which parses an XML file and returns the CLOB data.
    I have a statement as
    "insert into t values(xmltype(getData('abc.xml')));"
    I get the following error
    ERROR at line 1:
    ORA-00600: internal error code, arguments: [17177], [0x0], [], [], [], [], [],
    ORA-31011: XML parsing failed
    ORA-06512: at "SYS.XMLTYPE", line 0
    ORA-06512: at line 1
    ORA-06512: at "ADAPT.AP_CREATE_INSP_LOAD", line 57
    ORA-06512: at line 1
    At line 57 I have the above mentioned "insert into..." statement.
    Can anybody tell me what can be the problem.
    Interestingly enough, the same things work on same Oracle version on Windows 2k, Windows 2k3, another Solaris 8 machine.
    Please help asap as I am in fire fighting mode.
    Thanks & Regards,
    Aniruddha Deshpande

    Hi Aniruddha
    I think you need to post to a db forum rather than XMLP.
    Tim

Maybe you are looking for