Cursor in Reports

hiiiiiiiiiiii allllllllll,
in my reports i have a 2 columns Positive, Negative, i have a query which returns single columns with values negative and positive. i want that positive values should display in positive columns and negative values should display in negative columns. plz tell me how can i do this.
regards
Tayyab

with T as (select 7 amt from dual UNION
           select -3 amt from dual UNION
           select 0 amt from dual)
select decode(sign(amt),-1,null,amt) pos,
       decode(sign(amt),-1,amt) neg
from T
POS     NEG
     -3
0     
7     

Similar Messages

  • Ref cursor in Reports details

    Hi All
    we are planning to create a D2K report using
    ref cursor the problem for me is that i want to know
    whether it is feasible for creating a report which
    contains around 5 complicated queries and number of
    formula columns etc.can you please give me points
    how to go about or if it is not feasible can you
    give me the reasons for that.

    Hello,
    Ref Cursor queries are useful in sharing queries across reports, and exploiting commonality between them. You can segregate your individual queries into ref cursors and combine them in your data model. You can also create formula columns based on data fetched by the ref cursor, since Reports treats any data fetched from the data source in a generic manner.
    Please take a look at the 'Building a Paper Report with Ref Cursors' section of the 'Building Reports' manual on OTN at http://otn.oracle.com/products/reports/htdocs/getstart/docs/B10310_01/orbr_refcur.htm#1009556 for further details on building and using ref cursor reports.
    Thanks,
    The Oracle Reports Team.

  • REF Cursor in Reports 3.0.5.8

    I have developed a report (REPORTS 3.0.5.8)based on REF Cursor
    Query. I Created a local Package and called the function in the
    package in the QR_1RefCurDS function. I am able to get the
    results when I tried to run from my machine.
    The report was compiled, saved and generated and copied the REP
    file on to a different machine on the N/W.
    But when I tried to access the same report over the network, it
    fails giving the following error:
    REP-1401: 'beforereport': Fatal PL/SQL error occured.
    ORA-06508: PL/SQL: could not find the program unit being called.
    Runtime Engine and REP file reside on a single machine and I
    access the report in the following format:
    //Computer Name/Oracle_Home/Bin/R30RUN32.EXE //Computer
    Name/D/ReportName.Rep userid/password@SID
    I have been unsuccessful after trying to move the package to the
    database(I get a Virtual memory error ! !)
    Is there any other way to accomplish the same task(dynamic
    changing of the SQL statements) ?? Is LEXICAL Parameters is the
    only answer apart from the REF Cursor which does not work ?????
    Database:
    Oracle Server Release 7.3.4.3.0
    Oracle PL/SQL V2.3.4.3.0 Production Release
    Reports 3.0.5.8:
    Oracle Server Release 7.3.4.0.0
    Oracle PL/SQL V2.3.4.0.0 Production Release
    Does this make a difference ????
    Thanks a bunch...

    try recompiling the pll <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by kumaran:
    I am getting the following error when I try to run a report after upgrading from reports 3.0.5.8 to 3.0.5.12.2 on UNIX.
    I am able to successfully generate the rep file.
    but I am not able to run it. the report references a library(pll file) and this library is in the reports30_path
    ORA-06508: PL/SQL: could not find program unit being called
    any suggestions would be greately appreciated
    Thanks<HR></BLOCKQUOTE>
    null

  • Error in function cursor in report version 9.0.4.10

    I created a funtion with this cursor
    Cursor C2(c_leasecomp lease.leaseid%Type) is
    select distinct sorg.orgid department
    from space_lease sl,spaceorg sorg,org org,
    (select case when (select 1 from space_lease where UOM_STD_ID = 'METR_MTR' and rownum = 1) = 1 then 1
    when (select 2 from space_lease where UOM_STD_ID = 'ACRE' and rownum = 1) = 2 then 2
    else 3
    end case_col
    from dual) d1
    where sl.uom_std_id = decode(d1.case_col,1,'METR_MTR',
    2,'ACRE',
    3,'PARK',
    null)
    and sl.leaseid = c_leasecomp
    and sl.bldgid = sorg.bldgid
    and sl.FLRID = sorg.FLRID
    and sl.spid = sorg.SPID
    and sorg.orgid = org.orgid
    and ( org.ORGCLASS = 'ABC'
    or org.ORGCLASS = 'GD'
    or sorg.orgid IN (select orgid from cst_spaceorg_exception))
    order by sl.leaseid;
    But am having the error below
    Error 103 at line 12 , column 34
    (-+ Case mode not null others<an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    count current exists max min prior sql stddev sum variance----
    I ran this as an anonymous function is Sql and it worked. Is this the report engine thing or am doing something wrong. The Database is 10g

    Duplicate Report9i not generating more then 50852 pages in PDF format
    Regards,
    Martin Malmström

  • Converting cursor to ref cursor in Report builder pl/sql

    Hi,
    I am trying to use dynamic sql in My report 's pl/sql code.
    I can not use execute Immediate statement since this feature is not suppoerted at client side and i am doing the coding In my local mchine and running the report loaclly.......???
    Another way to use dynamic sql is by using dbms_sql package.
    Using dbms_sql to run a sql will give me a normal cursor as an output.
    Since in report builder pl/sql only ref cursor is allowed as a return type from a function........the problem i m facing is conversion of the cursor to ref cursor......
    in oracle 11g we have a built in function in dbms_sql package that can be used for the conversion....
    i m using oracle 10 g where the above mentioned feature is not available............
    Please give some way to resolve this issue............!!!!!!!!!!!!
    Thanks in Advance.....!!!!!!!
    Abhishant

    You may use some stored procedures that will take full advantage of dynamic SQL. Make a stored proc that inserts rows in a global temporary table. You will call that stored proc in the afterpform trigger. And you will have the report querry select from the temporary table populated by the stored proc.
    I did some things like that.
    HTH

  • Set Cursor in Report Program

    Hi,
      I am doing a report program. After display the report i am coming down.
      For a particular position I have to click which will open a screen.
      But when I close screen then my cursor position is coming to beginning.
      Plz help me.
    Thanks,
    Sunil Sahoo

    Hi,
    why dont you use set cursor to set the position in the screen in at selection-screen output.

  • Ref Cursor on Report 6i

    I am trying to build a report based on Ref Cursor query with dynamic string as given below.
    OPEN loc_ref_cur_ugss_pay_car FOR 'SELECT name, email_id, job, remarks FROM employee_desc' ;
    On compile I am getting following error.
    Encountered the symbol "SELECT....." when expecting one of the following: select.
    Can't I use ref cursor with dynamic string?
    Thanks & regards,
    Rakesh

    If I will use Select statement without quote then it will be a static query. I want to use the dynamic one which will use different table names depending upon condition. The tables which are to be used here are temparary tables and will be be created through report only.

  • Question about Cursor in Reports

    Hello I new in this forum
    I need some help, i've started using Reports and I need to show in a Jsp report the result of a stored Procedure this procedure returns a cursor , so my question is How I can to show this selection (result of the cursor) in the report? ' cause when creating a Report with the wizard or manually the application asks for the selection

    inolau :
    Thanks for the link, it's was very useful.
    Well a have another question I need to display a report but pl/sql sends an error because the sql sentece is dynamic and do not allow to use a record
    example
    type v_record is record (deptos.no_folio%type,deptos.dependencia%type,empleado.name%type);
    type depto_ref is ref cursor return v_record
    create or replace function fnc_depto (idempl in varchar2) return depto_ref
    is
    v_cursor depto_ref;
    v_select varchar2(2000);
    begin
    v_select ='select deptos.no_folio,deptos.dependencia,empleado.name
    from deptos join empleado on (deptos.no_folio=empleados.no_folio)
    where empleados.idempleado in (' || idempl || ' ) ';
    open v_cursor for
    v_select;
    return v_cursor;
    end;
    when I create the function it's good but when you execute it returns an error that says
    PL/SQL: Statement ignored
    PLS-00455: el cursor 'V_CURSORDETALLE' cannot use it in a sentece OPEN of Dynamic SQL
    Do you know some solution for it?
    thanks for your time
    cheers!
    best regards

  • Weak and Strongly Typed Reference Cursors in Reports

    Our custom reports has been using a reference cursor. I have inherited the code and not sure why there is a need to use a reference cursor when it can be done by a simple select statements. I see no dynamic select statements passed or any special parameters to reason out for use of reference cursor in our custom reports. Prior developers had reason out the benefits of using reference cursor for performance. I tested this by running a report with reference cursor versus plain select statement and still the report that is using the plain select statement performed better (faster) than the report that has the reference cursor, there is a big difference.
    I have seen some disadvantage of using reference cursor on the reports that when there is a database object change even if the package that sourced the reference cursor has not been updated or modified the reports needs to be recompiled each time we get this error message coming from the report server queue:
      Terminated with error: <br>REP-8: Run time error in the PL/SQL development
      environment (DE). PDE-PSD001 Could not resolve reference to <Unknown Program Unit>
      while loading <Unknown> <Unknown>. REP-0008: Unexpected memory error while
      initializing preferences.In 9iAS reports prior version the error is occurring rarely. When we moved to 10.1.2.2.0 reports it appears the error occurs most often. We have made an effort to research about the issue and appears to be a bug. One suggestion is to use a strongly typed reference cursor. I have tried to researched about the difference between a weak and strongly typed reference cursor but failed to understand them. I appreciate any help about examples differentiating a weak versus a strongly typed reference cursors.
    Thanks,
    Warren

    I guess my point, for what it's worth, is that whether you use only a strongly typed REF CURSOR, or whether you also use a weakly typed REF CURSOR, you may still end up getting the REP-0008 error (at least if your report is in .REP format). You can avoid this by using a pipelined function instead (or by putting the SQL directly in the report, or possibly by using .RDF or .JSP format).
    To test this, you might:
    1. Create a database package with an SQL*Plus script that that looks something like this:
    CREATE OR REPLACE PACKAGE TEST AS
        TYPE RECORD_TYPE IS RECORD
            USERNAME ALL_USERS.USERNAME%TYPE
        TYPE TABLE_TYPE IS TABLE OF RECORD_TYPE;
        TYPE WEAKLY_TYPED_REF_CURSOR_TYPE IS REF CURSOR;
        TYPE STRONGLY_TYPED_REF_CURSOR_TYPE IS REF CURSOR RETURN RECORD_TYPE;
        FUNCTION GET_WEAKLY_TYPED_REF_CURSOR RETURN WEAKLY_TYPED_REF_CURSOR_TYPE;
        FUNCTION GET_STRONGLY_TYPED_REF_CURSOR RETURN STRONGLY_TYPED_REF_CURSOR_TYPE;
        FUNCTION GET_PIPELINED_TABLE RETURN TABLE_TYPE PIPELINED;
    END TEST;
    CREATE OR REPLACE PACKAGE BODY TEST AS
        FUNCTION GET_WEAKLY_TYPED_REF_CURSOR RETURN WEAKLY_TYPED_REF_CURSOR_TYPE
        IS
            cWeaklyTypedRefCursor WEAKLY_TYPED_REF_CURSOR_TYPE;
        BEGIN
            OPEN cWeaklyTypedRefCursor FOR
            SELECT USERNAME FROM ALL_USERS;
            RETURN cWeaklyTypedRefCursor;
        END GET_WEAKLY_TYPED_REF_CURSOR;
        FUNCTION GET_STRONGLY_TYPED_REF_CURSOR RETURN STRONGLY_TYPED_REF_CURSOR_TYPE
        IS
            cStronglyyTypedRefCursor WEAKLY_TYPED_REF_CURSOR_TYPE;
        BEGIN
            OPEN cStronglyyTypedRefCursor FOR
            SELECT USERNAME FROM ALL_USERS;
            RETURN cStronglyyTypedRefCursor;
        END GET_STRONGLY_TYPED_REF_CURSOR;
        FUNCTION GET_PIPELINED_TABLE
        RETURN TABLE_TYPE PIPELINED
        IS
        BEGIN
            FOR rec IN
                SELECT USERNAME FROM ALL_USERS
            LOOP
                PIPE ROW(rec);
            END LOOP;
        END GET_PIPELINED_TABLE;
    END TEST;
    /2. Create a report based on REF CURSOR query using only a strongly typed REF CURSOR. The PL/SQL statement that you use in the report as the data source for the query might look something like this:
    function QR_1RefCurDS return test.strongly_typed_ref_cursor_type is
    begin
      return test.get_strongly_typed_ref_cursor;
    end;3. Compile the report to a .REP file and run it to make sure it works as expected.
    4. Drop and re-create the TEST package in the database.
    5. Try running the .REP file again. I expect you will get the REP-0008 error.
    6. Modify the REF CURSOR query to use an underlying weakly typed REF CURSOR by changing the PL/SQL statement (from Step 2) to something like this:
    function QR_1RefCurDS return test.strongly_typed_ref_cursor_type is
    begin
      return test.get_weakly_typed_ref_cursor;
    end;7. Repeat Steps 3 through 5. I expect you will get the REP-0008 error again.
    8. Replace the REF CURSOR query in report with an SQL query that looks something like this:
    SELECT * FROM TABLE(TEST.GET_PIPELINED_TABLE)9. Repeat Steps 3 through 5. I expect you will not get the REP-0008 error.
    Hope this helps.

  • Huge numbers of open cursors mistakenly reported

    Hi,
    We recently received an alert stating:
    Metrics "Current Open Cursors Count" is at 4294966978
    I'm trying to ascertain the source of the erroneous number of open cursors. There also seems to be a very strange graph on the alert page in EM. The graph shows the entire Y axis as: 4294966978, yet the plot moves up and down.
    Investigating the issue, I encountered a statistic even more bizarre. In EM, clicking on the Performance tab, and then selecting "Instance Activity" from the list at the bottom of the page, brings up a chart, and a radio button to switch to "Tabular" view. The Tabular view reports that:
    "opened cursors current" is 2^63-1
    Which is plainly impossible. Has anyone else noted this behavior, or have any insight into the cause of it? Viewing the v$ tables doesn't give anything like the bizarre numbers here.
    Thanks,
    Matt

    Do you see a version number in what you posted?
    Neither do I.
    Surely you don't expect people working an anything from 7.0.12 to 11.1.0.6 to have anything relevant to say with respect to your specific problem without know your operating system and version.
    What metalink docs have you searched looking or the answer?

  • Cursor in report 6i

    please
    i use this formula in column and it show turn many line, but it repeat the only first line, and i do not know how to solve and how to your cursors
    function CF_spartFormula return Char is
    v varchar2(400);
              cursor c is
              select s.spart_no
              from as_job_ordd_sp s
              where YEAR = :year
              and ORD_NO = :ord_no
    begin
    open c;
    fetch c into v;
    close c;
    return v;
    /*for i in c loop
         fetch c into v;
    v := v || v;
    end loop;
    return v;*/
    end;
    please help me

    Hi,
    You can use lexical paramters in the sql query
    x - char - parameter
    select * from emp &x
    you need to pass the value for x in the parameter as
    'where sal < 1234'.
    Note : Lexical variable should be of char datatype.
    This is an alternative to the ref cursors.
    This works. Hope this is clear.

  • Report based on Ref Cursor and lock package/table (ORA-04021)

    Hi,
    I have reports based on Ref Cursor. Report builder and Reports Background Engine make pins for package, which consist of Ref Cursor, and for tables, which is used in package. So I can't grant any privileges on these tables anybody.
    For example, after next statement:
    GRANT SELECT ON table_name TO user_name
    I received the next error:
    ORA-04021: timeout occurred while waiting to lock object table_name
    Thanks

    Hi,
    I have reports based on Ref Cursor. Report builder and Reports Background Engine make pins for package, which consist of Ref Cursor, and for tables, which is used in package. So I can't grant any privileges on these tables anybody.
    For example, after next statement:
    GRANT SELECT ON table_name TO user_name
    I received the next error:
    ORA-04021: timeout occurred while waiting to lock object table_name
    Thanks

  • Report based on Ref Cursor and grant privileges

    Hi,
    I have reports based on Ref Cursor. Report builder and Reports Background Engine make pins for package, which consist of Ref Cursor, and for tables, which is used in package. So I can't grant any privileges on these tables anybody.
    For example, after next statement:
    GRANT SELECT ON table_name TO user_name
    I received the next error:
    ORA-04021: timeout occurred while waiting to lock object table_name
    Thanks

    Hi,
    I have reports based on Ref Cursor. Report builder and Reports Background Engine make pins for package, which consist of Ref Cursor, and for tables, which is used in package. So I can't grant any privileges on these tables anybody.
    For example, after next statement:
    GRANT SELECT ON table_name TO user_name
    I received the next error:
    ORA-04021: timeout occurred while waiting to lock object table_name
    Thanks

  • Ref cursors and dynamic sql..

    I want to be able to use a fuction that will dynamically create a SQL statement and then open a cursor based on that SQL statement and return a ref to that cursor. To achieve that, I am trying to build the sql statement in a varchar2 variable and using that variable to open the ref cursor as in,
    open l_stmt for refcurType;
    where refcurType is a strong ref cursor. I am unable to do so because I get an error indication that I can not use strong ref cursor type. But, if I can not use a strong ref cursor, I will not be able to use it to build the report based on the ref cursor because Reports 9i requires strong ref cursors to be used. Does that mean I can not use dynamic sql with Reports 9i ref cursors? Else, how I can do that? Any documentation available?

    Philipp,
    Thank you for your reply. My requirement is that, sometimes I need to construct a whole query based on some input, and sometimes not. But the output record set would be same and the layout would be more or less same. I thought ref cursor would be ideal. Ofcourse, I could do this without dynamic SQL by writing the SQL multiple times if needed. But, I think dynamic SQL is a proper candidate for this case. Your suggestion to use lexical variable is indeed a good alternative. In effect, if needed, I could generate an entire SQL statement and place in some place holder (like &stmt) and use it as a static SQL query in my data model. In that case, why would one ever need ref cursor in reports? Is one more efficient over the other? My guess is, in the lexical variable case, part of the processing (like parsing) is done on the app server while in a function based ref cursor, the entire process takes place in the DB server and there is probably a better chance for re-use(?)
    Thanks,
    Murali.

  • Ref cursor and dynamic sql

    Hi..
    I'm using a ref cursor query to fetch data for a report and works just fine. However i need to use dynamic sql in the query because the columns used in the where condition and for some calculations may change dynamically according to user input from the form that launches the report..
    Ideally the query should look like this:
    select
    a,b,c
    from table
    where :x = something
    and :y = something
    and (abs(:x/:y........)
    The user should be able to switch between :x and :y
    Is there a way to embed dynamic sql in a ref cursor query in Reports 6i?
    Reports 6i
    Forms 6i
    Windows 2000 PRO

    Hello Nicola,
    You can parameterize your ref cursor by putting the query's select statement in a procedure/function (defined in your report, or in the database), and populating it based on arguments accepted by the procedure.
    For example, the following procedure accepts a strongly typed ref cursor and populates it with emp table data based on the value of the 'mydept' input parameter:
    Procedure emp_refcursor(emp_data IN OUT emp_rc, mydept number) as
    Begin
    -- Open emp_data for select all columns from emp where deptno = mydept;
    Open emp_data for select * from emp where deptno = mydept;
    End;
    This procedure/function can then be called from the ref cursor query program unit defined in your report's data model, to return the filled ref cursor to Reports.
    Thanks,
    The Oracle Reports Team.

Maybe you are looking for

  • Mail wont open, please help!

    Mail won't open! its there on the strip on the desktop but there is a ? over the icon and I can't find mail at all in applications or system pref's.

  • Send report in email ! URGENT !

    hey everyone, i have a requirement where we want to broadcast a report once the loads are finished. I have a process chain "zdaily". the requirement states that once the process chain is successful, we want to broadcast a report "Orders by Customer"

  • Radix sort help again

    I created a linked list and are now trying to pass a word into a radix sort (which works outside of this particular program) so that it will sort the words and place them back into the appropriate places in the list. Just for the record, I haven't re

  • Is there any way of downloading adobe flash player on ipad2?

    How can I get adobe flash player on ipad2?

  • Applet can't be instanciated

    Hello, I'm trying to deploy an applet since one week, but I have no luck. Can anyone help? Running the applet from JDeveloper works well (accessing Oracle8i with InfoBus). I made a jar-archive without excluding any class. But when I apply the applet