MySQL Insert with autoincremented primary key

I did not before MySQL.  I try and hit a roadblock soon enough.

I would like to insert new records and have the auto-generated primary key / auto-increment.

So, I have attached a few screenshots.  The first is a screenshot of the MySQL settings for the table that I'm writing.  The second is the Labview code that I threw as well as I am trying to run.

The complete of the error I get is:

> Database Connection.viADO error: 0x80004005
Exception occurred in the Microsoft OLE DB provider for ODBC drivers: [MySQL] [ODBC 3.51 Driver] [mysqld - 5.7.11 - log] field 'techniciansID' didn't is not a default value to create a NI_Database_API.lvlib:Rec - Command.vi-> NI_Database_API.lvlib:Cmd Execute.vi-> NI_Database_API.lvlibData.vi B tools insert-> Connection.vi in the database

I know that this error indicates that the techniciansID has no default value and he won't write because of it... but since it is an AutoIncrement field, it seems like it should work.

Any help would be appreciated.  Thank you

Thad

Setting to 0 did not work, but I understand it.  For some reason any when I was refreshing my tables in MySQL server and using the "Forward Engineer" feature, the changes were not multiplication.  I had to drop the schema of the database (attached image) and then do an "engineer forward."  I made the changes, but the tables and the columns still had the attributes of origin... guess they cannot be updated by the script during execution.

After doing this and the original settings I had (autoincremented primary key), the insert works in MySQL and Labview.

Thanks for all the answers.  They made me think and check some things I didn't have before.

-Thad

Tags: NI Software

Similar Questions

  • Another user changed the row with a primary key oracle.jbo.Key]

    I see many discussions about this error, but still cannot understand the difficulty that I need in my scenario.

    I am an Oracle Developer and completely new to ADF, please bear with me.

    I use JDeveloper 11.1.1.9.0

    My scenario:

    Creates an object editable view (UVO) with sub selects in the query, which is from several db tables.

    Creating a table using the UVO

    When I try to update a field in the table, and then click the validate, I get the error message:

    Another user changed the row with a primary key oracle.jbo.Key]

    Can someone explain in what scenarios I see this error and how do I solve this problem?

    Try the viewObject execution after validation and reQueryOnCommit set to true

    For details see - binary: a reason more for "Houston-25014: another user has modified the line containing oracle.jbo.Key primary key '

    Ashish

  • Update line programmatically with Composite primary keys

    Hi all

    I use JDeveloper 11.1.2.4.0,I want to update the program with two primary keys PK1_ID and PK2_ID line

    When I have a primary key I can do it by:

    /////////////////////////////////////////////////////

    Key = new key (new Object() {empid});

    Employees1ViewImpl vo = (Employees1ViewImpl) this.getEmployees1View1 ();

    Locate the line using key reference in the View object.

    Line k = vo.getRow (key);

    using this method, we can set the new FirstName

    k.setAttribute ("FirstName", "Vero");

    this.getDBTransaction () .commit ();

    ///////////////////////////////

    Is it possible to use the same code with more of primary key?




    Kind regards

    The key class contains an array of attributes that identify the line you're looking for. In your case, the key has two attributes

    Key = new key (new Object() {pkId1, pkId2});

    the rest of the method works as what.

    Timo

  • Problems with the primary key of the query string

    Moving from asp to php, to work with David Power's book: The Essential Guide to Dreamweaver CS4 with CSS, AJAX, and PHP.  Recycling of my brain, so starting from scratch in the learning process.

    Everything was going perfectly until I tried to add the primary key of a record in a query string.  I compared my code with the example code for the book, and everything matches.  When previewing the page in my browser and hover over the link which must pass the main code on the next page, the query string does not appear correctly.  It shows user_id = but no figure shows, as it is supposed to.  www.webpage.com/update_user.php?user_id=

    Here is my code: (Please note, <>have been removed, as I was unable to find a way view the code in the correct way here (copy/paste was doesn't work do not, nor insert syntax))

    ? PHP {?}

    ? PHP echo $row_listUser ['family_name'];? PHP echo $row_listUser ["FirstName"];?

    ? PHP echo $row_listUser ['username'];?       ? PHP echo $row_listUser ["admin_priv"];?

    a href = "update_user.php? user_id =? php echo $row_listUser ['user_id'];?" "Edit / has

    a href = "delete_user.php? user_id =? php echo $row_listUser ['user_id'];?" ' Delete / has

    ? PHP} while ($row_listUser = mysql_fetch_assoc ($listUser));?

    Any ideas that could help me understand why this part does not in particular would be greatly appreciated.  Writing to the database worked perfectly, I see that there are numbers in the database as user_id, and it is defined as my primary key in the configuration database.  Such a simple process that is causing me headaches!

    Thank you

    You have the code to request a copy in your folder:

    $query_listUser = 'SELECT user_id, username, first_name, family_name, admin_priv from users ORDER BY family_name ASC';

    $listUser = mysql_query ($query_listUser, $connSCFDIR) or die (mysql_error ());

    $row_listUser = mysql_fetch_assoc ($listUser);

    $totalRows_listUser = mysql_num_rows ($listUser);

    $query_listUser = 'SELECT username, first_name, family_name, admin_priv from users ORDER BY family_name ASC';

    $listUser = mysql_query ($query_listUser, $connSCFDIR) or die (mysql_error ());

    $row_listUser = mysql_fetch_assoc ($listUser);

    The $listUser table will contain the results of the second query, which does not include the field user_id. delete the redundant code.

  • Insert with 2 primary passes

    Table with 2 passes key id primary column...

    INSERT INTO tbl_name (col1, col2, col3,...) SELECT (seq.nextval, col1, col2, col3,... from table_name);
    or
    INSERT INTO tbl_name (col1, col2, col3,...) SELECT (seq.nextval, col3... table_name from);


    What is the rt?

    user548261 wrote:
    can someone please answer.

    Go to your supervisor. Tell him that you need more training to do your work. Mark B. you gave the answer as far as I know, if you can not get the one, you clearly have problems with training or don't really understand the purpose of this forum. Probably and instead of or.

  • Problem with the primary key

    Hi all
    I have a table with the same data repeat 2 times. I mean that the lines are depating twice. so now, I create a primary key for the table. He throws me an error saying voilation key primary. I'll give you the clear script.

    create table employee)
    ID VARCHAR2 (4 BYTE) NOT NULL,
    First name VARCHAR2 (10 BYTE),
    VARCHAR2 (10 BYTE) last_name,
    START_DATE DATE,
    End_date DATE,
    Number (8.2) of salary.
    City VARCHAR2 (10 BYTE),
    Description VARCHAR2 (15 BYTE)
    )


    insert into employee values ('01', 'Jason', 'Martin', to_date('19960725','YYYYMMDD'), to_date('20060725','YYYYMMDD'), 1234.56, 'Toronto', 'Program');
    insert into employee values ('02', "Alison", "Mathews', to_date('19760321','YYYYMMDD'), to_date('19860221','YYYYMMDD'), 6661.78, 'Vancouver', 'Tester');
    insert into employee values ('03', 'James', 'Smith', to_date('19781212','YYYYMMDD'), to_date('19900315','YYYYMMDD'), 6544.78, 'Vancouver', 'Tester');
    insert into employee values ('04', 'Celia', 'Rice', to_date('19821024','YYYYMMDD'), to_date('19990421','YYYYMMDD'), 2344.78, "Vancouver", "Manager");
    insert into employee values ('05', 'Robert', 'Black', to_date('19840115','YYYYMMDD'), to_date('19980808','YYYYMMDD'), 2334.78, 'Vancouver', 'Tester');
    insert into employee values ('07', 'David', 'Larry', to_date('19901231','YYYYMMDD'), to_date('19980212','YYYYMMDD'), 7897.78, 'New York', 'Manager');
    insert into employee values ('06', 'Linda', 'Green', to_date('19870730','YYYYMMDD'), to_date('19960104','YYYYMMDD'), 4322.78, 'New York', 'Tester');
    insert into employee values ('08', 'James', 'Cat', to_date('19960917','YYYYMMDD'), to_date('20020415','YYYYMMDD'), 1232.78, 'Vancouver', 'Tester')
    insert into employee values ('07', 'David', 'Larry', to_date('19901231','YYYYMMDD'), to_date('19980212','YYYYMMDD'), 7897.78, 'New York', 'Manager');
    insert into employee values ('06', 'Linda', 'Green', to_date('19870730','YYYYMMDD'), to_date('19960104','YYYYMMDD'), 4322.78, 'New York', 'Tester');


    The table is now with 10 columns

    ID FIRST_NAME LAST_NAME START_DAT END_DATE SALARY CITY DESCRIPTION
    ---- ---------- ---------- --------- --------- ---------- ---------- ---------------
    Jason Martin 25 July 96 01 25 July 06 1234.56 Toronto programmer
    02 Alison Mathews 21 March 76 February 21, 86 6661.78 Vancouver Tester
    03 James Smith December 12, 78 March 15, 90 6544.78 Vancouver Tester
    04 Celia rice 24 October 82 21 April 99 2344.78 Vancouver Manager
    Robert Black 05 January 15, 84 8 August 98 2334.78 Vancouver Tester
    Linda Green 06 July 30, 87 January 4, 96 4322.78 tester of New York
    Manager of New York 07 David Larry 31 December 90 February 12, 98 7897.78
    08 James Cat 17-AUG-96 April 15 02 1232.78 ester of Vancouver


    Create a primary key for the table

    "Employee to ALTER TABLE PRIMARY KEY (ID, First_Name, Last_Name, start_date, end_date,
    Salary, city, Description); »

    I get error voilation primary key

    IS IT POSSIBLE TO CREATE THE KEY PRIMARY ON THE TABLE WITH ON THE DELETION OF THE DATA?
    Is IT POSSIBLE CREATING PRIMARY KEY USING 'GROUP BY' FUNCTION or OTHER FUNCTIONS?

    Published by: user11872870 on September 23, 2010 17:41

    Primary key columns cannot contain NULL values. If you tried to create a primary key constraint, you will get an error like this:

    ERROR at line 1:
    ORA-01449: column contains NULL values: cannot alter to NOT NULL
    

    However, you can add a unique constraint by doing something like the following:

    ALTER TABLE test ADD CONSTRAINT test_unq UNIQUE (column1, column2);
    

    I still wonder why you take the approach you take. I have a vague feeling that're missing us the key pieces of information to recommend the correct solution.

  • exp/imp with sequential primary key table.

    Hello

    I have a general question about EXP/IMP a table with primary key sequence. I need exp rows in this table of 11g DB and their imp to 9i DB. This table is the same on 11g and 9i. Table 11g is updated daily. I want to import lines which are the only new records to 9i to expedite the process. As this main table of the key is sequential, I intend to export with where table_key > N, N is the max of last importing table_key and then proceed to import on this dump file. Don't you see any problem doing it this way?
    Your expertise is greatly appreciated!

    Hello

    I have no problem at all.
    If you do not forget to use the 9i export tool, then you should be OK
    Also a full table export and import with ignore = Yes will ignore the records that violate the primary key and import only new records.
    However, it is not a very clean way to do it.

    Success!
    FJFranken

  • Oracle 11g: problem with disable primary key

    Hello
    I have this problem:

    I performed "EXECUTE IMMEDIATE"ALTER TABLE your table of KEY PRIMARY DISABLE";"

    This operation returns an error
    but when I did 'insert into table... ". »... Oracle returned ora-0001.

    The operations are in the same stored procedure, so in the same session.

    Database: Oracle 11.2.0.2

    How is that possible?
    All solutions?

    Thanks in advance.

    Best regards.
    Alessandro Zenoni

    Try to add 'DROP INDEX' to your disable command.

    not tested

    alter table xy disable primary key drop index
    
  • Problem with the primary key and indexes

    Hi all

    I'm looking a mess on one of our main tables.
    One of the developers here added an index on 3 columns in the table, thinking that it would speed up (not noticing that it had not a PK).

    Subsequently another developer has noticed there do not have a primary on key. So they added a touch of primry on the single column.

    The problem is that now the index created on 3 columns is bein used as the primary key index. As when the primary key is created a new index was not created.

    Is there anyway to get rid of this index/change it correct?

    This table is related to many many other tables, so when we tried to remove the index we could not due to the primary key and foreign key violations with other tables.

    Thanks in advance

    Oracle, as you found, is quite capable to use a column enformce multi index a single column primary key, as long as the pk column is the leader in the index. This should not cause performance issues for a search of PK and if the three indexed columns are often selected only may benefit from these types of queries.

    The only way to change that now, would be to drop all CF, drop and add the PK constraint and then add all the FK constraints. A long time and potentially dangerous (if you miss to add back of the FKs) endeavour. Certainly not worth the risk in my opinion.

    John

  • Insert into table primary key (automatic numbering) for back in class resultset

    Hello

    I connect to Oracle 10 g via JDBC (ojdbc14.jar is).
    My SQL statement is:

    INSERT into student (studentName, phone, e-mail, address) values ('Jason', '12345678', 'test', 'test');
    SELECT Student_studentId_SEQ. NEXTVAL FROM DUAL;

    FYI - the Student table has a trigger to support the generation of a primary key (integer) based on a sequence when a new record is inserted.

    The above will do (from the point of view of Java app) is to create a school record and automatically select the student card and student card is accessible via the resultset in Java.

    I get the error message ' ORA-00911: invalid character '. Can you please help?


    Kind regards
    Jason

    Published by: user10394130 on October 13, 2008 02:40

    As I said already try using a refcursor like that.

    DECLARE
    seqNbr_studentId NUMBER (12): = 0;
    stud_cur SYS_REFCURSOR;
    BEGIN
    INSERT into student (studentName, phone, e-mail, address) values ('Jason', '12345678', 'test', 'test')
    StudentId INTO seqNbr_studentId RETURN;
         
    Stud_cur OPEN to SELECT seqNbr_studentId OF MODEL;
    END;

    Thank you
    Knani.

  • Large partition table with the primary key referenced by several child tables

    I tested this procedure and it works perfectly. Although when children tables refer to the key column, after execution of dbms_redefinition.finish_redef_table they all are referring to table exercised. In test I deal forced FK droped on tables children and recreated them. What could be the best way to do this in this scenario?

    Thanks for all comments/opinions!

    Are you sure? You should end up with the original FK constraint (disabled and renamed to have a prefix of $$ TMP) pointing to the staging table (which is of course the famous original table), and allowed a new constraint with the correct name, pointing to the new version of the table. so all you need to do to bring order to the top is to remove the constraint of renamed.

    This running-in of the SCOTT schema clearly indicates:

    create the table deptint in select * from dept where 1 = 2;

    exec dbms_redefinition.start_redef_table (user, 'dept', 'deptint')

    n number of var

    exec dbms_redefinition.copy_table_dependents (user, "dept', 'deptint', DBMS_REDEFINITION.") CONS_ORIG_PARAMS, TRUE, TRUE, TRUE, TRUE,: n)

    Print n

    exec dbms_redefinition.finish_redef_table (user, 'dept', 'deptint')

    Select CONSTRAINT_NAME, CONSTRAINT_TYPE, TABLE_NAME, user_constraints STATE;

  • RadioButton with submit does not insert new primary key/registration

    Hello

    I have a form with radio buttons. Originally, I used the button create automatically generated to send the page, record the value and creates a branch to another page. If the primary key is zero, it would create a new record with a primary key in the sequence.

    I changed the radio button to be 'submit' and now he passes on the next page, but does not create the new key.

    I don't see what is the difference between the two methods, but it is probably simple...

    Any help is greatly appreciated.

    Thank you
    Matt

    I don't see what you're doing. The page that loads the record must be programmed to do a checkout of the line using the element as the PK value if the element is not null. Attribute of the Source of this element should probably also be «Just...» ».

    Scott

  • Need to create a new line in the table with the same data as the primary key, but new PK

    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    user9970447 wrote:
    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    something like

    insert into mytable values ('literal for new pk',
                                           select non-pk-1,
                                                    non-pk-2,
                                                    non-pk-n
                                           from mytable
                                           where pk-col = 'literal for existing pk')
    
  • Returns the primary key of the new line (generated by the trigger) to an insert procedure

    Hello
    I have a table with a primary key (number), which increases with the trigger
    I use a procedure to insert data into this table
    How can I find the primary key of the row inserted to this procedure?

    When you make use of the insert:

    INSERT .... RETURNING key_column INTO variable;
    

    (where key_column is your key on the table column and variable is a variable to store the value of the same data type)

    to get the value in a variable.

  • Adding primary keys with javascript.

    I have a database that has no metadata.

    We have the primary key definitions in an external system.

    The primary key information are easy to get.

    I want to update the relational model (and display) with the primary key information.

    Is it possible to update the primary key of infromation in the model of the relationship of Javascript?

    Hello

    You can try to settle for your use:

    // get table name
    tname = ...;
    //get pk name
    pkname = ....;
    table = model.getTableSet().getByName(tname);
    if(table !=n ull){
    index = table.createIndex();
    index.setName(pkname);
    index.setPK(true);
    // get column name - should iterate in case of multi column PK
    cname = ...;
    column = table.getElementByName(cname);
    if(column != null){
      index.add(column);
    }
    table.setDirty(true);
    }
    

    Philippe

Maybe you are looking for

  • HP DC7700 SFF does not turn on

    I bought a HP DC7700 and is not turning on. I was wondering if there is a way to distirnguish if the fault is with the motherboard or the power supply? See you soon

  • Have Dell Inspiron 1720, it doesn't read any type of dvd

    I have windows vista and my cd/dvd drive does not read or play any type of dvd.

  • Processor fan speed problem

    Hi all I have a Dell Inspiron 580 and the processor fan is limit every 13 seconds or more.  It runs all the time, but then accelerates.  Here's a video of him cs_setInnerHtml ('video_bb2015e9 - 6 c 21-4ad4-a1d8-b126466fbeab', "); Any suggestions? Tha

  • PS4100X performance has deteriorated

    Hi Sir, I have a warning in vCenter VMware ESXi 5.5 as this "device naa.5000c5000b36354b performance deteriorated. I/O latency increased from the average value of 3107 microsecond to microsecond 1413679' I try to install SANHQ and look at the point o

  • PCD.exe has stopped working

    Sometimes I get an error message screen: "PCD.exe has stopped working".  The query option MS to check the problem shows no effect or results.  Closing screen is the only other choice, but it recurs regularly.  Is that indicates any problem specific t