Problem with SYS_CONTEXT in WHERE clause in 10g

I am running the following SELECT statement in 9i and 10g
SELECT COUNT(*)
FROM mapinfo.mapinfo_mapcatalog
WHERE tablename IN ('ESU_GRAPHICS', 'STREETS', 'ASD_STREETS', 'NSG_ARCHIVE_ESU_GRAPHICS')
AND ownername = sys_context('USERENV','CURRENT_SCHEMA');
When running in 9i it returns 4, the correct answer, but in 10g it always returns 0. I have tried populating a variable with the result from sys_context('USERENV','CURRENT_SCHEMA') such as:
SELECT sys_context('USERENV','CURRENT_SCHEMA')
INTO currentschema
FROM dual;
I have checked the variable and it is giving me the correct result in 10g, but I still get 0 returned from the select statement.
What am I missing to get this working in 10g?
Cheers
Sean

- Does the value for CURRENT_SCHEMA actually match
the ownername column for the tables in your IN
clause? Yes
>
- Is there anything different between 9i and 10g?
E.g. did you have any fine grained access control?Not that I know of, but I am not a DBA so I could not say for sure.
Were you setting CURRENT_SCHEMA with an ALTER SESSION
statement in 9i that you have missed in your 10g
environment?No we do not use any ALTER SESSION statements.
>
- What do you get if you run the following?
select user from dual;
select sys_context('USERENV','CURRENT_SCHEMA') from
dual;
Exactly the same result
>
- What do you get if you run the following?
SELECT tablename, ownername FROM
mapinfo.mapinfo_mapcatalog
WHERE tablename IN ('ESU_GRAPHICS', 'STREETS',
'ASD_STREETS', 'NSG_ARCHIVE_ESU_GRAPHICS');
380 rows of data including the 4 that I am interested in
- Can you also show the value of your variable when
you use a SELECT INTO in PL/SQL... Were you using
uppercase for USERENV and CURRENT_SCHEMA in PL/SQL
(there was an incorrect results bug when using
lowercase attributes in PL/SQL SYS_CONTEXT calls)?I am showing the value of the variable and it is holding the correct value, and yes I am using uppercase USERENV and CURRENT_SCHEMA.
After more investigation it looks like it is not SYS_CONTEXT, it is using a variable in the WHERE clause. If I set the variable to a hard coded value I still get the same result. If I replace the variable for a hard-coded string in the WHERE clause I get the correct result.

Similar Messages

  • Problem with one time where clause

    Hi All,
    I am working with Oracle Forms 10g.
    I have developed A new custom with Find window in that form. When we open the form First the find window will come first, and i have 10 fields in that form. For example PO number, supplier name,supplier site etc. When the user give po number and click find button in the find window it will move to my main form and query that po. If the user simply click find button all the po will listed. If the user give the supplier name alone and click find it will open the main form and query that supplier listed po alone. All working fine.
    Now i need to refresh the my page when it moves from find window to my main window. So i use Execute_query built in.But when i use Execute_query when i give single po alone and click find it querying all the po in my custom table. So i used onetime_where clause.
    But i dont know How to give more than one field in the onetime_where clause.
    This is my syntax and its not working in my scenario
    set_block_property('QUERY_FIND_BLK',ONETIME_WHERE,'C_PO_NUMBER='||:QUERY_FIND_BLK.C_PO_NUMBER);
    go_block('BANK_GUARANTEE_BLK');
    execute_query;
    So i tried by different
    set_block_property('QUERY_FIND_BLK',ONETIME_WHERE,
    'C_PO_NUMBER || C_PROJECT_ID || C_SUPPLIER_NAME || C_SUPPLIER_SITE_NAME || C_GUARANTEE_NUMBER
    || C_APPROVAL_STATUS || C_BG_TYPE AND C_BANK_NAME || C_BANK_BRANCH_NAME || C_GUAR_ISSUE_DATE || C_GUAR_ISSUE_DATE='
    || nvl(:QUERY_FIND_BLK.C_PO_NUMBER , :QUERY_FIND_BLK.C_PO_NUMBER )
    || nvl(:QUERY_FIND_BLK.C_PROJECT_NAME,:QUERY_FIND_BLK.C_PROJECT_NAME)
    || nvl(:QUERY_FIND_BLK.C_SUPPLIER_SITE,:QUERY_FIND_BLK.C_SUPPLIER_SITE)
    || nvl(:QUERY_FIND_BLK.C_SUPPLIER_SITE,:QUERY_FIND_BLK.C_SUPPLIER_SITE)
    || nvl(:QUERY_FIND_BLK.C_GUARANTEE_NO,:QUERY_FIND_BLK.C_GUARANTEE_NO)
    || nvl(:QUERY_FIND_BLK.C_APPROVAL_STATUS,:QUERY_FIND_BLK.C_APPROVAL_STATUS)
    || nvl(:QUERY_FIND_BLK.C_GUARANTEE_TYPE,:QUERY_FIND_BLK.C_GUARANTEE_TYPE)
    || nvl(:QUERY_FIND_BLK.C_BANK_NAME,:QUERY_FIND_BLK.C_BANK_NAME)
    || nvl(:QUERY_FIND_BLK.C_BRANCH_NAME,:QUERY_FIND_BLK.C_BRANCH_NAME)
    || nvl(:QUERY_FIND_BLK.C_FROM_DATE,:QUERY_FIND_BLK.C_FROM_DATE)
    || nvl(:QUERY_FIND_BLK.C_TO_DATE,:QUERY_FIND_BLK.C_TO_DATE));
    go_block('BANK_GUARANTEE_BLK');
    execute_query;
    But now again its querying all the records when i give a single po number in the query window.
    Can any one tell that how to use this onetime_where clause with multiple parameter
    Regards
    Srikkanth

    Hi Srikkanth,
    Try out below logic.
    PROCEDURE FIND_DETAILS IS
    V_WHERE VARCHAR2(2000);
    BEGIN
    V_WHERE := ' 1=1 ';
    IF :FIND_BLK.JOB_NUMBER IS NOT NULL THEN
    V_WHERE := V_WHERE || ' AND UPPER(JOB_NAME) LIKE '''||UPPER(:FIND_BLK.JOB_NUMBER) ||'''';
    END IF;
    IF :FIND_BLK.JOB_STATUS IS NOT NULL THEN
    V_WHERE := V_WHERE || ' AND STATUS_TYPE IN (SELECT lookup_code FROM mfg_lookups
    WHERE lookup_type = ''WIP_JOB_STATUS''
    AND UPPER(meaning) LIKE '''||UPPER(:FIND_BLK.JOB_STATUS)||''')';
    END IF;
    IF :FIND_BLK.WIP_CLASS IS NOT NULL THEN
    V_WHERE := V_WHERE || ' AND UPPER(WIP_CLASS_CODE) LIKE '''||UPPER(:FIND_BLK.WIP_CLASS)||'''';
    END IF;
    IF :FIND_BLK.ORG_CODE IS NOT NULL THEN
    V_WHERE := V_WHERE || ' AND ORG_ID = ' || :FIND_BLK.ORGANIZATION_ID;
    END IF;
    SET_BLOCK_PROPERTY('BLOCK_NAME',DEFAULT_WHERE,V_WHERE);
    GO_BLOCK('BLOCK_NAME');
    EXECUTE_QUERY;
    EXCEPTION
    WHEN OTHERS THEN
    FND_MESSAGE.SET_STRING('Unable to Match Search Criteria');
    FND_MESSAGE.SHOW;
    END;
    By using above where clause you can also do wild search e.g. C_PO_NUMBER like '%323' etc.
    Regards,
    Nisarg

  • Cardinality estimator 2014 is off with OR in where clause

    Here is my test setup on SQL Server 2014.
    -- Create big table
    CREATE TABLE [dbo].[Store](
    Id int IDENTITY(1,1) NOT NULL,
    City int NOT NULL,
    Size int NOT NULL,
    Name varchar(max) NULL,
    CONSTRAINT [PK_Store] PRIMARY KEY CLUSTERED ([Id] ASC)
    GO
    CREATE NONCLUSTERED INDEX [IX_Store] ON [dbo].[Store] (City ASC, Size ASC)
    GO
    -- Fill with 100k rows
    INSERT Store
    SELECT i % 101, i % 11, 'Store ' + CAST(i AS VARCHAR)
    FROM
    (SELECT TOP 100000 ROW_NUMBER() OVER (ORDER BY s1.[object_id]) AS i
    FROM sys.all_objects s1, sys.all_objects s2) numbers
    GO
    -- Create small table
    CREATE TABLE #StoreRequest (City int NOT NULL, Size int NOT NULL)
    GO
    INSERT #StoreRequest values (55, 1)
    INSERT #StoreRequest values (66, 2)
    Now I execute the following query (I force the index to show statistics estimates)
    SELECT s.City
    FROM #StoreRequest AS r
    INNER JOIN Store AS s WITH(INDEX(IX_Store), FORCESEEK)
    ON s.City = r.City AND s.Size = r.Size
    WHERE s.Size <> 1 OR r.City <> 55
    Here are the estimates that I get (I'm not allowed to upload pictures):
    Index Seek IX_Store
    Actual Number of Rows: 90
    Estimated Number of Rows: 50000
    Fixing WHERE clause to use one table not two makes the estimate perfect:
    SELECT s.City
    FROM #StoreRequest AS r
    INNER JOIN Store AS s WITH(INDEX(IX_Store), FORCESEEK)
    ON s.City = r.City AND s.Size = r.Size
    WHERE s.Size <> 1 OR s.City <> 55
    Index Seek IX_Store
    Actual Number of Rows: 90
    Estimated Number of Rows: 89.74
    Switching to 2012 compatibility mode gives estimate of 1 in both cases:
    Index Seek IX_Store
    Actual Number of Rows: 90
    Estimated Number of Rows: 1
    Could anyone explain the first result? I'm a bit worried about it. The fix in this case is trivial, but this problem gave us quite some headache in more complex real life queries with multiple joins.
    Thank you!

    But not full statistics on a field basis, just sometimes some default stats like total row count that some plans will build.  Even your StoreRequest table only has one two-field index that will have a full histogram.
    But I've seen SQL Server make massively bad plans on two-field indexes.
    I've seen SQL Server go wrong one-column indexes, so that is not a very relevant point.
    Temp tables or not, the estimate here is clearly incorrect. SQL Server knows the density of Size and City. It knows the cardinality of the temp table. The density information gives how many rows the the join will produce. The WHERE clause will then remove
    a certain number of rows. With no statistics for the temp table, it does not now how many, but it will apply some standard guess.
    50000 is a completely bogus number, because the join cannot produce that many rows, and SQL Server is able to compute the join with out the WHERE clause decently. (Well, it estimates 90, when the number is 180.) No, this is obviously a case of the cardinality
    estimator giving up completely.
    It is worth noting that both these WHERE clauses gives reasonable estimates:
     WHERE r.Size <> 11 OR r.City <> 550
     WHERE s.Size <> 11 OR s.City <> 550
    Whereas these two gives the spooky 50000:
     WHERE s.Size <> 11 OR r.City <> 550
     WHERE r.Size <> 11 OR s.City <> 550
    Erland Sommarskog, SQL Server MVP, [email protected]

  • I have problem with Itunes losing where podcasts and some purchased music is located. Don't know how Itunes losing the locations of the files and I can't find the files on my hard drive. What can I do to stop Itunes losing location and restore my files?

    I have problem with Itunes losing where podcasts and some purchased music is located. Don't know how Itunes losing the locations of the files and I can't find the files on my hard drive. What can I do to stop Itunes losing location and restore my files?

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • On success of form save I want to go to another for with a detail where clause

    I have the follow code snippet which is intented to go to a form on a successfull save. I query some data based on the save then build a url to navigate to a new form. I want the form to show only data that is lacking in one column not being populated (column is null). The url works, but the form detail where clause is ignored. Does anyone have any experience with passing detail where clauses to a form? Did I miss something in the code below?
    begin
    select count(rl_id) into n_rl_id_cnt
    from rfq_lines
    where part_part_id is null and rh_rh_id=n_rh_id;
    exception
    when others then
    null;
    end;
    htp.p('cnt '||to_char(n_rl_id_cnt));
    if n_rl_id_cnt>0 then
    htp.p('cnt >1');
    my_url := 'PORTAL30.wwa_app_module.link?' ||
    'p_arg_names=_moduleid&p_arg_values=3677858481' ||
    '&p_arg_names=_show_header&p_arg_values=YES' ||
    '&p_arg_names=rh_id&p_arg_values=' || LTRIM(TO_CHAR(n_rh_id)) ||
    '&p_arg_names=_rh_id_cond&p_arg_values=%3D'||
    '&p_arg_names=_detail_where_clause&p_arg_values=part_part_id%20is%20null'; -- <this is not working right. where clause is ignored.
    htp.p(my_url);
    go (my_url);

    Hi Jeffrey ,
    You need to use a custom Format script for the field.
    Regards
    Sukrit Dhingra

  • Create a view with a changing where clause

    Hi all,
    i'm developing an application with oracle forms i want to create a view in the database with a different where clause in every time , the where clause is determined due to the department id of the current user .
    thanks alot.

    SQL> create view emp_view as select empno, ename, deptno from emp;
    View created.
    SQL> select * from emp_view where deptno = 10;
         EMPNO ENAME          DEPTNO
          7782 CLARK              10
          7839 KING               10
          7934 MILLER             10
    SQL>

  • Define a Standalone Download Integrator with an Additional Where clause - SQL error

    Hi,
    I am trying to create a standalone integrator with an Additional Where clause. Followed the steps mentioned in the metalink note 360105.1. When I run the integrator, I get the following error message.
    Please resolve the following error to continue.
    SQL error: ORA-00936: missing expression occurred
    processing stored SQL for Content 20007:GENERAL_441_CNT.
    When I look at the log file, here is what I can see:
    10/22/14 10:50 AM AJPRequestHandler-HTTPThreadGroup-15 TRACE          BneHrSQLControl - SQL:SELECT  FROM PER_PEOPLE_V where last_name=$PARAM$.last_name
    10/22/14 10:50 AM AJPRequestHandler-HTTPThreadGroup-15 TRACE          validateSQLStatement value of sqlStatement is: SELECT  FROM PER_PEOPLE_V where last_name=:RSQLP1
    10/22/14 10:50 AM AJPRequestHandler-HTTPThreadGroup-15 DETAIL         BneHrSQLControl.validateSQLStatement() paramName: last_name
    10/22/14 10:50 AM AJPRequestHandler-HTTPThreadGroup-15 DETAIL         BneHrSQLControl.validateSQLStatement() error in SQL: java.sql.SQLSyntaxErrorException: ORA-00936: missing expression
    So, clearly, the SQL statement that is getting built internally is wrong. Ideally, I would expect the statement to be something like this:
    SELECT *  FROM PER_PEOPLE_V where last_name=$PARAM$.last_name.
    RDBMS : 11.2.0.3.0
    Oracle Applications : 12.1.3
    Any pointers towards the resolution of the issue would be of great help.
    Thanks in Advance!
    Lalitha.

    This is a duplicate post of your other question:  create trigger automatic
    DO NOT start duplicate threads for the same question.
    Locking this thread

  • Trouble with OR in where clause

    Hello,
    I'm having trouble with execution speed. The problem seems to be with using OR in my where clause.
    Here's the meat of the function where i_pledge_number is an input parm:
    BEGIN
    SELECT /*+ INDEX (pp) */ SUM(pp.prim_pledge_amount)
    INTO return_amount
    FROM
    primary_pledge pp
    WHERE
    -- Get total if multiple allocations
    pp.prim_pledge_number IN
    (SELECT pc.pledge_number
    FROM pledge_codes pc
    WHERE pc.pledge_code_type = 'M'
    AND pc.pledge_code = 'AC'
    AND lpad(pc.pledge_comment,10,'0') = i_pledge_number)
    -- Get total if single allocation
    OR pp.prim_pledge_number = i_pledge_number;
    RETURN return_amount;
    END;
    If I comment out either half of the OR statement (either the subquery or the pp.prim_pledge_number = i_pledge_number half) the function returns a value in .02 seconds. If I leave the OR in, it takes 2.764 seconds to execute?? Can someone please show me a better way (faster) to do this? I tried using nvl() around the subquery but couldn't get it to compile.
    Thanks

    These things are difficult to diagnose remotely, but here is something you can try....
    SELECT */ SUM(pp.prim_pledge_amount)
    INTO return_amount
    FROM   primary_pledge pp
    WHERE  pp.prim_pledge_number IN (SELECT pc.pledge_number
                                     FROM pledge_codes pc
                                     WHERE pc.pledge_code_type = 'M'
                                     AND pc.pledge_code = 'AC'
                                     AND lpad(pc.pledge_comment,10,'0') = i_pledge_number
    UNION ALL
    SELECT i_pledge_number FROM dual)
       RETURN return_amount;
    END;If that doesn't do anything (and it might well not) there are a large number of different ways we can recast this query. To save us further guessing please give us more details: execution plans, database version number, volumetrics.
    Cheers, APC

  • Performance - composite index with 'OR' in 'WHERE' clause

    I have a problem with the performance of the following query:
    select /*+ index_asc(omschact oma_index1) */ knr, projnr, actnr from omschact where ((knr = 100 and actnr > 30) or knr > 100)
    and rownum = 1;
    (rownum used only for test purpose)
    index:
    create index on omschact (knr, projnr);
    Execution plan:
    Id Operation
    0 SELECT STATEMENT
    1 COUNT STOPKEY
    2 TABLE ACCESS BY INDEX ROWID
    3 INDEX FULL SCAN
    If I'm correct, the 'OR' in the 'WHERE' clause is responsible for the INDEX FULL SCAN, what makes the query slow.
    A solution would be then to separate the 'WHERE' clause in 2 separate select's (1 with 'knr = 100 and actnr > 30' and 1 with 'knr > 100' and combine the results with a UNION ALL.
    Since it's necessary to have all rows in ascending order (oma_index1) I still have to use an ORDER BY to make sure the order of the rows is correct. This results again in a (too) low performance.
    Another solution that does the trick is to create an index with the 2 fields (knr, projnr) concatenated and to use the same in the 'WHERE' clause:
    create index oma_index2 on omschact (knr || projnr);
    select /*+ index_asc(omschact oma_index2) */ knr, projnr, actnr from omschact where (knr || projnr) > 10030;
    I just can't believe this work-around is the only solution, so I was hoping that someone here knows of a better way to solve this.

    padders,
    I'll give the real data instead of the example. The index I really use consists of 4 fields. In this table the fields are just numbers, but in other tables I need to use char-fields in indexes, so that's why I concatenate instead of using formula's (allthough I would prefer the latter).
    SQL> desc omschact
    Name Null? Type
    KNR NOT NULL NUMBER(8)
    PROJNR NOT NULL NUMBER(8)
    ACTNR NOT NULL NUMBER(8)
    REGELNR NOT NULL NUMBER(3)
    REGEL CHAR(60)
    first methode:
    SQL> create index oma_key_001(knr,projnr,actnr,regelnr);
    Index created.
    SQL> select /*+ index_asc(omschact oma_key_001) */ * from omschact where
    2 (knr > 100 or
    3 (knr = 100 and projnr > 30) or
    4 (knr = 100 and projnr = 30 and actnr > 100000) or
    5 (knr = 100 and projnr = 30 and actnr = 100000 and regelnr >= 0));
    Execution Plan
    Plan hash value: 1117430516
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 11M| 822M| 192K (1)| 00:38:26 |
    | 1 | TABLE ACCESS BY INDEX ROWID| OMSCHACT | 11M| 822M| 192K (1)| 00:38:26 |
    |* 2 | INDEX FULL SCAN | OMA_KEY_001 | 11M| | 34030 (1)| 00:06:49 |
    Predicate Information (identified by operation id):
    2 - filter("KNR">100 OR "KNR"=100 AND "PROJNR">30 OR "KNR"=100 AND "PROJNR"=30
    AND "ACTNR">100000 OR "ACTNR"=100000 AND "KNR"=100 AND "PROJNR"=30 AND
    "REGELNR">=0)
    second method (same index):
    SQL> select * from (
    2 select /*+ index_asc(omschact oma_key_001) */ * from omschact where knr > 100
    3 union all
    4 select /*+ index_asc(omschact oma_key_001) */ * from omschact where knr = 100 and projnr > 30
    5 union all
    6 select /*+ index_asc(omschact oma_key_001) */ * from omschact where knr = 100 and projnr = 30 and actnr > 100000
    7 union all
    8 select /*+ index_asc(omschact oma_key_001) */ * from omschact where knr = 100 and projnr = 30 and actnr = 100000 and regelnr > 0)
    9 order by knr, projnr, actnr, regelnr;
    Execution Plan
    Plan hash value: 292918786
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 11M| 1203M| | 477K (1)| 01:35:31 |
    | 1 | SORT ORDER BY | | 11M| 1203M| 2745M| 477K (1)| 01:35:31 |
    | 2 | VIEW | | 11M| 1203M| | 192K (1)| 00:38:29 |
    | 3 | UNION-ALL | | | | | | |
    | 4 | TABLE ACCESS BY INDEX ROWID| OMSCHACT | 11M| 822M| | 192K (1)| 00:38:26 |
    |* 5 | INDEX RANGE SCAN | OMA_KEY_001 | 11M| | | 33966 (1)| 00:06:48 |
    | 6 | TABLE ACCESS BY INDEX ROWID| OMSCHACT | 16705 | 1272K| | 294 (1)| 00:00:04 |
    |* 7 | INDEX RANGE SCAN | OMA_KEY_001 | 16705 | | | 54 (0)| 00:00:01 |
    | 8 | TABLE ACCESS BY INDEX ROWID| OMSCHACT | 47 | 3666 | | 4 (0)| 00:00:01 |
    |* 9 | INDEX RANGE SCAN | OMA_KEY_001 | 47 | | | 3 (0)| 00:00:01 |
    | 10 | TABLE ACCESS BY INDEX ROWID| OMSCHACT | 1 | 78 | | 4 (0)| 00:00:01 |
    |* 11 | INDEX RANGE SCAN | OMA_KEY_001 | 1 | | | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    5 - access("KNR">100)
    7 - access("KNR"=100 AND "PROJNR">30)
    9 - access("KNR"=100 AND "PROJNR"=30 AND "ACTNR">100000)
    11 - access("KNR"=100 AND "PROJNR"=30 AND "ACTNR"=100000 AND "REGELNR">0)
    third method:
    SQL> create index oma_test(to_char(knr,'00000000')||to_char(projnr,'00000000')||to_char(actnr,'00000000')||to_char(regelnr,'000'));
    Index created.
    SQL> select /*+ index_asc(omschact oma_test) */ * from omschact where
    2 (to_char(knr,'00000000')||to_char(projnr,'00000000')||
    3 to_char(actnr,'00000000')||to_char(regelnr,'000')) >=
    4 (to_char(100,'00000000')||to_char(30,'00000000')||
    5* to_char(100000,'00000000')||to_char(0,'000'))
    Execution Plan
    Plan hash value: 424961364
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 553K| 55M| 1712 (1)| 00:00:21 |
    | 1 | TABLE ACCESS BY INDEX ROWID| OMSCHACT | 553K| 55M| 1712 (1)| 00:00:21 |
    |* 2 | INDEX RANGE SCAN | OMA_TEST | 99543 | | 605 (1)| 00:00:08 |
    Predicate Information (identified by operation id):
    2 - access(TO_CHAR("KNR",'00000000')||TO_CHAR("PROJNR",'00000000')||TO_CHAR("
    ACTNR",'00000000')||TO_CHAR("REGELNR",'000')>=TO_CHAR(100,'00000000')||TO_CHAR(3
    0,'00000000')||TO_CHAR(100000,'00000000')||TO_CHAR(0,'000'))

  • Pagination after executequery with a dynamic where clause

    Hi all,
    I have a problem with pagination after setting a where clause dynamically and performing an executequery in ViewObjectImpl.java.
    As a result of this, the amount of records are decreased returned by the viewobject, however the pagination is not changed. It still reflects the previous amount. It changes only if you have selected the last range of the changed recordset
    Does anybody know how to get the pagination to refect the correct amount of the updated recordset of the viewobject?
    Jdeveloper version 10.1.3.4 / Jheadstart 10.1.3.3.81
    Thanks in advance, Erwin

    Hi,
    I would not add this to the VO query. Instead I would create a View Criteria that uses a bind variable. Then in the Application Module Data Model, you select the VO instance and choose edit (button on top) to permanently associate the view criteria)
    Advantages of this approach
    - The VO definition can be used elsewhere without the restriction
    - the bind variable is not mandatory and yu can set it such that if no value is provided a full query is executed
    Frank

  • How to create VO with multiple dynamic where clauses on select with UNION?

    I am trying to implement the View Object for the UNION query that looks like this:
         select a,b,c...
              from t1,t2,...
              where dynamic_where_clause1     
         union all
         select a,b,c,...
              from t11,t12, ...
              where dynamic_where_clause2
    There are up to 60 input parameters that are used to generate dynamic where clauses. They are actually created by calling PL SQL function.
    So far, I was not able to assign both where clauses to the view object. Is there a workable solution for this problem, besides resorting to programmatic View Object?
    I understand that recommended way with UNIONs is to wrap both queries into a parent select:
    select * from (
         select a,b,c...
              from t1,t2,...
              where ... -- table relationship joints
         union all
         select a,b,c,...
              from t11,t12, ...
              where ... -- table relationship joints
    ) QRSLT
         where dynamic_where_clause
    Unfortunately this approach doesn't work here, since individual selects are producing unmanageable amount of data and resulting query takes forever to complete.

    I afraid I would not have any real benefits from using VO if I replace the entire query with every request. Actually, the performance may suffer.
    I solved the problem by creating a POJO Data Control and invoking the custom select query from java. Not sure if it is the best approach to the problem, but implementation time is limited and it works.
    Actually, this is not the first time I see the need to implement VO with complicated SQL like select with unions and dynamic pieces. It would be nice to find a solution and not resort to workarounds.
    Edited by: viksicom on Aug 2, 2012 8:48 AM

  • Updating one table with mult. table where clause

    I'm having problems with my update statement. I want to update one table that has a mulitple table where clause. Not sure how to accomplish this. Here is what I have so far.
    update lawson.apvenmast a
    set vendor_status = 'I'
    where ((select * from apinvoice i
    where i.due_date <= TO_DATE('20011231', 'YYYYMMDD') and
    i.vendor = a.vendor)
    ((apvenmast.ven_class = 'INS') or
    (apvenmast.ven_class = 'REF')));
    Am I on the right track?
    thanks in advance for any help.
    Lisa Mears

    A lot is missing.
    where ((select * from apinvoice iA where clause should be like
    where <something> IN (select <something> from ...)
    ((apvenmast.ven_class = 'INS') or
    (apvenmast.ven_class = 'REF')));Where does this belong? There is no AND or OR with these two lines.
    Check your table aliases too.

  • Dynamic Order by with user defined Where clause...

    Hello!
    I have a block based on a table, with no order by set and no where clause.
    The block is queryable so users can filter the data to be retrieved.
    Each of the columns on the form have a button above which requeries the block, applying the order by (SET_BLOCK_PROPERTY ( 'B12', ORDER_BY, :bc1.h_b12_custom_orderby ); )
    The problem is that each time the block is requeried the user definied filter criteria is lost. Is there any way I can get a handle on this and maintain the filtering?
    GET_BLOCK_PROPERTY(item, DEFAULT_WHERE); only retrieves the query entered while in design mode so this won't work.
    I'm using Oracle Forms 6i, web based. Any suggestions are very much appreciated.
    Thanks in advance,
    Jay

    Many thanks for your response Hedy,
    Below is the procedure I used to achieve this.
    I found GET_BLOCK_PROPERTY ( p_block, LAST_QUERY ) worked better than :SYSTEM.last_query. As the first time it is called within a block :SYSTEM.last_query returned the query made in another block - which I'm sure has it's applications.
    Thanks again,
    Jay
    PROCEDURE set_last_query_where ( p_block IN VARCHAR2
    , p_where IN VARCHAR2 DEFAULT NULL )IS
    l_last_query VARCHAR2(10000);
    l_last_where VARCHAR2(10000);
    BEGIN
    IF p_where IS NULL THEN
    l_last_query := UPPER(GET_BLOCK_PROPERTY ( p_block, LAST_QUERY ));
    l_last_where := SUBSTR ( UPPER ( l_last_query),
    INSTR ( l_last_query, 'WHERE')+6, INSTR(SUBSTR(UPPER(l_last_query), INSTR(l_last_query, 'WHERE')+8), 'ORDER BY'));
    ELSE
    l_last_where := p_where;
    END IF;
    SET_BLOCK_PROPERTY ( p_block, DEFAULT_WHERE, l_last_where );
    EXCEPTION
         WHEN FORM_TRIGGER_FAILURE THEN
         ref_raise_ftf;
         WHEN OTHERS THEN
         ref_others( 'P-SLQW' );
    END;

  • Problem with prepared statement where cluase when passing string value.Help

    I am updating a table using the following code. I am using string parameter in where clause. if I use Long parameter in where clause with ps.setLong , this code is working. Is there any special way to pass string value? Am I doing anything wrong?
    ===================
    updateMPSQL.append("UPDATE MP_Table SET ");
         updateMPSQL.append("MPRqmt = ?,End_Dt = ? ");
              updateMPSQL.append("where POS = ? ");
              System.out.println(updateMPSQL.toString());
              con     = getConnection(false) ;
              ps      = con.prepareStatement(updateMPSQL.toString());
              ps.setLong(1,MPB.getMPRqmt());
              ps.setDate(2,MPB.getEnd_Dt());
              ps.setString(3,MPB.getPos());
    result = ps.execute();
              System.out.println("Result : " + result);
    ==========
    Please help me.
    Thanks in advance.
    Regards,
    Sekhar

    doesn't Pos look like a number rather than a string variable?
    if I use Long
    parameter in where clause with ps.setLong , this code
    is working.
    updateMPSQL.append("where POS = ? ");
    ps.setString(3,MPB.getPos());

  • Problem with type 4 driver using oracle 10g

    HI,
    I am unable to establish a type 4 connection with oracle 10g.
    Specs:
    Driver used: OracleDriver that comes with the ojdbc14.jar along with oracle 10g
    JDK used: Tried using both j2sdk1.4.2 and using JDK 5.0
    JRE: Again, JRE that was shipped with j2sdk 1.4.2 and JRE 5.0
    OS: Windows XP sp2
    I am able to compile the following piece of code, so there is no classpath problem, etc.
    When I try to run the program, the exception thrown is "No Suitable Driver"
    There is no problem with the TNSListener, etc...even if all Oracle related services in 'services.msc' are Started/Stopped, the error remains.
    I am, however, able to establish the connection using type1 driver.
    Please Help!
    import java.sql.*;
    import java.io.*;
    class TestConn
         Connection connection;
         Statement statement;
         ResultSet resultset;
         public void testConn() throws SQLException, ClassNotFoundException
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleStatement());
              //DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
              connection = DriverManager.getConnection("oracle:jdbc:thin:@127.0.0.1:1521", "scott", "tiger");
              //connection = DriverManager.getConnection("jdbc:odbc:dsn1", "scott", "tiger");
              System.out.println("Connection Established");
              statement = connection.createStatement();
              resultset = statement.executeQuery("select ename from emp");
              while(resultset.next())
                   System.out.println(resultset.getString(1));
    class Test
         public static void main(String args[]) throws SQLException, ClassNotFoundException
              TestConn obj = new TestConn();
              obj.testConn();
    };

    The JDBC URL should include the database SID. For example, if the database SID is Orcl
    connection = DriverManager.getConnection("oracle:jdbc:thin:@127.0.0.1:1521:Orcl", "scott", "tiger");

Maybe you are looking for

  • Insufficient Memory

    Hey! Our Editor is getting this error: "Insufficient Memory. Specify a smaller recording range, quit any unused application and install more system RAM." .. when trying to use the Voice Over Tool. She has a 2.5ghz G5 PowerMac, 4GB DDR SDRAM. We're ru

  • COPA document with missing values

    Hi Experts, after posting in SD (debit memo rebilling) a CO-PA document is created, but with missing value for value field 'interest'. In transaction KE4I, there is correct assignment of SD condition to value field 'interest'. We use cost based CO-PA

  • Download CRM Contact into Outlook and Create vcard in Outlook.

    Is it possible to Download a CRM Contact into Outlook and Create vcard in Outlook? I can't seem to find a way to even download the contacts full details.

  • Changing the color of bar graph

    I have created a bar graph in graphics builder and I want the report to display different colors to indicate different values in the field. What is the best way to do this? Can someone provide me with sample code? Thanks

  • Clone tool problems

    I recently purchased the Adobe cs5 upgrade. it works fine but I am encountering a huge problem with the clone tool.I am trying to clone from one image to another. I click on the source image and the familiar tool with the crosshair appears. When I mo