Select * from table_name

Hi All,
I have small scenario like i have one table X which is an empty table. When i do a select query on that table X, its giving output after 5-10 mints. What will be the reason?
Thanks,
Mani

Most likely explanation:
http://mwidlake.wordpress.com/2012/04/18/shrinking-tables-to-aid-full-scans/
How to know not guess:
HOW TO: Post a SQL statement tuning request - template posting
When your query takes too long ...

Similar Messages

  • PROBLEM WITH Select * from table_name with JDBC

    Hello,
    I am using thin driver. The problem that i am having is as
    follows.
    when i execute select * from any_table_name from within java
    code i only get FIRST row back. I am using Employee.java example.
    Is there something else i should do?
    Alex
    null

    Hi Alex,
    I am writing a client application with Java. Everything works
    really well, but - same problem as you had (I know, you solved it
    - that's why I'm writing :) - reading only first column. Actually
    it works fine on its own, but when embedded in my java app -
    that's when I get the first column displayed.
    Also executing "select * from emp;" gives me a sequence of
    numbers (displayed in columns) 20, 30, 30 etc, which are in fact
    present as one of the columns when running this query without
    java.
    I appreciate your help!
    Malgosia
    Alex Korneyev (guest) wrote:
    : Hello,
    : I am using thin driver. The problem that i am having is as
    : follows.
    : when i execute select * from any_table_name from within java
    : code i only get FIRST row back. I am using Employee.java
    example.
    : Is there something else i should do?
    : Alex
    null

  • How to select rowid with select * from table_name

    Hello guys i have a cursor like so.
      Cursor c1 IS SELECT * FROM FZRASST;
      -- Row of type FZRASST row
      fzrasst_row c1%ROWTYPE;when i try to reference the row id like this
    fzrasst_row.rowid;i get an error invalid indentifier? how can i reference the row id without implicitely selecting rowid? is this possible or do i need to change my select statement to select every column on the table?
    Any help would be greatly appreciated.

    Hi,
    mlov83 wrote:
    Hello guys i have a cursor like so.
    Cursor c1 IS SELECT * FROM FZRASST;
    -- Row of type FZRASST row
    fzrasst_row c1%ROWTYPE;when i try to reference the row id like this
    fzrasst_row.rowid;i get an error invalid indentifier? how can i reference the row id without implicitely selecting rowid? is this possible or do i need to change my select statement to select every column on the table?Fzrasst_row contains every column that is in the SELECT clause, and nothing more. If you want fzrasst_row to include pseudo-columns (such as ROWID) or anything else, then you have to include them in the SELECT clause.
    To avoid naming every single column in hte table, you can do something like this:
    Cursor c1 IS
        SELECT  FZRASST.*
        ,       ROWID   AS r_id
        FROM    FZRASST;(assuming the table doesn't already have a column called r_id).
    Edited by: Frank Kulash on Feb 13, 2012 3:29 PM

  • Selecting from another schema

    If I want to select table from another schema, I have to type
    select * from [username].table_name.
    What can I do inorder not to write shema name all the time.
    for instance:
    instead of writing
    select * from [username].table_name.
    select * from table_name.

    create synonym for the object in other schema:
    create synonym <syn-name> for schema.tablename;
    then use syn-name in place of schema.tablename in ur query
    like
    select * from syn-name;

  • Select from multiple fileds

    Hi Gurus
    I need select datas from a table where i need to check ten fileds what all having this two values 1,2.For example if there alco1 to alco10 these are names of fileds i need to select the data whcih all the fileds having 1 or 2 in these ten fileds.
    Can u please give me help regading this
    Thanks & Regards
    Manikandan K.

    Your explanation of what you want is poor.
    Do you mean this?
    select *
    from table_name
    where 1 in (alco1,alco2,alco3,alco4,alco5,alco6,alco7,alco8,alco9,alco10)
    and 2 in (alco1,alco2,alco3,alco4,alco5,alco6,alco7,alco8,alco9,alco10)

  • Can not select from my own MV. Please help.

    Hello Gurus,
    I have created a MV with following clauses
    CREATE or REPLACE MATERIALIZED VIEW "OWNER_NAME1"."MV_Name1"
    BUILD IMMEDIATE
    USING INDEX
    REFRESH COMPLETE
    AS
    SELECT column1, column2 .... from table1,table2
    where .....
    I have logged in to DB with the 'owner_name1' schema itself which is the owner of the MV.
    But, when I try to select from the above MV. It gives error "Ora-00942 table or view does not exist"
    I can see the same under 'user_objects' view as an object of owner_name1 schema.
    Could you please help me in understanding where I have gone wrong?
    DB - Oracle 9i on unix platform.
    Thanks in advance!
    Abhijit.

    Oh! I missed to mention the exact steps followed by me which created error for me,
    viz.
    1) I have 2 Database and their users as follows
    bq. i) DB1 in local server - 'localUser'
    bq. ii) DB2 in remote server - 'RemoteUser1' and 'RemoteUser2'
    2) 'RemoteUser2' user in DB2 has 'select' privilage on table 'RemoteTable1' of 'RemoteUser1' ( both are remote DB's users ! )
    i.e. select * from RemoteUser1.RemoteTable1; --works okay when logged into RemoteUser2. no synonyms are created hence using schema_name.table_name convention.
    3) Logged in to 'localUser' in DB1.
    4) Created a DB link 'local_to_remote2' in 'localUser' schema ( in DB1) to 'RemoteUser2' schema (in DB2)
    i.e.
    create database link local_to_remote2 connect to RemoteUser2 identified by password using 'connection_string';
    DBLink was created successfully.
    5) I could select from the tables of 'RemoteUser2' using DB Link. (by logging in to 'localUser')
    i.e. select * from RemoteUser1.RemoteTable1@local_to_remote2 ; --- gives me expected output. no issues!
    6) Now, I created below MV in 'localUser' ( no need to tell in 'DB1' )
    the exact syntax I used is as follows,
    CREATE or REPLACE MATERIALIZED VIEW "localUser"."MV_Name1"
    BUILD IMMEDIATE
    USING INDEX
    REFRESH COMPLETE
    AS
    SELECT column1, column2
    From RemoteUser1.RemoteTable1@local_to_remote2
    where condition1
    and condition2;
    The MV was created successfully, and I could see it as an 'Valid' object of 'localUser' schema.
    i.e. select * from user_objects where object_name ='MV_NAME1' and status ='VALID' --- tells that above create MV is an object of owner 'localUser'
    But, when I try to select from the said MV. it gives me error "Ora-00942 table or view does not exist"
    i.e. select * from MV_Name1; ---- neither this
    select * from localUser.MV_Name1; ---- nor this works :(
    Even when I try to drop the same MV it gives me same error. :(
    Could you please suggest me anything so that I will be able to select from MY OWN MV ?
    Please help Gurus.

  • No rows returned by spatial query wrapped in SELECT * FROM ...

    Hi,
    I'm getting some really weird behaviour when running a sub query with SDO_EQUAL. The SDO_EQUAL query on its own works fine, but if I wrap it in SELECT * FROM then I get no results. If I wrap SDO_ANYINTERACT in SELECT * FROM then I get the expected result.
    It looks like the spatial index is used when running the regular SDO_EQUAL query, but not when wrapped in SELECT * FROM. Weird. The spatial index is also not used when SDO_ANYINTERACT is wrapped in SELECT * FROM... so I'm not sure why that returns the right answer.
    I am getting this problem on 11.2.0.2 on Red Hat Linux 64bit and 11.2.0.1 on Windows XP 32bit (that's all the 11g versions I've tried). The query works as expected on 10.2.0.5 on Windows Server 2003 64bit.
    Any ideas?
    Confused in Dublin (John)
    Test case...SQL>
    SQL> -- Create a table and insert the same geometry twice
    SQL> DROP TABLE sdo_equal_query_test;
    Table dropped.
    SQL> CREATE TABLE sdo_equal_query_test (
      2  id NUMBER,
      3  geometry SDO_GEOMETRY);
    Table created.
    SQL>
    SQL> INSERT INTO sdo_equal_query_test VALUES (1,
      2  SDO_GEOMETRY(3003, 81989, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1),
      3  SDO_ORDINATE_ARRAY(1057.39, 1048.23, 4, 1057.53, 1046.04, 4, 1057.67, 1043.94, 4, 1061.17, 1044.60, 5, 1060.95, 1046.49, 5, 1060.81, 1047.78, 5, 1057.39, 1048.23, 4)));
    1 row created.
    SQL>
    SQL> INSERT INTO sdo_equal_query_test VALUES (2,
      2  SDO_GEOMETRY(3003, 81989, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1),
      3  SDO_ORDINATE_ARRAY(1057.39, 1048.23, 4, 1057.53, 1046.04, 4, 1057.67, 1043.94, 4, 1061.17, 1044.60, 5, 1060.95, 1046.49, 5, 1060.81, 1047.78, 5, 1057.39, 1048.23, 4)));
    1 row created.
    SQL>
    SQL> -- Setup metadata
    SQL> DELETE FROM user_sdo_geom_metadata WHERE table_name = 'SDO_EQUAL_QUERY_TEST';
    1 row deleted.
    SQL> INSERT INTO user_sdo_geom_metadata VALUES ('SDO_EQUAL_QUERY_TEST','GEOMETRY',
      2  SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', 0, 100000, .0001), SDO_DIM_ELEMENT('Y', 0, 100000, .0001), SDO_DIM_ELEMENT('Z', -100, 4000, .0001))
      3  ,81989);
    1 row created.
    SQL>
    SQL> -- Create spatial index
    SQL> DROP INDEX sdo_equal_query_test_spind;
    DROP INDEX sdo_equal_query_test_spind
    ERROR at line 1:
    ORA-01418: specified index does not exist
    SQL> CREATE INDEX sdo_equal_query_test_spind ON sdo_equal_query_test(geometry) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    Index created.
    SQL>
    SQL> -- Ensure data is valid
    SQL> SELECT sdo_geom.validate_geometry_with_context(sdo_cs.make_2d(geometry), 0.0001) is_valid
      2  FROM sdo_equal_query_test;
    IS_VALID
    TRUE
    TRUE
    2 rows selected.
    SQL>
    SQL> -- Check query results using sdo_equal
    SQL> SELECT b.id
      2  FROM sdo_equal_query_test a, sdo_equal_query_test b
      3  WHERE a.id = 1
      4  AND b.id != a.id
      5  AND sdo_equal(a.geometry, b.geometry) = 'TRUE';
            ID
             2
    1 row selected.
    SQL>
    SQL> -- Check query results using sdo_equal wrapped in SELECT * FROM
    SQL> -- Results should be the same as above, but... no rows selected
    SQL> SELECT * FROM (
      2       SELECT b.id
      3       FROM sdo_equal_query_test a, sdo_equal_query_test b
      4       WHERE a.id = 1
      5       AND b.id != a.id
      6       AND sdo_equal(a.geometry, b.geometry) = 'TRUE'
      7  );
    no rows selected
    SQL>
    SQL> -- So that didn't work.  Now try sdo_anyinteract... this works ok
    SQL> SELECT * FROM (
      2       SELECT b.id
      3       FROM sdo_equal_query_test a, sdo_equal_query_test b
      4       WHERE a.id = 1
      5       AND b.id != a.id
      6       AND sdo_anyinteract(a.geometry, b.geometry) = 'TRUE'
      7  );
            ID
             2
    1 row selected.
    SQL>
    SQL> -- Now try a scalar query
    SQL> SELECT * FROM (
      2       SELECT b.id
      3       FROM sdo_equal_query_test a, sdo_equal_query_test b
      4       WHERE a.id = 1
      5       AND b.id != a.id
      6  );
            ID
             2
    1 row selected.
    SQL> spool offHere's the explain plan for the query that works. Note that the spatial index is used.
    SQL> EXPLAIN PLAN FOR
      2  SELECT b.id
      3  FROM sdo_equal_query_test a, sdo_equal_query_test b
      4  WHERE a.id = 1
      5  AND b.id != a.id
      6  AND sdo_equal(a.geometry, b.geometry) = 'TRUE';
    Explained.
    SQL> @?/rdbms/admin/utlxpls.sql
    PLAN_TABLE_OUTPUT
    Plan hash value: 3529470109
    | Id  | Operation                     | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT              |                            |     1 |  7684 |     3   (0)| 00:00:01 |
    |   1 |  RESULT CACHE                 | f5p63r46pbzty4sr45td1uv5g8 |       |       |            |       |
    |   2 |   NESTED LOOPS                |                            |     1 |  7684 |     3   (0)| 00:00:01 |
    |*  3 |    TABLE ACCESS FULL          | SDO_EQUAL_QUERY_TEST       |     1 |  3836 |     3   (0)| 00:00:01 |
    |*  4 |    TABLE ACCESS BY INDEX ROWID| SDO_EQUAL_QUERY_TEST       |     1 |  3848 |     3   (0)| 00:00:01 |
    |*  5 |     DOMAIN INDEX              | SDO_EQUAL_QUERY_TEST_SPIND |       |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - filter("B"."ID"!=1)
       4 - filter("A"."ID"=1 AND "B"."ID"!="A"."ID")
       5 - access("MDSYS"."SDO_EQUAL"("A"."GEOMETRY","B"."GEOMETRY")='TRUE')
    ..... other stuff .....     Here's the explain plan for the query that does not work. Note that the spatial index is not used.
    SQL> EXPLAIN PLAN FOR
      2  SELECT * FROM (
      3     SELECT b.id
      4     FROM sdo_equal_query_test a, sdo_equal_query_test b
      5     WHERE a.id = 1
      6     AND b.id != a.id
      7     AND sdo_equal(a.geometry, b.geometry) = 'TRUE'
      8  );
    Explained.
    SQL> @?/rdbms/admin/utlxpls.sql
    PLAN_TABLE_OUTPUT
    Plan hash value: 1024466006
    | Id  | Operation           | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |                            |     1 |  7684 |     6   (0)| 00:00:01 |
    |   1 |  RESULT CACHE       | 2sd35wrcw3jr411bcg3sz161f6 |       |       |            |          |
    |   2 |   NESTED LOOPS      |                            |     1 |  7684 |     6   (0)| 00:00:01 |
    |*  3 |    TABLE ACCESS FULL| SDO_EQUAL_QUERY_TEST       |     1 |  3836 |     3   (0)| 00:00:01 |
    |*  4 |    TABLE ACCESS FULL| SDO_EQUAL_QUERY_TEST       |     1 |  3848 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - filter("B"."ID"!=1)
       4 - filter("A"."ID"=1 AND "B"."ID"!="A"."ID" AND
                  "MDSYS"."SDO_EQUAL"("A"."GEOMETRY","B"."GEOMETRY")='TRUE')
    ..... other stuff .....               

    That looks like a bug to me. As a workaround, you can materialize the inline view by adding rownum>0. Please see the reproduction and workaround below.
    SCOTT@orcl_11gR2> SELECT *
      2  FROM   (SELECT b.id
      3            FROM   sdo_equal_query_test a, sdo_equal_query_test b
      4            WHERE  a.id = 1
      5            AND    b.id != a.id
      6            AND    sdo_equal (a.geometry, b.geometry) = 'TRUE')
      7  /
    no rows selected
    Execution Plan
    Plan hash value: 1024466006
    | Id  | Operation          | Name                 | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |                      |     1 |  7676 |     6   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS      |                      |     1 |  7676 |     6   (0)| 00:00:01 |
    |*  2 |   TABLE ACCESS FULL| SDO_EQUAL_QUERY_TEST |     1 |  3832 |     3   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| SDO_EQUAL_QUERY_TEST |     1 |  3844 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter("B"."ID"<>1)
       3 - filter("A"."ID"=1 AND "B"."ID"<>"A"."ID" AND
                  "MDSYS"."SDO_EQUAL"("A"."GEOMETRY","B"."GEOMETRY")='TRUE')
    Note
       - dynamic sampling used for this statement (level=2)
    SCOTT@orcl_11gR2> SELECT *
      2  FROM   (SELECT b.id
      3            FROM   sdo_equal_query_test a, sdo_equal_query_test b
      4            WHERE  a.id = 1
      5            AND    b.id != a.id
      6            AND    sdo_equal (a.geometry, b.geometry) = 'TRUE'
      7            AND    ROWNUM > 0)
      8  /
            ID
             2
    1 row selected.
    Execution Plan
    Plan hash value: 2329953927
    | Id  | Operation                       | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                |                            |     1 |    13 |     3   (0)| 00:00:01 |
    |   1 |  VIEW                           |                            |     1 |    13 |     3   (0)| 00:00:01 |
    |   2 |   COUNT                         |                            |       |       |            |          |
    |*  3 |    FILTER                       |                            |       |       |            |          |
    |   4 |     NESTED LOOPS                |                            |     1 |  7676 |     3   (0)| 00:00:01 |
    |*  5 |      TABLE ACCESS FULL          | SDO_EQUAL_QUERY_TEST       |     1 |  3832 |     3   (0)| 00:00:01 |
    |*  6 |      TABLE ACCESS BY INDEX ROWID| SDO_EQUAL_QUERY_TEST       |     1 |  3844 |     3   (0)| 00:00:01 |
    |*  7 |       DOMAIN INDEX              | SDO_EQUAL_QUERY_TEST_SPIND |       |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - filter(ROWNUM>0)
       5 - filter("B"."ID"<>1)
       6 - filter("A"."ID"=1 AND "B"."ID"<>"A"."ID")
       7 - access("MDSYS"."SDO_EQUAL"("A"."GEOMETRY","B"."GEOMETRY")='TRUE')
    Note
       - dynamic sampling used for this statement (level=2)
    SCOTT@orcl_11gR2>

  • Select from a table from other schema

    Hi,
    I want to make a select from a table how is into other Schema and into other instance.
    form example, if I have _2 schemas (in diferent instances)_:
    SCHEMA1 =
    *(DESCRIPTION =*
    *(ADDRESS =*
    *(PROTOCOL = TCP)*
    *(HOST = XXX.XXX.XXX.XX1)*
    *(PORT = 1560)*
    *(CONNECT_DATA =*
    *(SERVER = DEDICATED)*
    *(SERVICE_NAME = SCHEMA1)*
    SCHEMA2 =
    *(DESCRIPTION =*
    *(ADDRESS =*
    *(PROTOCOL = TCP)*
    *(HOST = XXX.XXX.XXX.XX2)*
    *(PORT = 1560)*
    *(CONNECT_DATA =*
    *(SERVER = DEDICATED)*
    *(SERVICE_NAME = SCHEMA2)*
    and into SCHEMA2 there is a table TABLE_A.
    If I`m connected into SCHEMA1:
    how can I do to make a select from the TABLE_A?
    thanks very much.

    1) Referring to an entry in the tnsnames.ora file as a "schema" as you have here with schema1 and schema2 is likely to be confusing. You have multiple schemas in the same database-- in this case, you appear to be trying to query tables in a different database. If we try to answer using your TNS aliases "schema1" and "schema2", there is likely to be a great deal of confusion between schemas/ databases/ and TNS aliases. So I will assume that your tnsnames.ora file actually reads
    TNS_ALIAS1 =
      (DESCRIPTION =
        (ADDRESS =
          (PROTOCOL = TCP)
          (HOST = HOST1)
          (PORT = 1560)
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = DB1)
    TNS_ALIAS2 =
      (DESCRIPTION =
        (ADDRESS =
          (PROTOCOL = TCP)
          (HOST = HOST2)
          (PORT = 1560)
      (CONNECT_DATA =
        (SERVER = DEDICATED)
        (SERVICE_NAME = DB2)
    )2) Given the TNS aliases above, assuming that we are talking about the tnsnames.ora file on HOST1, you would need to create a database link from DB1 to DB2. You can either specify a fixed username and password for the database link or you can specify that the connection happens as the current user (which assumes that the passwords are synchronized between the databases).
    CREATE DATABASE LINK to_db2
      CONNECT TO username_on_db2
      IDENTIFIED BY password_on_db2
      USING 'TNS_ALIAS2'3) Assuming the database link is in place
    SELECT *
      FROM schema2.table_name@to_db2Justin

  • ALV grid list  report when selected  from  selection screen

    Hi folks,
                I need to get ALV grid display in my list report when selected the interval values from  the selection screen. If I change the values in list of ALV grid it needs to be updated when I press UPDATE pushbutton. The output of list should be in ALV grid display.I need sorting ,flitering,totaling functionality in the list output.
    For example if I selected BUKRS = 100 and 200 in the selection screen ,I need to display the ALV grid list in below the selection screen as ALV grid display...
    Its urgent as  I am new to ALV grid functionality...
    Thanks in advance..

    hi raja,
    check with the folllowing code.
    REPORT zca0m_zca0fcstftop NO STANDARD PAGE HEADING
                                    MESSAGE-ID zcsv_usrtbl_maintain.
    Type pools                                                           *
    TYPE-POOLS : slis.                          " Used for ALV display
    Tables
    TABLES: zca0fcstftop,
            dd04t,                         "R/3 DD: Data element texts
            tactt.                         "Activities that can be protected
    internal tables
    DATA: BEGIN OF wa_zca0fcstftop .
            INCLUDE STRUCTURE zca0fcstftop.
    DATA: END OF wa_zca0fcstftop.
    DATA: t_zca0fcstftop LIKE STANDARD TABLE OF wa_zca0fcstftop.
    DATA: BEGIN OF i_fcode OCCURS 0,
            fcode LIKE sy-ucomm,
          END OF i_fcode.
    *Record for variant selection
    DATA : BEGIN OF ws_variant,
             selected TYPE c,
             variant  LIKE ltdx-variant,  "Variant name
             text     LIKE ltdxt-text,    "Variant description
           END OF ws_variant.
    *Table for variant selection
    data : itab_variant LIKE STANDARD TABLE OF ws_variant WITH HEADER LINE.
    Variant selection pop-up global variables
    DECLARATION OF TABLECONTROL 'VARIANT_CNTL' ITSELF
    CONTROLS: variant_cntl TYPE TABLEVIEW USING SCREEN 0200.
    LINES OF TABLECONTROL 'VARIANT_CNTL'
    DATA:     g_variant_cntl_lines  LIKE sy-loopc.
    DATA:grid1 TYPE REF TO  cl_gui_alv_grid ,
         g_custom_container TYPE REF TO cl_gui_custom_container.
    Work fields
    DATA: table_name LIKE dd02l-tabname,   "To store table name
          field_name LIKE dd03l-fieldname, "To Store Field Name
          act_auth LIKE tactz-actvt,       "To pass Activity ID
          tab_maint LIKE dd02l-tabname,    "To pass Table Name to be Maintd.
          wg_confirm_ind,                  "To trap User responses
          flag,                            "To trap changes made to an entry
          f_copy,                          "To Identify 'COPY' Command Use
          f_select,                        "To decide between Select-options
                                           " and Internal Table
          l_transaction_code LIKE tstc-tcode,
          v_langu LIKE sy-langu,
          v_repid LIKE sy-repid,
          s_variant TYPE disvariant.
    DATA: ok_code LIKE sy-ucomm.
    DATA:selected_rows TYPE lvc_t_row  ,
         sel_rows TYPE lvc_t_row WITH HEADER LINE.
    DATA:t_lines TYPE i.
    Constants                                                            *
    CONSTANTS :
               c_x TYPE c VALUE 'X',             " Constant 'X'.
               c_f TYPE c VALUE 'F'.             " Constant 'F'.
    Parameters and Selection Options
    *Selection Screen for table maintenance
    *Selection option for Plant
    SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-b01.
    PARAMETERS:  p_werks   LIKE zca0fcstftop-werks OBLIGATORY.
    SELECT-OPTIONS: s_prdfml  FOR zca0fcstftop-product_family,
                    s_bmach   FOR zca0fcstftop-base_machine,
                    s_factop FOR zca0fcstftop-factory_top,
                    s_optval  FOR zca0fcstftop-option_value,
                    s_week    FOR zca0fcstftop-week.
    SELECTION-SCREEN END OF BLOCK block1.
    SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-b02.
    PARAMETERS     : p_varant LIKE ltdx-variant.          " ALV variant
    SELECTION-SCREEN END OF BLOCK block2.
    At selection screen                                                  *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varant.
      PERFORM alv_variant_f4 CHANGING p_varant.
    AT SELECTION-SCREEN ON p_werks .
    Validating Plant on the selection screen
      PERFORM validate_plant.
    Initialization
    INITIALIZATION.
    Check Authorization for the Transaction
    Authorization Check For T Code
      SELECT tcode
         INTO l_transaction_code
         FROM tstc UP TO 1 ROWS
         WHERE pgmna = sy-repid.
      ENDSELECT.
      AUTHORITY-CHECK OBJECT 'S_TCODE'
                          ID 'TCD' FIELD l_transaction_code.
      IF sy-subrc NE 0.
        MESSAGE e001 WITH l_transaction_code.
      ENDIF.
      v_langu = sy-langu.                             " language
      v_repid = sy-repid .                            " abap Program name
    Start Of Selection
    START-OF-SELECTION.
      CALL SCREEN 0050.
    *&      Form  validate_plant                                           *
          Validating Plant on the selection screen                       *
    FORM validate_plant .
      DATA : l_werks LIKE t001w-werks.                          " Plant
      IF p_werks IS NOT INITIAL.
        SELECT SINGLE werks
            FROM t001w
            INTO l_werks
            WHERE werks EQ p_werks.
        IF sy-subrc NE 0.
          MESSAGE e100(ra) WITH text-001 .
        ENDIF.
      ENDIF.
      AUTHORITY-CHECK OBJECT 'Z_PP_PLANT'
               ID 'ACTVT' FIELD '03'
               ID 'WERKS' FIELD p_werks
               ID 'TCD' FIELD l_transaction_code.
      IF sy-subrc NE 0.
        MESSAGE e000(oo) WITH 'No authorization for plant:'(e80) p_werks.
      ENDIF.
    ENDFORM.                    " validate_plant
    *&      Form  get_data                                                 *
          Get data                                                       *
    FORM get_data .
      SELECT * FROM zca0fcstftop
        INTO TABLE t_zca0fcstftop
        WHERE werks           = p_werks
          AND product_family IN s_prdfml
          AND base_machine   IN s_bmach
          AND factory_top    IN s_factop
          AND option_value   IN s_optval
          AND week           IN s_week.
    ENDFORM.                    " get_data
    *&      Form  fill_fcode
    FORM fill_fcode USING    value(p_0029).
      i_fcode-fcode = p_0029.
      APPEND i_fcode.
      CLEAR i_fcode.
    ENDFORM.                               " fill_fcode
    *&      Module  STATUS_0100  OUTPUT
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'UPDATE'.
      CLEAR flag.
    ENDMODULE.                             " STATUS_0100  OUTPUT
    *&      Module  MODIFY_0100  OUTPUT
    MODULE modify_0100 OUTPUT.
      IF sy-ucomm = 'CHNG' OR
           sy-ucomm = 'PICK'.
        LOOP AT SCREEN.
          CHECK screen-group1 = 'CHG'.
          screen-required = '0'.
          screen-output   = '1'.
          screen-input    = '0'.
          MODIFY SCREEN.
        ENDLOOP.
      ENDIF.
    Check if you are in create mode & if yes then set the screen elements
    as mandatory
      IF ok_code = 'CREA'.
        LOOP AT SCREEN.
          CHECK screen-group1 = 'CHG'.
          screen-required = '1'.
          screen-output   = '1'.
          screen-input    = '1'.
          MODIFY SCREEN.
        ENDLOOP.
      ENDIF.
    ENDMODULE.                             " MODIFY_0100  OUTPUT
    *&      Module  Check_Exit  INPUT
          text
    MODULE check_exit INPUT.
      IF ( sy-ucomm = 'BACK' OR sy-ucomm = 'CANC' OR sy-ucomm = 'EXIT' ) AND
           ( flag = 'Y' ).
        CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
          EXPORTING
            defaultoption  = 'Y'
            textline1      = text-008
            textline2      = text-009
            titel          = text-004
            cancel_display = ' '
          IMPORTING
            answer         = wg_confirm_ind.
        CASE wg_confirm_ind.
          WHEN 'J'.                                             "Yes
            sy-ucomm = 'SAVE'.
            CLEAR flag.
          WHEN 'N'.                                             "No
            sy-ucomm = 'BACK'.
            CLEAR flag.
        ENDCASE.
      ENDIF.
    ENDMODULE.                             " Check_Exit  INPUT
    *&      Module  Exit_0100  INPUT
          text
    MODULE exit_0100 INPUT.
      SET SCREEN 0. LEAVE SCREEN.
    ENDMODULE.                             " Exit_0100  INPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'SAVE'.                       "Save
        Check to see if the user has the appropriate authorization
          IF p_werks NE zca0fcstftop-werks.
          could not update - not in selection
            MESSAGE e000(oo) WITH 'Entry not within selection'.
            SET SCREEN 0. LEAVE SCREEN.
            PERFORM get_data.
          ENDIF.
          IF f_copy = 'X'.
            INSERT zca0fcstftop.
            IF sy-subrc = 0.
              MESSAGE s004.
              PERFORM initialize.
              SET SCREEN 0. LEAVE SCREEN.
              PERFORM get_data.
            ELSE.
              MESSAGE w005.
            ENDIF.
          ELSE.
            MODIFY zca0fcstftop.
            IF sy-subrc = 0.
              MESSAGE s004.
              PERFORM initialize.
              SET SCREEN 0. LEAVE SCREEN.
              PERFORM get_data.
            ELSE.
              MESSAGE w005.
            ENDIF.
          ENDIF.
          PERFORM get_data.
        WHEN 'BACK'.                       "Back
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'CANC'.                       "Cancel
          SET SCREEN 0. LEAVE SCREEN.
        WHEN OTHERS.
      ENDCASE.
      COMMIT WORK.
    ENDMODULE.                             " USER_COMMAND_0100  INPUT
    *&      Form  Initialize
    FORM initialize.
      CLEAR :   table_name,
                field_name,
                wg_confirm_ind,
                f_copy,
                flag,
                t_zca0fcstftop,
                zca0fcstftop,
                wa_zca0fcstftop,
                i_fcode.
      REFRESH: t_zca0fcstftop.
    ENDFORM.                               " Initialize
    *&      Form  alv_variant_f4
          text
         <--P_VARIANT  text
    FORM alv_variant_f4  CHANGING variant.
      DATA: rs_variant LIKE disvariant.
      DATA nof4 TYPE c.
      CLEAR nof4.
      LOOP AT SCREEN.
        IF screen-name = 'VARIANT'.
          IF screen-input = 0.
            nof4 = 'X'.
          ENDIF.
        ENDIF.
      ENDLOOP.
      rs_variant-report   = sy-repid.
      rs_variant-username = sy-uname.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = rs_variant
          i_save     = 'A'
        IMPORTING
          es_variant = rs_variant
        EXCEPTIONS
          OTHERS     = 1.
      IF sy-subrc = 0 AND nof4 EQ space.
        variant = rs_variant-variant.
      ENDIF.
    ENDFORM.                               " ALV_VARIANT_F4
    *&      Module  STATUS_0050  OUTPUT
          text
    MODULE status_0050 OUTPUT.
    In this module Initialize the container and put the grid in it
      DATA:grid_layout  TYPE lvc_s_layo,
           fieldcat TYPE lvc_t_fcat,
           wa_fieldcat LIKE LINE OF fieldcat.
      PERFORM set_auth.
      SET PF-STATUS 'UPD_0050' EXCLUDING i_fcode.
      SET TITLEBAR 'UPD_0050'.
      IF g_custom_container IS INITIAL .
        CREATE OBJECT g_custom_container
           EXPORTING
              container_name = 'FTDATA'.
        CREATE OBJECT grid1
           EXPORTING
            i_parent = g_custom_container.
      ELSE.
        CALL METHOD grid1->free.
        CALL METHOD g_custom_container->free.
        CREATE OBJECT g_custom_container
           EXPORTING
              container_name = 'FTDATA'.
        CREATE OBJECT grid1
           EXPORTING
            i_parent = g_custom_container.
      ENDIF.
    Every time refresh The variables
      PERFORM initialize.
      PERFORM get_data.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'ZCA0FCSTFTOP'
        CHANGING
          ct_fieldcat      = fieldcat.
      grid_layout-grid_title = text-t01.
      grid_layout-sel_mode = 'A'.
      grid_layout-stylefname = 'CT'.
      s_variant-report   = sy-repid.
      s_variant-username = sy-uname.
      s_variant-variant  = p_varant.
      CALL METHOD grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = 'ZCA0FCSTFTOP'
          is_layout        = grid_layout
          is_variant       = s_variant
          i_save           = 'A'
        CHANGING
          it_outtab        = t_zca0fcstftop
          it_fieldcatalog  = fieldcat.
      Create Object to receive events and link them to handler methods.
      When the ALV Control raises the event for the specified instance
      the corresponding method is automatically called.
    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->handle_button_click FOR grid1.
    ENDMODULE.                 " STATUS_0050  OUTPUT
    *&      Module  USER_COMMAND_0050  INPUT
    MODULE user_command_0050 INPUT.
      CALL METHOD grid1->get_selected_rows
        IMPORTING
          et_index_rows = selected_rows.
      DESCRIBE TABLE selected_rows LINES t_lines.
      IF t_lines > 1 .
        MESSAGE e048(zcsv_sfdr).
      ENDIF.
    Clear Header
      CLEAR wa_zca0fcstftop.
      sel_rows[] = selected_rows .
      READ TABLE sel_rows INDEX 1.
      READ TABLE t_zca0fcstftop INTO wa_zca0fcstftop INDEX sel_rows-index.
      CASE ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
        WHEN 'CREA'.
          CLEAR zca0fcstftop.
          ok_code = sy-ucomm.
          zca0fcstftop-werks = p_werks.
          CALL SCREEN 100.
        WHEN 'COPY'.
          MOVE wa_zca0fcstftop TO zca0fcstftop .
          CLEAR wa_zca0fcstftop.
          f_copy = 'X'.
          CALL SCREEN 100.
        WHEN 'CHNG'.
          CHECK NOT wa_zca0fcstftop IS INITIAL.
          MOVE wa_zca0fcstftop TO zca0fcstftop .
          CLEAR wa_zca0fcstftop.
          ok_code = sy-ucomm.
          CALL SCREEN 100.
        WHEN 'DELE'.
          CHECK NOT wa_zca0fcstftop IS INITIAL.
          CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
            EXPORTING
              defaultoption  = 'N'
              textline1      = text-005
              textline2      = text-006
              titel          = text-007
              cancel_display = ' '
            IMPORTING
              answer         = wg_confirm_ind.
          IF wg_confirm_ind EQ 'J'.
            DELETE zca0fcstftop FROM wa_zca0fcstftop .
            IF sy-subrc EQ 0.
              MESSAGE s004.
            ELSE.
              MESSAGE e005.
            ENDIF.
          ELSEIF wg_confirm_ind EQ 'N'.
          ENDIF.
      ENDCASE.
      CLEAR ok_code.
    ENDMODULE.                 " USER_COMMAND_0050  INPUT
    *&      Form  exit_program
    FORM exit_program .
      CALL METHOD g_custom_container->free.
      CALL METHOD cl_gui_cfw=>flush.
      SET SCREEN 0.
      LEAVE SCREEN.
    ENDFORM.                    " exit_program
    *&      Form  set_auth
    FORM set_auth.
      REFRESH: i_fcode.
    Check authorization for change
      MOVE '02' TO act_auth.        "02 --> Change
      MOVE 'ZCA0FCSTFTOP' TO tab_maint.
      AUTHORITY-CHECK OBJECT 'ZZ:TABLMNP'
        ID 'ACTVT' FIELD act_auth
        ID 'TABLE' FIELD tab_maint.
      IF sy-subrc NE 0.
        PERFORM fill_fcode USING 'CHNG'.
      ENDIF.
    Check for authorization for create
      MOVE '01' TO act_auth.        "01 --> Create
      MOVE 'ZCA0FCSTFTOP' TO tab_maint.
      AUTHORITY-CHECK OBJECT 'ZZ:TABLMNP'
        ID 'ACTVT' FIELD act_auth
        ID 'TABLE' FIELD tab_maint.
      IF sy-subrc NE 0.
        PERFORM fill_fcode USING 'CREA'.
        PERFORM fill_fcode USING 'COPY'.
      ENDIF.
    Check for authorization for delete
      MOVE '06' TO act_auth.        "06 --> Delete
      MOVE 'ZCA0FCSTFTOP' TO tab_maint.
      AUTHORITY-CHECK OBJECT 'ZZ:TABLMNP'
        ID 'ACTVT' FIELD act_auth
        ID 'TABLE' FIELD tab_maint.
      IF sy-subrc NE 0.
        PERFORM fill_fcode USING 'DELE'.
      ENDIF.
    ENDFORM.                    " set_auth
    *&      Module  check_change  INPUT
    MODULE check_change INPUT.
      flag = 'Y'.
    ENDMODULE.                 " check_change  INPUT
    regards,
    vikas.
    plz reward if helpful

  • SELECT * FROM mytable WHERE ANYCOLUMN like myString

    Hi ALL,
    Is there a way i can select a row wherein any of the columns contain my search string?
    SELECT *
    FROM mytable
    WHERE ANYCOLUMN like '%myString%'Thanks!
    BROKEN

    Example of it working...
    SQL> var val varchar2(5)
    SQL> exec :val := 'KING'
    PL/SQL procedure successfully completed.
    SQL> ed
    Wrote file afiedt.buf
      1  select distinct substr (:val, 1, 11) "Searchword",
      2                  substr (table_name, 1, 14) "Table",
      3                  substr (t.column_value.getstringval (), 1, 50) "Column/Value"
      4             from cols,
      5                  table
      6                     (xmlsequence
      7                         (dbms_xmlgen.getxmltype ('select ' || column_name
      8                                                  || ' from ' || table_name
      9                                                  || ' where upper('
    10                                                  || column_name
    11                                                  || ') like upper(''%' || :val
    12                                                  || '%'')'
    13                                                 ).extract ('ROWSET/ROW/*')
    14                         )
    15                     ) t
    16         where table_name = 'EMP'
    17*        order by "Table"
    SQL> /
    Searchword  Table          Column/Value
    KING        EMP            <ENAME>KING</ENAME>
    SQL>

  • Selecting from multiple sqlserver databases with HS

    I have setup HS from oracle 8.1.7 to sqlserver 7.0 for one database and it works fine. I have about six databases on the same NT server and will like to select from the various databases, the tables I need to update Oracle. I have edited the odbc.ini file to add the other sqlserver database entries. I have also updated the inithsmsql.ora file to add multiple entries for the other databases. When I select from distinct tables in the databases it works fine. But if I have the same tables in database A,B and C and want to select column from table A in database A, I get the result for table A in database B. Is there a way to select from identical tables from different databases and get the result for the table and database that is needed.
    ie select column from data_souce_name.table_name@hsmsql. Is there a syntax or configuration for that.
    Thanks

    Vira I am actually making multiple entries of these parameters in the inithsmsql.ora file. The first data source is test then I will copy it and edit it for another data source test1 etc. Even making one init.ora file in the hs/admin directory for the databases how will the system know from which database to query if one table exist in more than one database. Also even adding multiple listeners for the different sids won't help as the program= will be same for all. ? multiple tnsnames entries?
    HS_FDS_CONNECT_INFO = test
    HS_FDS_TRACE_LEVEL = 2
    HS_FDS_TRACE_FILE_NAME = test5.trc
    HS_FDS_SHAREABLE_NAME = /dbdata/odbc/lib/libodbc.so

  • Selection from a Maintenance View

    Hi,
        I have to fetch data from a view, unfotunately that view is a mainteance view. Is there any other way to select/fetch data from that view in my report program ?
    Regards,
    Bharath Mohan B

    Hi
    U cannot access the data from maintanence view.
    Only projection and database view can be used in ABAP code.
    If u want to access the Data from more the one table , Create the DATABASE VIEW and use this view in ur program.
    For example : UR Database view name is Ztest
    in ur program
    table Ztest.
    select * from Ztest ***************
    *******************UR Business Logic
    <b>Reward if useful</b>

  • URGENT : select from table statement in ABAP OO

    Hi all,
    I am an absolute ABAP OO beginner and need some quick help from an expert. How can I make a selection from an existing table (eg MARA) in an BADI which is programmed according to ABAP OO principles.
    In the old ABAP school you could make a TABLES statement at the beginning and the do a SELECT¨* FROM but this does not work in ABAP OO.
    How should i define such simple selections from existing tables. Anyone ?
    Thanks a lot,
    Eric Hassenberg

    *define internal table
    data: i_mara like standard table of mara.
    *select to this table
    select * from mara into table i_mara.
    Also you have to define work area for this internal table in order to use it.
    data:w_mara like line of i_mara.

Maybe you are looking for

  • Need recommendations for hardware and software - Current control

    Hi all, I am doing a project related to current control. The purpose is to keep the current at constant. So I measure the current and get the value; and send a analog signal to tell our machine to discharge or to charge in order to keep the current a

  • Recent update to 10.6.8 and now Finder app wont open.  Error 10810

    I cannot open finder after a recent update.  I get one error messages such as The application Finder can't be opened. - 10810. On reboot I get nothing but "finder quit unexpectedly" Can anyone help?  Im pretty much a novice and only recently upgraded

  • HT1926 Installation fails because Apple Mobile Device Service failed to start?

    When  I attempted to update ITunes, it failed at the starting services point because "Apple Mobile Device Service failed to start".  The ignore button would not work.  Retry did not fix it.  I have deleted all ITunes from my computer, restarted, and

  • Still Image Noise

    I've imported some high resolution still .jpeg frames that I need for a project into FCP 4.5. The images look fine on my Cinema Display but are a bit shaky and there is a herringbone effect and noise on my external monitor. Any suggestions? Thanks

  • Is it possible to run steam as a service in the background?

    Now that Steam In-Home streaming works from a Linux host, I was wondering if was possible to get Steam t run as a background service?  The idea being that I simply need to boot the host computer and can then play games on my laptop elsewhere without