TABLE FUNCTION - Using database view - send parameters to the function.

Hi everybody:
1.- I have a function returning a TABLE OF, and that function recieve 2 parameters of type NUMBER.
2.- I'm able to call this function as a table function like this:
SELECT * FROM TABLE(my_function(3,4))
3.- I want to create a database View, To use this query in diferent places of my app.
CREATE OR REPLACE VIEW NAME_OF_MY_VIEW AS SELECT * FROM TABLE(my_function(:_idOne,:idTwo))
4.- My problem is, that I want to send the parameters dinamically to the function, and use those parameters to populate the rows, using a database view, the previous code does not compile... and I don't know another way to do this.
Please help.
thnks in advance.
Alex.

Yes you can:
SQL> CREATE PACKAGE pkg
AS
   a_global   VARCHAR2 (30);
   FUNCTION f (a VARCHAR2)
      RETURN varchar_tab;
   FUNCTION ret_global
      RETURN VARCHAR2;
   FUNCTION set_ret_global (ret_global VARCHAR2)
      RETURN INTEGER;
END;
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY pkg
AS
   FUNCTION f (a VARCHAR2)
      RETURN varchar_tab
   AS
      l_varchar_tab   varchar_tab := varchar_tab ();
   BEGIN
      FOR i IN 1 .. 10
      LOOP
         l_varchar_tab.EXTEND;
         l_varchar_tab (i) := a;
      END LOOP;
      RETURN l_varchar_tab;
   END f;
   FUNCTION ret_global
      RETURN VARCHAR2
   AS
   BEGIN
      RETURN a_global;
   END ret_global;
   FUNCTION set_ret_global (ret_global VARCHAR2)
      RETURN INTEGER
   AS
   BEGIN
      a_global := ret_global;
      RETURN 1;
   END set_ret_global;
END pkg;
Package body created.
SQL> CREATE OR REPLACE VIEW v
AS
   SELECT *
     FROM TABLE (pkg.f (pkg.ret_global))
View created.
SQL> SELECT *
  FROM v
WHERE 1 = pkg.set_ret_global (5)
COLUMN_VALUE                                                                   
5                                                                              
5                                                                              
5                                                                              
5                                                                              
5                                                                              
5                                                                              
5                                                                              
5                                                                              
5                                                                              
5                                                                              
10 rows selected.
SQL> SELECT *
  FROM v
WHERE 1 = pkg.set_ret_global (4)
COLUMN_VALUE                                                                   
4                                                                              
4                                                                              
4                                                                              
4                                                                              
4                                                                              
4                                                                              
4                                                                              
4                                                                              
4                                                                              
4                                                                              
10 rows selected.

Similar Messages

  • How to use Database views in XI

    Hi Folks,
    Any idea about how to use Database views for sending and receiving messages in XI ?
    Regards,

    Farooq,
    My doubt is do i have work in the same fashion as if i am working on a Database Table...?
    For Ex :
    Creating Source and Target Data structure for JDBC adapter in the same format....etc
    Regards.

  • Using database views in ADF mobile client application

    Hi,
    I am using Jdeveloper 11.1.1.4 and WLS 10.3.4.
    I have developed a POC in ADF mobile client application both with and without synchronization. However, both work with entity objects based on tables.
    I need to use database views instead of tables. When I try to include entity object (based on views) in the view object, it shows an error saying "Only the entity objects based on tables can be selected"
    Please guide me if there is a work around for this.
    Also, please let me know if there is way to develop an ADF mobile client application skipping the use of entity objects at all and using view objects directly to specify the database query and fetch data from the database.
    Thanks in advance.
    Ansh
    Edited by: ansh on Mar 28, 2011 5:40 AM

    Hi, Ansh:
    Currently, out of box, ADF Mobile Client does not support synchronization against Database Views. This is because Mobile Server imposes some schema restrictions to ensure synchronization with multi-table views would work correctly. This schema restriction requires, for example, the view must have a primary parent table with key defined, and also all base table must be included in the data publication. These dependencies requires manual resolution and advanced planning, and is managed outside of the ADF Mobile Client/JDeveloper project.
    To continue development, you would need to create server Entity Objects directly against the base tables. You can then create the mobile ADF Business Component (EOs, VOs, etc). You can then create View Objects in your ADF Mobile Client application based on the database views, in order to retrieve the data you need exactly. In other words, instead of basing EO on the database view, create View Objects in the mobile applicaiton to mimic what you had in the View Object.
    Is there any other reason why you would need to access data via database views, instead of directly against base tables?
    Thanks,
    Joe Huang

  • How to make a link in textflow that send parameters to a function?

    How to make a link in textflow that send parameters to a function?

    In the examples included with the weekly builds there is a CustomLinkEventHandler.as example.  Passing parameters would be done in the CustomClickHandler function.  You could attach the parameters to the LinkElement as user styles using the setStyle API.
    Hope that helps,
    Richard

  • 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

  • Chaging the sender address in the function module

    Hi All,
    Can we change the sender address in the function module 'SO_NEW_DOCUMENT_SEND_API1' .
    Thanks & Regards
    Warun Kumar todimala

    Hi Vijay,
    Ima getting sy-subrc as 5 document_error when iam using this function module.
    Regards
    Warun

  • Change the database log on parameters in the run time with CR10 Delphi2007?

    Hi,
    I'm using crystal report 10 and Crystal VCL for Delphi. How can I change the database log on parameters in the run time?

    You have to use the ConnectBuffer. See [this|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do] note for details.
    Also, consider searching the notes database:
    https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_ossnotes&query=&adv=true
    The search; VCL database crystal, returns a number of notes that may be of use.
    Ludek

  • Parameters of the functions importFiles() and exportTimeline() in Premiere Pro Extension

    Hi, Can anybody explain the parameters of the functions importFiles() and exportTimeline() in Adobe Premiere Pro Extension Builder?  I used an Array of String(File paths) as the parameter for importFiles(), And it worked out. But can we give anything else as the parameter for that function? Because it shows "Object" is the actual parameter for importFiles(). And what about exportTimeline()? I don't have any idea about that function.
    Thanks in advance.

    Hello!
    You are correct; importFiles() takes an array of strings.
    exportTimeline() is exercised in the SDKPanel sample, available here:
    https://workspaces.acrobat.com/?d=NJnaZfBRpmwGwrzOFEWRAA
    The only argument is the match name of the Export Controller in question; the sample panel uses the SDK Export Controller sample, from the Premiere Pro C++ SDK:
    http://www.adobe.com/devnet/premiere/sdk/cs6.html

  • Iv bought a touchpad app for my iPhone 5 to use on my Mac mini, all the functions work accept the zoom one, how can I fix this problem

    Iv bought a touchpad app for my iPhone 5 to use on my Mac mini, all the functions work apart from the zoom one. How can I fix this please

    Iv bought a touchpad app for my iPhone 5 to use on my Mac mini,''
    Considering the app for the iPhone is for iOS, you may have problems using it on the Mac (Mac OS X)
    Two different operating sysems.
    From iTunes for the touchpad app:
    Requirements: Compatible with iPhone, iPod touch, and iPad. Requires iOS 5.1 or later. This app is optimized for iPhone 5.
    From here >  https://itunes.apple.com/us/app/touchpad/id297623931?mt=8

  • How to use HyperTerminal to send characters to the cRIO

    Hello, I built an RS232 serial cable using three wires interface of serial port (Rx, TX, GND). And I connected it between my computer and the cRIO. I would like to ask is it possible to use HyperTerminal to send characters to the cRIO? What vi. do I need to do so?
    And is my cable interface correct? Do I need to connect other pins besides Rx, TX and GND?
    Thank you very much for helping.

    So did it or did it not work when you typed words in by hand in hyperterminal?  I'm not clear on this from your response.
    What kind of things are you trying to send?  What code do you have on your SBRIO to handle the other end of the communication.
    It could mean your connection failed.  It could mean you have the wrong cable between the two (null modem vs. straight through), it could mean you aren't sending the data in the same way the code on the RIO is expecting.  Look at such things like any termination characters you send at the end of the message.
    It's kind of hard to help without know more details of what you are trying to do and whether it is working for you in Hyperterminal or not.

  • Progammatic update a table with a database view  in the page

    Hi All,
    I am using JDev 11g. With FOD database schema, I have one database view Products which comes from two tables Products_Base and Product_Transactions. I created three EOs (ProductEO, ProductsBaseEO, ProductTransactionsEO) and three VOs (ProductVO, ProductsBaseVO, ProductTransactionsVO) based on their EOs respectively.
    Here is my scenario. I have an ADF form which is based on the database view Products and is dragged and dropped from Data Controls->ProductVO. When an existing record is submitted, a backing bean method will be called to update the data against the table Products_Base (and the table Product_Transactions at the same time) programmatically. An update method updateProductPrice() is added into the Application Module and published it to UI Client. The submit button in the page is created by directly dragging and dropping Data Controls->updateProductPrice into the page. When I run it, I got the following error message,
    Failed to post data to database during "Update": SQL Statement "UPDATE PRODUCTS ProductEO SET COST_PRICE=:1 WHERE PRODUCT_ID=:2".
    What I don't understand here is that, in my update method updateProductPrice(), it supposes to update the table Products_Base. But from the error, it appears that it is trying to update the view Products. Can anyone give me a help on what I did wrong here? When I try to debug it, it throws an exception to this line in the method updateProductPrice(),
    getDBTransaction().commit();
    Here are my codes,
    The method which got called in the backing bean
    public String cb6_action() {
    DCBindingContainer bc = (DCBindingContainer)getBindings();
    FacesCtrlAttrsBinding ProductId = (FacesCtrlAttrsBinding)bc.get("ProductId");
    FacesCtrlAttrsBinding CostPrice = (FacesCtrlAttrsBinding)bc.get("CostPrice");
    JUCtrlActionBinding action =
    (JUCtrlActionBinding)bc.findCtrlBinding("updateProductPrice");
    DCDataControl dc = action.getDataControl();
    ApplicationModule am = (ApplicationModule)dc.getDataProvider();
    AppModule service = (AppModule)am;
    service.updateProductPrice(new Long(ProductId.toString()), CostPrice.toString());
    return null;
    public BindingContainer getBindings() {
    return BindingContext.getCurrent().getCurrentBindingsEntry();
    The update method defined in the Application module (AppModuleImpl.java)
    public void updateProductPrice(long productId, String costPrice) {
    ProductsBaseEOImpl product = retrieveProductById(productId);
    if (product != null) {
    try {
    product.setCostPrice(new Number(costPrice));
    getDBTransaction().commit();
    catch (JboException ex) {
    getDBTransaction().rollback();
    throw ex;
    catch (SQLException ex1) {
    getDBTransaction().rollback();
    private ProductsBaseEOImpl retrieveProductById(long productId) {
    EntityDefImpl productDef = ProductsBaseEOImpl.getDefinitionObject();
    Key productKey = ProductsBaseEOImpl.createPrimaryKey(new DBSequence(productId));
    return (ProductsBaseEOImpl)productDef.findByPrimaryKey(getDBTransaction(),productKey);
    Edited by: john wang on Oct 27, 2009 7:14 AM

    or
    merge into test
    using (select rowid rid
                , id
                , sub_id
                , startdate
                , lead (startdate) over (order by id, sub_id) - 1 ed
           from test) x
    on (x.rid = test.rowid)
    when matched then
       update set end_date = x.ed
    ;

  • Using Database Views in XI

    Hi Guys,
    We have come across requirement where we have to use Views rather then Database Tables...
    Kindly share your knowledge and views..:
    1. Is there any difference in handling the views as compred to Tables....?
    2. Like Tables do we have to create the similar type of source and target message types for views also...?
    3. From XI point ...where we can expect the difference views/ tables..in terms of developing design and configuration objects..?
    Regards,

    Hi
    Views are windows to the tables.When you create views in the DB, technically there is not much difference between them.
    Therefore just like tables we have to create similar type of source and target messages for views also.
    Moreover while developing design and configuration objects also no difference will be observed.
    Thanks

  • Is the best practice to use database views or view objects?

    Hi everyone,
    If the option is available, is it preferable consolidate as much data as possible into a database view instead of doing this through view view objects? It seems the answer would be yes, but I would like to hear the pros and cons related to performance, etc.
    While I do not mind a detailed discussion, practical "rule-of-thumb" advice is what I am after; I am a newbie that needs general guidelines - not theories.
    James

    Performance is the main driver behind the question because I am wondering if it is faster to send a single large record set across a network or several small ones and "assemble" them at the client level.
    Probably is better to send one large record, but you will need to take in account time required to create this one large record in db(maybe oracle object types, or arrays of oracle object types).
    Check this for some VO performance advices: Advanced View Object Techniques  (especially property: "In Batches Of" which defines number of roundtrips between app server and db)
    As far as creating an updatable database view, I know there are minor tricks that are required to make that happen from a strictly SQL standpoint. But, I am curious the best way to go in JDeveloper.
    Some solutions:
    Using Updatable Views with ADF | Real World ADF
    Andrejus Baranovskis's Blog: How to Update Data from DB View using ADF BC DoDML Method
    Dario

  • Finding the base tables of a database view

    Hi
    I have a database view like VIQMEL, VIQMSM .So how can i find the what are the base tables for these views.
    pls let me know
    kumar

    Hi ,
    In SE11,
    1. Type in VIQMSM.
    2. Display
    3. you have a tabe "Table & Join Condition.... to list all the releated tables for this view...
    If the hint is useful… Say thanks by reward….
    Regards,
    Prabhu Rajesh

  • How to Export/Import specific/selected table columns (can database view be

    All,
    I like to export and import some selected columns and rows of a table from one oracle database to another database.
    For example, I like to export the following SQL's result data to another oracle database.
    select ename, sal from emp where dno = 100;
    Can I create a database view based on the above SQL and export the view with data (I don't think data will be exported along with database view?)
    I know, I can do this either with SQL*Loader or by creating DBLink between databases and using insert-select statement.
    Please let me know if this is possible in exp/imp.
    Appreciate your help.
    Thanks
    Kumar

    Hello,
    You can Query and table option to export and import and i recommend you to create parameter file to use query option
    parfile.par
    file=myexport.dmp
    tables=table1,table2,table3
    query="where dno=2"
    ..Conventional export/import, you can also consider using datapump if you are using 10g.
    exp username/password parfile=parfile.par log=myexport.log
    imp username/password file=myexport.dmp tables=table1,table2,table3 log=myimport.logRegards

Maybe you are looking for

  • Error: is not a primary database file.

    Hello If I try to set a database online with: ALTER DATABASE mydb SET online this error occurs: Msg 5171, Level 16, State 1, Line 1 E:\Data\mydb_log.ldf is not a primary database file. Msg 5171, Level 16, State 2, Line 1 E:\Data\mydb.mdf is not a pri

  • Assign applications to spaces is Lion

    How do you assign specific applications to spaces in OS X Lion?

  • Trying to uninstall Acrobat 7 on Mac running OS 10.4

    I am doing an uninstall and then a reinstall on all my Adobe Creative Suite products and  I cannot uninstall Acrobat 7.  The message says "The application selected was not a valid Acrobat 7.0 application for this uninstaller.  Please rerun the uninst

  • Php appli and apache agent

    Hi, I've used the j2ee agent with a j2ee web app and it is pretty easy to retrieve the username and role of the user with the getUserPrincipal and isUserInRole methods. I'd like to know if I can grant access to php applications running on a apache se

  • Crystal Reports Java Viewer

    I need to be able to view web reports of a payroll aplication. The payroll vendor told me that I need to install a Crystal Reports with the java viewer component. I am not going to develop I just need to view web reports. Which Crystal Reports versio