Help with last insert id

i have create 2 preparedstatement and it is like this,
PreparedStatement pstmt = con.prepareStatement("insert into placemark(userid, date, time,longtitude,latitude) values(?,?,?,?, ?) ");
after that i have pstmt.executedUpdate()
and i have created another preparedStatement for the last_insert_id
PreparedStatement pstmt1 = con.prepareStatement("SELECT LAST_INSERT_ID(placemarkid)");
can anybody tell me is my syntext for the last insert id correct?

hmm, allow me to explain my logic to all of you again. This is my first time using last_insert_id and have no idea how to implement. But i have found out it is performed an insert query into a table that contains an AUTO_INCREMENT field. And my placemarkid is a primary key which is auto_increment.
Here is my code
public boolean add(Placemark pm){
        boolean result = false;
        try {
            PreparedStatement pstmt = con.prepareStatement("insert into placemark(placemarkid, userid, date, time,longtitude,latitude) values(?,?,?,?,?,?)");
            pstmt.setInt(1, pm.getPlacemarkid());
            pstmt.setInt(2, pm.getUserid());
            pstmt.setDate(3, pm.getDate());
            pstmt.setTime(4, pm.getTime());
            pstmt.setDouble(5, pm.getLongtitude());
            pstmt.setDouble(6, pm.getLatitude());
            int num = pstmt.executeUpdate();
            if(num==1)
                result = true;
            //  PreparedStatement pstmt1 = con.prepareStatement("SELECT LAST_INSERT_ID FROM placemark WHERE placemarkid = ?");
            //pstmt1.setInt(1, pm.getPlacemarkid());
            // ResultSet rs = pstmt1.executeQuery();
            pstmt.close();
            // pstmt1.close();
        } catch(SQLException e){
            e.printStackTrace();
            result = false;
        return result;
    }ok, i need to query out the last insert id and set it into the placemark object using the "setPlacemarkId" method.Also, the sql statement to get the last inserted id is "SELECT LAST_INSERT_ID()".Can anyone please help me of the last_insert_id. I;m quite confused to the previous post that u all have send me as this is my first time using.

Similar Messages

  • Help with the insert table/form tool in BIP 10.1.3.2.1

    Hi, I'm trying to use the insert table/form tool in BIP, and running into some issues that I don't understand. First off, my data coming in looks like this (left column of tool):
    Rowset
    --- Row
    ------ Customer ID
    ------ Customer Name
    ------ Customer City
    ------ Product
    ------ Amount Sold
    I would like the output to do the following:
    a) have one page per customer. Customer should be determined by customer ID, and has attributes of customer ID, customer Name, Customer City
    b) Show a table of all products and the total Amount Sold by product for that customer
    c) Give a "grand total" for the customer
    Can someone help with the steps needed to do this? I've tried several variations of the following without much luck:
    1) Added Rowset and all children to the "Template" pane
    2) Clicked on the "Row" group, and set Grouping = Customer ID, with a break of "New page per Element"
    3) Clicked on the newly created (from step 2) Cust ID group, and set it to group by Product
    4) Moved "amount sold" to be at same level as Product
    5) Moved all of the customer attributes (name, address, etc.) to be at same level as Cust ID
    6) On the Cust ID level, set the style to table
    7) on row and rowset levels, set style to free form
    This seems to be VERY close, except that it isn't creating a total amount for the sum of all products purchased by a customer. What do I need to do inside the tool to get a total per customer to show up?
    Thanks in advance!
    Scott
    p.s. the final hierarchy in the template window looks like this:
    Rowset (style = freeform, no grouping/sort by/breaks)
    --- Row (style = freeform, group by customer ID, break new page per element)
    ------ Customer ID (style = table, group by product, no breaks)
    --------- Product (nothing special)
    --------- Amount Sold (calc for grouping = SUM)
    ------ Customer Name (nothing special)
    ------ Customer City (nothing special)
    Thanks very much for the help!
    Scott

    To anyone else who sees this post, the answer is to do the following. Insert the Amount Sold field using the "Insert Field" tool, and set the function to sum, with the grouping checkbox turned on.
    Thanks,
    Scott

  • Openbox script-drag titlebar to unmaximize, help with last step?

    Hey all,
    I really missed the feature in other WM's where one could drag a maximized window out of maximize and have it restore to the original size. I have written a small shell script to get the size of the current window and then implemented it in rc.xml. The only little issue is that, for some reason, when restoring from the values originally saved, the window comes out of the "maximized" state but retains the maximized dimensions. In other words, I can drag it out of "maximized' but it stays big, and does not go back to the original saved size. Any thoughts?
    getdimcur.sh
    #!/bin/bash
    activew="$(xwininfo -id $(xdotool getactivewindow)|awk '/Width/ {print $2}')"
    activeh="$(xwininfo -id $(xdotool getactivewindow)|awk '/Height/ {print $2}')"
    echo -en "$activew $activeh" > /home/ts/scripts/curwin/curwindim
    rc.xml snippet
    <context name="Titlebar">
    <mousebind button="Left" action="DoubleClick">
    <action name="Execute">
    <command>bash /home/ts/scripts/curwin/getdimcur.sh</command>
    </action>
    <action name="Execute">
    <command>wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz</command>
    </action>
    </mousebind>
    <mousebind button="Left" action="Drag">
    <action name="if">
    <maximized>yes</maximized>
    <then>
    <action name="Execute">
    <command>wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz</command>
    </action>
    <action name="Execute">
    <command>bash /home/ts/scripts/curwin/restorewin.sh/</command>
    </action>
    </then>
    </action>
    <action name="Move"/>
    </mousebind>
    </context>
    restorewin.sh
    xdotool getactivewindow windowsize $(cat /home/ts/scripts/curwin/curwindim|awk '{print $1}') $(cat /home/ts/scripts/curwin/curwindim|awk '{print $2}')
    Testing these commands in terminal individually is successful, so what am I missing?
    Thank you.

    I have solved moving a window by dragging the title bar with the following openbox configuration, which is located in ~/.config/openbox/lxde-rc.xml on my machine:
    <context name="Titlebar">
    <mousebind button="Left" action="Drag">
    <action name="if">
    <maximized>yes</maximized>
    <then>
    <action name="Unmaximize"/>
    <action name="MoveResizeTo">
    <y>0</y>
    </action>
    </then>
    </action>
    <action name="Move"/>
    </mousebind>
    <mousebind button="Left" action="DoubleClick">
    <action name="ToggleMaximizeFull"/>
    </mousebind>
    </context>
    After holding down the left mouse button on the title bar and moving the mouse, the window is unmaximized and moved to the top of the desktop with the actions Unmaximize and MoveResizeTo. Unmaximizing and moving to the top is only done, if the window is maximized. Then in each case the action Move starts the modus for moving the window with the mouse. This configuration simulates nearly the same behavior as in Windows 7 while dragged the title bar with the left mouse button.
    After a left double click on the title bar, the action ToggleMaximizeFull switches the window state once between maximized and unmaximized.
    See also http://openbox.org/wiki/Help:Actions
    Last edited by raimar (2014-01-04 23:48:06)

  • Looking for some help with building insert statements...

    Hi, I am using some sql to build some insert statements for me to update a set of tables in our qa environments. The scripts that I have created were working great until someone added a column to some of the tables in the qa env which in turn makes my scripts break because I was simply building the statment to do someting like this...
    insert into dest_table (select * from source_table@dblink);
    But now when the coumns in the tables do not match it breaks...
    This is the dynamic create script I use, can anyone help or suggest a better way to be able to build update statements update to qa tables when the columns are mismatched?
    spool insert.sql
    select
    'insert into ' || table_name || ' (select * from ' || table_name || '@prod );' || chr(10) || ' commit;'
    from user_tables
    where table_name in
    (select * from refresh_tablesl)
    any help is greatly appreciated,
    Thanks.

    See my reply to your duplicate post
    looking for help building dynamic insert statements...

  • Help with BULK Insert

    Hello SQL Buddies,
    I am trying to run a BULK insert.
    Here is my code:
    Code start:
    use Lagerliste
    drop table Import
    use Lagerliste
    create table Import
    TOTALQTY float null,
    PARTNO nvarchar (255) null,
    [DESC] nvarchar (255) null,
    CO nvarchar (255) null,
    BIN nvarchar (255) null,
    PRICE float null,
    DISCOUNT nvarchar (255) null,
    LASTPURC nvarchar (255) null,
    AGECODE nvarchar (255) null,
    MANFPART nvarchar (255) null
    use Lagerliste
    bulk
    insert Import
    from 'D:\FTP\RG\Stockfile.csv'
    with
    formatfile = 'D:\FormatFile\test.xml',
    Errorfile = 'D:\FormatFile\error.txt'
    Code stop..
    My format file code is here:
    Code start:
    <?xml version="1.0"?>
      <BCPFORMAT xmlns = "http://schemas.microsoft.com/sqlserver/2004/bulkload/format"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <RECORD>
          <FIELD ID="1"    xsi:type="CharTerm"        TERMINATOR= ',"'    />
          <FIELD ID="2"    xsi:type="CharTerm"    MAX_LENGTH="255"    TERMINATOR= '","' />
          <FIELD ID="3"    xsi:type="CharTerm"    MAX_LENGTH="255"    TERMINATOR= '","'    />
          <FIELD ID="4"    xsi:type="CharTerm"    MAX_LENGTH="255"    TERMINATOR= '","'    />
          <FIELD ID="5"    xsi:type="CharTerm"    MAX_LENGTH="255"    TERMINATOR= '",'    />
          <FIELD ID="6"    xsi:type="CharTerm"      TERMINATOR= ',"'    />
          <FIELD ID="7"    xsi:type="CharTerm"    MAX_LENGTH="255"    TERMINATOR= '","'    />
          <FIELD ID="8"    xsi:type="CharTerm"    MAX_LENGTH="255"    TERMINATOR= '","'    />
          <FIELD ID="9"    xsi:type="CharTerm"    MAX_LENGTH="255"    TERMINATOR= '","'    />
          <FIELD ID="10"    xsi:type="CharTerm"    MAX_LENGTH="255"    TERMINATOR= '"'        />
        </RECORD>
        <ROW>
          <COLUMN SOURCE="1" NAME="TOTALQTY"    xsi:type="SQLFLT8"/>
          <COLUMN SOURCE="2" NAME="PARTNO"    xsi:type="SQLNVARCHAR"/>
          <COLUMN SOURCE="3" NAME="DESC"        xsi:type="SQLNVARCHAR"/>
          <COLUMN SOURCE="4" NAME="CO"        xsi:type="SQLNVARCHAR"/>
          <COLUMN SOURCE="5" NAME="BIN"        xsi:type="SQLNVARCHAR"/>
          <COLUMN SOURCE="6" NAME="PRICE"        xsi:type="SQLFLT8"/>
          <COLUMN SOURCE="7" NAME="DISCOUNT"    xsi:type="SQLNVARCHAR"/>
          <COLUMN SOURCE="8" NAME="LASTPURC"    xsi:type="SQLNVARCHAR"/>
          <COLUMN SOURCE="9" NAME="AGECODE"    xsi:type="SQLNVARCHAR"/>
          <COLUMN SOURCE="10" NAME="MANFPART"    xsi:type="SQLNVARCHAR"/>
        </ROW>
      </BCPFORMAT>
    Code stop..
    If i run the code it says:
    Msg 4832, Level 16, State 1, Line 20
    Bulk load: An unexpected end of file was encountered in the data file.
    Msg 7399, Level 16, State 1, Line 20
    The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
    Msg 7330, Level 16, State 2, Line 20
    Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".
    And the error file says:
    Row 473629 File Offset 42503226 ErrorFile Offset 0 - HRESULT 0x80004005
    If i then in my bulk insert adds: "Lastrow = '473629' it works all fine. So it will mean that it gets an error at the last line where there is no more data? But this sql query should run every day, so i have to do so it dont gets the error.
    Can someone help me?
    Looking forward to an answer, i hope someone have a solution.
    Regards Christian.

    Try the below format file,
    <?xml version="1.0"?>
    <BCPFORMAT xmlns = "http://schemas.microsoft.com/sqlserver/2004/bulkload/format"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <RECORD>
    <FIELD ID="1" xsi:type="CharTerm" TERMINATOR= ',"' />
    <FIELD ID="2" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
    <FIELD ID="3" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
    <FIELD ID="4" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
    <FIELD ID="5" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '",' />
    <FIELD ID="6" xsi:type="CharTerm" TERMINATOR= ',"' />
    <FIELD ID="7" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
    <FIELD ID="8" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
    <FIELD ID="9" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
    <FIELD ID="10" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '"\r\n' />
    </RECORD>
    <ROW>
    <COLUMN SOURCE="1" NAME="TOTALQTY" xsi:type="SQLFLT8"/>
    <COLUMN SOURCE="2" NAME="PARTNO" xsi:type="SQLNVARCHAR"/>
    <COLUMN SOURCE="3" NAME="DESC" xsi:type="SQLNVARCHAR"/>
    <COLUMN SOURCE="4" NAME="CO" xsi:type="SQLNVARCHAR"/>
    <COLUMN SOURCE="5" NAME="BIN" xsi:type="SQLNVARCHAR"/>
    <COLUMN SOURCE="6" NAME="PRICE" xsi:type="SQLFLT8"/>
    <COLUMN SOURCE="7" NAME="DISCOUNT" xsi:type="SQLNVARCHAR"/>
    <COLUMN SOURCE="8" NAME="LASTPURC" xsi:type="SQLNVARCHAR"/>
    <COLUMN SOURCE="9" NAME="AGECODE" xsi:type="SQLNVARCHAR"/>
    <COLUMN SOURCE="10" NAME="MANFPART" xsi:type="SQLNVARCHAR"/>
    </ROW>
    </BCPFORMAT>
    Refer
    http://stackoverflow.com/questions/8530353/sql-bulk-insert-xml-format-file-with-double-quotes-in-terminator
    http://technet.microsoft.com/en-us/library/ms191234(v=sql.105).aspx
    Regards, RSingh

  • Help with SQL insert

    Hi,
    Brand new to CF - using CF9. Have SQL Server 2005 database. Only one table. Using CF for frontend. Do not know proper syntax to get INSERT to work. Keep getting "Element XXXXXX is undefined in FORM."
    Database name is RAWH.
    Columns for insert are:
    startdate
    enddate
    TypeHrs
    NoOfHours
    projects
    justification
    Frontend has forms and fields which are:
    Form                                       Field (value)
    firstDates                                startdate
    firstDates                                enddate
    typHrs                                     TypeHrs
    noHrs                                      NoOfHours
    none                                        projects
    none                                        justification
    Do not know how to code for INSERT - have this for now - which obviously does not work:
    <cfquery name="RAWH" datasource="RAWH">
    INSERT INTO RAWH
    (startdate, enddate, TypeHrs, NoOfHours, projects, justification)
    VALUES
    (#Form.firstDates#, '#Form.startdate#', '#Form.enddate#', #Form.typHrs#, '#Form.TypeHrs#', #Form.noHrs#, '#Form.NoOfHours#')
    </cfquery>
    What am I doing wrong?
    Get this:
    Element FIRSTDATES is undefined in FORM.
    The error occurred in D:\ColdFusion9\wwwroot\RAWH1\RAWH1.cfm: line 5
    3 : (startdate, enddate, TypeHrs, NoOfHours, projects, justification)
    4 : VALUES
    5 : (#Form.firstDates#, '#Form.startdate#', '#Form.enddate#', #Form.typHrs#, '#Form.TypeHrs#', #Form.noHrs#, '#Form.NoOfHours#')
    6 : </cfquery>
    7 :
    Really appreciate any help - thank you. BTW - datasource is in CF Admin.
    John
    RAWH 
    Microsoft SQL Server 
    OK 

    Ian & Dan,
    Thanks. I added "<cfdump var="#form#">" and the result is "struct [empty]."
    I altered the form/input code thusly,
    <form id="beginDate" name="beginDate" onclick="function compareDate(); method="post"
                   style="width: 1px; height: 1px;">
              <td><input style="width: 70px" type="text" id="startdate" name="startdate" /></td>
            </form>
            <form id="endnDate" name="endDate" onclick="function compareDate(); method="post"
                   style="width: 1px; height: 1px;">
              <td><input style="width: 70px" type="text" id="enddate" name="enddate" /></td>
            </form>
    Should this be a cfform? I also made separate forms for startdate and enddate rather than one form for both.
    The cfquery is this:
    <cfquery name="RAWH" datasource="RAWH">
    INSERT INTO RAWH
    (startdate, enddate, TypeHrs, NoOfHours, projects, justification)
    VALUES
    (#Form.beginDate#, '#Form.startdate#', '#Form.endDate#', '#Form.enddate#', #Form.typHrs#, '#Form.TypeHrs#', #Form.noHrs#, '#Form.NoOfHours#', 'projects', 'justification')
    </cfquery>
    Still the same result -
    Element BEGINDATE is undefined in FORM.
    The error occurred in D:\ColdFusion9\wwwroot\RAWH1\RAWH1.cfm: line 7
    5 : (startdate, enddate, TypeHrs, NoOfHours, projects, justification)
    6 : VALUES
    7 : (#Form.beginDate#, '#Form.startdate#', '#Form.endDate#', '#Form.enddate#', #Form.typHrs#, '#Form.TypeHrs#', #Form.noHrs#, '#Form.NoOfHours#', 'projects', 'justification')
    8 : </cfquery>
    9 :
    What am I doing wrong?
    Dan - you said that I do not have a form until I submit one - I get this error by opening the web page (F12). There is no onsubmit coding done.
    Sorry guys, I am lost with this.
    Thank you,
    John

  • Help with sql insert single quotes

    String insert = "INSERT INTO users(firstName, lastName, emailAdd, password) VALUES("+ firstNameForm + "," + lastNameForm + "," + emailForm + "," + passwordForm + ")";
    Statement stmt = conn.createStatement();
         int ResultSet = stmt.executeUpdate(insert);
    I have that sql insert statment in my servlet the servlet compiles fine but does not insert into the users table, i have been told that it is something to do with single quotes in sql statement, can anybody help me out?

    Or can i change my sql table is there a autonumber which would increase everytime this servlet runs?make your field autoincrement :-)
    example
    ALTER TABLE `users` CHANGE `user_id` `user_id` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL AUTO_INCREMENT To insert record in the table.
    example:
    you have a table test and got two fields,
    id = (INT) autoincrement
    name = VARCHAR / TEXT etc.
    to insert data to the table test try something like this:
    String SQLStatement = "INSERT INTO test";
    SQLStatement += "(name)";
    SQLStatement += " VALUES (?)";
    statement = Conn.prepareStatement(SQLStatement);
    statement.setString(1, "Duke");
    statement.executeUpdate();
    statement.close();
    Conn.close();Note we dont provide the field for id on our sql statement since it is set as auto-increment ;-)
    regards,
    Message was edited by:
    jie2ee

  • Help with simple INSERT statement?

    How can I do an insert into Oracle without having to
    specify EVERY field name in the table? This isn't necessary
    with Access or
    SQL Server, which will insert null's in the non-specified
    fields, the Oracle SQL
    tool tells me that there aren't enough field values when I run
    this SQL Statement:
    INSERT INTO TABLE_NAME VALUES (1234, 'test', 'test')
    There are over 10 different fields, but I get the error message:
    Native Error Code 947, Not enough values.
    TIA
    Kris
    null

    Kristofer Goss (guest) wrote:
    : How can I do an insert into Oracle without having to
    : specify EVERY field name in the table? This isn't necessary
    : with Access or
    : SQL Server, which will insert null's in the non-specified
    : fields, the Oracle SQL
    : tool tells me that there aren't enough field values when I run
    : this SQL Statement:
    : INSERT INTO TABLE_NAME VALUES (1234, 'test', 'test')
    : There are over 10 different fields, but I get the error
    message:
    : Native Error Code 947, Not enough values.
    : TIA
    : Kris
    You may omit the columns list, but if you do then the VALUES
    clause must provide values for every column in the table.
    FOR EXAMPLE: if your table were created as follows:
    COLUMN_1 NOT NULL, VARCHAR2(4)
    COLUMN_2 NUMBER(6)
    COLUMN_3 DATE
    COLUMN_4 VARCHAR2(4)
    You could submit a statement like:
    insert into my_table VALUES ('ALLA', , , 'XYZ');
    You could also submit a statement like:
    insert into my_table (column_1, column_4) VALUES ('ALLA', 'XYZ');
    If you do not want to store any value in a particular column,
    then that column must be allowed to accept NULLs.
    Hope this helps.
    null

  • Help with automatic insert

    Hello forum members!
    Today I created an auxiliar table (t_final_qtd) to make a report lighter. it worked as expected but now the problem is that this table does not receive data automatically from the system.
    This table receives data from 2 other tables (aevent and disposition) that receive data automatically, they're used to store event history. Each time the program inserts a new row to the event, both tables update a column called curent on the past rows changing it to 'F' and the most actual to 'T'. I want t_final_qtd to store only the rows with 'T'.
    At first i thought about creating triggers but there's one problem, t_final_qtd's lighter because it only receives the most actual row of an event, it doesn't depends on "Where curent = 'T'" to retrieve data. I wanted to do with this table something like a materialized view (but not one, because the parameters are not set) that refreshes itselft, maybe a trigger or some job. Is it possible?
    Thank you very much!

    K- wrote:
    BluShadow wrote:
    That's not a valid test.
    The first time you ran it (using the view) it had to do lots of I/O to read the data.
    The second query ran quicker because the same data was already cached and didn't have to be read using expensive I/O.
    The two queries are essentially the same and performance of them will be the same.
    You should either do the same test, restarting the database before each query to get the same type of I/O hit, or try clearing out the cache via other means (though that's not completely accurate in itself).
    The other thing you can do is to look at the explain plans and execution plans from tracing the query execution, which will show there is really no difference except for the cached data.I did the explain plans and there was really a cost difference as bellow. The view vw_final_qtd I'm using has the same structure as the table t_final_qtd.
    Using vw_final_qtd: SELECT STATEMENT 83220
    Using t_final_qtd: SELECT STATEMENT 1050Cost is not truly indicative of the time a query takes to execute.
    The view is a stored SQL statement, so your first query...
    SELECT *
    FROM vw_final_qtd v --a view created exatcly as the table t_final_qtd
    ,ev_t e
    WHERE v.dispo = e.typecode
    AND v.adts BETWEEN '20101119' and '20101119235959';is essentially processed by the SQL engine as... (assuming your view is defined as "select * from t_final_qtd where current = 'T'")
    SELECT *
    FROM (select * from t_final_qtd where current = 'T')
    ,ev_t e
    WHERE v.dispo = e.typecode
    AND v.adts BETWEEN '20101119' and '20101119235959';... which the optimizer will look at and see that it is just the same as
    SELECT *
    FROM t_final_qtd t
    ,ev_t e
    WHERE t.dispo = e.typecode
    AND t.adts BETWEEN '20101119' and '20101119235959'
    and t.current = 'T';... so will most likely execute it just like that, hence there is no difference between the two queries.
    You can't just look at the explain plans, you need to look at the traces of the queries if you want to compare.
    However, take our word for it, the two things are the same and there's no reason you can't use the view.
    What would be more of a concern is the where clause:
    AND t.adts BETWEEN '20101119' and '20101119235959'which is doing a range comparison on strings rather than dates or numbers. That's open to potential errors, and may be causing lack of index usage if the column is actually a data or number.

  • Help With Multiple Inserts

    We are running oracl 8i and trying to get this statement to update Unit_warr_test with 20 to 30 lines from the refence table spec_comp_warranty when there is no entries for a given unit_id in the unit_warr_test that matches the unit_main and then matches the spec_no column to the spec_comp_warr table from the unit_main table. Below is the script that we are running. Right now this script returns 85,000,000,000 rows. The spec_comp_warr table only has 46,000 rows in it and the unit_main only has 7,000 rows. there is no reference between spec_comp_warranty table other than the spec_no and each spec has 20 to 30 rows in spec_comp_warranty. Any Ideas on how to get this script to run and insert the 20 30 rows in unit_warr_test when the unit is not in unit_warr_test by matching the spec_no?
    insert into unit_warr_test (COMPONENT,
    DIST_USAGE,
    DURATION,
    EXP_DT,
    EXP_USAGE,
    INVOICE,
    PART,
    TIME_USAGE,
    UNIT_ID,
    U_SYSTEM,
    VENDOR_NO,
    WARR_EXCLUDE_FL,
    RECORD_TYPE,
    ON_WARRANTY_CLAIM,
    POSSIBLE_WARRANTY_CLAIM)
    select
    a.component,
    NULL,
    a.DURATION,
    NULL,
    '0',
    NULL,
    a.PART,
    NULL,
    b.unit_id,
    a.u_system,
    a.vendor_no,
    a.warr_exclude_fl,
    'E',
    'N',
    'N'
    from SPEC_COMP_WARRANTY a, UNIT_MAIN b, UNIT_WARR c
    where b.unit_id <> c.unit_id
    and a.spec_no = b.spec_no and b.spec_no is not null

    It looks like your generating a Cartesian product. Try
    FROM   spec_comp_warranty A, unit_main B
    WHERE   a.spec_no = b.spec_no
    AND    b.spec_no IS NOT NULL
    AND     NOT EXISTS (SELECT c.unit_id
                    FROM  UNIT_WARR c
                    WHERE c.unit_id = c.unit_id )Cheers, APC

  • Really need help with an insert form

    I attempted to implement a cascading select list (via sergios blog); which was helpful. I created an office_id field as a select list with submit in order to populate another select list with the appropriate list of salespeople. But now the rest of my fields on the page are reset and I can't successfully add a record. I am wondering if I should be using a select list with submit or redirect or perhaps a computation for the page to achieve the same behavior but that doesn't submit the page until all fields are completed. Even if I fill out the office_id (the submit occurs)> I pick my salesperson then proceed to fill out the rest of the fields the row will not save when clicking the create button.

    select
    from table(cast(V_UserInfoin as T_UserInfo));

  • Please help with multiple insert query into nested table!!!!

    I am having a problem with inserting multiple references to objects into a nested table using the following query:
    INSERT INTO TABLE(SELECT Taken_by FROM courses WHERE course_number= 001)
    (SELECT REF(p) FROM persons p
    WHERE p.enroled_in = 'Computing for Business'
    The database says that p.enroled_in is an invalid identifier. I know why this is. This is because the field enroled_in is part of a subtype of person called student_type and the query above is not accounting for this properly. I would like to know the correct syntax to use so I can insert into the nested table wherever a student is enroled into the 'computing for business' course. My full schema is below:
    CREATE TYPE person_type;
    CREATE TYPE student_type;
    CREATE TYPE staff_type;
    CREATE TYPE course_type;
    CREATE TYPE module_type;
    CREATE TYPE address_type AS OBJECT
    Street VARCHAR2 (30),
    Town     VARCHAR2 (30),
    County VARCHAR2 (30),
    Postcode VARCHAR2 (9)
    CREATE TYPE person_type AS OBJECT
    Name VARCHAR2 (50),
    Address address_type,
    DOB     DATE
    ) NOT FINAL;
    CREATE TYPE staff_type UNDER person_type
    Staff_number NUMBER (2,0)
    ) FINAL;
    CREATE TYPE student_type UNDER person_type (
    Student_number NUMBER (2,0),
    Enroled_in VARCHAR2(50),
    MEMBER FUNCTION getAge RETURN NUMBER
    )NOT FINAL;
    CREATE OR REPLACE TYPE BODY student_type AS
    MEMBER FUNCTION getAge RETURN NUMBER AS
    BEGIN
    RETURN Trunc(Months_Between(Sysdate, DOB)/12);
    END getAge;
    END;
    CREATE TYPE module_type AS OBJECT
    Module_number VARCHAR2(6),
    Module_name VARCHAR2(50),
    Credit NUMBER(2,0),
    Taught_in VARCHAR2(50)
    CREATE TYPE students_tab AS TABLE OF REF person_type;
    CREATE TYPE modules_tab AS TABLE OF REF module_type;
    CREATE TYPE course_type AS OBJECT
    Course_number NUMBER (2,0),
    Course_name VARCHAR2(50),
    Dept_name VARCHAR2(50),
    Taken_by Students_tab,
    Contains Modules_tab
    CREATE TABLE modules OF module_type(
    constraint pk_modules primary key (Module_number)
    CREATE TABLE courses OF course_type(
    constraint pk_courses primary key (Course_number)
    NESTED TABLE Taken_by STORE AS students_nt,
    NESTED TABLE Contains STORE AS modules_nt;

    By the way I am using oracle 9i and trying to insert into the nested table data from a subtype (i.e student is a subtype of person)

  • Help with ASP Insert Into Command

    Hi All,
    I'm trying to get the following command (insert into) to
    work, but am having
    no joy. I would be greatful if you could highlight what i
    have done wrong.
    Its an for an ASP site using an MS SQL database -
    <%
    if(Session("BATCHID2") <> "") then
    insertaccountinvoice__MMColParam =
    Session("BATCHID2")
    if(Session("SITEID") <> "") then
    insertaccountinvoice__MMColParam2 =
    Session("SITEID")
    %>
    <%
    set insertaccountinvoice =
    Server.CreateObject("ADODB.Command")
    insertaccountinvoice.ActiveConnection = MM_recruta2_STRING
    insertaccountinvoice.CommandText = "INSERT INTO
    dbo.JBAccountInvoice
    (JBACISiteID, JBACIClientID, JBACIAccountType,
    JBACIAccountOverwrite,
    JBACIBillingContact, JBACIClientName, JBACIClientAddress,
    JBACIClientEmail,
    JBACIBatchID) VALUES (dbo.JBClient(JBCLSiteID, JBCLID,
    JBCLAccountType,
    JBCLreguserMonthlyOverwrite, JBCLBillingContact, JBCLName,
    JBCLAddress,
    JBCLEmail ), " + Replace(insertaccountinvoice__MMColParam,
    "'", "''") + "
    WHERE JBCLSiteID = '" +
    Replace(insertaccountinvoice__MMColParam2, "'", "''")
    + "' and JBCLAccountLive = 'y' and (JBCLAccountType = 'Reg
    User' OR
    JBCLAccountType = 'Reg User5' OR JBCLAccountType = 'Reg
    User10' OR
    JBCLAccountType = 'Multi User')) "
    insertaccountinvoice.CommandType = 1
    insertaccountinvoice.CommandTimeout = 0
    insertaccountinvoice.Prepared = true
    insertaccountinvoice.Execute()
    %>
    <% Response.Redirect("
    http://www.recruta.co.uk")
    %>

    In general, the syntax for this kind of insert is:
    insert into t1 (a,b,c)
    select a,b,c from t2 where a=5
    Jules
    http://www.charon.co.uk/products.aspx
    Charon Cart
    Ecommerce for ASP/ASP.NET

  • Help with rewrite INSERT statement

    Hi,
    is there any way to rewrite this statement in 9.2.0.8 ,so I can compare execution plans ?
    INSERT INTO tasks
                (id , data
       (SELECT :b17, NVL (:b12, SYSDATE)
          FROM DUAL
         WHERE EXISTS (
                  SELECT 1
                    FROM queue_definitions
                   WHERE df_id = :b17
                     AND (   df_max_depth = 0
                          OR df_max_depth >
                                   (SELECT COUNT (*)
                                      FROM tasks
                                     WHERE t_df_id = :b17 AND t_audit_stat != 0)
                         Regards
    GregG

    GregG wrote:
    Hi,
    is there any way to rewrite this statement in 9.2.0.8 ,so I can compare execution plans ?
    INSERT INTO tasks
    (id , data
    (SELECT :b17, NVL (:b12, SYSDATE)
    FROM DUAL
    WHERE EXISTS (
    SELECT 1
    FROM queue_definitions
    WHERE df_id = :b17
    AND (   df_max_depth = 0
    OR df_max_depth >
    (SELECT COUNT (*)
    FROM tasks
    WHERE t_df_id = :b17 AND t_audit_stat != 0)
    )));Regards
    GregGCan you eliminate the DUAL portion of the select, putting the insert bind varibles where 'SELECT 1' is instead using ROWNUM to restrict the number of rows to 1?

  • Need Help with Inserting Timeline Markers

    Friends,
    I have not use my premiere element 3.2 since 2008 and forgot some of the procedures. now, I need help with the insertion of Timeline Markers. I did what the Help Page showed me. But the markers were not effective in the resulting DVD, or, even when viewing the video in the editing page as if thye were not there! Here is what I did:.
    1)  Click the Timeline button.
    2)  Click in an empty space in a video or audio track in the Timeline to make the Timeline active and deselect any clips.
    3)  Move the current-time indicator in the Timeline to the frame where I need the marker.
    4)  Click the Add Marker icon in the Timeline to place the Marker 5 times where I want them.
    5)  Verified that each Timeline Marker is present at the intended place.
    6)  Burned DVD
    7)  Can NOT jump to any of the intended Marker in the Resulting DVD during playback.
    The question is "What did I do wrong or didn't do?" It seems that I did the same before and worked! Please advise!
    Also, what are the significance of the Red line just below the Timeline and the yellow bars inside the video and audio frames. But after preforming Timeline/Render Work Area, they were all gone? What purposes do they serve and what is the significance of Rendering? Thank you for your help!
    I repeat the process and did a Rendering before making the DVD also. It did not help!
    Andy Lim

    Steve,
    Long time no talk! You used to help me out many times when the PE-1 through PE-3 came out. I was HOPING you would still be around and you are! You came through again this time! Many thanks to you.
    I use the Add DVD Scene button to insert the Markers. They are Green. Made a DVD and the markers work OK although ythey are "effective" during play back using the editing window.
    While that problem was solved, will you come back and answer the other two questions concerning Rendering and the Red/Yellow lines? I would appreciate it very much!
    Andy Lim
    ~~~~~~~~~~~~~~~~

Maybe you are looking for

  • How do I insert multiple images inline with text in Pages 5.0?

    I have over 20 images in my iPhoto library that I want to insert in a document one after the other (inline with text). How do I do this without having to insert them one by one and going into the image options to change the formatting? It's a pain to

  • How to Install Cinema 4D lite for free in Adobe CC?

    Who can help?

  • Creating a dynamic job in OEM

    Hi, I need to run an SQL script every night across all of my database targets. My problem is that the data contained in the script will change every day, so I need some way of creating a dynamic job. Any ideas on this? Could I create/submit the job u

  • Import of Playlist not possible

    Hi, since iTunes 8.1 it's impossible to import and sync prepared playlists (format: m3u). The playlist are listed, but they are empty. The music library is empty too. If I use an older version (i.e. 8.0.2), everything works fine. Looks like bug in iT

  • I can't execute Photoshop CC 2014 in my computer.

    I can't execute Photoshop CC 2014 in my computer. Whenever I execute Photoshop, I saw the massage 'Can't operate programs because of some problem'. They didn't give any information What is the cause of problem. My computer version is Window 8. Is it