Table query

hi all
i have one requierment that i have to create a table that can generate an auto-generated number.
i am not sure wether is it possible if yes ..plz can anyone tell me how...it will be great help..
is there any other way for genrating auto-generated number.
regards
parul

Hi parul,
1. a table that can generate an auto-generated number
   The statement is not clear.
2. A Table cannot generate any number.
3. We have to write our own abap code
   for generating new number.
4. We can use Number range interval concept
   to do this.
5. If ur requirement is thru SM30 (table mainteance)
   , still then,
   one has to code on the event
   for generating new number
   either using MAX + 1 concept
   or number range interval.
I hope it helps.
regards,
amit m.

Similar Messages

  • Inserting into Table-in-Table after re-execution the Outer Table query

    Hi Gurus,
    I have a problem with inserting into Table-in-Table after re-execution the Outer Table query:
    The problem:
    I have two tables; both tables are based on VO; tables have a VL between them;
    The Inner Table is hidden when page lode.
    I'm executing the Outer Table, open the details to see the Inner Table, I can add rows to the Inner Table. Everything is OK.
    But-
    After I'm executing the Outer Table again –
    Adding new rows to the Inner Table is not work anymore, despite I'm executing the Inner Table RowSet query.
    Scenario is:
    In processRequest():
    In the processRequest() I'm calling executeQuery() of the Outer Table Only.
    (So the Details executeQuery() will be done by VL and Its works fine.)
    In processFormRequest():
    User opens the details to see the Inner Table.
    On some event, I'm executing the Outer Table query.
    On some other event, programmatically I am inserting a new row to the Inner Table, and a new row is displayed in the Inner Table as I wanted.
    In this way, one row after another, I can add as many rows as I wish, without any problem.
    (This scenario should behave as same clicking on button of type "Add-Another-Row", just adding the row automatically)
    The code for the inserting (as specified in the chapter "Classic Tables" --> "table-in-table"):
    OARow newRow = (OARow) innerRowSet.createRow();
    innerRowSet.insertRow(newRow);
    innerRowSet.setRangeSize(innerRowSet.getRangeSize()+ 1);
    innerRowSet.executeQuery();
    If the user won't cause to re-execution of the outer table – no problem occurs.
    * Should I add something after the Outer Table VO execution?
    * Maybe to the inserting to the Inner Table code?
    Please help…

    Hi, Thanks.
    I don't know which one of the Outer Table rows is the current row,
    But-
    Only the Details (the Inner Tables) who where opened before the executeQuery() of the Outer table are not acts as they should.
    All the Details who where closed before the executeQuery() of the Outer table are still works fine.
    Please advise.

  • SQL+-MULTI TABLE QUERY PROBLEM

    HAI ALL,
    ANY SUGGESTION PLEASE?
    SUB: SQL+-MULTI TABLE QUERY PROBLEM
    SQL+ QUERY GIVEN:
    SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,
    HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,
    DLC_POLYMORPHS_NORMAL_VALUE FROM PATIENTS_MASTER1, HAEMATOLOGY1,
    DIFFERENTIAL_LEUCOCYTE_COUNT1
    WHERE PATIENT_NUM = HMTLY_PATIENT_NUM AND PATIENT_NUM = DLC_PATIENT_NUM AND PATIENT_NUM
    = &PATIENT_NUM;
    RESULT GOT:
    &PATIENT_NUM =1
    no rows selected
    &PATIENT_NUM=2
    no rows selected
    &PATIENT_NUM=3
    PATIENT_NUM 3
    PATIENT_NAME KKKK
    HMTLY_TEST_NAME HAEMATOLOGY
    HMTLY_RBC_VALUE 4
    HMTLY_RBC_NORMAL 4.6-6.0
    DLC_TEST_NAME DIFFERENTIAL LEUCOCYTE COUNT
    DLC_POLYMORPHS_VALUE     60
    DLC_POLYMORPHS_NORMAL_VALUE     40-65
    ACTUAL WILL BE:
    &PATIENT_NUM=1
    PATIENT_NUM 1
    PATIENT_NAME BBBB
    HMTLY_TEST_NAME HAEMATOLOGY
    HMTLY_RBC_VALUE 5
    HMTLY_RBC_NORMAL 4.6-6.0
    &PATIENT_NUM=2
    PATIENT_NUM 2
    PATIENT_NAME GGGG
    DLC_TEST_NAME DIFFERENTIAL LEUCOCYTE COUNT
    DLC_POLYMORPHS_VALUE     42
    DLC_POLYMORPHS_NORMAL_VALUE     40-65
    &PATIENT_NUM=3
    PATIENT_NUM 3
    PATIENT_NAME KKKK
    HMTLY_TEST_NAME HAEMATOLOGY
    HMTLY_RBC_VALUE 4
    HMTLY_RBC_NORMAL 4.6-6.0
    DLC_TEST_NAME DIFFERENTIAL LEUCOCYTE COUNT
    DLC_POLYMORPHS_VALUE     60
    DLC_POLYMORPHS_NORMAL_VALUE     40-65
    4 TABLES FOR CLINICAL LAB FOR INPUT DATA AND GET REPORT ONLY FOR TESTS MADE FOR PARTICULAR
    PATIENT.
    TABLE1:PATIENTS_MASTER1
    COLUMNS:PATIENT_NUM, PATIENT_NAME,
    VALUES:
    PATIENT_NUM
    1
    2
    3
    4
    PATIENT_NAME
    BBBB
    GGGG
    KKKK
    PPPP
    TABLE2:TESTS_MASTER1
    COLUMNS:TEST_NUM, TEST_NAME
    VALUES:
    TEST_NUM
    1
    2
    TEST_NAME
    HAEMATOLOGY
    DIFFERENTIAL LEUCOCYTE COUNT
    TABLE3:HAEMATOLOGY1
    COLUMNS:
    HMTLY_NUM,HMTLY_PATIENT_NUM,HMTLY_TEST_NAME,HMTLY_RBC_VALUE,HMTLY_RBC_NORMAL_VALUE     
    VALUES:
    HMTLY_NUM
    1
    2
    HMTLY_PATIENT_NUM
    1
    3
    MTLY_TEST_NAME
    HAEMATOLOGY
    HAEMATOLOGY
    HMTLY_RBC_VALUE
    5
    4
    HMTLY_RBC_NORMAL_VALUE
    4.6-6.0
    4.6-6.0
    TABLE4:DIFFERENTIAL_LEUCOCYTE_COUNT1
    COLUMNS:DLC_NUM,DLC_PATIENT_NUM,DLC_TEST_NAME,DLC_POLYMORPHS_VALUE,DLC_POLYMORPHS_
    NORMAL_VALUE,
    VALUES:
    DLC_NUM
    1
    2
    DLC_PATIENT_NUM
    2
    3
    DLC_TEST_NAME
    DIFFERENTIAL LEUCOCYTE COUNT
    DIFFERENTIAL LEUCOCYTE COUNT
    DLC_POLYMORPHS_VALUE
    42
    60
    DLC_POLYMORPHS_NORMAL_VALUE
    40-65
    40-65
    THANKS
    RCS
    E-MAIL:[email protected]
    --------

    I think you want an OUTER JOIN
    SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,
    HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,
    DLC_POLYMORPHS_NORMAL_VALUE
    FROM PATIENTS_MASTER1, HAEMATOLOGY1,  DIFFERENTIAL_LEUCOCYTE_COUNT1
    WHERE PATIENT_NUM = HMTLY_PATIENT_NUM (+)
    AND PATIENT_NUM = DLC_PATIENT_NUM (+)
    AND PATIENT_NUM = &PATIENT_NUM;Edited by: shoblock on Nov 5, 2008 12:17 PM
    outer join marks became stupid emoticons or something. attempting to fix

  • Exceptions Table query help?

    I ahve two exceptions tables cust_day_of_week and cust_date
    Cust_day_of the week has following fields:
    Key_Id,Day_week,begintime,endtime
    1,1,8,20 1--is oracle number for sunday
    cust_date has following fields
    Key_Id, exception_date,begintime,endtime
    2,08/24/2011,8,20
    i am writing a function to get the key_id to use for some purpose by checking if the sysdate falls in any of the exception
    say sysdate is sunday then profile ID =1 shud be returned
    if date exception is to be checked then the Cust_day table shud be checked...
    is there a way to get the profileid from both tables in one function by chekcing which exception is fullfilled....Hope i am clear...
    say i wnat to check if the sysdate day is sunday or not..if yes then return profileid =1
    else if i want check if tuday =08/24/2011 the retrun profile id =2 but this shud be done in one function if possible...is it possible...
    This is the function i planning to create....
    how to check the for the Cust_date table date exception in the same query...
    FUNCTION key_ID
    ( v_date     IN          DATE     DEFAULT SYSDATE
    RETURN     Number IS
    ret_value number:=0
    select Key_ID into ret_value from cust_day_of_week
    where (to_char( v_date,'D') in (select day_week from cust_day_of_week ))
    retun ret_value;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line('Error:'||SQLERRM);
    RETURN 0;
    END ;
    Edited by: 874167 on Aug 25, 2011 1:43 PM

    Does this help?
    It's not a function, but I don't see a need for one.
    drop table cust_date purge;
    drop table cust_day_of_week purge;
    create table cust_day_of_week (key_id number,Day_week number,begintime number,endtime number);
    insert into cust_day_of_week values (1,1,8,20);
    insert into cust_day_of_week values (2,2,8,20);
    insert into cust_day_of_week values (3,3,8,20);
    insert into cust_day_of_week values (4,4,8,20);
    insert into cust_day_of_week values (5,5,8,20);
    insert into cust_day_of_week values (6,6,8,20);
    insert into cust_day_of_week values (7,7,8,20);
    create table cust_date (key_id number,exception_date date,begintime number,endtime number, constraint edunique unique(exception_date));
    insert into cust_date values (8,to_date('08/24/2011','MM/DD/YYYY'),8,20);
    insert into cust_date values (9,to_date('08/25/2011','MM/DD/YYYY'),8,20);
    commit;
    select key_id from (
    SELECT key_id from cust_date where exception_date = trunc(sysdate)
    union all
    SELECT key_id from cust_day_of_week where day_week = to_number(to_char(sysdate,'D','nls_date_language = AMERICAN')))
    where rownum =1;I am not 100% sure that you are allowed to rely on union all preserving the order. I have not seen otherwise, but I am not sure whether it's guaranteed.
    As documentation doesn't say it's guaranteed, it probably isn't.
    to be sure, this is a safe way of doing it. Maybe someone else can say whether there is a shorter way of doing that:
    select key_id from (
    select key_id ,rank() over (order by sorted) rnk from (
    SELECT key_id, 1 sorted from cust_date where exception_date = trunc(sysdate)
    union all
    SELECT key_id, 2 sorted from cust_day_of_week where day_week = to_number(to_char(sysdate,'D','nls_date_language = AMERICAN')))
    ) where rnk = 1;

  • How to find out what the underlying table/query of a form in Oracle Apps.

    Hi
    I am trying to find out who owns the underlying objects of a query when a user runs the Transactions > Line_Items form for Receivables .
    I have selected Help > Record History but I get a message Record History not available here.
    The query is running slow and I'd like to see if the objects have been analyzed lately.
    Thanks
    Andy

    Hi
    I should have said in the ticket that this is version 11.5.10
    It was close to giving me the answer I need. It gives me the following details. Unfortunately it doesn't give me the underlying sql. I hhave tried using v$session and sys.v_$sql but the sql is over 1000 characters long so I dont get to see the table/object being referenced.
    I appreciate the feedback.
    Thanks
    Andy
    Database Server
    RDBMS : 10.2.0.4.0
    Oracle Applications : 11.5.10.2
    Machine : alabama
    User : APPS
    Oracle SID : accausr1
    System Date : 12-SEP-2011 13:33:58
    Database Server PID : 16875
    Session SID : 1065
    SERIAL# : 1273
    AUDSID : 201640233
    Database CPU Usage (in secs) : 8.85
    Forms Server
    Oracle Forms Version : 6.0.8.27.0
    Application Object Library : 11.5.0
    Machine : AUSTIN
    Forms User CPU (secs) : 3.430000
    Forms System CPU (secs) : 0.840000
    Forms Process ID : 6347
    Forms Server Environment Variables
    AU_TOP : /oracle/finapps/accausr1/accausr1appl/au/11.5.0
    FDBDMCHK : [Unset]
    FDFGCXDBG : [Unset]
    FDSQLCHK : [Unset]
    FDUDEBUG : [Unset]
    FNDNAM : APPS
    FND_TOP : /oracle/finapps/accausr1/accausr1appl/fnd/11.5.0
    FORMS60_APPSLIBS : APPCORE FNDSQF APPDAYPK APPFLDR GLCORE HR_GEN HR_SPEC ARXCOVER
    FORMS60_CATCHTERM : 1
    FORMS60_ERROR_DATETIME_FORMAT : [Unset]
    FORMS60_ERROR_DATE_FORMAT : [Unset]
    FORMS60_FORCE_MENU_MNEMONICS : 0
    FORMS60_MAPPING : http://austin.accanet.org:8002/OA_TEMP
    FORMS60_MMAP : [Unset]
    FORMS60_OUTPUT : /oracle/finapps/accausr1/accausr1comn/temp
    FORMS60_OUTPUT_DATETIME_FORMAT : [Unset]
    FORMS60_OUTPUT_DATE_FORMAT : [Unset]
    FORMS60_PATH : /oracle/finapps/accausr1/accausr1appl/au/11.5.0/resource:/oracle/finapps/accausr1/accausr1appl/au/11.5.0/resource/stub:/oracle/finapps/accausr1/accausr1appl/au/11.5.0/forms/US
    FORMS60_RESOURCE : [Unset]
    FORMS60_TIMEOUT : 5
    FORMS60_USER_DATETIME_FORMAT : DD-MON-RRRR HH24:MI:SS
    FORMS60_USER_DATE_FORMAT : DD-MON-RRRR
    FORMS60_USE_CBO : [Unset]
    GWYUID : APPLSYSPUB/PUB
    NLS_DATE_FORMAT : DD-MON-RR
    NLS_DATE_LANGUAGE : AMERICAN
    NLS_LANG : AMERICAN_UNITED KINGDOM.WE8ISO8859P1
    NLS_NUMERIC_CHARACTERS : .,
    ORACLE_HOME : /oracle/finapps/accausr1/accausr1ora/8063
    ORACLE_PATH : [Unset]
    ORA_NLS_CHARSET_CONVERSION : [Unset]
    TNS_ADMIN : /oracle/finapps/accausr1/accausr1ora/8063/network/admin/accausr1_austin
    TWO_TASK : accausr1
    Current Form
    Form Application : Receivables
    Form Name : ARXTWMAI
    Form Path : /oracle/finapps/accausr1/accausr1appl/ar/11.5.0/forms/US/ARXTWMAI.fmx
    Form Version : 11.5.200
    Form Last Modified : $Date: 2005/01/07 11:50 $
    Forms
    APPSTAND : 11.5.33
    ARXRWMAI : 11.5.21
    ARXRWMAI : 11.5.21
    ARXTWMAI : 11.5.200
    FNDSCSGN : 11.5.122
    Form Menus
    FNDMENU : 11.5.51
    Forms PL/SQL
    APPCORE : 11.5.151
    APPFLDR : 11.5.55
    ARXARWIN : 11.5.65
    ARXBOEIF : 11.5.2
    ARXCWUTL : 11.5.8
    ARXPLCOM : 11.5.68.15104.2
    ARXQRCIF : 11.5.2
    ARXRCTIF : 11.5.2
    ARXRWBAT : 11.5.96
    ARXRWMAI : 11.5.19
    ARXTWBAT : 11.5.11
    ARXTWMAF : 11.5.27
    ARXTWMAI : 11.5.302.15104.9
    ARXTWUTL : 11.5.39.15104.2
    FNDSQF : 11.5.111
    GHR : 11.5.174
    GLOBE : 11.5.38
    GMS : 11.5.230.90.7
    IGILUTIL2 : 11.5.97
    IGILUTIL : 11.5.29
    OPM : 11.5.33.115100.2
    PQH_GEN : 11.5.124
    PSA : 11.5.162
    PSAC : 11.5.16
    PSB : 11.5.24
    VERT : 11.5.6

  • XML in Oracle 9i (best method to return a xml file from a table query)

    Hello.
    What is the best method to query a table, or set of tables (that will return thousands of rows) using xml in oracle? (best performance)
    I'm currently using DBMS_XMLGen, is there a better method ?

    I think, if your talking about generating XML, that you should use XMLElement, XMLForest, etc. to create your XML.
    Lets assume that you base is relational data, then maybe the following great example will give you an idea how to do it : Re: Generate XML Schema from oracle tables
    As michaels pointed out (did you read the link/ URL given?), the general expectancy is that the packages will be less and less important. So also maintenance wise the XMLElement, etc way will be the best, also for the future, maintainable method.

  • Require help with Pivot table query in SQL Server 2008

    Hi,
    I have a query regarding converting columns to rows in SQL Server 2008. Please look at the table below. 
    I need the output to look something like this :
    The columns for the children can be dynamic or fixed ( max of 6 children) based on the Family_ID.  For Example: A family can have 1 child or more than 1 child.
    Not sure how to go about it. Would appreciate your help :)

    Looks like you need dynamic pivot on multiple columns. I have two articles on this topic, start from this one
    T-SQL:
    Dynamic Pivot on Multiple Columns
    It has reference to my other blog post.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Index was not used in join tables query

    I tested the following query on my dev 10g and the explain plan did not indicated to use the index of a(t$trec, t$tdoc)
    select a.somecolumns, b.othercolumns
    from a, b
    where (a.t$trec = 1 or a.t$trec = 4 and t$tdoc = ' ')
    and a.t$ttyp = b.t$ityp and a.t$ninv = b.t$idoc
    | Id  | Operation          | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |              |   613 | 81529 |   578   (1)| 00:00:07 |
    |*  1 |  HASH JOIN         |              |   613 | 81529 |   578   (1)| 00:00:07 |
    |   2 |   TABLE ACCESS FULL| B            |  2362 |   186K|    32   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| A            |  9988 |   507K|   545   (1)| 00:00:07 |
    -----------------------------------------------------------------------------------t$tdoc = ' ' is NO NULL column with a [space] value when no enter entered.
    So why system did not pick up the index?

    Because Oracle believes, for any number of possible reasons, that the use of the index would be less efficient.
    Force the index usage with a hint and see how Oracle reacts or run a 10053 trace and see why Oracle is making the decision it is making.
    Perhaps it is as impressed by a column holding a single space as a placeholder for null as I am. <g>

  • Partition Table Query taking Too Much Time

    I have created partition table and Created local partition index on a column whose datatype is DATE.
    Now when I Query table and use index column in the where clause It is scaning all the table (Full scan) . The quey is :
    Select * From mytable
    where to_char(transaction_date, 'DD-MON-YY') = '01-Aug-07';
    I have to use to_char function not to_date due to Front end application problem.

    Before we go too far with this, if you manually query with TO_DATE on the variable instead of TO_CHAR on the column, does the query actually use the index?
    The TO_CHAR on the column will definitely stop Oracle from using any index on the column. If the query will use the index if you TO_DATE the variable, as I see it, you have three options. First, fix the application problem that won't let you use TO_DATE from the application. Second, change the application to call a function returning a ref cursor, get the date string as a parameter to the function, and do the TO_DATE in the function.
    Third, you could consider creating a function-based index on TO_CHAR(transaction_date, 'dd-Mon-yy'). This would be the least desirable option, particularly if you would also be selecting records based on a range of transaction_dates, since it loses a lot of information that the optimizer could use in devising an efficient query plan. It could also change your results for a range scan.
    John

  • How to impreove performance of 5 tables query?

    Hello Experts,
    I am using 6 tables in my report.i want to display recores by AT NEW and Related stuff.
    Can i use following code for query and internal tables ?
    or Sujjest me Better code.
    to use loop within loop is not good idea.
    please sujjest me perfect and fast code !!
    Thanks in advance !!
    ( see my below code)
    TABLE DECLARATION ************************
    TABLES : VBAK,AFPO,AUFM,MAKT,KNA1,VBAP.
    INTERNAL TABLE DECLARATION *******************
    DATA :  BEGIN OF T1 OCCURS 0,
              AUART TYPE VBAK-AUART,
              NETWR TYPE VBAK-NETWR,
              KUNNR TYPE VBAK-KUNNR,
              VBELN TYPE VBAK-VBELN,
              AUDAT TYPE VBAK-AUDAT,
            END OF T1.
    DATA :  BEGIN OF T2 OCCURS 0,
             NETWR TYPE VBAP-NETWR,
             POSNR TYPE VBAP-POSNR,
            END OF T2.
    DATA : BEGIN OF T3 OCCURS 0,
            AUFNR TYPE AFPO-AUFNR,
            KDPOS TYPE AFPO-KDPOS,
            KDAUF TYPE AFPO-KDAUF,
            PSMNG TYPE AFPO-PSMNG,
            WEMNG TYPE AFPO-WEMNG,
           END OF T3.
    DATA : BEGIN OF T4 OCCURS 0,
             DMBTR TYPE AUFM-DMBTR,
             MATNR TYPE AUFM-MATNR,
             ELIKZ TYPE AUFM-ELIKZ,
           END OF T4.
    DATA : BEGIN OF T5 OCCURS 0,
            NAME1 TYPE KNA1-NAME1,
           END OF T5.
    DATA : BEGIN OF T6 OCCURS 0,
            MAKTX TYPE MAKT-MAKTX,
           END OF T6.
    FREE T1.
    SELECT VBELN NETWR AUART AUDAT KUNNR FROM VBAK INTO CORRESPONDING FIELDS
    OF TABLE T1 WHERE  AUART IN AUART AND  VBELN IN VBELN.
    FREE T2.
    SELECT  NETWR POSNR FROM VBAP INTO CORRESPONDING FIELDS OF TABLE T2
    FOR ALL ENTRIES IN T1 WHERE  VBELN = T1-VBELN .
    FREE T3.
    SELECT AUFNR PSMNG WEMNG KDPOS FROM AFPO INTO CORRESPONDING FIELDS OF
    TABLE T3 FOR ALL ENTRIES IN T1 WHERE KDAUF =  T1-VBELN .
    FREE T4.
    SELECT DMBTR MATNR ELIKZ FROM AUFM INTO CORRESPONDING FIELDS OF
    TABLE T4 FOR ALL ENTRIES IN T3 WHERE AUFNR = T3-AUFNR.
    FREE T6.
    SELECT  MAKTX FROM MAKT INTO CORRESPONDING FIELDS OF TABLE T6 WHERE
    MATNR = T4-MATNR.
    FREE T5.
    SELECT NAME1 FROM KNA1 INTO CORRESPONDING FIELDS OF TABLE T5 WHERE
    KUNNR =  T1-KUNNR.

    hi,
    first avoid <b>into corresponding fields</b> statement intead of this u can define <b>into table</b>,
    if u r using for all entries in, then check for all entries internal table first like this,
    if  is T1[] not initial.
    "then u can write select statement.
    endif.
    reward points if useful,
    regards,
    seshu.

  • Derived table query size limit 65KB?

    Hi.  When in Edit Derived Table, if I paste a query larger than about 65KB, the end of the query will be cut off.  Then I must create multiple Derived Tables.  Has anyone else experienced this?  Do you find the limit to be about 65KB?
    Thanks,
    Mike

    Most databases cut off at that limit, so it's not really a Designer limitation.
    Frankly, if you have a derived table with 65K of SQL you need to fix your ETL.

  • Data pump using table query

    I am trying to perform a data pump export on a table using a query within a parfile and I am getting some odd behaviour. The database version is 10.2.0.4.3 and the OS is AIX 5.3. The query looks like this.
    QUERY="POSDECLARATIONQUEUE:where SESSIONID in (select 'B.SESSIONID' from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C where 'B.SESSIONID' = 'C.ID' and 'C.ACCOUNTID' = 'A.ID' and 'A.SITE' = '10252')"
    This works but gets 0 rows. If I run the query against the instance in an SQLPlus session as below then I get 0 rows returned.
    select * from POSDECLARATIONQUEUE where SESSIONID in (select 'B.SESSIONID' from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C where 'B.SESSIONID' = 'C.ID' AND 'C.ACCOUNTID' = 'A.ID' and 'A.SITE' = '10252');
    If I take out the single quotes from around the columns within the query against the instance within SQLPlus, I get over 2000 rows returned.
    SQL> select count(*) from POSDECLARATIONQUEUE where SESSIONID in (select B.SESSIONID from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C where B.SESSIONID = C.ID and C.ACCOUNTID = A.ID and A.SITE = 10252);
    COUNT(*)
    2098
    If I remove the single quotes from the parfile query then I get the following error within the data pump export.
    UDE-00014: invalid value for parameter, 'schemas'.
    The SCHEMAS option is not specified within the parfile and the TABLES option only specifies the table POSDECLARATIONQUEUE.
    Can someone assist with this, I just can't seem to be able to get the syntax right for it to work within data pump.
    Kind Regards.
    Graeme.
    Edited by: user12219844 on Apr 14, 2010 3:34 AM

    It looks like your query might be a little wrong:
    This is what you have:
    QUERY="POSDECLARATIONQUEUE:where SESSIONID in (select 'B.SESSIONID' from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C where 'B.SESSIONID' = 'C.ID' and 'C.ACCOUNTID' = 'A.ID' and 'A.SITE' = '10252')"
    This is what I would have thought it should look like:
    QUERY=POSDECLARATIONQUEUE:"where SESSIONID in (select B.SESSIONID from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C where B.SESSIONID = C.ID and C.ACCOUNTID = A.ID and A.SITE = 10252)"
    You want double " arount the complete query, and you don't need the single ' around all of the =. The single ' are treating those values as strings and it says
    'B.SESSIONID' = 'C.ID'
    is the string B.SESSIONID equal to the string C.ID
    In your query that you used in sql was
    B.SESSIONID = C.ID
    which says is the value stored B.SESSIONID equal to the value stored at C.ID
    Which is what you want.
    Dean

  • Materialized views on prebuilt tables - query rewrite

    Hi Everyone,
    I am currently counting on implementing the query rewrite functionality via materialized views to leverage existing aggregated tables.
    Goal*: to use aggregate-awareness for our queries
    How*: by creating views on existing aggregates loaded via ETL (+CREATE MATERIALIZED VIEW xxx on ON PREBUILT TABLE ENABLE QUERY REWRITE+)
    Advantage*: leverage oracle functionalities + render logical model simpler (no aggregates)
    Disadvantage*: existing ETL's need to be written as SQL in view creation statement --> aggregation rule exists twice (once on db, once in ETL)
    Issue*: Certain ETL's are quite complex via lookups, functions, ... --> might create overy complex SQLs in view creation statements
    My question: is there a way around the issue described? (I'm assuming the SQL in the view creation is necessary for oracle to know when an aggregate can be used)
    Best practices & shared experiences are welcome as well of course
    Kind regards,
    Peter

    streefpo wrote:
    I'm still in the process of testing, but the drops should not be necessary.
    Remember: The materialized view is nothing but a definition - the table itself continues to exist as before.
    So as long as the definition doesn't change (added column, changed calculation, ...), the materialized view doesn't need to be re-created. (as the data is not maintained by Oracle)Thanks for reminding me but if you find a documented approach I will be waiting because this was the basis of my argument from the beginning.
    SQL> select * from v$version ;
    BANNER                                                                                                                                                                    
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production                                                                                                    
    PL/SQL Release 11.2.0.1.0 - Production                                                                                                                                    
    CORE     11.2.0.1.0     Production                                                                                                                                                
    TNS for Linux: Version 11.2.0.1.0 - Production                                                                                                                            
    NLSRTL Version 11.2.0.1.0 - Production                                                                                                                                    
    SQL> desc employees
    Name                                                                                            Null?    Type
    EMPLOYEE_ID                                                                                     NOT NULL NUMBER(6)
    FIRST_NAME                                                                                               VARCHAR2(20)
    LAST_NAME                                                                                       NOT NULL VARCHAR2(25)
    EMAIL                                                                                           NOT NULL VARCHAR2(25)
    PHONE_NUMBER                                                                                             VARCHAR2(20)
    HIRE_DATE                                                                                       NOT NULL DATE
    JOB_ID                                                                                          NOT NULL VARCHAR2(10)
    SALARY                                                                                                   NUMBER(8,2)
    COMMISSION_PCT                                                                                           NUMBER(2,2)
    MANAGER_ID                                                                                               NUMBER(6)
    DEPARTMENT_ID                                                                                            NUMBER(4)
    SQL> select count(*) from employees ;
      COUNT(*)                                                                                                                                                                
           107                                                                                                                                                                
    SQL> create table mv_table nologging as select department_id, sum(salary) as totalsal from employees group by department_id ;
    Table created.
    SQL> desc mv_table
    Name                                                                                            Null?    Type
    DEPARTMENT_ID                                                                                            NUMBER(4)
    TOTALSAL                                                                                                 NUMBER
    SQL> select count(*) from mv_table ;
      COUNT(*)                                                                                                                                                                
            12                                                                                                                                                                
    SQL> create materialized view mv_table on prebuilt table with reduced precision enable query rewrite as select department_id, sum(salary) as totalsal from employees group by department_id ;
    Materialized view created.
    SQL> select count(*) from mv_table ;
      COUNT(*)                                                                                                                                                                
            12                                                                                                                                                                
    SQL> select object_name, object_type from user_objects where object_name = 'MV_TABLE' ;
    OBJECT_NAME                                                                                                                      OBJECT_TYPE                              
    MV_TABLE                                                                                                                         TABLE                                    
    MV_TABLE                                                                                                                         MATERIALIZED VIEW                        
    SQL> insert into mv_table values (999, 100) ;
    insert into mv_table values (999, 100)
    ERROR at line 1:
    ORA-01732: data manipulation operation not legal on this view
    SQL> update mv_table set totalsal = totalsal * 1.1 where department_id = 10 ;
    update mv_table set totalsal = totalsal * 1.1 where department_id = 10
    ERROR at line 1:
    ORA-01732: data manipulation operation not legal on this view
    SQL> delete from mv_table where totalsal <= 10000 ;
    delete from mv_table where totalsal <= 10000
    ERROR at line 1:
    ORA-01732: data manipulation operation not legal on this view While investigating for this thread I actually made my own question redundant as the answer became gradually clear:
    When using complex ETL's, I just need to make sure the complexity is located in the ETL loading the detailed table, not the aggregate
    I'll try to clarify through an example:
    - A detailed Table DET_SALES exists with Sales per Day, Store & Product
    - An aggregated table AGG_SALES_MM exists with Sales, SalesStore per Month, Store & Product
    - An ETL exists to load AGG_SALES_MM where Sales = SUM(Sales) & SalesStore = (SUM(Sales) Across Store)
    --> i.e. the SalesStore measure will be derived out of a lookup
    - A (Prebuilt) Materialized View will exist with the same column definitions as the ETL
    --> to allow query-rewrite to know when to access the table
    My concern was how to include the SalesStore in the materialized view definition (--> complex SQL!)
    --> I should actually include SalesStore in the DET_SALES table, thus:
    - including the 'Across Store' function in the detailed ETL
    - rendering my Aggregation ETL into a simple GROUP BY
    - rendering my materialized view definition into a simple GROUP BY as wellNot sure how close your example is to your actual problem. Also don't know if you are doing an incremental/complete data load and the data volume.
    But the "SalesStore = (SUM(Sales) Across Store)" can be derived from the aggregated MV using analytical function. One can just create a normal view on top of MV for querying. It is hard to believe that aggregating in detail table during ETL load is the best approach but what do I know?

  • Can't join tables.query dependency not found "" in EUL

    hi ALL,
    i created one report in disco 3.1.38 and its' running fine but after storing it in database and then again trying to open it from database it gives me error "can't join tables."name of query folder" dependency not found "" in EUL"
    if any one has come across such problem and has solution for it ..please reply back.
    thanks in anticipation
    manish

    Manish,
    I have not run into this error before and maybe one of the oracle consultants could answer this better. But I here it goes. I would first try a refresh on the folders that the report in question is using. Is it possible that the under lining tables have changed? Do you have another copy of the same report outside of the database and does it still work?
    Christopher

  • Multiple Table Query

    Hey All!
    It's been a while since I last posted a message in these
    forums. But it looks like I need your help again.
    So here is the problem:
    I have to create a list of the companies' projects, yet to
    compile the complete list I have to query 4 tables, with a one to
    many and many to many relation ship.
    Here is what I have so far.
    the main table is the projects table, hence I start with
    that. Right now I can query the table, plus the companies table
    that each project is linked to. Also, each project may have a link
    to multiple companies, so I normalized the data by creating a
    companies link table:
    SELECT projects.project_id, project.project_name,
    compproj_link.company_id
    /* I only get the company id and convert it to an actual
    name when I output */
    FROM projects LEFT JOIN compproj_link ON
    compproj_link.project_id = projects.project_id
    /* here I also filter to get only active projects */
    WHERE project.status in(1,2)
    /* I group by the project id since there might be several
    companies linked to a specific project */
    GROUP BY projects.project_id, project.project_name,
    compproj_link.company_id
    ORDER BY project_name
    This works perfectly fine when I output with the group
    attribute, but now I have to link another table... called the
    airdates. The reason is that I want to order my list by the
    contents of this table (which may or may not be present)...
    this airdates that is linked to my projects is structured
    like so:
    airdates
    airdates_id - auto num
    project_id - the project it is linked to hence could be
    linked to many projects
    then there are the actual air dates
    airdateslist
    airdateslist_id auto num
    airdates_id - since for each air date record could be
    multiple dates
    airdate_date - date field
    airdate_backupdate - another date field
    airdate_current - this is a yes/no, and specifies whether
    this date is most current.
    Hence, by doing two more LEFT OUTER JOINS in my main query
    would work fine, BUT I need to get the most current date from the
    airdateslist that is set for a particular project. and when I do
    this I get no records because as of yet, no project has an airdate
    that is current.
    So my question is if I can somehow add those airdates tables
    to my main query, and be able to sort by the current date, IF it is
    present, and if not, still have all my projects displayed?
    PS. I think I have confused myself even more when writing
    this out, so if you have any questions please write. Thank you in
    advance!
    Vega...

    First, this:
    * I group by the project id since there might be several
    companies linked to a specific project */
    GROUP BY projects.project_id, project.project_name,
    compproj_link.company_id
    doesn't accomplish anything.
    Second, when I read what you posted about the two airdates
    tables, I'm not convinced that the table structure achieves what
    the comments and fieldnames describe as the objective.
    You say none of your projects have a current airdate. Do
    these tables have any data at all? If not, it's going to be hard to
    write a query when you can't ensure you got the correct
    results.

  • Sql table query,

    Hi
    I am new to, sql queries. I have two tables say table A, table B. Table A has column 1, column2, ......and same for table B. They can have any number of rows.
    I will take table B and will go row by row, compare the combination of column1, 2, 3 with column1, 2, 3 of Table A. If corresponding combination is not found in Table A, I want to populate the corresponding table B value.
    Please help me in generating SQL Query in MS Access
    Thanks

    If corresponding combination is not found in Table A, I want to populate the corresponding table B value. That doesn't make any sense. Define "populate" and "corresponding table b value".
    Do you perhaps mean
    Update B
    set does_tableA_value_exist = 'NO'
    where not exists (
      select 1
      from A
      where a.col1=b.col1
      and a.col2 = b.col2
      and a.col3 = b.col3)

Maybe you are looking for