Help with a select statement from a SQL Server within a DTS !!

Hello Gurus!
I help with the script bellow, when I run it within DTS (in SQL Sever 2000), I got the error Invalid number/or not a valid month.
Please bellow with the WHERE CLASUE '08/01/2001' AND '03/09/2002'
And in the other hand I change this forma to '01-AUG-01' AND
'03-MAR-2002', the DTS start and run witha successful messages, but it does not returns row, which is wrong.
Somebady please help!
Thanks Gurus!
GET Total ANIs with Trafic By Area Code
select
     substr(b.ct_num, 0,3) as Area_Codes,
     COUNT(DISTINCT B.CT_NUM) AS ANIS
from
     wasabi.v_trans A,
     wasabi.V_Sur_Universal B,
     wasabi.V_Sub C,
     wasabi.V_Trans_Typ D
where
     D.Trans_typ = A.Trans_Typ AND
     A.Sur_ID = B.Sur_ID AND
     C.Sub_ID = A.Sub_ID AND
     a.trans_stat != 'X' AND     
     a.Trans_DTTM >= '08/01/2001'AND
     a.Trans_DTTM < '03/09/2002 AND
     B.AMA3 = 'PHONE1'
     AND C.SUB_ID not in (100117)
GROUP BY
     substr(b.ct_num, 0,3)
ORDER BY
     Area_Codes

I think that you need a "to_date" function eg
change '08/01/2001' to to_date('08/01/2001','dd/mm/yyyy')

Similar Messages

  • Quick help with a select statement...

    Hello all,
    I will try to lay this out as simply as possible.  I have the following table in my code:
    TYPES: BEGIN OF ty_table,
        vbeln TYPE likp-vbeln,
        lfdat TYPE likp-lfdat,
        lfart TYPE likp-lfart,
        wadat_ist TYPE likp-wadat_ist,
        vstel TYPE likp-vstel,
        route TYPE likp-route,
        vsbed TYPE likp-vsbed,
        inco1 TYPE likp-inco1,
        inco2 TYPE likp-inco2,
        kunnr TYPE likp-kunnr,
        kunag TYPE likp-kunag,
        brgew TYPE lips-brgew,
        matnr TYPE lips-matnr,
        arktx TYPE lips-arktx,
        meins TYPE lips-meins,
        lgmng TYPE lips-lgmng,
        vgbel TYPE lips-vgbel,
        name2 TYPE adrc-name2,
        street TYPE adrc-street,
        city1 TYPE adrc-city1,
        region TYPE adrc-region,
        post_code1 TYPE adrc-post_code1,
        lifnr  TYPE lfa1-lifnr,
        name1 TYPE adrc-name1,
        so_vbeln TYPE vbak-vbeln,
        erdat TYPE vbak-erdat,
      END OF ty_table.
    DATA: it_table TYPE TABLE OF ty_table.
    I then run through a select statement as follows:
    * Get data from LIKP and LIPS.
      SELECT a~vbeln a~lfdat a~lfart a~wadat_ist a~vstel a~route a~vsbed b~brgew a~inco1 a~inco2 a~kunnr a~kunag
               b~matnr b~meins b~lgmng b~vgbel b~arktx INTO CORRESPONDING FIELDS OF TABLE it_table
               FROM likp AS a
                INNER JOIN lips AS b ON b~vbeln = a~vbeln
                WHERE a~vstel IN so_vstel
                AND a~wadat_ist IN so_wadat
                AND b~mtart IN so_mtart.
    That works fine.  The next statement, in the report, is the following select.  When this next select runs it clears all of the fields except for vbeln and erdat.  I want c~vbeln to go into it_table-so_vbeln.  Now it is going into it_table-vbeln.
    * Get Sales order info from VBAK
      SELECT c~vbeln c~erdat INTO CORRESPONDING FIELDS OF TABLE it_table
          FROM lips AS a
            INNER JOIN vbap AS b ON b~vbeln = a~vgbel
            AND b~posnr = a~vgpos
              INNER JOIN vbak AS c ON c~vbeln = b~vbeln
              FOR ALL ENTRIES IN it_table
                WHERE a~vgbel = it_table-vgbel.
    I then tried to write the select statement by takign out "into corresponding fields" like the following but it gives my a syntax error on (it_table-so_vbeln , it_table-erdat).
    * Get Sales order info from VBAK
      SELECT c~vbeln c~erdat INTO (it_table-so_vbeln , it_table-erdat)
        FROM lips AS a
          INNER JOIN vbap AS b ON b~vbeln = a~vgbel
          AND b~posnr = a~vgpos
            INNER JOIN vbak AS c ON c~vbeln = b~vbeln
            FOR ALL ENTRIES IN it_table
              WHERE a~vgbel = it_table-vgbel.
    Is there a way to write the second select (the select that is pulling data from VBAK) so that it will not clear the other entries in the table?  Also, is there a way to combine the two selects into one join? 
    Regards,
    Davis

    Following is the entire report, if that makes it easier:
    *& Report  Z_TRANS_EVAL
    REPORT  z_trans_eval.
    TABLES: likp, lips, adrc, vbpa.
    TYPE-POOLS: truxs.
    TYPES: BEGIN OF ty_table,
        vbeln TYPE likp-vbeln,
        lfdat TYPE likp-lfdat,
        lfart TYPE likp-lfart,
        wadat_ist TYPE likp-wadat_ist,
        vstel TYPE likp-vstel,
        route TYPE likp-route,
        vsbed TYPE likp-vsbed,
        inco1 TYPE likp-inco1,
        inco2 TYPE likp-inco2,
        kunnr TYPE likp-kunnr,
        kunag TYPE likp-kunag,
        brgew TYPE lips-brgew,
        matnr TYPE lips-matnr,
        arktx TYPE lips-arktx,
        meins TYPE lips-meins,
        lgmng TYPE lips-lgmng,
        vgbel TYPE lips-vgbel,
        name2 TYPE adrc-name2,
        street TYPE adrc-street,
        city1 TYPE adrc-city1,
        region TYPE adrc-region,
        post_code1 TYPE adrc-post_code1,
        lifnr  TYPE lfa1-lifnr,
        name1 TYPE adrc-name1,
        so_vbeln TYPE vbak-vbeln,
        erdat TYPE vbak-erdat,
      END OF ty_table.
    DATA: it_table TYPE TABLE OF ty_table,
          wa_table LIKE LINE OF it_table,
          it_table_csv TYPE truxs_t_text_data.
    DATA : lv_tabix LIKE sy-tabix.
    DATA temp_string TYPE string.
    DATA w_adrnr TYPE vbpa-adrnr.
    DATA: w_adrnr_sp TYPE vbpa-adrnr.
    * Selction criteria
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-004.
    SELECT-OPTIONS: so_vstel FOR likp-vstel,
                    so_wadat FOR likp-wadat_ist,
                    so_mtart FOR lips-mtart.
    SELECTION-SCREEN END OF BLOCK b2.
    * CSV output filename
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (16) text-002 FOR FIELD p_file.
    PARAMETERS: p_file(30) TYPE c.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK b3.
    START-OF-SELECTION.
    * Get data from LIKP and LIPS.
      SELECT a~vbeln a~lfdat a~lfart a~wadat_ist a~vstel a~route a~vsbed b~brgew a~inco1 a~inco2 a~kunnr a~kunag
               b~matnr b~meins b~lgmng b~vgbel b~arktx INTO CORRESPONDING FIELDS OF TABLE it_table
               FROM likp AS a
                INNER JOIN lips AS b ON b~vbeln = a~vbeln
                WHERE a~vstel IN so_vstel
                AND a~wadat_ist IN so_wadat
                AND b~mtart IN so_mtart.
    * Get Sales order info from VBAK
      SELECT c~vbeln c~erdat INTO CORRESPONDING FIELDS OF TABLE it_table
          FROM lips AS a
            INNER JOIN vbap AS b ON b~vbeln = a~vgbel
            AND b~posnr = a~vgpos
              INNER JOIN vbak AS c ON c~vbeln = b~vbeln
              FOR ALL ENTRIES IN it_table
                WHERE a~vgbel = it_table-vgbel.
    * Get internal address number for ship to party
      LOOP AT it_table INTO wa_table.
        lv_tabix = sy-tabix.    "update counter.
        SELECT SINGLE adrnr FROM vbpa INTO w_adrnr WHERE
        vbeln = wa_table-vgbel
        AND parvw = 'WE'.
        SELECT SINGLE lifnr FROM vbpa INTO wa_table-lifnr WHERE
          vbeln = wa_table-vbeln
          AND parvw = 'SP'
          AND  posnr = '000000'.
        SELECT SINGLE name1 FROM lfa1 INTO wa_table-name1 WHERE
          lifnr = wa_table-lifnr.
    * Get address data from VBPA
        SELECT city1 region post_code1 INTO CORRESPONDING FIELDS OF wa_table
        FROM adrc WHERE
        addrnumber = w_adrnr.
        ENDSELECT.
    * Update the internal table
        MODIFY  it_table INDEX lv_tabix FROM wa_table.
      ENDLOOP.
    END-OF-SELECTION.
    * Call correct display procedure(s).
      IF p_file <> ''.
    * Save a CSV file
        PERFORM display_csv.
      ELSE.
    *Display in ALV
        PERFORM display_alv.
      ENDIF.
    *&      Form  display_alv
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display_alv .
      DATA: gr_alv TYPE REF TO cl_salv_table,
            gr_func TYPE REF TO cl_salv_functions,
            gr_columns TYPE REF TO cl_salv_columns_table,
            gr_column TYPE REF TO cl_salv_column_table,
            gr_error TYPE REF TO cx_salv_error.
      TRY.
          CALL METHOD cl_salv_table=>factory
            IMPORTING
              r_salv_table = gr_alv
            CHANGING
              t_table      = it_table.
        CATCH cx_salv_msg INTO gr_error.
      ENDTRY.
      gr_func = gr_alv->get_functions( ).
      gr_func->set_all( abap_true ).
      gr_alv->display( ).
    ENDFORM.                    " display_alv
    *&      Form  display_csv
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display_csv .
      DATA: w_filename TYPE string.
      CONCATENATE p_file temp_string INTO w_filename.
      CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
        EXPORTING
          i_field_seperator    = ';'
        TABLES
          i_tab_sap_data       = it_table
        CHANGING
          i_tab_converted_data = it_table_csv
        EXCEPTIONS
          conversion_failed    = 1
          OTHERS               = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename = w_filename
        TABLES
          data_tab = it_table_csv
        EXCEPTIONS
          OTHERS   = 1.
      PERFORM display_alv.
    ENDFORM.                    " display_csv

  • Need help with Thin JDBC connecting Oracle to SQL server.

    I am fairly new to JAVA. We have ORACLE 8.1.7 running on Solaris 8. I have a need to
    periodically extract data from ORACLE DB and transfer it to SQL Server. I am limited to
    moving data from the ORACLE/UNIX environment to SQL Server side.
    From what I have read, Server-side Thin driver should work.
    1) Are there any issues in trying to achieve this with ORACLE running on the UNIX platform?
    2) Will the Server-side Thin driver talk to both the DBs ?
    3) Is it possible to provide some sample code ?
    Thanks in advance,
    Solomon

    Quattro,
    I had complete success in reading from Oracle and writing to SQL Server. First of all let me thank you for all your help. I do have one last request. Its more on optimization than any thing else.
    I was trying to optimize my code by grouping both the connections in one place and to keep my reads and inserts together so that I don't commit at the end of each insert etc. I don't seem to have the scope rules under control yet. Could you suggest how to improve this:
    import java.sql.*;
    public class Test_Combined2 {
    public static void main(String args[]) throws SQLException {
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    // Connect to the database
    // You must put a database name after the @ sign in the connection URL.
    // You can use either the fully specified SQL*net syntax or a short cut
    // syntax as <host>:<port>:<sid>. The example uses the short cut syntax.
    Connection con2 = DriverManager.getConnection ("jdbc:oracle:thin:@Test:1521:PSDEVElOP",
    "SOLOMON","SOL1");
    // Create a Statement
    Statement stmt2 = con2.createStatement ();
    String url = "jdbc:microsoft:sqlserver://INTRADEV:1433;DatabaseName=Measure";
    Connection con;
    String query = "select dataYear, dataMonth, yieldRate from tblYield " ;
    Statement stmt;
    try {
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.print(e.getMessage());
    // Select the ENAME column from the EMP table
    ResultSet rset = stmt2.executeQuery ("select year_start, monthofyear, percent_comp " +
    " from ps_usm_ytd_yield ");
    // Iterate through the result and print the employee names
    while (rset.next ()) {
    System.out.println (rset.getFloat (3));
    int ps_dataYear = rset.getInt(1);
    int ps_dataMonth = rset.getInt(2);
    float ps_yieldRate = rset.getFloat(3);
    try{
    con = DriverManager.getConnection (url, "tmpuser","tmppush");
    stmt = con.createStatement();
    PreparedStatement insertTblYield;
    String insertString = "insert into tblYield " +
    " values(?, ?, ?)";
    //con.setAutoCommit(false);
    insertTblYield = con.prepareStatement(insertString);
    insertTblYield.setInt(1, ps_dataYear);
    insertTblYield.setInt(2, ps_dataMonth);
    insertTblYield.setFloat(3, ps_yieldRate);
    insertTblYield.executeUpdate();
    con.commit();
    //con.setAutoCommit(false);
    /*ResultSet rs = stmt.executeQuery(query);
    System.out.println("dataYear, dataMonth, yieldRate");
    while (rs.next()) {
    int dataYear = rs.getInt(1);
    int dataMonth = rs.getInt(2);
    float yieldRate = rs.getFloat(3);
    System.out.println(" " + dataYear + ", " + dataMonth + ", " + yieldRate);
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.print("SQLException: ");
    System.err.println(ex.getMessage());
    } //while
    stmt2.close();
    con2.close();

  • Help with copying SP List data to SQL Server

    I need to read some data from a SP list and copy it to a table in SQL Server.
    Visual Studio  BIDS 2013. SharePoint 2010. Planning to migrate to 2013 this year. I tried to use the
    SP Data source/destination adapter with SSIS, but learned that I can't with Visual Studio 2013. I'm really looking for any way to read data from a SP list and import it into a SQL database (SQL 2014). Haven't found anything online that has worked for me the
    way they say it should (such as OData connection in SSIS). Maybe it's version issues.
    Does anyone have a solid step-by step to do this? I am not a C# developer...

    Hi,
    According to your description, my understanding is that you want to read SharePoint list data and copy it to SQL Server table.
    Hatim's option is a way to achieve it manually.
    If you want to do it automatically, I suggest you can create a console application to read SharePoint list using CAML Query and Client Object Model, Then use SqlConnection object to connect database, then you can insert record using SqlCommand object.
    Here are some detailed code demos for your reference:
    http://www.codeproject.com/Articles/399156/SharePoint-Client-Object-Model-Introduction
    https://msdn.microsoft.com/en-us/library/ms233812.aspx
    Thanks
    Best Regards
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jerry Guo
    TechNet Community Support

  • Need help with a SELECT statement

    Dear forumers,
    I'm a newbie in ABAP and I'm trying to figure out what the following line means (in bold letters):-
    SELECT SINGLE STAT2 FROM PA0000 INTO PA0000-STAT2
    WHERE PERNR = ITAB_DATA-STAFF_NO.
    Does this mean that the single data from the STAT2 field is selected and then placed back into the same field (doesn't quite makes sense, right)?
    Please help and many thanks in advance!

    SELECT SINGLE STAT2 FROM PA0000 INTO PA0000-STAT2
    WHERE PERNR = ITAB_DATA-STAFF_NO.
    Does this mean that the single data from the STAT2 field is selected and then placed back into the same field (doesn't quite makes sense, right)?
    it sense very much right.
    have you heared about table buffer concept?
    here this concept exactly comes.
    try with this below code:
    TABLES:pa0000."tables must be decleare
    SELECT SINGLE STAT2 FROM PA0000 INTO PA0000-STAT2.
      write:PA0000-STAT2.
    and since you are using select single than you should be use much key as much possible for getting accurate data.other wise system will pick first data which match your where condition.
    Amit.

  • Can you please help with this select statement.

    The following code has a result, I need to modify the select somehow which only gives me the rows which are common between all PLSTS.
    Any suggestions?
    Thank you
    SELECT DISTINCT P.PLST, P.MENU, I,PNL, P.ACCESS
    FROM AUTHITEM P, I.MENUITEM
    WHERE P.MENU = I.MENU
    AND P.PNL = I.PNL
    AND P.MENU IN ('MSN, CPP')
    AND P.ACESS >= 8
    GROUP BY P.PLST, PMENU, I.PNL, P.ACCESS
    HAVING COUNT (*) >=2
    ORDER BY 2,3,4,1
    This is the result with having count > = 1, and if I add having count > =1 I get the following result
    PLST     MENU     PNL     ACCESS
    C001     MSN     LNAME     14
    C002     MSN     LNAME     14
    B008     MSN     LNAME     14
    B005     MSN     FNAME     14
    M009     MSN     LNAME     14
    C001     MSN     GNAME     14
    C002     MSN     GNAME     14
    B008     MSN     LNAME     14
    C001     MSN     FNAME     14
    C002     MSN     FNAME     14
    k008     CPP     MNAME     14
    I need this result
    PLST     MENU     PNL     ACCESS
    C001     MSN     LNAME     14
    C002     MSN     LNAME     14
    C001     MSN     GNAME     14
    C002     MSN     GNAME     14
    C001     MSN     FNAME     14
    C002     MSN     FNAME     14

    why bother with DISTINCT ?
    have a look at the results of :
    SELECT P.PLST, P.MENU, I.PNL, P.ACCESS , COUNT(*) ZCOUNT
      FROM AUTHITEM P, I.MENUITEM
    WHERE P.MENU    = I.MENU
       AND P.PNL     = I.PNL
       AND P.MENU  IN ('MSN, CPP')
       AND P.ACCESS >= 8
    GROUP BY P.PLST, P.PMENU, I.PNL, P.ACCESS
    ORDER BY 2,3,4,1
    ;and then apply HAVING COUNT(*) >= ...

  • Help with a select statement

    I have a table in the folowing format:
    date(dd/mm/yyyy) comments(varchar2)
    04/09/2007 abcd
    04/09/2007 efghij
    07/09/2007 klmn
    08/09/2007 opqrs
    08/09/2007 tuvwxyz
    I trying to write a SQL to give me the length of
    longest concatenated string of "comments' among the dates.
    eg. the query should return : 12 , because date '08/09/2007'
    has the longest string when concatenated.
    thanks in advance.

    I am not sure if the use of the row_number function inside the following query works on 10.1.0.5. If you have troubles, you'd have to nest the row_number analytic function a level deeper.
    This one works on 10gR2:
    SQL> select max(c) keep (dense_rank last order by length(c)) comments
      2    from ( select mydate
      3                , rn
      4                , c
      5             from mytable
      6            model
      7                  partition by (mydate)
      8                  dimension by (row_number() over (partition by mydate order by comments) rn)
      9                  measures (cast(comments as varchar2(100)) c)
    10                  rules
    11                  ( c[any] order by rn desc = c[cv()] || c[cv()+1]
    12                  )
    13         )
    14   where rn = 1
    15  /
    COMMENTS
    opqrstuvwxyz
    1 rij is geselecteerd.Note that there isn't a column present that decides which comment should be before another comment.
    Regards,
    Rob.

  • I need help with a SELECT query - help!

    Hello, I need help with a select statement.
    I have a table with 2 fields as shown below
    Name | Type
    John | 1
    John | 2
    John | 3
    Paul | 1
    Paul | 2
    Paul | 3
    Mark | 1
    Mark | 2
    I need a query that returns everything where the name has type 1 or 2 but not type 3. So in the example above the qery should bring back all the "Mark" records.
    Thanks,
    Ian

    Or, if the types are sequential from 1 upwards you could simply do:-
    SQL> create table t as
      2  select 'John' as name, 1 as type from dual union
      3  select 'John',2 from dual union
      4  select 'John',3 from dual union
      5  select 'Paul',1 from dual union
      6  select 'Paul',2 from dual union
      7  select 'Paul',3 from dual union
      8  select 'Paul',4 from dual union
      9  select 'Mark',1 from dual union
    10  select 'Mark',2 from dual;
    Table created.
    SQL> select name
      2  from t
      3  group by name
      4  having count(*) <= 2;
    NAME
    Mark
    SQL>Or another alternative if they aren't sequential:
    SQL> ed
    Wrote file afiedt.buf
      1  select name from (
      2    select name, max(type) t
      3    from t
      4    group by name
      5    )
      6* where t < 3
    SQL> /
    NAME
    Mark
    SQL>Message was edited by:
    blushadow

  • Limitation on SQL executing select statement from ADO and Oracle 8.1.7.1 OleDB Driver

    Hi,
    we are running a query with a big dunamic select statement from VB code using ADO command object. When Execute method is called system hangs and control won't return back to the application. it seems to be that there is some type limitation on Query string length. Please tell us if there is any?
    we are running Oracle 8.1.7 Server on Windows 200 Server and connecting from a W2K professional, ADO 2.6 and Oracle OLEDB 8.1.7.1 OLEDB Driver.
    Sample code:
    Dim rs As ADODB.Recordset
    Dim cmd As ADODB.Command
    Set cmd = New Command
    With cmd
    .CommandText = ' some text with more than 2500 characters
    .CommandType = adCmdText
    Set rs = .Execute
    End With
    when i debug using VB6 and when .Execute line is called system hangs or return a message method <<somemethod> of <<some class name>> failed error.
    Any help is appreciated.
    Thanks,
    Anil

    A stored procedure would only slow you down here if it was poorly written. I suspect you want to use the translate function. I'm cutting & pasting examples from the documentation-- a search at tahiti.oracle.com will give you all the info you'll need.
    Examples
    The following statement translates a license number. All letters 'ABC...Z' are translated to 'X' and all digits '012 . . . 9' are translated to '9':
    SELECT TRANSLATE('2KRW229',
    '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
    '9999999999XXXXXXXXXXXXXXXXXXXXXXXXXX') "License"
    FROM DUAL;
    License
    9XXX999
    The following statement returns a license number with the characters removed and the digits remaining:
    SELECT TRANSLATE('2KRW229',
    '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '0123456789')
    "Translate example"
    FROM DUAL;
    Translate example
    2229
    Also, LIKE '%<string>%' is going to be rather expensive simply because it has to compare the entire string and because it forces full table scans, rather than using indexes. You could speed this sort of query up by using interMedia Text (Oracle Text now in 9i). If you can eliminate one of the '%' options, you could also improve things.
    My guess is that your stored procedure is inefficient and that's causing the problem-- 5k rows per table should be pretty trivial.
    If you post your query over on the PL/SQL forum, there are better performance tuners than I that might have more hints for you. To get really good advice, though, you'lllikely have to get at least the execution plan for this statement and may need to do some profiling to identify the problem areas.
    Justin

  • Select statement from a join file deletes the primary records with MS Expl.

    Hello,
    is reality,
    Select statement from a join file deletes the primary records with MS Explorer 6, Firefox not, this with a normal data provider or with a normal "select..." statement.
    This is very strange, I should have a.a.s.p. a solution or workaround
    Thanks, Franco.
    Message was edited by:
    fbiaggi

    Please see the following excerpt from the online documentation.
    http://docs.oracle.com/cd/E11882_01/server.112/e22490/ldr_modes.htm#SUTIL1332
    Enabled Constraints
    During a direct path load, the constraints that remain enabled are as follows:
    NOT NULL
    UNIQUE
    PRIMARY KEY (unique-constraints on not-null columns)
    NOT NULL constraints are checked at column array build time. Any row that violates the NOT NULL constraint is rejected.
    Even though UNIQUE constraints remain enabled during direct path loads, any rows that violate those constraints are loaded anyway (this is different than in conventional path in which such rows would be rejected). When indexes are rebuilt at the end of the direct path load, UNIQUE constraints are verified and if a violation is detected, then the index will be left in an Index Unusable state. See "Indexes Left in an Unusable State".

  • How to delete a row from a SQL Server CE Table with multiple JOINs?

    I want to delete a record from a SQL Server CE table.
    There are 3 tables scripts, options and results. I would like to remove a record from the results table. The where clause contains dynamic information which retrieved via other queries to different tables in the same database. These queries work fine and deliver
    the desired data.
    The Compact server is a clone of a remote table created using the sync framework. The same query to the remote table works fine.
    The error I get is:
    There was an error parsing the query. [ Token line number = 1,Token line offset = 10,Token in error = from ]
    The code that throws the exception is as follows:
    Dim connLoc As SqlCeConnection = New SqlCeConnection(My.Settings.ConnectionString)connLoc.Open()     Dim strDel As String = "Delete r from ResultsTable r inner join OptionsTable o ON o.TestName=r.TestName inner join ScriptTable c ON r.TestName=c.TestName WHERE r.TestName = '" & ds1Loc.Tables(0).Rows(0)(1) & "' AND [Index] = '" & lstIndex & "'"Dim cmdDel As SqlCeCommand = New SqlCeCommandcmdDel.CommandText = strDelcmdDel.Connection = connLoccmdDel.ExecuteNonQuery()
    The values held in ds1Loc.Tables(0).Rows(0)(1) and lstIndex are
    correct so should not be the problem.
    I also tried using parameterised queries
    Dim strDel As String = "Delete r from [ResultsTable] r inner join [OptionsTable] o ON o.TestName=r.TestName inner join [ScriptTable] c ON r.TestName=c.TestName WHERE r.TestName = @TestName AND [Index] = @lstIndex"
    Dim cmdDel As SqlCeCommand = New SqlCeCommand        cmdDel.CommandText = strDel       
    With cmdDel.Parameters           
    .Add(New SqlCeParameter("@TestName", ds1Loc.Tables(0).Rows(0)(1)))           
    .Add(New SqlCeParameter("@lstIndex", lstIndex))       
    End With 
    cmdDel.Connection = connLoc        cmdDel.ExecuteNonQuery()
    I have tried replacing the "=" with "IN" in the the WHERE clause but this has not worked.
    Is it the join that is causing the problem? I can do a select with the same search criteria and joins from the same database.
    Also this query works with SQL Server. Is it perhaps that SQL CE does not support the Delete function the same as SQL Server 2008? I have been looking at this for a while now and cannot find the source of the error. Any help would be greatly appreciated.

    Hello,
    In SQL Server Compact, we can use join in FROM clause. The DELETE statement fail may be caused by the FOREIGN KEY constraint.
    Please refer to:
    DELETE (SQL Server Compact)
    FROM Clause (SQL Server Compact)
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Need help with the session state value items.

    I need help with the session state value items.
    Trigger is created (on After delete, insert action) on table A.
    When insert in table B at least one row, then trigger update value to 'Y'
    in table A.
    When delete all rows from a table B,, then trigger update value to 'N'
    in table A.
    In detail report changes are visible, but the trigger replacement value is not set in session value.
    How can I implement this?

    You'll have to create a process which runs after your database update process that does a query and loads the result into your page item.
    For example
    SELECT YN_COLUMN
    FROM My_TABLE
    INTO My_Page_Item
    WHERE Key_value = My_Page_Item_Holding_Key_ValueThe DML process will only return key values after updating, such as an ID primary key updated by a sequence in a trigger.
    If the value is showing in a report, make sure the report refreshes on reload of the page.
    Edited by: Bob37 on Dec 6, 2011 10:36 AM

  • Update with a select statement

    hi experts,
    I need some help again.. :)
    I have an insert query here with a select statement.. Juz wondering how to do it in update?
    insert into newsmail_recipient
            (IP_RECIPIENTID,NF_LISTID,NF_STATUSID,D_CREATED,D_MODIFIED,C_NAME,C_EMAIL,USER_ID,NEWSMAIL_ID)
            select newsmail_recipientid_seq.nextval
              , liste
              , 1
              , sysdate
              , sysdate
              , null
              , null
              , ru.nf_userid
              , null
            from roleuser ru, unit u, userinfo ui
            where u.ip_unitid = ru.nf_unitid
            and u.ip_unitid = unit_id
            and ui.ip_userid = ru.nf_userid
            and ui.nf_statusid = 1
            and n_internal = 0
            and ui.ip_userid not in (select user_id
                                       from newsmail_recipient
                                      where user_id = ui.ip_userid
                                        and nf_listid = liste
                                        and nf_statusid = 1);let me know your thoughts.
    Regards,
    jp

    Hi,
    924864 wrote:
    ... I have an insert query here with a select statement.. Juz wondering how to do it in update?How to do what, exactly?
    MERGE can UPDATE existing rows, and INSERT new rows at the same time. In a MERGE statement, you give a table or a sub-query in the USING clause, and define how rows from that result set match rows in your destination table. If rows match, then you can UPDATE the matching row with values from the sub-query.
    Very often, MERGE is easier to use, and perhaps more efficient, than UPDATE just for changing existing rows. That is, while MERGE can do both INSERT and UPDATE, it doesn't have to . You can tell MERGE just to do one or the other if you wish.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Since you're asking about a DML statement, such as UPDATE, the sample data will be the contents of the table(s) before the DML, and the results will be state of the changed table(s) when everything is finished.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Multiple Select statements in EXECUTE SQL TASK in SSIS

    Can we write multiple select statements in execute sql task(SSIS).
    If possible how to assign them to variables in result statement

    Hi ,
    You can use below steps to set result set to variable.
    1.In the Execute SQL Task Editor dialog box, on the General page, select the Single row, Full result set, or XML result set type(According to your result set).
    2.Click Result Set.
    3.To add a result set mapping, click Add.
    4.From the Variables Name list, select a variable or create a new variable.
    What is multiple selection ? May be below can be used in your scenario !
    http://stackoverflow.com/questions/17698908/how-to-set-multiple-ssis-variables-in-sql-task
    What you want to achieve ?
    Thanks
    Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com

  • Help with this update statement..

    Hi everyone,
    I am trying to update a column in a table .I need to update that column
    with a function that takes patient_nbr and type_x column values as a parameter.
    That table has almost "300,000" records. It is taking long time to complete
    almost 60 min to 90 min.
    Is it usual to take that much time to update that many records?
    I dont know why it is taking this much time.Please help with this update statement.
    select get_partner_id(SUBSTR(patient_nbr,1,9),type_x) partner_id from test_load;
    (it is just taking 20 - 30 sec)
    I am sure that it is not the problem with my function.
    I tried the following update and merge statements .Please correct me if i am wrong
    in the syntax and give me some suggestions how can i make the update statement fast.
    update test_load set partner_id = get_partner_id(SUBSTR(patient_nbr,1,9),type_x);
    merge into test_load a
    using (select patient_nbr,type_x from test_load) b
    on (a.patient_nbr = b.patient_nbr)
    when matched
    then
    update
    set a.partner_id = get_partner_id(SUBSTR(b.patient_nbr,1,9),b.type_x);
    there is a index on patient_nbr column
    and the statistics are gathered on this table.

    Hi Justin,
    As requested here are the explain plans for my update statements.Please correct if i am doing anything wrong.
    update test_load set partner_id = get_partner_id(SUBSTR(patient_nbr,1,9),type_x);
    "PLAN_TABLE_OUTPUT"
    "Plan hash value: 3793814442"
    "| Id  | Operation          | Name             | Rows  | Bytes | Cost (%CPU)| Time     |"
    "|   0 | UPDATE STATEMENT   |                  |   274K|  4552K|  1488   (1)| 00:00:18 |"
    "|   1 |  UPDATE            |        TEST_LOAD |       |       |            |          |"
    "|   2 |   TABLE ACCESS FULL|        TEST_LOAD |   274K|  4552K|  1488   (1)| 00:00:18 |"
    merge into test_load a
    using (select patient_nbr,type_x from test_load) b
    on (a.patient_nbr = b.patient_nbr)
    when matched
    then
    update
    set a.partner_id = get_partner_id(SUBSTR(b.patient_nbr,1,9),b.type_x);
    "PLAN_TABLE_OUTPUT"
    "Plan hash value: 1188928691"
    "| Id  | Operation            | Name             | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |"
    "|   0 | MERGE STATEMENT      |                  |   274K|  3213K|       |  6660   (1)| 00:01:20 |"
    "|   1 |  MERGE               |        TEST_LOAD |       |       |       |            |          |"
    "|   2 |   VIEW               |                  |       |       |       |            |          |"
    "|*  3 |    HASH JOIN         |                  |   274K|    43M|  7232K|  6660   (1)| 00:01:20 |"
    "|   4 |     TABLE ACCESS FULL|        TEST_LOAD |   274K|  4017K|       |  1482   (1)| 00:00:18 |"
    "|   5 |     TABLE ACCESS FULL|        TEST_LOAD |   274K|    40M|       |  1496   (2)| 00:00:18 |"
    "Predicate Information (identified by operation id):"
    "   3 - access("A"."patient_nbr"="patient_nbr")"Please give some suggestions..
    what's the best approach for doing the updates for huge tables?
    Thanks

Maybe you are looking for

  • In BO 4.0,how to convert field values into column heading.

    Currently Product Codes are represented in "Code" and "Value" fields. Please retain the code and value fields, so that if the user adds another code and immediately needs to report on them they can through this functionality. Current: Fund Code Code

  • Itunes 11.1.4 stops working on Windows 7 (64b)

    iTunes opens OK & operates normally  for a period of time (usally around an hour or so) & then an error message comes up that itunes has stopped working & must be closed down. My system is Windows 7 (64 bit) & this close down happens every time. Even

  • Financial Reports February 2009

    I wonder if it is only me, which has not received any financial report for February 2009. Normally they show up around 10 in the month, but today it is already 16 Marts.

  • Replace text with wildcard in the middle

    I am looking to change several config file keys that have server names in the format  <server>server01</server> <server>server02</server> <server>server03</server> I would like to change all of the server tags to contain the same server, for example

  • Blank "Album URL" when publishing photos to MobileMe

    When I upload photos to MobileMe, there is nothing liste under the "Album URL." Granted, I know how to find the album easily enough, but I have a few albums that have not shown up recently and I was hoping to visit their URL directly. Does anyone els