MODIFY with Where

Hi Gurus,
Could you please give me the code, on how can I use the modify with where statement to update dictionary table from an internal table. In this case, I don't want to use update with set statement as I have many fields.
Thanks,
David.

hi,
TABLES : mkpf,
         mseg,
         zamatdoc,
         mara.
DATA :BEGIN OF gi_mkpf OCCURS 100,
      mblnr LIKE mkpf-mblnr,
      mjahr LIKE mkpf-mjahr,
      END OF gi_mkpf.
  data gi_mseg like zamatdoc occurs 100 with header line.
DATA: BEGIN OF gi_mseg OCCURS 0.
        INCLUDE STRUCTURE zamatdoc.
DATA: END OF gi_mseg.
DATA: gv_date(11)," LIKE ekpo-aedat,
      gv_date1(11),
      year(4),
      month(2),
      day(2),
      flag(1),
      read_flag(1).
DATA :char TYPE i,
      count TYPE i.
*select-options : s_mtart for mara-mtart obligatory.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-110.
SELECT-OPTIONS : records FOR char. " OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK b1.
START-OF-SELECTION.
  gv_date1 = sy-datum.
  year = gv_date1+0(4).
  month = gv_date1+4(2).
  day = gv_date1+6(2).
  year = year - 3.
  CLEAR gv_date1.
  CONCATENATE year month day INTO gv_date1.
CONCATENATE day month year INTO gv_date1.
  SELECT mblnr
         mjahr
         FROM mkpf
         INTO TABLE gi_mkpf
         WHERE  budat <= gv_date1.">" and BUDAT >=  ).
  IF sy-subrc = 0.
    SORT gi_mkpf BY mblnr.
    DELETE ADJACENT DUPLICATES FROM gi_mkpf.
    CLEAR count.
    IF NOT gi_mkpf[] IS INITIAL.
      IF NOT records-low IS INITIAL .
        IF NOT records-high IS INITIAL.
          DESCRIBE TABLE gi_mkpf LINES count.
          IF records-high < count.
            DELETE gi_mkpf FROM records-high TO count.
          ENDIF.
          IF records-low <> 1.
            IF records-low <> 0.
              DELETE gi_mkpf FROM 1 TO records-low.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
SELECT matnr werks FROM mseg INTO CORRESPONDING FIELDS OF TABLE gi_mseg
    PACKAGE SIZE 100  FOR ALL ENTRIES IN gi_mkpf
           WHERE mblnr = gi_mkpf-mblnr
             AND mjahr = gi_mkpf-mjahr.
      MODIFY zamatdoc FROM TABLE gi_mseg.
      COMMIT WORK.
    ENDSELECT.
regards
siva

Similar Messages

  • How do I modify the WHERE clause in my SQL query?

    This seems like such a straight-forward part of the report design, but I'm fairly new to Crystal Reports and I only have experience with modifying reports someone else has already written.  In this particular case, I just need to modify the WHERE clause of the SQL query.  I can select Show SQL Query and see what statement is being used to select data, but I can't find where to modify it since it's grayed out.  I see how to change the selection criteria, parameters, grouping, etc...just not the WHERE clause.  The report is linked to a database used for reporting with a table created and populated by a stored procedure.  I don't need to modify the stored procedure because the data I want to filter by is currently in the table--I just don't know how to filter by what I need.  Here's part of the query:
    SELECT "rpt_dist"."startdate", "rpt_dist"."transtype", "rpt_dist"."laborcode", "rpt_dist"."crewid", "rpt_dist"."regularhrs" FROM   "Reporting"."dbo"."rpt_dist" "rpt_dist"
    WHERE  (rpt_dist."transtype" <> 'WORK' AND rpt_dist."transtype" <> 'WMATL') AND rpt_dist."laborcode" LIKE 'S%' AND (rpt_dist."crewid" = 'HOUS' OR rpt_dist."crewid" = 'HOUS2' ...
    I would like to add another crewid to the WHERE clause.  Thanks for any input.

    1.Open the report in the crystal designer
    2.Go to the field explorer(if hidden go to view menu->field explorer)
    3.Rt. click on the database fields->choose database expert
    4.Now you will see 2 columns-Available DataSource  and Selected Tables
    5.Rt. click on the object(ex.command) available in the Selected Tables column->Choose Edit command
    6.A new Modify Command window will appear,here you can edit your SQL Query
    I get to step 4 and I see the two columns including my database and the report table, but there is no command object available.  If I right-click on my table, I can just view the Properties. ??
    As for the other tip to modify the record selection:  I don't see anywhere the other crewid values are set and if I add the one I'm missing, it doesn't modify the existing SQL Query and when I preview the report it throws off the results so that no data displays??
    I'm using Crystal Reports 11.5 if that makes a difference.  Thanks again.

  • How to modify the where clause in this to include other things

    How do I modify the WHERE clause in this code:
    $expected = array(first_name, last_name, level, language, 'city', 'state', 'zip', );
    $query_search = 'SELECT * FROM french;
    $where = false;
    foreach ($expected as $var) {
    if (isset($_GET[$var]) && !empty($_GET[$var])) {
    if ($where) {
    $query_search .= ' AND ';
    } else {
    $query_search .= ' WHERE ';
    $where = true;
    $query_search .= $var . ' = '. GetSQLValueString($_GET[$var], 'text');
    to include things like searching multiple columns and IF NULL:
    SELECT * from MyTable where (MyCol1 = %s or MyCol1 Is Null) AND (MyCol2 = %s or MyCol2 Is Null)
    Where on earth does it go?
    Thanks
    Brian

    My goal is to have a search form and results combination that:
    1) allows the user to ignore any of the page’s existing search fields that
    they don’t need, (to search with empty form fields);
    2) to use whichever search form fields they choose to use even if the
    Registrant for whom they are searching did not insert that information when
    they registered, (they are filled in the search form but empty in the
    database table);
    3) and to permit some of the seach fields to search multiple columns, for
    example the search form field ‘sonsName’ would look for that information in
    three different database table colums, (sonsName1, sonsName2 etc.).
    You’ve given me code that permits 1) above to work beautifully. You’ve also
    sent along code that should let me accomplish the other two, and though I’ve
    been able to recreate below what I want the multiple search column to do, I
    can get neither the multiple column nor the IS NULL sections to work in the
    code you sent most recently.
    How do I take something like this:
    $colname_rsSearch = "-1";
    if (isset($_POST['first_name_now'])) {
      $colname_rsSearch = $_POST['first_name_now'];
    $colname2_rsSearch = "-1";
    if (isset($_POST['last_name_now'])) {
      $colname2_rsSearch = $_POST['last_name_now'];
    $colname3_rsSearch = "-1";
    if (isset($_POST['sonsName'])) {
      $colname3_rsSearch = $_POST['sonsName'];
    mysql_select_db($database_connStr_Milo_db, $connStr_Milo_db);
    $query_rsSearch = sprintf("SELECT milo.first_name_now, milo.last_name_now,
    milo.ws_number, milo.ws_number_3, milo.ws_number_4 FROM milo WHERE
    milo.first_name_now = %s AND milo.last_name_now = %s AND (milo.sonsName1 =
    %s) ||  (milo.sonsName2 = %s) || (milo.sonsName3 = %s)",
    GetSQLValueString($colname_rsSearch,
    "text"),GetSQLValueString($colname2_rsSearch,
    "text"),GetSQLValueString($colname3_rsSearch,
    "text"),GetSQLValueString($colname3_rsSearch,
    "text"),GetSQLValueString($colname3_rsSearch, "text"));
    $rsSearch = mysql_query($query_rsSearch, $connStr_Milo_db) or
    die(mysql_error());
    $row_rsSearch = mysql_fetch_assoc($rsSearch);
    $totalRows_rsSearch = mysql_num_rows($rsSearch);
    ?> (I’ve excluded the IS NULL part from my example, but need it in the final
    version)
    …and make it work using your code below (which permits someone to search
    with empty form fields, but does not yet enlighten me on what to group (with
    parenthesis) to make the code execute the multiple column search and the IS
    NULL parts of the search.
    mysql_select_db($database_connStr_Milo_db, $connStr_Milo_db);
    $expected = array('first_name_now', 'last_name_now', sonsName'
    $query_search = 'SELECT milo.first_name_now, milo.last_name_now,
    milo.ws_number, milo.ws_number_3, milo.ws_number_4  FROM milo';
    $where = false;
    foreach ($expected as $var) {
      if (isset($_POST[$var]) && !empty($_POST[$var])) {
        if ($where) {
          $query_search .= ' AND ';
        } else {
          $query_search .= ' WHERE ';
          $where = true;
      $query_search .= '(' . $var . ' = '. GetSQLValueString($_POST[$var],
    'text') .
      ' OR ' . $var . ' IS NULL)';
    $search = mysql_query($query_search, $connStr_Milo_db) or
    die(mysql_error());
    $row_search = mysql_fetch_assoc($search);
    $totalRows_search = mysql_num_rows($search);
    As always, thank you.

  • Select sdo_nn with where-clause on large table

    Hi spatial-experts,
    I've following problem. I use a table with more than 2.500.000 dataset. Every dataset represents one point (SDO_GEOMETRY, SDO_POINT_TYPE) and have further (text) information. (PI (point of interest) table from TeleAtlas mn_pi)
    Following Select works fine:
    SELECT /*+ ORDERED NO_INDEX(pi IX_PI_FEATTYP) */
    sdo_nn_distance(1) distance,
    id, feattyp, arnamelc, name, stname, stnamelc, hsnum, postcode
    FROM multinet.mn_pi pi
    WHERE
    pi.feattyp IN ( 9373,9374)
    AND
    SDO_NN(
    pi.geom,
    SDO_GEOMETRY( 2001, 8307, SDO_POINT_TYPE(613.86865234375/60, 3002.94677734375/60, NULL), NULL, NULL),
    'sdo_batch_size=0', 1) = 'TRUE'
    AND rownum = 1
    ORDER BY distance
    (P.S. IX_PI_FEATTYP is an index on column feattyp, here not used. When I'm using it the select do not work (it last very long...))
    When I now modify the where clause to an pi which feat type that does not exists (no entry in table) the select lasts very long (I canceled the select after 5 minutes).
    for example: pi.feattyp = 9756
    Otherwise I add a further where clause like
    AND arnamelc = 'ITA'
    the select also works very long. The point are now in italy. refrence point is in germany and is more than 500km away.
    Are there some solutions to solve this problems
    (should I use for every feat type a own table)?
    Why is the select so slow?
    Thanks for all helpfully answers,
    Matthias

    Hi Matthias,
    When you use nearest neighbor, Oracle will use the spatial index to find the nearest neighbor that meets the query criteria. It probes into the index, calculates distances, and returns data in distance order.
    Using SDO_BATCH_SIZE, it keeps going back to the database, returning more and more records in distance order until the other predicates are satisfied (in your case, pi.feattyp IN ( 9373,9374).
    When you specified pi.feattyp = 9756 (which doesn't exist), you told Oracle to keep going and calculating distances for each of the more than 2.500.000 records in the the data set (you killed it after 5 minutes).
    I don't know why adding: AND arnamelc = 'ITA' caused Oracle to take extra time. Sometimes I will do a: set autotrace trace exp
    then compare plans for something that runs quickly vs. something that runs slowly. If you want to post the plans for the fast and slow versions it might be interesting to look at.
    My guess is you may want to look at a solution that incorporates various possibilities. For instance, if there are only a few of some feattyp values, you may want to select those using the non-spatial index then use sdo_geom.sdo_distance to find the closest point rather than risk having to look through a few million values for a match.
    I'm sure other people have thoughts as well...
    Kind regards,
    Dan

  • Private, protected Access Modifiers with a class

    Why cant we use private and protected access modifiers with a class?
    Thanks.

    Matiz wrote:
    >
    Public access allows you to extend a parent class in some other package. If you only want users to extend your class rather than instantiate it directly, make the class abstract and design for extension.Agreed. However, would the same argument be not true for the default access at the class level? No. Default access would only allow you to extend a parent class in the same package (as opposed to some other package).
    Now my confusion is why is a class allowed default access at the top level and not protected?Because protected for a top-level class makes no sense. The protected keyword provides member access to any other class in the same package and extending classes outside the package. A top-level class isn't a member of a class, by definition, so there's nothing that protected would do provide differently than public.
    So, the two access modifiers for a top-level class are public and default. Public allows access to the class outside the package, whereas default restricts access to the class within the package.
    ~

  • Populate list by executing query with where clause

    Hi,
    I m populating my list from database table using following command.
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("learning", new HashMap());
    EntityManager em = emf.createEntityManager();
    String query = "select d from Dept d";
    List list = em.createQuery(query).getResultList();
    My list is getting populated with all of rows in my database table(dept). The problem is, I cant use where clause in my query string.
    String query = "select d from Dept d where d.dept_name='ANYNAME'";
    Moreover I cant select even indivisual columns by using following line
    String query = "select d.dept_code,d.dept_name from Dept d";
    It looks like that my query is getting all rows from table as Object.
    What to do to
    1. put some where clause
    2. get some particular colums instead of all columns
    3. apply some table joins in query
    plz help.

    Hi Alex,
    I misunderstood your question. You had mentioned "My list is getting populated with all of rows in my database table(dept). The problem is, I cant use where clause in my query string. "
    I thought you might not have permissions to modify the code in the class, and that's why I suggested that you could write new classes.
    1) write new classes,? means if I need just two columns from a table >(instead of all columns), do I need to write new class with just two >columns (getters and setters)?You can write a SQL statement anyway you want , there are no restrictions in JDBC , so if you need just 2 columns you can write a custom query for that.
    "select column1 as a, column2 as be from table_name where column3 = xyz" etc.
    2) Is not anyway to write SQL statement like
    select dept_code,dept_name from dept where dept_name='anything'The above SQL is correct, it should work.
    3) Stored procedures? can I get some example(code) to get an idea >how to implement complex queries with where clause and joinings >using stored procedures?Stored procedures are specific to the database you are using, Oracle has a particular syntax for store procdures.
    You can call stored procedures from JDBC also, search on Google for
    "Calling stored procedures from JDBC"
    4) I m using hibernate. can I get any example of using hibernate own >query?Tutorial on Hibernate Query Language:
    http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html

  • Export (expdp) with where clause

    Hello Gurus,
    I am trying to export with where clause. I am getting below error.
    Here is my export command.
    expdp "'/ as sysdba'" tables = USER1.TABLE1 directory=DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= “USER1.TABLE1:where auditdate>'01-JAN-10'” Here is error
    [keeth]DB1 /oracle/data_15/db1> DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= USER1.TABLE1:where auditdate>'01-JAN-10'                    <
    Export: Release 11.2.0.3.0 - Production on Tue Mar 26 03:03:26 2013
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Starting "SYS"."SYS_EXPORT_TABLE_03":  "/******** AS SYSDBA" tables=USER1.TABLE1 directory=DATA_PUMP dumpfile=TABLE1.dmp logfile=TABLE1.log query= USER1.TABLE1:where auditdate
    Estimate in progress using BLOCKS method...
    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 386 MB
    Processing object type TABLE_EXPORT/TABLE/TABLE
    Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
    Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
    Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
    Processing object type TABLE_EXPORT/TABLE/TRIGGER
    Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
    ORA-31693: Table data object "USER1"."TABLE1" failed to load/unload and is being skipped due to error:
    ORA-00933: SQL command not properly ended
    Master table "SYS"."SYS_EXPORT_TABLE_03" successfully loaded/unloaded
    Dump file set for SYS.SYS_EXPORT_TABLE_03 is:
      /oracle/data_15/db1/TABLE1.dmp
    Job "SYS"."SYS_EXPORT_TABLE_03" completed with 1 error(s) at 03:03:58Version
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production

    Hello,
    You should use parameter file.Another question i can see you are using 11g.Why don't you use data pump?.
    Data Pump is faster and have more features and enhancement than regular imp and exp.
    You can do the following:
    sqlplus / as sysdba
    Create directory DPUMP_DIR3  for 'Type here your os path that you want to export to';then touch a file:
    touch par.txt
    In this file type the following the following :
    tables=schema.table_name
    dumpfile=yourdump.dmp
    DIRECTORY=DPUMP_DIR3
    logfile=Your_logfile.log
    QUERY =abs.texp:"where hiredate>'01-JAN-13' "then do the following
    expdp username/password parfile='par.txt'
    If you will import from Oracle 11g to version 10g then you have to addthe parameter "version=10" to the parameter file above
    BR
    Mohamed ELAzab
    http://mohamedelazab.blogspot.com/

  • Outer Join with Where Clause in LTS

    HI all,
    I have a requirement like this in ANSI SQL:
    select p1.product_id, p1.product_name, p2.product_group
    from product p1 left outer join product_group p2 on p1.product_id = p2.product_id
    and p2.product_group = 'NEW'
    In Regular SQL:
    select p1.product_id, p1.product_name, p2.product_group
    from product p1, product_group p2
    WHERE p1.product_id *= p2.product_id and p2.product_group = 'NEW'
    In OBIEE, I am using a left outer join between these two in Logical table Source, and also, Gave
    p2.product_group = 'NEW' in WHERE clause of LTS.
    This doesn't seem to solve purpose.
    Do you have any idea how to convert WHERE clause in physical query that OBIEE is generating to something like
    product p1 left outer join product_group p2 on p1.product_id = p2.product_id AND p2.product_group = 'NEW'
    I am using Version 10.1.3.4.1
    Creating an Opaque view would be my last option though.

    Hello
    I have read your post and the responses as well. and I understand that you have issues with the Outer Join with where Clause in LTS.
    Try this solution which worked for me (using your example ) -
    1. In the Physical Layer created a Complex join between PRODUCT and PRODUCT_GROUP tables and use this join relationship :
    PRODUCT.PROD_ID = PRODUCT_GROUP.PROD_ID  AND  PRODUCT_GROUP.GROUP_NAME = 'MECHANICAL' 
    2. In the General Tab of PRODUCT table LTS add PRODUCT_GROUP  table and select Join Type as Left Outer Join.
    3. Check Consistency and make sure there are no errors .
    when you run a request you should see the following query generated -
    select distinct T26908.PROD_ID as c1,
         T26908.PROD_NAME as c2,
         T26912.GROUP_NAME as c3
    from
         PRODUCT T26908 left outer join PRODUCT_GROUP T26912 On T26908.PROD_ID = T26912.PROD_ID and T26912.GROUP_NAME = 'MECHANICAL'
    order by c1, c2, c3
    Hope this works for you. If it does please mark this response as 'Correct' .
    Good Luck.

  • Iweb page modified with a simple html editor , now not display navigation menu

    Hello i've designed a site http://www.ballettgastini.ch with Iweb and was working till i've the needs to update a simple text in one page and get it via ftp from the server, modified with a simple html editor !!!!, and update via ftp on the server. now the page do not diplay the navigation menu bar !!!! the page is here  : http://www.ballettgastini.ch/stundenplan.html ... any suggesion ? i'm working now with a new imac with no possibility to modify the entire web site on the server...but the need it's really to change few text lines so i think to use a simple html editor... any ideas ? thanks luca giay turin italy

    Why not continue in the topic you started earlier?
    https://discussions.apple.com/message/21158910#21158910
    Anyway, the scripts folder with essential files is missing :
    http://www.lakesweddingmusic.com/Scripts/iWebImage.js
    + more
    And this is missing too :
    http://www.lakesweddingmusic.com/feed.xml
    No feed, no menu.
    And we keep finding more webpage. This one is made with iWeb 1
    http://www.lakesweddingmusic.com/The_Barn.html

  • Select clause with where part is needs 600 times longer to complete

    Hello.
    I have two select clauses one with where, which needs 120 seconds to complete and one without where, which completes in 0,3 seconds. I want to know why is that.
    120 seconds
    SELECT B.* FROM
    (SELECT A.OLOG, MCL_ISPROTOCOLALLOWED('LMOD', 'MCLI', A.OPRG) ALLOWED FROM  (SELECT DISTINCT OLOG, OPRG FROM FLOG WHERE FIRM = '001') A) B WHERE B.ALLOWED = '1' ORDER BY OLOG;0,3 seconds
    SELECT B.* FROM
    (SELECT A.OLOG, MCL_ISPROTOCOLALLOWED('LMOD', 'MCLI', A.OPRG) ALLOWED FROM  (SELECT DISTINCT OLOG, OPRG FROM FLOG WHERE FIRM = '001') A) B ORDER BY OLOG;Table FLOG has arround 270000 records, but only 40 of them are distinct.
    IsProtocolAllowed checks if user has a permision to view the record.
    Thank you for your help.
    Regards,
    Borut Ojcinger
    Edited by: 993896 on 14.3.2013 7:24

    Hi,
    welcome to the forum.
    Please read SQL and PL/SQL FAQ
    If you have a performance issue have a look at SQL and PL/SQL FAQ
    Additionally when you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Merge with where clause after matched and unmatched

    Hai,
    Can anybody give me one example of merge statement with
    where clause after matched condition and after the unmatched condition.
    MERGE INTO V1 VV1
    USING (SELECT     A.CNO XXCNO, A.SUNITS XXSU, A.DDATE XXDD, XX.SUM_UNITS SUMMED
    FROM V1 A,
    (SELECT                
    SUM(SUNITS) SUM_UNITS FROM V1 B                                   
    GROUP BY CNO) c
    WHERE
    A.DDATE=0 AND A.SUNITS <>0 AND
    A.ROWID=(SELECT MAX(ROWID) FROM V1 )) XX
    ON (1=1)
    WHEN MATCHED THEN UPDATE SET
    VV1.SUNITS=XX.SUMMED
    WHERE XX.XXDD=0
    WHEN NOT MATCHED THEN INSERT
    (VV1.CNO, VV1.SUNITS, VV1.SUNITS)
    VALUES (XX.XXCNO, XX.XXSU, XX.XXDD)
    WHERE XX.XXDD<>0
    i am getting the error
    WHERE XX.XXDD=0
    ERROR at line 13:
    ORA-00905: missing keyword
    Thanks,
    Pal

    One of the example is there:
    http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_9016.htm#sthref7014
    What Oracle version do you use ?
    Besides the condition (1=1) is non-deterministic,
    I would expect there an exception like "unable to get a stable set of rows".
    Rgds.

  • Insert with Where Clause

    Hi,
    Can we write Insert with 'Where' clause? I'm looking for something similar to the below one (which is giving me an error)
    insert into PS_AUDIT_OUT (AUDIT_ID, EMPLID, RECNAME, FIELDNAME, MATCHVAL, ERRORMSG)
    Values ('1','10000139','NAMES','FIRST_NAME',';','')
    Where AUDIT_ID IN
    (  select AUDIT_ID from PS_AUDIT_FLD where AUDIT_ID ='1' and RECNAME ='NAMES'
    AND FIELDNAME = 'FIRST_NAME' AND MATCHVAL = ';' );
    Thanks
    Durai

    It is not clear what are you trying to do, but it looks like:
    insert
      into PS_AUDIT_OUT(
                        AUDIT_ID,
                        EMPLID,
                        RECNAME,
                        FIELDNAME,
                        MATCHVAL,
                        ERRORMSG
    select  '1',
            '10000139',
            'NAMES',
            'FIRST_NAME',
      from  PS_AUDIT_FLD
      where AUDIT_ID = '1'
        and RECNAME ='NAMES'
        and FIELDNAME = 'FIRST_NAME'
        and MATCHVAL = ';'
    SY.

  • Hierarchical query with where clause

    Hi,
    How can I query hierarchically a query with WHERE clause? I have a table with three fields session_id,id and root_id.
    When I try with the following query,
    select id, level from relation
    where session_id = 79977
    connect by prior id = root_id start with id = 5042;
    It gets duplicate values.
    I want the query to show in the hierarchical manner with a filter condition using WHERE clause. Please help me how can I achieve this. If you know any link that describes more about this, please send it.
    Thanks in Advance.
    Regards,
    -Parmy

    Hi Sridhar Murthy an others,
    Thanks a lot for your/the answer. It's working for me. It saved a lot of other work around without the proper knowledge of hierarchical query. Please send me any link that describes these issues in detail and also I hope as I have mentioned in the other message, same cannot be achieved on views or ( on two different tables ???)
    Any way thanks for your reply,
    It's working for me.
    With happiness,
    -Parmy

  • Export/Import with where condition

    DearAll,
    I am facing a problem in the delete of a huge table that take 3 hours
    DELETE FROM HST HST
    WHERE JV_TYPE <> 999
    and ( HST.VALUE_DATE <= TO_DATE ('31/12/2010','DD/MM/YYYY')
    AND HST.TRANS_DATE <= TO_DATE ('31/12/2010','DD/MM/YYYY'))
    what i am trying to do is to export the HST table and import it into another table
    but what i need to do is to have a dump with where condition including only the needed records in the table not deleted in the DML above as well as the indexes, triggers.
    Thanks

    If I try the following:
    CONN / AS SYSDBA
    CREATE OR REPLACE DIRECTORY dpump_dir1 AS '/folder/';
    GRANT READ, WRITE ON DIRECTORY dpump_dir1 TO bokprod;
    expdp bokprod/bokprod@uat TABLES=HST PARFILE=hst_query.par
    In the parfile:
    QUERY=hst:"WHERE JV_TYPE <>999 and ( HST.VALUE_DATE > TO_DATE ('31/12/2010','DD/MM/YYYY') AND HST.TRANS_DATE > TO_DATE ('31/12/2010','DD/MM/YYYY'))"
    DUMPFILE=exp.dmp
    DIRECTORY=dpump_dir1
    LOGFILE=exp.log
    impdp bokprod/bokprod@uat DIRECTORY=dpump_dir1 DUMPFILE=exp.dmp
    TABLES=bokprod.hst REMAP_TABLE=bokprod.hst:hst_imported
    My question is:
    1- the parameter file, if i put it in the dpump_dir1 directory, is it read by the expdp command?
    2- the hst_imported table created by the remap_table command , is it created with the indexes and triggers already existant on hst table?
    Appreciate yoyr help Dears

  • CASE with where clasue issue

    Hi I have select query which is giving issue saying missing key word in case statement else part please do suggest.
    /* Formatted on 2012/11/02 16:19 (Formatter Plus v4.8.8) */
    SELECT a.kintana_number, a.crid, a.projectestimateid, a.reasonimpacts
    FROM (SELECT p.kintana_number AS kintana_number, cr.crid AS crid,
    pe.projectestimateid AS projectestimateid,
    l.lookupvalue AS reasonimpacts,
    (SELECT COUNT (1)
    FROM (SELECT p.projectestimateid
    FROM projectestimates p INNER JOIN projectestapplications pa
    ON pa.projectestimateid = p.projectestimateid
    AND pa.impacted = 1
    INNER JOIN applicationsupproviders asp
    ON asp.appid = pa.appid
    INNER JOIN optionssupportproviders osp
    ON osp.providerid = asp.providerid
    AND LOWER (TRIM (osp.provider)) = 'ibm - adm'
    WHERE asp.providertypeid = 2
    OR p.admvendornercid IS NOT NULL
    UNION
    SELECT p.projectid
    FROM project p INNER JOIN impactedgroups ig
    ON ig.projectid = p.projectid
    AND ig.impacted = 1
    INNER JOIN optionsgroups og
    ON ig.groupid = og.groupid
    WHERE og.ibmtowerid IS NOT NULL)
    WHERE projectestimateid = pe.projectestimateid) AS v_count
    FROM project p LEFT OUTER JOIN projectestimates pe
    ON p.projectid = pe.projectid
    INNER JOIN attcr.cr_detail cr ON pe.crid = cr.crid
    LEFT OUTER JOIN attcr.cr_detail_reason r ON r.crid = cr.crid
    LEFT OUTER JOIN attcr.site_lookup l ON l.lookupid =
    r.crreasonid
    WHERE (CASE
    WHEN v_count = 0
    THEN pe.estimatestatusid <> 3
    ELSE pe.projectestimateid IN (1, 2, 3)
    END
    AND pe.crid IS NOT NULL) a

    WHERE (CASE
    WHEN v_count = 0
    THEN pe.estimatestatusid <> 3
    ELSE pe.projectestimateid IN (1, 2, 3)
    END
    )You cant use CASE statement like that. Modify your where clause like this.
    WHERE (
         (v_count = 0 and pe.estimatestatusid != 3) or
         (v_count != 0 and pe.projectestimateid IN (1, 2, 3)
          )

Maybe you are looking for