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

Similar Messages

  • Customized Insert into Command

    Dear All,
    Here, I want to make a SQL script to do an INSERT INTO Statement from TABLE “A” to “B” like this
    Insert into A select * from B
    But catch is that – TABLE “A” is having e 4 extra columns(Year, Month, Week, Day), those not exists in TABLE “B”, & due to this Plain INSERT INTO statement is not working.
    Therefore, I want to create a dynamic  INSERT INTO command with skip of 4 said columns.
    You can better understand this in this way..
    My Desired.
    Insert into A ( Id,Name,Address,City,Zip)
    select Id,Name,Address,City,Zip from B
    Please Help !
    Thanks..

    Hi Visakh16,
    Sorry for my earlier remark I was unclear.
    Actually Error message is like this ..
    Msg 512, Level 16, State 1, Line 4
    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
     If I’m executing this piece of code..
    DECLARE @SQl varchar(max)
    SELECT @SQL = 'INSERT A  (' +
    STUFF(
    (SELECT ',' + COLUMN_NAME
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = t.TABLE_NAME
    AND TABLE_SCHEMA = t.TABLE_SCHEMA
    ),1,1,'') + ')
    SELECT ' +
    STUFF(
    (SELECT ',' + COLUMN_NAME
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = t.TABLE_NAME
    AND TABLE_SCHEMA = t.TABLE_SCHEMA
    ),1,1,'') + ' FROM ' + TABLE_NAME
    FROM INFORMATION_SCHEMA.TABLES as t
    WHERE TABLE_NAME = 'Sale2013'
    --print @SQL
    EXEC (@SQL)
    Please help me to diagnose this ..

  • My Mac G-4 OS X will not image an icon of the zip disk with I inserted into my computer's built-in Zip Drive, therefore I can not remove the zip disk from my computer.  What can I do?

    My Mac G-4 OS X will not image an icon of the zip disk with I inserted into my computer's built-in Zip Drive, therefore I can not remove the zip disk from my computer.  What can I do?

    Thanks Old Comm Guy, BD Aquam and Texas Mac Man for youradvice and reply to my question
    and problem with my Zip Drive.  However:
        1.  Depressing mouse buttonon start up did not eject the zip disk.
        2.  To examine front of zipdrive, I had to remove many screws and several plastic case
             coverings.  Upon doing thatI discovered that, unfortunately, there is no whole in front
              of mybuilt-in zip hardware drive for me to insert a paper clip to manually eject zipdisk.
          3.  I went to the Utilities folder in myMac OS X Application folder, but I could not find
               theiomega zip drive in there.
    Also, I did go into my "9" System folder and thento the Extensions folder within it and did find an icon of an
    Iomega Driver. When double clicking on it a window came upstating I was opening the application
    "ColorSync Extension" for thefirst time, and asking if I was sure I wanted to open this application.
    Uponclicking open nothing happened - nothing opened.
    I also went into the "System X" folder>Libraryfolder>Extension folder>IomegaSAM.ket icon and double
    clicked on it and asmall window opened stating "Compiling file List", however nothingopened it just
    continued to compile, so I closed it.
    Within my Mac OS X HD>  Applications>Iomega folder>Iomega Tools.app a smallwindow opened up
    with several options (Erase, Protect, Disk Info and DriveInfo). Clicking on the Drive Info a message says:
    "No Iomega Drives or noIomega Driver found.  Therefore, Ihave gone to Mac, Iomega and other websites
    trying to find a Driver for thebuilt-in Zip Drive in my Mac G-4 OS X 10.4.11, but have not really found anythat work.
    CAN ANYONE TELL ME IF THERE IS A WEBSITE WHERE I CANDOWNLOAD A NEW DRIVER FOR MY ZIP DRIVE?
    Thanks,     Peterfromcrystallake

  • 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 Connections - New User

    I just set up a hosting account with 1 and 1 for a simple
    website to catalog a series of yo-yo contest that we coordinate. I
    have a simple MS Access database for organizing contest information
    that we are trying to get online.
    I am new to the application side of this and know very little
    about connection strings, DSN, etc. I am experiencing problems with
    connecting to the MS Access database that I have uploaded to the
    1and 1 servers. If I hardcode the Javascript into the page, I can
    connect and pull information but I definitely want to take
    advantage of the design interface that Dreamweaver MX 2004 offers.
    This is the code from the page that I can get working based
    on the FAQ Sheet that 1and 1 offers for database connections:
    <html>
    <title>Database query using ASP</title>
    <body bgcolor="FFFFFF">
    <h2>Query table <b>Products</b> with
    ASP</h2>
    <%
    Set dbaseConn = Server.CreateObject("ADODB.Connection")
    dbaseConn.Open "DRIVER={Microsoft Access Driver
    (*.mdb)};DBQ=" & Server.Mappath("\db\League.mdb") & ";"
    SQLQuery = "SELECT * FROM Contest_Information"
    Set RS = dbaseConn.Execute(SQLQuery)
    %>
    <%
    Do While Not RS.EOF
    %>
    <%=RS("cStartDate")%>, <%=RS("cName")%>,
    <%=RS("cWebsite")%> List
    <p>
    <%
    RS.MoveNext
    Loop
    RS.Close
    Set RS = Nothing
    dbaseConn.Close
    Set dbaseConn = Nothing
    %>
    </body>
    </html>
    If I put in a "Custom Connection String" using the previous
    code:
    "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &
    Server.Mappath("\db\League.mdb") & ";"
    Dreamweaver can connect to the database when the connection
    is 'tested' but cannot pull any tables and therefore cannot create
    bindings.
    Guidance...help...I'm stuck...
    Thanks in advance.

    Hello Lucky.da.boss,
    And welcome to Apple Discussions!
    is asking can I or is there anyway i can transfer my music off that iPod to my touch?
    See this article for tips on how to copy music from your 5th generation iPod to your iTunes library. Once you have successfully done that, you can sync them over to your iPod Touch. There is no way to do it directly.
    http://macs.about.com/od/backupsarchives/ss/ipodcopy.htm
    Also, I have two applications that aren't downloading I want to know how to delete them.
    Tap your finger on one of them and hold it there until you see all your Apps start to wiggle. You will also see a small x in the upper right hand corner of the Apps you can delete. Go ahead and tap this to delete the App. When you are finished, hit the Home button to make the Apps stop wiggling. It might also help to have a look at your iPod's *User Guide.
    http://manuals.info.apple.com/enUS/iPod_touch_iOS4.1_UserGuide.pdf
    Can you have constant internet service or do they run solely off wi-fi?
    Only Wi-fi.
    B-rock

  • Help! about insert into one table from two tables'data?

    hi,all friends!
    i have a question:
    i have two table as like this:
    table_one(id,ipaddr,col1,col2) primary key(id,ipaddr)
    table_two(id,ipaddr,col1,col3,col4) primary key(id,ipaddr)
    about table_one and table_two,it's columns may change execept id and ipaddr,
    how can i insert the data of table_one and table_two into table_three,the columns of table_three may change with the columns of table_one and table_two
    table_three may dynamic create,but it's primary key is (id,ipaddr)
    thanks!
    pls help!
    any suggestion welcome!

    insert into table_3
    (id, ipaddr, col1, col2, col3, col4)
    select t1.id, t1.ipaddr, t1.col1, t1.col2, t2.col3, t2.col4
    from table_1 t1, table_2 t2
    where t2.id = t1.id
    and t2.ipaddr = t1.ipaddr;

  • 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

  • Help on Chinese insert into mysql (urgent)

    Dear Friends,
    we are running an coldfusion mx application on window,
    perfect, the database is mysql, utf-8 encoding.
    But when we moved to redhat linux +mysql, the chinese in the
    database displayed as ?????. when we insert into database, the
    chinese inserted like ????? as well...
    Any thing that we missed to config...please help.
    thanks,

    [This page|http://java.sun.com/developer/technicalArticles/Intl/HTTPCharset/] has a good explanation of where the issues might be.
    The thing with character encodings is that you have to get it right at every step. If you miss one of them, then the whole thing blows apart.
    From the minimal info you have here, I would take a look at the request.setCharacterEncoding() methd.
    cheers,
    evnafets

  • Need help with the restore-mailbox command

    I just started playing around with the restore-mailbox command now that the Recovery Storage Group and exmerge are not options in 2010. I am hoping someone can help me out here. I am working in a test environment. What I did was backup a database with a
    single mailbox on it called testex2010. I used Windows backup. I then restored the database and logs, created the recovery database using the shell and was able to mount the database after running eseutil /R etc...
    I now want to recover the data in the mailbox testex2010 to another mailbox called Recovery Mailbox in the production database. I was able to successfully restore testex2010 to itself. I proved  this by deleting all the messages in the live database,
    running the restore command and seeing the messages back in the live mailbox.
    The command I used was restore-mailbox -identity testex2010 -RecoveryDatabase RDB1
    I am prompted with the "are you sure" text and after hitting yes, all goes well. I now want to restore to another mailbox in the production database called Recovery Mailbox. This is where it breaks down. No matter how I format the command, I cannot get it
    to work. Two questions:
    1) should I be able to see mailboxes in the Recovery Database using the GUI or the Shell or do you just assume they are there?
    2) what is the command to restore messages from a mailbox in the Recovery Database to another mailbox in the production environment?
    Is what I am trying even possible? Just so you know, I did try this command"
    Restore-mailbox -identity testex2010 -RecoveryDatabase RDB1 -RecoveryMailbox "Recovery Mailbox" -TargetFolder testex2010
    It fails telling me that the mailbox Recovery mailbox is not in the Recovery Database.

    Restore-mailbox -identity testex2010 -RecoveryDatabase RDB1 -RecoveryMailbox "Recovery Mailbox" -TargetFolder testex2010
    The wording of the
    Restore-Mailbox command can be tricky. If I look at your example above, this is what it would attempt to do...
    Restore the content of the mailbox with display name "Recovery Mailbox" in the RDB into the mailbox testex2010 under a folder named testex2010.
    Think of the -Identity parameter as the mailbox you want to restore INTO.
    Think of the -RecoveryMailbox parameter as "Recoverying The Mailbox of..."
    Also get into the habit of using the DisplayName with -RecoveryMailbox.
    Microsoft Premier Field Engineer, Exchange
    MCSA 2000/2003, CCNA
    MCITP: Enterprise Messaging Administrator 2010
    Former Microsoft MVP, Exchange Server
    My posts are provided “AS IS” with no guarantees, no warranties, and they confer no rights.

  • 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

  • Problem with using INSERT INTO script

    Hi guys,
    I was trying to duplicate a table with the following script:
    CREATE TABLE TAB3(
    KEYATTR     NUMBER(3)     NOT NULL,
    BODY1     CHAR(1000)     NOT NULL,
    BODY2      CHAR(1000)     NOT NULL,
    BODY3     CHAR(1000)     NOT NULL,
         CONSTRAINT TAB3_PKEY PRIMARY KEY(KEYATTR) )
    INSERT INTO TAB3
         SELECT      *           
         FROM system.table3
         ORDER BY DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) DESC, KEYATTR DESC
    However, when I execute the script, I keep getting a 'missing right parenthesis' error. Any idea what went wrong?

    You don't need braces.
    Just
    INSERT INTO TAB3
    SELECT *
    FROM system.table3
    ORDER BY DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) DESC, KEYATTR DESCshould work.

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

Maybe you are looking for

  • How much recording time on my iphone 4 voice memo?

    How much recording time on iphone4 voice memo?

  • Cover flow problem

    I recently converted to Mavericks. I'm finding that when I view files in 'cover flow' and delete a file from the list the picture of the file does not simultaneously delete and so become out of sync with the list. Anyone have this problem? a solution

  • Is it possible to designate stapling when printing a PDF form?

    I am using Adobe Lifecycle Designer (ver. 10.0.1029120306.1.870331) to set up a new report for an SAP application.  I can certainly designate duplex printing from within the form by using Form Properties and the PDF Print Options, but no stapling opt

  • New computer, no backup, can I import from iphone?

    My computer crashed and unfortunately I don't have a backup of my iphone.  I downloaded Itunes to my new laptop and I'm afraid if I choose Sync I will erase all the contacts/apps/music on my iphone. Is this correct?  And if so how can I import all mu

  • LabVIEW 8 & Windows XP Embedded?

    We have a system running XP Embedded and I would like to run a compiled LV8 application on it.  It requires one of the DAQCards (1200) to gather data.  I guess I'm just not sure how this will all fit on the system.  Traditional NI-DAQ 7.4.1 is a 386M