Creating a cursor that returns a set and a singleton

I have a situation where I have dozens of defined statically pl/sql cursors, with treatment outcome, where I would like to change the cursor definitions so that they can be used to return a single line or a set.

The effect would be to dynamically add a ' where xx.id = < variable > ' predicate to the game oriented cursor return one row, but where if I tell something (I know I can't) as 'where xx.id = ANY', then the predicate is actually ignored.»

I don't want to use dynamic sql for performance reasons, and of course I don't want to have repeated reams of code and queries.

Does anyone have any ideas on how to do that?

Thanks, Jim

Published by: 922615 on March 21, 2012 19:35

Looks like you just want

CURSOR cursor_name( p_id IN NUMBER )
    IS SELECT *
         FROM some_table
        WHERE (p_id IS NULL or id = p_id );

If you pass a NULL value for p_id, you will get all the back ranks. If you pass a non - NULL ID, you'll just line after line.

Justin

Tags: Database

Similar Questions

  • Do stuff to PL/SQl that returns the value and redirect to modal page by setting this value

    Hello

    a button click Page1 I would perform a PL/SQL procedure that returns a value in P1_ITEMVAL and then redirect to a page 2 (modal page) and the value of an item on this page with the value previously returned. To do the same thing with a normal page is quite easy:

    Button action is present, then process of PL/SQL that returns the value in the P1_ITEMVAL element and, finally, a branch at page 2 that sets P2_ITEMVAL with P1_ITEMVAL. I really have no idea how to do the same thing when the target is a modal page.

    I created a unit test on https://apex.oracle.com/pls/apex (application 1554 - redir_to_modal)

    Workspace: tests

    USER: supporter

    PWD: supporter1234

    Any help would be much appreciated.

    Kind regards

    Pavel

    Pavel

    If you prepare a URL using the value calculated in the PLSQL of DA part you can then use a subsequent stage of javascript to set the location of the window.

    This will jump to the top of the page of the modal dialog box

    : P1_URL: = apex_util.prepare_url)

    ' f ? p ='|| : APP_ID - Application id

    |': 2' - Page id

    ||': ' || : APP_SESSION - Session id

    ||':'                      -- Request

    ||':NO'                    -- Debug

    : ': ' - Clear Cache

    : ': ' - Settings

    ||' P2_ITEMVAL'

    : ': ' - Parameter values

    || (: P1_ITEMVAL);

    then in the action of javascript

    Window.Location.Replace ($v ('P1_URL'));

    Hope this is of some use

    Concerning

    Kelvin

  • How can I create a watermark that has the text and graphics?

    Lightroom does not seem to offer a text watermark OR graphic, can create a watermark that has both?

    Basically, you need create a chart with text it contains.

  • How to create an interactive cursor that returns a numeric value.

    Hello world

    I am trying to create an interactive slider that the user can drag an icon from left to right, in order to select a numerical value. This numeric value will be output to a dynamic text box to capture the data. Please see the example at the link below...

    http://www.carbontrust.co.UK/solutions/CarbonFootprinting/carbonfootprintindicator.htm

    I welcome suggestions of action script to create a slider like that.

    Thanks for your help

    Just as an example, open a new file and add a movieclip on the stage... give it an instance name of "handle" and place it at x = 0, y = 100.  Then place this code in a layer of actons (code red, it's how the drag limits are set)

    handle.addEventListener (MouseEvent.MOUSE_DOWN, mouseDown)

    function mouseDown(event:MouseEvent):void {}
    handle.startDrag (false, new Rectangle (0, handle.y, 200, 0));
    }
    handle.addEventListener (MouseEvent.MOUSE_UP, mouseReleased);

    function mouseReleased(event:MouseEvent):void {}
    handle.stopDrag ();
    }

  • copy of XSLT creates a xml that returns empty while trying to access the elements using XPATH

    Hello

    I'm doing a copy - of the function by using the XSLT in jdev. That's what I do

    < xsl: param name = "appdataDO" / >

    < xsl: template match = "/" >

    < ns1:applicationData >

    < ns1:applicationId >

    < xsl: value-of select = "$appdataDO / ns1:applicationData / ns1:applicationId" / >

    < / ns1:applicationId >

    < xsl: copy-of select = "/ fslo:ExternalapplicationData / fslo:ApplicationsHDRAddInfo" >

    < / xsl: Copy - of >

    < / ns1:applicationData >

    < / xsl: template >

    < / xsl: stylesheet >

    After that, I can see the document created in the flow of process like this:

    < ns1:applicationData >

    < ns1:applicationId > MMMM < / ns1:applicationId >

    < ns2:ApplicationsHDRAddInfo >

    < ns3:genericFromBasePrimitive > iuoui < / ns3:genericFromBasePrimitive >

    < ns4:EstimatedMarketValue > 77 < / ns4:EstimatedMarketValue >

    Jih < ns4:PropertyInsuranceFee > < / ns4:PropertyInsuranceFee >

    hjh < ns4:LoanOriginationFee > < / ns4:LoanOriginationFee >

    KKKKK < ns4:RegistrarFee > < / ns4:RegistrarFee >

    hjh < ns4:LoanCashInFee > < / ns4:LoanCashInFee >

    < ns4:LoanPaidInCashFlag > cddffgd < / ns4:LoanPaidInCashFlag >

    < / ns2:ApplicationsHDRAddInfo >

    < / ns1:applicationData >

    But whenever I am trying to extract all nodes output I get an empty result. I can copy the whole dataset in the same type of variable.

    But I am unable to get the individual elements using XPATH.

    I tried to use the exslt for all nodes and xslt 2.0 without success.

    Namespaces may be the culprit here. The test in the jdev method can produce a result, but during the execution, the xpath expression returns empty.

    I created another transformation where I try to copy the data from the DataObject precious a simple string in an another data object.

    This is the test sample source xml transformation created by jdev when testing with all the namespaces, where I try to copy the data into a simple string in an another data object.

    " < applicationData xmlns: xsi =" http://www.w3.org/2001/XMLSchema-instance "xsi: schemaLocation =" http://xmlns.Oracle.com/bpmpa/FS/ulo/types file:/C:/JDeveloper/NewAPP/Xfrm/xsd/ApplicationData.xsd "xmlns =" http://xmlns.Oracle.com/bpmpa/FS/ulo/types "> "

    applicationId289 < applicationId > < / applicationId >

    < ApplicationsHDRAddInfo >

    " < genericFromBasePrimitive xmlns =" http://xmlns.Oracle.com/BPM/PA/Extn/types/BasePrimitive "> genericFromBasePrimitive290 < / genericFromBasePrimitive > .

    " < EstimatedMarketValue xmlns =" http://xmlns.Oracle.com/BPM/PA/Extn/headerCategories/ "> 291 < / EstimatedMarketValue > .

    " < PropertyInsuranceFee xmlns =" http://xmlns.Oracle.com/BPM/PA/Extn/headerCategories/ "> PropertyInsuranceFee292 < / PropertyInsuranceFee > .

    " < LoanOriginationFee xmlns =" http://xmlns.Oracle.com/BPM/PA/Extn/headerCategories/ "> LoanOriginationFee293 < / LoanOriginationFee > .

    " < RegistrarFee xmlns =" http://xmlns.Oracle.com/BPM/PA/Extn/headerCategories/ "> RegistrarFee294 < / RegistrarFee > .

    " < LoanCashInFee xmlns =" http://xmlns.Oracle.com/BPM/PA/Extn/headerCategories/ "> LoanCashInFee295 < / LoanCashInFee > .

    " < LoanPaidInCashFlag xmlns =" http://xmlns.Oracle.com/BPM/PA/Extn/headerCategories/ "> LoanPaidInCashFlag296 < / LoanPaidInCashFlag > .

    < / ApplicationsHDRAddInfo >

    < / applicationData >

    And the xslt transformation

    < xsl: template match = "/" >

    < ns1:DefaultOutput >

    < ns1:attribute1 >

    < xsl: value-of select = "/ fslo:applicationData / fslo:ApplicationsHDRAddInfo / custom: LoanOriginationFee" / >

    < / ns1:attribute1 >

    < / ns1:DefaultOutput >

    < / xsl: template >

    The result is an empty attribute1. Any help will be appreciated.

    Please remove attributeFormDefault = "qualified" elementFormDefault = "qualified" in your XSD

    Please visit the following link:

    http://www.oraclefromguatemala.com.gt/?p=34

  • How to create a polygon that covers a set of geometries?

    Hi people,

    I have a spatial table with the parcel data. Some are polygons and lines.
    What I have to do is to create a single polygon that covers all these plots.
    I tried some spatial functions, but the result is not perfect.
    Could you guys give some advice on how to do it using the Oracle Spatial functions?

    Thank you
    Luis

    Luis etc.,

    Delicate using the ST_PolygonBuilder (JTS) that implements my code SC4O Java-in-the-database and some coding, I managed to product a polygon that covers the data correctly.

    Note that I use only external linestrings which provides some Luis.

    -- First create a table holding only the outer lines.
    --
    create table outerLines as
      SELECT SDO_GEOMETRY(2002, 8292, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(-49.6878936628642, -18.4995538840232, -49.6875224063873, -18.4994400734344, -49.6882811644211, -18.4960292763006, -49.6886251490431, -18.4958803030445, -49.6906307026931, -18.4950115281619)) as geom from dual union all
      SELECT SDO_GEOMETRY(2002, 8292, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(-49.6884083531774, -18.4917625230274, -49.6886528151554, -18.4922451253898, -49.6898503241639, -18.4946091658756, -49.690098431643, -18.4950991112698, -49.6902068702432, -18.4950498009285, -49.6905958643821, -18.4948724904445)) as geom from dual union all
      SELECT SDO_GEOMETRY(2002, 8292, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(-49.6883413960309, -18.4918992292229, -49.6885491287687, -18.4923048595269, -49.6849860033691, -18.4934740072225, -49.6855427926656, -18.4945793006294, -49.6857982402423, -18.4950861997106, -49.6860079716291, -18.4955025995491, -49.6836133980005, -18.4962994912622, -49.6834396716227, -18.4957578264012)) as geom from dual union all
      SELECT SDO_GEOMETRY(2002, 8292, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(-49.6792385551751, -18.5000418095053, -49.6797119992317, -18.4998345697814, -49.6783397446724, -18.4980535328215, -49.6810365599698, -18.4971609552001, -49.6810385833744, -18.4971564511947, -49.6835051531636, -18.4963355157698, -49.6833312619652, -18.4958030666281)) as geom from dual union all
      SELECT SDO_GEOMETRY(2002, 8292, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(-49.6878678853177, -18.4996181336176, -49.6861731626715, -18.4991017919552, -49.6834080082784, -18.4982775371379, -49.6833583465082, -18.4983066497055, -49.6832975737928, -18.4983520405102, -49.6831594052426, -18.4984987309426, -49.6830586383606, -18.4986094463067, -49.6829994956301, -18.4986769870823, -49.6829194669485, -18.4987385992949, -49.6828337343539, -18.4987905933782, -49.6827167582476, -18.4988411048671, -49.6825978712605, -18.4988566328165, -49.6824876108137, -18.4988587567866, -49.6824343436196, -18.4988638980162, -49.6823495710101, -18.498901802054, -49.6820036074112, -18.4990727977958, -49.6815739264209, -18.4993045655044, -49.6815394467332, -18.4993194542279, -49.6815037571481, -18.4993313944568, -49.681467095582, -18.4993402576461, -49.6814297528519, -18.4993459734892, -49.6813920251781, -18.4993484966453, -49.6813542118344, -18.4993478070996, -49.6813166127745, -18.4993439103221, -49.6812795262518, -18.4993368372241, -49.6812432464542, -18.4993266439127, -49.6812080820875, -18.4993134018902, -49.6793284309429, -18.5001537628556)) as geom from dual;
    
    -- Firstly, fill in the gaps between all the outer lines by generating small 2 point linestrings....
    -- This is what the CTE, connected_lines, produces
    --
    with connected_lines as (
    select row_number() over (order by 1) as rid,
           f.geom
      from (select sdo_geometry(2002,8292,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(sx,sy,ex,ey)) as geom
              from (select distinct sx,sy,ex,ey,dist,
                           min(dist) over (partition by sx,sy) as mdist
                      from (select a.x as sx,a.y as sy,b.x as ex,b.y as ey,
                                   sdo_geom.sdo_distance(sdo_geometry(2001,8292,sdo_point_type(a.x,a.y,null),null,null),
                                                         sdo_geometry(2001,8292,sdo_point_type(b.x,b.y,null),null,null),
                                                         0.005) as dist
                              from (select p.x as x, p.y as y
                                      from outerLines g,
                                           table(geom.getVector(g.geom)) v,
                                           table(geom.getPointSet(v.AsSdoGeometry(8292))) p
                                    group by p.x, p.y
                                    having count(*) = 1
                                   ) a,
                                   (select p.x as x, p.y as y
                                      from outerLines g,
                                           table(geom.getVector(g.geom)) v,
                                           table(geom.getPointSet(v.AsSdoGeometry(8292))) p
                                    group by p.x, p.y
                                    having count(*) = 1
                                   ) b
                              where a.x != b.x and a.y != b.y
                            )
                    )
                    where dist = mdist
            UNION ALL
            select g.geom
              from outerLines g
          ) f
    )
    /* Now ask SC4O's ST_PolygonBuilder to try and create a polygon from the set of lines */
    select sc4o.ST_PolygonBuilder(CAST(COLLECT(f.geom) as mdsys.sdo_geometry_array),8) as polygon
      from ( /* Now, the WITH connected_lines produces 2 copies of each linestring with the coordinates reversed.
                    These have to be removed/de-duped before being passed into the ST_PolygonBuilder */
            select sdo_geometry(2002,8292,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(sum(x1),sum(y1),sum(x2),sum(y2))) as geom
              from (SELECT rid,
                           case when rid=NVL((lag(rid,1) over (partition by rid order by x)),rid)
                                then case when vertexId = 1 then x else null end
                            end as x1,
                           case when rid=NVL((lag(rid,1) over (partition by rid order by x)),rid)
                                then case when vertexId = 1 then y else null end
                            end as y1,
                           case when rid=NVL((lag(rid,1) over (partition by rid order by x)),rid)
                                then case when vertexId = 2 then x else null end
                            end as x2,
                           case when rid=NVL((lag(rid,1) over (partition by rid order by x)),rid)
                                then case when vertexId = 2 then y else null end
                            end as y2
                    FROM   (select rid,
                                   row_number() over (partition by rid order by x) as vertexId,
                                   x, y
                              from (select min(m.rid) rid,
                                           t.x, t.y
                                      from connected_lines m,
                                           table(sdo_util.getVertices(m.geom)) t
                                     where sdo_util.GetNumVertices(m.geom) = 2
                                     group by t.x,t.y
                                     order by t.x )
                           )
                      )
                    group by rid
        union all
        /* Select and pass into ST_PolygonBuilder the original outer lines */
        select m.geom as geom
          from connected_lines m
         where sdo_util.GetNumVertices(m.geom) > 2
        ) f;
    -- Result
    --
    POLYGON
    -----------------------
    MDSYS.SDO_GEOMETRY(2003,8292,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),MDSYS.SDO_ORDINATE_ARRAY(-49.6906307026931,-18.4950115281619,-49.6886251490431,-18.4958803030445,-49.6882811644211,-18.4960292763006,-49.6875224063873,-18.4994400734344,-49.6878936628642,-18.4995538840232,-49.6878678853177,-18.4996181336176,-49.6861731626715,-18.4991017919552,-49.6834080082784,-18.4982775371379,-49.6833583465082,-18.4983066497055,-49.6832975737928,-18.4983520405102,-49.6831594052426,-18.4984987309426,-49.6830586383606,-18.4986094463067,-49.6829994956301,-18.4986769870823,-49.6829194669485,-18.4987385992949,-49.6828337343539,-18.4987905933782,-49.6827167582476,-18.4988411048671,-49.6825978712605,-18.4988566328165,-49.6824876108137,-18.4988587567866,-49.6824343436196,-18.4988638980162,-49.6823495710101,-18.498901802054,-49.6820036074112,-18.4990727977958,-49.6815739264209,-18.4993045655044,-49.6815394467332,-18.4993194542279,-49.6815037571481,-18.4993313944568,-49.681467095582,-18.4993402576461,-49.6814297528519,-18.4993459734892,-49.6813920251781,-18.4993484966453,-49.6813542118344,-18.4993478070996,-49.6813166127745,-18.4993439103221,-49.6812795262518,-18.4993368372241,-49.6812432464542,-18.4993266439127,-49.6812080820875,-18.4993134018902,-49.6793284309429,-18.5001537628556,-49.6792385551751,-18.5000418095053,-49.6797119992317,-18.4998345697814,-49.6783397446724,-18.4980535328215,-49.6810365599698,-18.4971609552001,-49.6810385833744,-18.4971564511947,-49.6835051531636,-18.4963355157698,-49.6833312619652,-18.4958030666281,-49.6834396716227,-18.4957578264012,-49.6836133980005,-18.4962994912622,-49.6860079716291,-18.4955025995491,-49.6857982402423,-18.4950861997106,-49.6855427926656,-18.4945793006294,-49.6849860033691,-18.4934740072225,-49.6885491287687,-18.4923048595269,-49.6883413960309,-18.4918992292229,-49.6884083531774,-18.4917625230274,-49.6886528151554,-18.4922451253898,-49.6898503241639,-18.4946091658756,-49.690098431643,-18.4950991112698,-49.6902068702432,-18.4950498009285,-49.6905958643821,-18.4948724904445,-49.6906307026931,-18.4950115281619))
    

    The result is a nice clean polygon.

    http://www.spatialdbadvisor.com/files/PolygonCoveringGeometrySet.PNG

    This, more than my last post is the best I can do. It took me many, many hours to implement. Please allow points since it is a correct result. Also, consider making a PayPal donation on my Web site for the hours I spent.

    NOTE: The package space companion 4 Oracle (SC4O) is available for download FREE on my site. Again, donations accepted if the code made what you want.

    concerning
    Simon

    Published by: Simon Greener on April 11, 2013 09:53 Changed where a.x, b.x and b.y-a.y etc. to where a.x! = b.x and a.y! b.y =

  • Possibility to create a script that automatically opens files and processes?

    I have a folder on my computer which has automatically downloaded image files periodically. I would like to have a script in photoshop that can batch process them automatically and then move them out of the folder so that they are not treated again - but I just wanted to know if it was common or even possible. I do a lot of scripts, but I'm good enough to understand things if anyone has information or examples of scripts that can do something like that, that would be greatly appreciated. Thank you!

    Did you search Forum yet?

    Re: folder

  • Creating a form that others can modify and then forward

    How can I make an editable form for my employees that they can then fill out and send to our customers in a non-editable format? I have the latest version of Acrobat Pro and LiveCycle.  Thank you!

    Start by

    http://help.adobe.com/en_US/acrobat/pro/using/WS58a04a822e3e50102bd615109794195ff-7e1e.w.h tml,

    Make sure your form is on. While your users can fill out and

    print the form in pdf format, if necessary and email clients for their

    documents. However, check the EULA for restrictions of use.

  • I am trying to create a function that would be on the table type returns.

    Gurus,

    I am trying to create a function that returns a table nested with 3
    columns in a table as a guy.

    my query is like

    Select col1, col2, col3 from table_1;

    I am a bit newbie in Oracle and have never used collections.
    Can you please guide?

    >
    I am a bit newbie in Oracle and have never used collections.
    >
    Then you should start with the documentation
    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/TOC.htm

    Chapter 5 is all about collections using PL/SQL and examples
    >
    I am trying to create a function that returns a table nested with 3
    columns in a table as a guy.
    >
    This isn't enough of a description to know what you're trying to do, or how you plan to use the service. The query you provided is completely irrelevant to the question you are asking.

    You ask about functions in pipeline? Here is an example of this

    -- type to match emp record
    create or replace type emp_scalar_type as object
      (EMPNO NUMBER(4) ,
       ENAME VARCHAR2(10),
       JOB VARCHAR2(9),
       MGR NUMBER(4),
       HIREDATE DATE,
       SAL NUMBER(7, 2),
       COMM NUMBER(7, 2),
       DEPTNO NUMBER(2)
      )
      /
    
    -- table of emp records
    create or replace type emp_table_type as table of emp_scalar_type
      /
    
    -- pipelined function 
    
    create or replace function get_emp( p_deptno in number )
      return emp_table_type
      PIPELINED
      as
       TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
        emp_cv EmpCurTyp;
        l_rec  emp%rowtype;
      begin
        open emp_cv for select * from emp where deptno = p_deptno;
        loop
          fetch emp_cv into l_rec;
          exit when (emp_cv%notfound);
          pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
              l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
        end loop;
        return;
      end;
      /
    
    select * from table(get_emp(20))
    
  • html5_init.js creates different behaviors of DB on OS5 and OS6! Help!

    Hello

    I am trying to create an application that runs on OS5 and OS6 and uses the html5_init.js scripts provided by RIM around the fact that os5 runs synchronously on gears and asynch OS6 on HTML5...

    After a lot of refactoring and rewrite, it remains now to the next obstacle. On OS5, it works as I hope as follows BUT on OS6 it doesn't, it behaves quite differently

    Example, I create an array of objects and itterate over them and insert them into a table of test.

    function insertTestData() {
        db.transaction(function(tx) {
            var testData = [];
            for (var i = 0; i < 3; i++) {
                var testCodeValue = new Object();
                testCodeValue.code = "code" + i.toString();
                testCodeValue.value = "value" + i.toString();
                testData.push(testCodeValue);
            }
    
            for (var y = 0; y < testData.length; y++) {
                var code = testData[y].code;
                var value = testData[y].value;
    
                alert(code);
                alert(value);
    
                tx.executeSql("INSERT INTO test(code,value) VALUES (?,?)", [code, value], rowInserted, function(tx, err) { alert("Error!"); });
            }
        });
    }
    

    the end result is:

    Hello

    Check out this post on loops in transactions for the asynchronous callbacks. He can help out you.

    for loops

    See you soon

    Andrew

  • Can I create a cursor and set the values by myself

    Can I create a cursor and set the values by myself, and it has not been filled by an SQL?

    Thanks in advance

    Yes, you can.
    Use variables with a default value or nvl (some_parameter, some_variable) in your cursor WHERE predicate.
    They provide an example if it isn't clear, since that's all I can think about reading your post...

  • all my pictures have disappeared? I work on a lot that I had downloaded, and then I selected, then went to create a new collection and baptized DH slideshow 2015, then press return and now it is gone! Help, please!

    All my pictures have disappeared? I work on a lot that I had downloaded, and then I selected, then went to create a new collection and baptized DH slideshow 2015, then press return and now it is gone! Help, please!

    You have created a new CATALOG... !  not a collection!  (looking at your screen-clip)

    Re-open your correct catalogue-'Lightroom Catalog.lrcat 5' in the Menu > file > open recent element.

    Select the pictures again, click [+] on the header of the COLLECTIONS Panel.

    Before going further, learn from this video tutorial-

    Lightroom CC - create custom images - YouTube Collections

  • Create the view and by using the function that returns a type oracle

    Following is possible?

    A function returns an ORACLE object Type, and I want to use this feature, in my opinion, it is possible to access each field of the type once the function is executed and make a column in the view?
    create or replace TYPE SOME_INFO AS OBJECT
    ( 
      CHARGE FLOAT,
      SOME_DATE DATE,
      SOME_VAL VARCHAR(50)
    );
    
    CREATE OR REPLACE
      FUNCTION CALCULATE_INFO
        (
          p_chargeId NUMBER)
        RETURN SOME_INFO 
      AS 
      v_some_info SOME_INFO := new SOME_INFO(0, null, null);
    BEGIN
     
    -- function body populates the v_some_info
    return v_some_info;
     
    END calculate_info;
    Now, I want to use the function according to me - if the underlying query of the view follows-
     select c.*, calculate_info(c.charge_id) as someInfo from some_charge;
    How to recover someInfo.CHARGE, someInfo.some_date, someInfo.some_val? I can put them as columns in the view?

    If you use only functions that return a single value in a view?

    Thank you
    Mustapha

    Published by: Tina Giri on April 16, 2009 05:47

    How to recover someInfo.CHARGE, someInfo.some_date, someInfo.some_val?

    SQL>  create or replace type some_info
    as
       object (charge float, some_date date, some_val varchar (50));
    /
    Type created.
    
    SQL>  create or replace function calculate_info (p_chargeid number)
       return some_info
    as
       v_some_info   some_info := new some_info (0, null, null);
    begin
       -- function body populates the v_some_info
       return v_some_info;
    end calculate_info;
    /
    Function created.
    
    SQL>  select your_view.someinfo.charge,
           your_view.someinfo.some_date,
           your_view.someinfo.some_val
      from (select c.*, calculate_info (c.empno) as someinfo
              from emp c) your_view where rownum <= 3
    
    SOMEINFO.CHARGE SOMEINFO SOMEINFO.SOME_VAL
    --------------- -------- --------------------------------------------------
                  0
                  0
                  0                                                            
    
    3 rows selected.
    
  • test a SP that returns a CURSOR

    I am using Oracle 11 and trying to use SQL Developer. However, I can't seem to get the DEBUGGING to work to test the call a SP that returns a cursor.

    I wrote a small test program to test, but they do not compile and I'm not sure why not. Can help you?

    the first code fragment is a package that I have that has a defined CURTYPE. It is used throughout my request, when you declare a cursor:
    create or replace
    PACKAGE          "SP_STATE" 
    Is
        type     curtype is ref cursor;
    ...
    now, here's the first part of the SP I want to test. Note that I've defined PriceCur as using the CURTYPE package.
    create or replace
    PROCEDURE          "USP_GETL_ACCOUNT_PRICES" (
      AcctNo          in     marketer_account.mka_last_full_css_acct_no%type,
      MktrNo          in     marketer_account.mka_mktr_no%type,
      Status                     in              varchar2 default null,     
      PriceCur          out            sp_state.curtype
      )
    as
    begin
    Open Pricecur For 
    Select 
    ...
    Now, here's my m.o.:
    Declare 
       Price_Cur  Sp_State.Curtype;
       price_rec  price_cur%rowtype;
    Begin
       Usp_Getl_Account_Prices('302189139000026', 11813,'A', price_cur);
       Open Price_Cur;
       Loop
          Fetch Price_Cur Into Price_Rec;
          Exit When Price_Cur%Notfound;
          dbms_output.put_line(price_cur%rowcount || ') ' || price_rec.apr_account_price_id);
       End Loop;
       close price_cur;
    end;
    They do not compile. What I'm doing here is call SP - pass 3 incoming parameters and retrieve a cursor.
    so I want to loop through the cursor and list some fields on...

    Where I'm going wrong? Any help would be greatly appreciated.

    Sean

    userLynx wrote:
    I get this error:

    Error report:
    ORA-06504: PL/SQL: return variables of the game results or the query types do not match
    ORA-06512: at line 7
    + 06504. 00000 - "PL/SQL: return of the variable result set or query types do not match." + "
    * Cause: Numbers or types of columns in a query does not match declared.
    return type of a variable result is defined or declared two result types
    Set of variables do not match.
    * Action: Change the program or the declaration statement. Check what query variable +.
    actually we want during execution.

    He doesn't like the var defined as varchar2. I can change that to a % rowType heart?

    When I proposed to modify the code according to your needs, I assume that you would like to change the instruction WRT Fetch your columns retrieved in the Refcursor; And so I suggest no changes in it.

    As riedelme says, a record would help for better maintainability. :)

    You do not experience other errors, you met earlier, right?

    Kind regards
    P

    Published by: Jen K on July 12, 2012 12:04 AM

  • Message box in function that returns a list deletes the created list... (Dialog box)

    Hello

    I work with a complex dialogue, its purpose is to manage a section in the PDF file.

    I use a "mclv" object in the dialog box to represent data entries in the PDF file in order to manage the result in another section.

    I created a function that creates the list based on a previous section in the PDF object, the function works perfectly well.

    But I have a small question, the function used to create the list of the dialog box object performs a check with the former front list created, as appropriate,

    and if in any case it is different from the old list, I need to warn the user that the list has changed and if there were any changes applied to the result it will be returned to zero and must be recreated.

    But when the poping that message box, all lists are deleted and nothing is displayed in the objects 'mclv.

    If I remove the message box, the lists are all very well...

    Is there anyone who have come across something like this before? If so, any solution to this problem?

    I asked my question a bit too quickly, I already found a work around

    But I still don't understand why he behaves like that tho...

    I just thought how to work around this problem.

    If anyone has encountered this problem can use this solution:

    Instead of having the message inside the function to return box, I declared a global Boolean variable to the Script object

    If the message box must be displayed, the Boolean value is set to True

    Once in the initialize event of the dialog box, if the value Boolean true I call the message box and reset the value Boolean false

Maybe you are looking for