Is it possible to create views with parameters ?

Hi,
As MS-Access, is it possible to create views with parameters ?
Ms-Access syntax : parameters [a] text; select * from table where code = [a]
If yes, can you give samples ?
Regards
Pascal

I suggest you you write a stored procedure that returns a recordset in oracle. Then execute the stored procedure and loop through the record set.
Look in in MS Knowledgebase searching on ADO Stored Proceedures for the VB/C++/VBS .. code.
Look in in Oracle PL/SQL guide for the Stored Proceedure code.

Similar Messages

  • Makes it possible to create view with parameters

    makes it possibel to create view with paramater, example
    create or replace view v_test(segment varchar2)
        select * from ref_user where segment = segmentThanks

    thanks..
    select count(distinct substr(a.svm_id,1,10)) jumlah " +
       " from daily_distribution_pop a, ref_toko b " +
       " where " +
       " substr(a.svm_id,1,10)=b.id and b.segment_type = 'A' and enable_flag='Y' " +
       " and a.tgl_visit between to_date('" + fromStartDate + "', 'dd/MM/yyyy') and to_date('" + fromEndDate + "', 'dd/MM/yyyy')
         and " + whereA + "= '" + whereB + "' " +
       " and substr(a.pom_id,1,2) = 'DP' and (a.qty_instore <> 0 or a.qty_delivered <> 0) ";
    {code}
    where fromStartDate,  fromEndDate, whereA, whereB  is variable parameter from asp.net.
    how to i can implement with view                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How I can create view with parameters?

    I have very big query (2000 rows) and 2 parameters.
    How I can create view with parameters?

    If I use this small part of my query than I have error :
    java.lang.NullPointerException
         at oracle.javatools.db.ora.OracleSQLQueryBuilder.buildQuery(OracleSQLQueryBuilder.java:199)
         at oracle.javatools.db.ora.OracleSQLQueryBuilder.buildQuery(OracleSQLQueryBuilder.java:147)
    What does it means?
    select
    ' Payroll ' as Revenue
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and ( nvl(a.scode, 0) between 60000 and 6009000 )
    union all ---------------------------------------------------------------------------------------------------------------------------------
    select
    ' Payroll Taxes '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    (nvl(a.scode, 0) between 60100 and 60690 )
    union all -------------------------------------------------------------------------------------------------------------------------------
    select
    ' Workers Comp/Disability '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    ( nvl(a.scode, 0) between 61200 and 61260)
    union all -------------------------------------------------------------------------------------------------------------------------------
    select
    ' Pension and Hospitalization '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    ( nvl(a.scode, 0) between 61000 and 61550 )
    union all -------------------------------------------------------------------------------------------------------------------------------
    select
    ' Other Labor Costs '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    ( nvl(a.scode, 0) between 616000 and 616400 )

  • How to create a view with parameters; read the documentation but nothing!

    Hello!
    I'm new to the Oracle world but together with my coworkers we need to very quickly study Oracle to figure out whether we'll add Oracle to our list of supported databases or not.
    Question: How do I create a view with parameters?
    I've read the documentation but I could not find this! I found the sql syntax to create a view but no parameters whatsoever...
    I have found on the web some very complicated way of doing this, but doesn't Oracle support Views with parameters?
    The goal here is to return a recordset, don't forget, so,please don't speak about stored procedures unless you are going to tell me how to get a recordset out of a stored procedure! ;)
    Thanks for all your help and attention!
    Jorge C.

    You can set up a parameterized view via context as follows:
    1. Set up a procedure to set your context values:
    create or replace procedure p_set_context (p_context IN VARCHAR2,p_param_name IN VARCHAR2,p_value IN VARCHAR2)
    as
    BEGIN
    sys.dbms_session.set_context(p_context,p_param_name,p_value);
    END;
    2. Create your context using the procedure you just created
    create or replace context my_ctx using p_set_context
    3. This is the test table I'll use
    create table my_table(col1 number)
    and populate it:
    begin
    for v_index in 1..10
    loop
    insert into my_table values(v_index);
    end loop;
    end;
    and the view that will be parameterised
    create or replace view v_my_table as select col1 from my_table where col1 between sys_context('my_ctx','start_range') and sys_context('my_ctx','end_range')
    4. Now set the parameters using the procedure above.
    begin
    p_set_context('my_ctx','start_range','1');
    p_set_context('my_ctx','end_range','5');
    end;
    5. Selecting from my_table will give you 1 to 10 (no surprise there :-) )
    selectng from v_my_table will give you 1 to 5
    You can use the context to set formats etc using the same principle. A common gotcha to watch for is trying to set the context directly using DBMS_SESSION.SET_CONTEXT instead of creating a procedure. This belongs to SYS and SYS won't have the privileges to set your context so you get an insufficient privileges result leading to much headscratching and unnecessary grants (at least that's my understanding of it).
    Sorry Jorge, as you're new to Oracle I should also have pointed out for completeness sake, that you can change the parameters at any time through recalling the p_set_context, for example, following on from above, after your "select * from v_my_table" and seeing 1 to 5, you could then do
    begin
    p_set_context('my_ctx','start_range','3');
    end;
    and when you requery 'Select * from v_my_table' you will now see rows 3 to 5.
    Bit of a simplistic example, but you can see how easy it is. :-)
    Message was edited by:
    ian512

  • Is it possible to create graph with in the table / Pivote table.

    Is it possible to create graph with in the table / Pivote table.
    Emp# Emp Name % Bonus Pay Amt
    111 AAA $28276
    222 BBB $78878
    In the place of Bonus I have to display Bar (Chart) instead of number.
    Is it possible in OBIEE? I know we can display chart and table next by next but my user want display just like above.
    Please help me on this issue
    Thank you very much for your time

    hi,
    it is better for 2 different questions,make 2 differents threads...
    You used the 2ond solution(google???),put in the dashboard...html enabled...and check your pdf again.
    Moreover,printing pdf with answer is discouraged...always prefer Xml Publisher.
    Last,there are 2 fst files which configure the *.pdf files , check them,
    http://obiee101.blogspot.com/2008/09/obiee-pdf-controls-fst-files.html
    hope i helped....
    http://greekoraclebi.blogspot.com/
    ///////////////////////////////////////

  • Create View  with Force and No Force

    Can Anyone Tell me how to create view with force and no force i have very little idea about this

    This is the syntax.
    CREATE [OR REPLACE] FORCE VIEW view
    [(alias[, alias]...)]
    AS subquery
    [WITH CHECK OPTION [CONSTRAINT constraint]]
    [WITH READ ONLY [CONSTRAINT constraint]];You can see interesting threads about this topic here.
    Re: Creating view forcibly
    Creating View forcefully
    Cheers
    Sarma.

  • Is it possible to create report with two databases in Web Analysis Studio

    Hi,
    I am new to Hyperion Web Analysis, Could anyone help me out, whether its possible to create report with two databases for eg: OLAP(ESSBASE) and relational.
    Thanks & Regards,
    Prashanthi.

    Hi Mohit,
    Thanks for the reply, could you throw out some scenario so that i can try it out.As I am just trying my hands wet on this would like to know in detail & even i have gone through WA user guide but dint get any clue. Please throw some light.
    thanks
    prasanthi

  • How to create messages with parameters In ADF model.

    In ADF model, How to create messages with parameters?

    To Create messages in message bundles with parameters, perform the steps as given below
    Scenario: To Create a message as "Department Name XXXXXXX is already existing "
    Step#1: For the given entity object “DepartmentEO”, Go to “overview” tab and click “Business Rules” finger tab.
    Step#2: Select “Entity Validators” in the list & click “+” to add a new entity level validation rule.
    Step#3: Now go to “Failure Handling” tab, and click the Magnifier Icon.
    Step#4: Now in the “Display Value” field, enter the message with flower-braces as below.
    Department Name {department_name} is already existing
    Step#5: Also modify the Key & Description fields as needed. And click “Save and Select” button.
    Step#6: Now go to “Token Message Expressions” section, double-click the Expression field corresponding to "department_name" & give the relevant Attribute names say "DepartmentName"
    Step#7: Now click “OK”.

  • Encapsulating a query in a view with "parameters"

    I have a complex query using analytic functions and an inline view, something like:
    select * from (
    select a, b, c, row_number() over (partition by x, order by y) rn
    where b like 'XXX%'
    where rn = 1;
    (The actual query is a little more complex, but that's the idea). This query performs very well.
    As the query is of some general use, I'd like to package it up. However, the 'XXX%' pattern will vary with each use.
    If I try to make a view v which is the query minus the XXX% where clause, the optimiser cannot merge the where clause and the view in a query like
    select * from v where b like 'XXX%'
    This doesn't surprise me too much - merging like that is going to be hard (if indeed it's possible at all!) As a result, the query using the view is significantly slower.
    Is there any way of making my original query reusable? For PL/SQL, I can use a function returning a REF CURSOR and taking the pattern as a parameter - but I need to use this from SQL.
    I could write a pipelined function and then do select * from table(my_fn('XXX%')). However, this is in 8i, where I don't have that option. Also, for a pipelined function, I'd need to define a record type and an associated table type - what seems like quite a lot of code for what is conceptually pretty simple.
    Have I missed any obvious options? I can live with the pipelined function and "no way until 9i" - but only as a general answer. For my current specific issue, that's equivalent to "you can't do this".
    I thought of using SYS_CONTEXT, but if I understand correctly, I can only use that in PL/SQL, as I can't set the context outside of an authorised package. Is that right, or is there a way I could use contexts? (Hmm, I need to be able to use the query from SQ, but I could probably execute a PL/SQL procedure before running the query, to set things up - does that help?)
    Thanks for any suggestions.
    Paul.

    SYS_CONTEXT would work, as would package global variables.
    I once wrote an example about this (though with TABLE function but for your case the principle stays the same) which you may find here:
    Re: TABLE FUNCTION - Using database view - send parameters to the function.
    hth, michael

  • View with parameters

    Hello,
    Can we create the view with the parameters? How to do that? We need to create the sql script with parameter for super user to query, instead of create sql script then we would like to create the view then user can select only view.
    Many thanks in advance. :-)

    Hi,
    Views using SYS_CONTEXT, as Justin mentioned, are perhaps the most common way to simulate parameterized views in Oracle.
    Another method is to use a table (usually a Global Temporary Table) to hold the parameters. The view can then join to the table, use it in scalar sub-queries, IN-sub-queries, etc.
    This is the best way if you need to use the same parameterized view two (or more) times in the same query, with different parameters each time.
    Edited by: Frank Kulash on Oct 10, 2008 4:04 PM
    Sorry, I meant to reply to OP.

  • How to create view with schemabinding on cross datbases(partitioned views)

    Hello Everyone,
    Please help me to sort this issue. I know it is not possible bind the scheman in below example. But is there any solution to solve this issue.
    I've tables like below
    create database D1--First database
    create table dbo.t1(
    id int
    create database D2--Second database
    create table dbo.t2(
    id int
    i want to create a view with the schema binding option on this
    create database D3
    use d3
    create view vw_v1
    with schemabinding
    as
    select id from d1.dbo.t1
    union all
    select id from d2.dbo.t2
    I'm getting this below error
    Msg 4512, Level 16, State 3, Procedure vw_v1, Line 7
    Cannot schema bind view 'vw_v1' because name 'd1.dbo.t12' is invalid for schema binding. Names must be in two-part format and an object cannot reference itself.
    Many thanks
    A-ZSQL

    CREATE VIEW
    SCHEMABINDING
    Binds the view to the schema of the underlying table or tables. When SCHEMABINDING is specified, the base table or tables cannot be modified in a way that would affect the view definition. The view definition itself must first be modified or dropped to remove
    dependencies on the table that is to be modified.
    > When you use SCHEMABINDING,
    the select_statement must include the two-part names (schema.object)
    of tables, views, or user-defined functions that are referenced.
    >
    All referenced objects must be in the same database.
    José Diz     Belo Horizonte, MG - Brasil

  • Cannot create view with parameter bindings

    Hi, I'm trying to create this view in SQLPlus:
    SELECT order_no, SUM(cut_qty),
    SUM(received_qty)
    FROM (
    SELECT order_no, cut.dated, DECODE(cut.bimetallic, 'F', cut.quantity, cut.quantity/2) cut_qty,0 AS received_qty
    FROM cut_shop_orders_dated cut
    WHERE cut.dated BETWEEN TO_DATE('&date1','DD/MM/YYYY') AND TO_DATE('&date2','DD/MM/YYYY')
    UNION
    (SELECT order_no, rec.dated, 0, rec.quantity
    FROM received_shop_orders_dated rec
    WHERE rec.dated BETWEEN TO_DATE('&date3','DD/MM/YYYY') AND TO_DATE('&date4','DD/MM/YYYY')))
    GROUP BY order_no
    The problem is that sqlplus asks me for the parameter values and then creates it with these values as literal dates in the to_date function, those not asking for parameter values in runtime.
    How can I create it using parameters with no values at design time?
    Thanks.
    Leandro.

    if you want something like :
    select * from emp $where_clause;
    you can write a procedure with parameter and run it as dynamic sql for example
    create or replace procedure pr1 ( p_where   varchar2) is
    begin
      execute immediate 'create or replace view view_name as select * from emp '|| p_where;
    end pr1;
    /then run it on sql*plus
    SQL> exec pr1('where deptno = 10');
    make sure you give yourself "create any view" rights explicitly.
    HTH
    Ghulam

  • Creating Views with DI APIs DoQuery-Method in SQL 2005

    Hi @All,
    I've had the following (solved) problem:
    The DB installer of one of our AddOns is also creating a bunsh of views for our UDTs. The installer always executes the following two statements for each view:
    IF OBJECT_ID ('[dbo].[@NSP_EXAMPLE_VIEW]', 'V' ) IS NOT NULL
        DROP VIEW  [dbo].[@NSP_EXAMPLE_VIEW];
    CREATE VIEW [dbo].[@NSP_EXAMPLE_VIEW] AS
    SELECT
         T0.U_Field3,
         T1.U_Field1,
    FROM
         [dbo].[@NSP_A] T0 INNER JOIN
         [dbo].[@NSP_B] T1 ON
         T0.U_Key=T1.U_Key  AND
         T0.U_CostNo=T1.U_CostNo;
    This has worked fine for the first 3 views we need. Then came the 4th view and we get an exception from the doQuery. I had to change the SQL-2005 compatibility level back to 80 to create the 4th view because of an incompatible "FOR BROWSE"-statement.
    When it was created under level 80 I saw the problem: ONLY the 4th view was extended with the "FOR BROWSE"-Statement by DI-API. I didn't see any difference in the 4th VIEW-statement which could be the reason that only this one gets the "FOR BROWSE"
    Anyway! Big thanks to  John Mackin and the users of this thread:
    [Formatted search;
    Adding an SQL-comment "--FOR BROWSE" at the end of the VIEW-creation statement has solved the problem.
    (I hope the DI-API query parser will not change this behaviour in the future :-o )
    Cheers,
    Roland

    Thanks for the replies, but casting gave me the original 'General Error' as well.
    I tried to make a stored procedure out of it. I used this page as a guide:
    http://www.davidhayden.com/blog/dave/archive/2005/12/30/2652.aspx
    The stored procedure looks like this:
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go
    CREATE PROCEDURE [dbo].[TestItems]
        @PageIndex INT,
        @PageSize INT
    AS
    BEGIN
    WITH tmpItems AS (
    SELECT ROW_NUMBER() OVER (ORDER BY ItemCode DESC)AS Row, ItemCode, ItemName
    FROM OITM)
    SELECT ItemCode, ItemName
    FROM tmpItems
    WHERE Row between (@PageIndex - 1) * @PageSize + 1 and @PageIndex*@PageSize
    END
    I am able to call this stored procedure like this:
    exec TestItems 10, 10  -- (returns item 91 to 100).
    This solution meets my immediate requirements, but I don't like the fact that I added the stored procedure to the administration itself. Is it possible to add the stored procedure to a different database and still use the DI server?
    Thanks for your time!
    Vincent

  • Create view with variables

    Is there any way of create a view that asks for the value of some parameters?
    something like...
    CREATE VIEW "VIEW1" AS
    SELECT NOMBRE
    FROM EPTABLA_01
    WHERE NOMBRE = ??? WITH READ ONLY

    The method below won't "ask" for a value, but if you set the variable, this will work as a parametrized view.
    SQL> create context my_ctx using my_proc
      2  /
    Context is aangemaakt.
    SQL> create procedure my_proc (p_nombre in number)
      2  is
      3  begin
      4    dbms_session.set_context('my_ctx','my_nombre',to_char(p_nombre));
      5  end;
      6  /
    Procedure is aangemaakt.
    SQL> create table eptabla_01 as select l nombre from (select level l from dual connect by level <= 10)
      2  /
    Tabel is aangemaakt.
    SQL> create view view1
      2  as
      3  select nombre
      4    from eptabla_01
      5   where nombre = sys_context('my_ctx','my_nombre')
      6    with read only
      7  /
    View is aangemaakt.
    SQL> exec my_proc(5)
    PL/SQL-procedure is geslaagd.
    SQL> select * from view1
      2  /
                                    NOMBRE
                                         5
    1 rij is geselecteerd.
    SQL> exec my_proc(8)
    PL/SQL-procedure is geslaagd.
    SQL> select * from view1
      2  /
                                    NOMBRE
                                         8
    1 rij is geselecteerd.Regards,
    Rob.

  • What is the use for CREATING VIEW WITH CHECK OPTION?

    Dear Legends,
    I have a doubt
    What is the use for creating view?
    A: First Data Integrity, Selecting Particular Columns..
    What is the use for creating a view with check option?
    A: As per oracle manual I read that its a referential integrity check through views.
    A: Enforcing constraints at DB level.
    A: using CHECK OPTION we can do INSERTS UPDATES for a view for those columns who have no constraints... is it right??
    A: If we do a INSERT OR UPDATE for columns who have constraints it will show error... is it right???
    Please clear my doubt's Legends
    Lots of Thanks....
    Regards,
    Karthik

    Hi, Karthick,
    karthiksingh_dba wrote:
    ... What is the use for creating view?
    A: First Data Integrity, Selecting Particular Columns..Most views are created and used for convenience. A view is a saved query. If the same operations are often done, then it can be very convenient to code those operations once, in a view, and refer to the view rather than explicitly doing those operations.
    Sometimes, views are created and used for security reasons. For example, you many want to allow some users to see only certain rows or certain columns of a table.
    Views are necessary for INSTEAD OF triggers.
    What is the use for creating a view with check option?
    A: As per oracle manual I read that its a referential integrity check through views.The reason is integrity, not necessarily referential integrity. The CHECK option applies only when DML is done through the view. It prohibits certain changes. For example, if a user can't see certain rows through a view, the CHECK option keeps the user from creating such rows.
    A: Enforcing constraints at DB level.I'm not sure what you mean. Please give an example.
    A: using CHECK OPTION we can do INSERTS UPDATES for a view for those columns who have no constraints... is it right??No. Using CHECK OPTION, you can do some inserts and updates, but not others. The columns involved may or may not have constraints in either case.
    A: If we do a INSERT OR UPDATE for columns who have constraints it will show error... is it right???If you try to violate a constraint, you'll get an error. That happens in views with or without the CHECK OPTION, and also in tables.

Maybe you are looking for