Where Clause in the block not executed

I have this in the where clause in my block, I want to exclude managers. I have added a flag column IS_MGR to prs_employee_profile and I added this line to query(where IS_MGR <> 2) “ value 2 for true” and but it doesn’t work. prs_amp_profile is the emp table and this block is based on atn_emp_week , emp_id is a foreign key. all the conditions are working except for the one i added and it is still bring the records for the managers. Any body can tell me why the condition is not being forced.
Original Where Clause
1=1 AND (emp_id in (select id from prs_employee_profile where
dpt_id in (select dept_id from prs_user_dept_priv where user_id = :global.usr)
and emp_id = decode(:global.emp_user_flag, 1, id, :global.emp_id)
and emp_sts_id in (select id from prs_employment_status where active_flag <> 0))
OR :GLOBAL.GRP='ATN_ADM')
After adding
1=1 AND (emp_id in (select id from prs_employee_profile where IS_MGR <>2
And dpt_id in (select dept_id from prs_user_dept_priv where user_id = :global.usr)
and emp_id = decode(:global.emp_user_flag, 1, id, :global.emp_id)
and emp_sts_id in (select id from prs_employment_status where active_flag <> 0))
OR :GLOBAL.GRP='ATN_ADM')

     1=1
AND (    emp_id in (select id
                      from prs_employee_profile
                     where IS_MGR!=2
                       And dpt_id in (select dept_id
                                        from prs_user_dept_priv
                                       where user_id = :global.usr
                       and emp_id = decode(:global.emp_user_flag, 1, id, :global.emp_id)
                       and emp_sts_id in (select id
                                            from prs_employment_status
                                           where active_flag!=0)
      OR :GLOBAL.GRP='ATN_ADM'
    )I don't know your table-structures, one possibility would be that :GLOBAL.GRP is ATN_ADM at testing for this overwrites the other conditions.
I would try to check the condition in sql*plus, apply it to the block when its working.

Similar Messages

  • Where Clause in the Forms doesn't work

    Hi,
    I am trying to execute a query in base table block. The block property 'Query allowed' is TRUE and WHere clause is null;
    I used 'SET_BLOCK_PROPERTY' and set the where clause. Did a GO_BLOCK and EXECUTE_QUERY;
    The block brings all records as if there is no where clause. TO make sure I put up a message 'GET_BLOCK_PROPERTY' to see the where clause. It showed correct where clause.
    null

    Setting the where clause the way you did usually works, and it worked fine for me several times.
    Yet, a couple of days ago I ran into something that defies my logic:
    1) when using the "=" operator, it fetched me several records that satisfied the condition
    2) when using the "<=" or ">=" operator it fetched only one of the records that satisfied the condition: the one that is strictly equal.
    I tried using the pre-query trigger, but to no avail.
    I'm looking forward for your succes.
    null

  • Plsql block not executing

    Hi ,
    The Below block not executing,please correct this block
    declare
    v_sql varchar2(1024);
    begin
     for c in (
       SELECT TABLE_NAME FROM USER_TABLES WHERE TABLE_NAME LIKE 'B2M_%' and PARTITIONED='YES';
    loop
      v_sql:='DELETE FROM '||'' || c.TABLE_NAME || ''||'WHERE SUB_SUBSIDIARYCODE=&1' ||''||'and TO_CHAR(DATE_FROM_PK, 'DD/MM/YYYY')=&2';
      execute immediate v_sql;
      end loop;
    end;
    thanks,
    tmadugula

    It would be helpful if you provided the actual errors and posted the code using \ tags so it was legible.
    Please see {thread:id=2174552}
    As far as your code, you don't need the semi-colon in the SELECT statement. Second, you should consider using bind variables in your code because it will prevent SQL injection attacks as well as make it easier to read/maintain your code. Also, instead of converting the DATE_FROM_PK to a character data type, consider converting your input value to a DATE data type.
    This should work (not tested), in versions 10.2 and up:DECLARE
    v_sql varchar2(1024);
    v_date_filter VARCHAR2(10);
    v_subsidiary_code_filter VARCHAR2(10); -- Correct this data type if incorrect.
    BEGIN
    v_subsidiary_code_filter := q'[&1]';
    v_date_filter := q'[&2]';
    FOR c IN
    SELECT table_name
    FROM user_tables
    WHERE table_name LIKE 'B2M_%'
    AND partitioned = 'YES'
    LOOP
    v_sql:='DELETE FROM '|| DBMS_ASSERT.SQL_OBJECT_NAME(c.TABLE_NAME) || ' WHERE SUB_SUBSIDIARYCODE = :1 ' || ' AND TRUNC(DATE_FROM_PK) = TO_DATE(:2,''MM/DD/YYYY'')';
    EXECUTE IMMEDIATE v_sql USING v_subsidiary_code_filter, v_date_filter;
    END LOOP;
    END;Edited by: Centinul on Mar 11, 2011 8:30 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Creating a where clause in the LOV query box

    Hi guys is any able to help me with this one
    i have a page in my app where there is a LOV drop down now the values for this drop down comes from a table that looks like this
    users_for _form_TBL
    E_MAIL
    Vendor
    [email protected]
    oracle
    [email protected]
    sap
    [email protected]
    IBM
    [email protected]
    Oracle
    [email protected]
    intergraph
    So my syntax for the LOV i mentioned looks like this
    select VENDOR as display_value, VENDOR as return_value
      from form_user_tab where E_MAIL = :APP_USER
    order by 1 ;
    so if [email protected] logs onto the app and has to make a selection on the LOV it would only display the vendors relative to his E_MAIL like oracle ,sap, IBM then he hits the submit button on the page then the vendor that he selected is inserted into another table .What i did on the insert table was create a trigger that after a vendor is inserted the trigger inserts a 1 into a column called assessed .
    What i did after this was add a select in the where clause of the LOV so that it would check in the insert table if that vendor had been chosen before and not display it again to be selected  my syntax the second time around in the SQL query box was
    select VENDOR as display_value, VENDOR as return_value
      from users_for _form_TBL where E_MAIL = :APP_USER
    and (select 'vendor' , 'ASSESSD' from inserted _tbl_imp is null);
    order by 1 ;
    But im getting an error any ideas guys .Thank you

    Hay man thanks for that info on the Tom Kyte Blog 
    --(the code you gave me )
    select 
        u.vendor display_value 
      , u.vendor return_value
    from 
        users_for_form_tbl u 
    where 
        u.e_mail = :app_user 
    and not exists (select null from inserted_tbl_imp i where u.vendor = i.vendor) 
    order by 
        u.vendor 
    --(After the error i tried )Then when i got the error i try'd using 'or exists'  like this
    --(code)
    where 
        u.e_mail = :app_user 
    and not exists (select null from inserted_tbl_imp i where u.vendor = i.vendor) 
                          or exists (select null from inserted_tbl_imp i where u.vendor = i.vendor)
    order by 
        u.vendor 
    But the all the vendors that where in the  same in the insert table came up in the drop down list  example is oracle was assessed before then only oracle would appear in the drop down list  and if it was assessed 3 times it would come up 3 times
    --Then i tried to select where 'Assessed' is null   ('Assessed' is a column in the insert table  which i created a trigger on to insert 1 in the 'ASSESSED' column  when a vendor is begin assessed  )  
    --(code)
    where 
        u.e_mail = :app_user 
    and not exists (select 'ASSESSED' from inserted_tbl_imp i where 'ASSESSED' is null ) 
    order by 
        u.vendor 
    This try didnt return any vendors at all
    --Then i tried distinct
    --(code)
    where 
        u.e_mail = :app_user 
    and not exists (select distinct 'VENDOR',  from inserted_tbl_imp i where u.vendor = i.vendor) 
    order by 
        u.vendor 
    This gave me a LOV ERROR
    This is what i have tried so far there where others syntax's i tried last night as well  but most of them came back as errors . Thanks again for you time and help  fac586  

  • Where clause in Data Block

    I'm running Forms 6i client/server.
    I have defined a where clause in the Property Palette for a Data Block.
    What I like to do is to extend the where clause with a subquery, but
    how can this be done? I mean, should I put the code in a trigger, which trigger?
    Regards
    Roar

    simple where clause with sub_query
    My block has name is dc_gmod. In the where pallete I put the text (and the all is work good!!!):
    exists
    select 1 from ttt.xxxxx_table v
    where (dc_gmod.cd_gmod = v.cd_gmod)
    and
    (instr(:fst.tmp_nm,cd_place,1) > 0
    or
    cd_place IN
    (select U_UNIT from ttt.xxxxxxxxx_tabe
    where RG_U = :QA.RG_UNIT_RUN
    AND SID = :QA.SID
    AND SERIAL# = :QA.SERIAL
    1.The dc_gmod.cd_gmod - is full name my block_name and item_name.
    2. The ttt.xxxxx_table is full name of my table what is source for block dc_gmod
    3. The cd_place is ITEM of BLOCK dc_gmod

  • How to set Where clause in the View Object of the MessageChoice ?

    Hi,
    How to set Where clause in the View Object of the
    MessageChoice ?
    Example:
    <bc4j:rootAppModuleDef name="EdEscolaCampusView1AppModule"
    definition="ed00050.Ed00050Module"
    releaseMode="stateful" >
    <bc4j:viewObjectDef name="EdEscolaCampusView1" >
    <bc4j:rowDef name="CreateEdEscolaCampusView1" autoCreate="true" >
    <bc4j:propertyKey name="key" />
    </bc4j:rowDef>
    </bc4j:viewObjectDef>
    <bc4j:viewObjectDef name="ListaTipLocalView1"
    rangeSize="9999">
    </bc4j:viewObjectDef>
    </bc4j:rootAppModuleDef>
    </bc4j:registryDef>
    messageChoice declaration:
    <bc4j:messageChoice name="SeqTipoLocalCampus"
    attrName="SeqTipoLocalCampus"
    prompt="Local do Campus">
    <contents>
    <bc4j:optionList attrName="SeqTipoBasico"
    textAttrName="NomTipoBasico"
    voName="ListaTipLocalView1"/>
    </contents>
    </bc4j:messageChoice>
    I would like set where clause of ViewObject, with dinamic parameters (using attribute1 = :1), before populate messageChoice.
    thanks...
    Danilo

    Hi Andy,
    I try set a where clause using the message:
    Set where Clause parameter using UIX , but my UIX Page have 2 messageChoice's of different ViewObject's, then I need implement this Java Class:
    //Nome da Package da Tela Detail
    package br.com.siadem.siaed.ed00050;
    // Importa as Bibliotecas necessárias
    import oracle.jbo.ViewObject;
    import oracle.jbo.ApplicationModule;
    import oracle.jbo.client.Configuration;
    import oracle.cabo.servlet.BajaContext;
    import oracle.cabo.servlet.Page;
    import oracle.cabo.servlet.event.PageEvent;
    import oracle.cabo.servlet.event.EventResult;
    import oracle.cabo.data.jbo.servlet.bind.*;
    import oracle.cabo.ui.data.BoundValue;
    import oracle.cabo.ui.data.DataBoundValue;
    import javax.servlet.http.HttpServletRequest;
    import br.com.siadem.siaed.util.*;
    import javax.servlet.http.Cookie;
    import oracle.cabo.data.jbo.def.NestedAppModuleDef;
    import oracle.cabo.data.jbo.def.ViewObjectDef;
    import oracle.cabo.data.jbo.def.AppModuleDef;
    // Classe que configura os parametros para a execução da Query,
    // utilizando variáveis de Sessao
    public class FunPreQueryLista
    public static EventResult FunConfiguraQuery(BajaContext context, Page page, PageEvent event) throws Throwable
    // TrataDadosSessao - Classe utilizada para retornar os valores das variáveis de sessão genéricas
    // Ex: CodCliente, CodMunicipio etc...
    TrataDadosSessao varDadosSessao = new TrataDadosSessao();
    // 1o. Parametro Configurado - Através da classe TrataDadosSessao, utilizando um método Get
    // <alterar>
    String valor1 = varDadosSessao.getCodCliente();
    String valor2 = varDadosSessao.getCodMunicipio();
    //Cria o objeto que retorna o ApplicationModule
    ApplicationModule am = ServletBindingUtils.getApplicationModule(context);
    // Início das Configurações da Query da Lista
    //Cria o objeto que retorna o view object da lista desejada
    //alterar
    ViewObject TipoLocal = am.findViewObject("ListaTipoLocalView1");
    //Configuração dos parametros definidos na query do view Object
    //alterar
    TipoLocal.setWhereClauseParam(0,valor1);
    TipoLocal.setWhereClauseParam(1,valor2);
    // Executa a Query
    TipoLocal.executeQuery();
    // Fim das Configurações da Query da Lista
    // Início das Configurações da Query da Lista
    //Cria o objeto que retorna o view object da lista desejada
    //alterar
    ViewObject TipoDestLixo = am.findViewObject("ListaDestinoLixoView1");
    //Configuração dos parametros definidos na query do view Object
    //alterar
    TipoDestLixo.setWhereClauseParam(0,valor1);
    TipoDestLixo.setWhereClauseParam(1,valor2);
    // Executa a Query
    TipoDestLixo.executeQuery();
    // Fim das Configurações da Query da Lista
    // Retorna o Resultado para a Página
    return new EventResult(page);
    The code works very well...
    And, I'm sorry for my two repost's in UIX Forum about this in a few time.
    Thank very much...
    Danilo

  • Resetting the "DO not Execute " in closed work orders.

    Hi Guys,
    I have a scenario where I have to open old and closed work orders to make some changes and then save it. I am facing problem wit some work orders which were closed by using the "do not Execute" option, is there a way to reverse it so that I can update the work orders and then closed them again?
    Thanks and regards
    Anoop Sharma

    Reference [Thread|changing of system status do not execute]
    -S.N

  • How can I pass multiple condition in where clause with the join table?

    Hi:
    I need to collect several inputs at run time, and query the record according to the input.
    How can I pass multiple conditions in where clause with the join table?
    Thanks in advance for any help.
    Regards,
    TD

    If you are using SQL-Plus or Reports you can use lexical parameters like:
    SELECT * FROM emp &condition;
    When you run the query it will ask for value of condition and you can enter what every you want. Here is a really fun query:
    SELECT &columns FROM &tables &condition;
    But if you are using Forms. Then you have to change the condition by SET_BLOCK_PROPERTY.
    Best of luck!

  • Where to check the  "SAP Notes"  -- Is it in search only or some where ?

    Hi All
       I am having doubt : where to search the SAP NOTES ?
      Is it in :go to -
    > sdn.sap.com
                   In search -
    > Enter the given code number ( Ex: 801868)
      It is again giving so many links based on this but i am not getting the exact 
      answer   ...!!!!1
      Help me on : " how to search the Exact SAP Note number "
    thanks
    kiran LVS

    check in <a href="http://service.sap.com">http://service.sap.com</a> or check directly in <a href="https://websmp101.sap-ag.de/notes">https://websmp101.sap-ag.de/notes</a>
    Ps: Award points to helpful replies.
    Message was edited by:
            Prabhu  S

  • Function Within a default where clause on a block

    Hi
    Within a forms 6 form I have a data base block I wish to amend the where clause depending on cetain search criteria. To do this I have created a database function to include in the where clause which if I execute using PL/SQL Develops returns the required results, however if I use a set_block_property default where and try to use the function if seems to be ignored and returns all rows not just the ones matching the function value, is there a resrtiction in the default where?
    Any help would be great
    Thanks
    Tina

    Make sure that you are not putting the "and" at the beginning of the query unnecssarily.
    If "lv_def_where" is null then you would not begin your query with "and"
    IF :control.t_primary_whs IS NOT NULL THEN
    . IF lv_def_where IS NULL
    . THEN
    . lv_def_where := lv_def_where ||'sce.find_primary_warehouse ('''||:customers_address.owner_code||''','''||:customers_address.owner_sub_code||''' ,'''||:customers_address.post_code||''',''CP'')= '''||:control.t_primary_whs||'''';
    . ELSE
    . lv_def_where := lv_def_where ||' and sce.find_primary_warehouse('''||:customers_address.owner_code||''','''||:customers_address.owner_sub_code||''' ,'''||:customers_address.post_code||''',''CP'')= '''||:control.t_primary_whs||'''';
    . END IF;
    END IF;
    Is that the case?

  • Variable in where clause of the logical table

    Hi,
    is it possible to define a variable in "where" clause of rpd's physical table (table type - select)? If yes, pls elaborate the steps including how to refresh it with every end user's request?
    Thanks and Regards,
    Igor
    P.S.
    If not, is there any workaround?

    Nico
    thanks, but I am afraid that is not my case. I need to refresh variable value interactively with every query by a dashboard prompt. To illustrate my need just imagine a recursive SQL (defined as a view/logical table in rpd):
    SELECT ....
    FROM ...
    WHERE ...
    START WITH .... columnA=variable1
    CONNECT BY PRIOR .... and columnB=varariable2;
    or
    SELECT c1,c2,c3,c4 from tabA where c1='A' and c2=variable1
    union
    SELECT c1,c2,c3,c4 from tabA where c1='A" and c2='D' and c1 NOT IN ( SELECT c1 FROM tabA where c1='A' and c2=variable1 );
    So, what I want to do is to pass value(s) to my variable(s) every time when respective select (view) is executed. I see above selects are not typical ones the OBI EE is intended for but nevertheless I wonder if such kind of reports are possible to do in OBI EE.
    Thanks and Regards,
    Igor

  • Performance hit using "where" clause in the query

    Hi All,
    I am facing a huge performance hit in the java code when using "where" clause in queries. Following are the details:
    1. SELECT * FROM Employee
    2. SELECT * FROM Employee where employeeid in (26,200,330,571,618,945)
    There is no difference in Query Execution Time for both queries.
    Business Logic Time is huge in second case as compared to first one (ratio - 1:20).
    Rows returned are more in first case as compared to second case.(ratio - 1:4)
    Business Logic is same for both the cases where I iterate through the ResultSet, get the objects and set them in a data structure.
    Does anybody know the reason of unexpected time difference for the business logic in the second case?

    Since you're mentioning clustering your index, I'll assume you are using Oracle. Knowing what database you are using makes it a lot easier to suggest things.
    Since you are using Oracle, you can get the database to tell you what execution plan it is using for each of the 2 SQL statements, and figure out why they have similar times (if they do).
    First, you need to be able to run SQL*Plus; that comes as part of a standard database installation and as part of the Oracle client installation - getting it set up and running is outside the scope of this forum.
    Second, you may need your DBA to enable autotracing, if it's not already:
    http://asktom.oracle.com/~tkyte/article1/autotrace.html
    http://www.samoratech.com/tips/swenableautotrace.htm
    Once it's all set up, you can log in to your database using sql*plus, issue "SET AUTOTRACE ON", issue queries and get execution plan information back.
    For example:
    SQL> set autotrace on
    SQL> select count(*) from it.ticket where ticket_number between 10 and 20;
      COUNT(*)
            11
    Execution Plan
    Plan hash value: 2983758974
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            |     1 |     4 |     1   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE   |            |     1 |     4 |            |          |
    |*  2 |   INDEX RANGE SCAN| TICKET_N10 |    12 |    48 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("TICKET_NUMBER">=10 AND "TICKET_NUMBER"<=20)
    Statistics
              0  recursive calls
              0  db block gets
              1  consistent gets
              0  physical reads
              0  redo size
            515  bytes sent via SQL*Net to client
            469  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL> This tells me that this query used an INDEX RANGE SCAN on index TICKET_N1; the query can't do much better than that logically... In fact, the statistic "1 consistent gets" tells me that Oracle had to examine only one data block to get the answer, also can't do better than that. the statistic, "0 physical reads" tells me that the 1 data block used was already cached in Oracle's memory.
    the above is from Oracle 10g; autotrace is available back to at least 8i, but they've been adding information to the output with each release.
    If you have questions about sql_plus, check the forums at asktom.oracle.com or http://forums.oracle.com/forums/category.jspa?categoryID=18
    since sql*plus is not a JDBC thing...
    Oh, and sql*plus can also give you easier access to timing information, with "set timing on".

  • How to pass the parameter in the where clause of the select statement

    Hi All,
    Iam getting one of the value from the Input otd and using this value i need to query one of the tables in oracle database and selected the table using the oracle eway otd like shown below .
    otdRISKBLOCK_1.getRISKBLOCK().select() .
    where clause in side the select takes a string parameter as Iam getting the string parameter from the input otd and passing this to where clause by creating a string literal after deployment it is giving an error saying "ORA-00920: invalid relational operator".
    can any one throw some input on this .
    Thanks in Advance
    Srikanth

    You will see this error if the search condition was entered with an invalid or missing relational operator.
    You need to include a valid relational operator such as
      =, !=, ^=, <>, >, <, >=, <=, ALL, ANY, [NOT] BETWEEN, EXISTS, [NOT] IN, IS [NOT] NULL, or [NOT] LIKE in the condition. in the sql statement.
    Can you throw some more light on how are you designing your project?

  • Outer join with where clause in the universe

    Hi,
    I have two tables such as:
    Patient Table (P)                          Territory Table (T)
    P. Alignment ID --------------------------   T.Alignment ID
    P. Patient ID                                    T. Region
    Two tables are joined on alignment ID, follow is how the data looks like
    When i run the query only on Patient Table  i get the following
    e.g.
    Select P.Patient ID, P.Alignment ID
    from Patient Table (P)
    Where P.Data_date=P.Latest data date
    ----Note that there is a Where clause here always & i get the following result
    P.Patient ID         P.Alignment ID      
        1                            1a
        2                             2a
        3                            3a
        4                            Null
        5                            Null
    Now when i join two tables on Alignment ID
    e.g.
    Select P.Patient ID, P.Alignment ID,T.Region
    from Patient Table (P)
    LEFT OUTER  JOIN Territory Table (T)
    ON P. Alignment ID =  T.Alignment ID
    Where P.Data_date=P.Latest data date
    AND T.Data_date=T.Latest data date
    Following is the result:
    P.Patient ID         P.Alignment ID      
        1                            1a
        2                            2a
        3                            3a
    Even with the left outer join it is not brining in the Null values , it seems that because of the WHERE clause the LEFT OUTER is working as a INNER join.
    How can i get the Null rows with my join to the territory table ?
    Please Advise,
    Thanks,
    Sheikh

    its not letting me atatched the excel extract but the data is simple as i shown above e.g.
    Patient Table (P)                          Territory Table (T)
    P. Alignment ID --------------------------   T.Alignment ID
    P. Patient ID                                    T. Region
    Two tables are joined on alignment ID, follow is how the data looks like
    When i run the query only on Patient Table  i get the following
    e.g.
    Select P.Patient ID, P.Alignment ID
    from Patient Table (P)
    Where P.Data_date='01-OCT-2014'
    ----Note that there is a Where clause here always & i get the following result
    P.Patient ID         P.Alignment ID      
        1                            1a
        2                             2a
        3                            3a
        4                            Null
        5                            Null
    Now when i join two tables on Alignment ID
    e.g.
    Select P.Patient ID, P.Alignment ID,T.Region
    from Patient Table (P)
    LEFT OUTER  JOIN Territory Table (T)
    ON P. Alignment ID =  T.Alignment ID
    Where P.Data_date='01-OCT-2014'
    AND T.Data_date='01-OCT-2014'
    Following is the result:
    P.Patient ID         P.Alignment ID      
        1                            1a
        2                            2a
        3                            3a
    Now the whole issue is that the condition in the WHERE clause is making it act like a inner join and iw ant the NULL rows to appear
    Sheikh

  • How can I avoid hard-coding this where clause in the inner select?

    This is extremely fast, but I have to hard-code the inner-most where clause, and I obviously can't do that. I know how to work-around it by creating a function that takes the CUSTOMER_ID and returns the ORDER_ID from the most recent payment, and that's reasonably fast, but I thought it would be worthwhile to see if there was a way to do this in straight SQL. I also know that better design could make the problem go away.
    Very much appreciate it if you could take a look and let me know if there's any way to get this kind of performance without hard-coding.
    Thanks,
    create or replace view customer_view as
    select customer.customer_id,
              customer.customer_name,
                   select t.order_id
                        from (
                                  select payment.order_id
                                       from payment
                                       where payment.customer_id = 1 -- <-- Here's the line where I'm hard-coding the customer_id. Is there any way to reference the customer_id without hard-coding this?
                                       order by payment.payment_date desc
                             ) t
                        where rownum = 1
              ) as latest_order_id
         from customer
    select * from customer_view where customer_id = 1; <-- I want that inner-most select to use this customer_id, without having to hard-code it.

    Hi Matt,
    Something like this could be a possibility (Not tested)
    create or replace view customer_view as
      select customer.customer_id,
             customer.customer_name,
             (select min (t.order_id)
                       keep (dense_rank first order by payment.payment_date desc)
              from   payment
              where  payment.customer_id = customer.customer_id)
               as latest_order_id
      from   customer;Regards
    Peter

Maybe you are looking for

  • Getting ora-01092 and ora-00600 error when trying to startup database

    hi friends,plz help me i am in serious problem i dont know what happen to my database oracle 11g R2 when trying to startup it its showing the below error SQL> startup ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance ORACLE

  • How to Open PDF in the browser...JSF

    String strUrl = http://..../xxxxxe43cb072378947fe8c1b7bcc7201691a.pdf FacesContext faces = FacesContext.getCurrentInstance(); ExternalContext context = faces.getExternalContext(); HttpServletResponse response = (HttpServletResponse)context.getRespons

  • Has anyone ever encountered a "shockwave player error" window when deleting cookies in Safari preferences under privacy?

    This window appears multiple times whenever I try to delete cookies. This afternoon, on the amazon.com site, the window kept opening and would not allow me to do anything else. I had to shut down my iMac and restart several times before I could get i

  • STATUS_SHOW_CHANGE_DOCUMENTS -export

    I have a requirement to get the status details -service order and notification also. Can I use the function module STATUS_SHOW_CHANGE_DOCUMENTS I can get the Service order no from AUFK and object no and passing input as object no for the above Funtio

  • Dynamic Link Error: Source is empty.

    This is an error I'm frequently getting when dragging Sequences over to Adobe Media Encoder.  The error is false, because all my Sequences have media in them. I have a couple of projects ongoing.  One has 7 sequences, another has 30.  I'm getting the