Dynamic return from a function based on an argument

I have a function that I am using to output a nested list of
child/parent relationships
the function works wonderfully except that i want to be able
to change the way the list is displayed depending on an argument
being passed
i want the list to be displayed twice on the same page, one
with output in a table, and one with output in a drop down box
i thought the easiest way would be to create an argument that
can be used in IF statements
look at my code below
quote:
<!--- establish default values --->
<cfparam name="output" default="">
<cfparam name="catNameOutput" default="">
<cfparam name="indent" default="">
<cffunction name="GenerateCategories" access="public"
returntype="string">
<!--- this holds the outermost parent value being passed
to the function --->
<cfargument name="GenCatParent" type="uuid"
required="yes" default=0 >
<!--- this holds the nested level we are on --->
<cfargument name="level" type="numeric" required="yes"
default=0 >
<!--- this holds the output_type we need for display
purposes --->
<cfargument name="output_type" type="numeric"
required="yes" default=0 >
<!--- grab the children of the received category --->
<cfquery name="rsCategoryChildren"
datasource="webdsn">
SELECT * FROM dbo.BlogCategories
WHERE catParent = '#GenCatParent#'
ORDER BY catName ASC
</cfquery>
<cfloop query="rsCategoryChildren">
<!--- keep track of the indentation needed depending on
which level we are at --->
<cfloop from="0" to="#arguments.level#" index="i">
<cfset indent = indent & "  ">
</cfloop>
<!--- if the nest is being used in the dropdown on the
category manage page, we need to use option tags --->
<cfif arguments.output_type EQ 1>
<cfset catNameOutput = "<option value='" & catPK
& "'>" & indent & Trim(catName) &
"</option>">
</cfif>
<!--- if the nest is being used in the table on the
category manage page, we need to use table row tags --->
<cfif arguments.output_type EQ 2>
<cfset catNameOutput = "<tr>
<td>edit</td> <td>delete</td> <td>"
& indent & Trim(catName) & "</td>
</tr>">
</cfif>
<cfset output = output & catNameOutput>
<!--- reset the indentation --->
<cfset indent = "">
<!--- check for children of this child --->
<cfquery name="checkForKids" datasource="webdsn">
SELECT * FROM dbo.BlogCategories
WHERE catParent = '#rsCategoryChildren.catPK#'
ORDER BY catName ASC
</cfquery>
<!--- if there are any, call this function recursively
--->
<cfif checkForKids.recordcount GT 0>
<cfset GenerateCategories(genCatParent=catPK, level =
level +1, output_type = arguments.output_type)>
</cfif>
</cfloop>
<cfreturn output>
</cffunction>
<cfquery name="rsCategoryParents" datasource="webdsn">
SELECT * FROM dbo.BlogCategories
WHERE catParent IS NULL
ORDER BY catName ASC
</cfquery>
and here is how i am calling the function for each situation
(the table and the dropdown):
quote:
<table width="100%" class="managementtable">
<tr bgcolor="#F6F6F6">
<td> </td>
<td> </td>
<td>Category Name</td>
</tr>
<cfloop query="rsCategoryParents">
<cfoutput><tr> <td>edit</td>
<td>delete</td> <td>#Trim(catName)#</td>
</tr></cfoutput>
<cfset recursivecats =
GenerateCategories(genCatParent=catPK,level=0,output_type=2)>
<cfoutput>#recursivecats#</cfoutput>
</cfloop>
</table>
<!---------------------------------------------------------------------------->
<select name="select">
<option>None</option>
<cfoutput query="rsCategoryParents">
<option value="#catPK#">#Trim(catName)#</option>
<cfset recursivecats =
GenerateCategories(genCatParent=catPK,level=0,output_type=1)>
#recursivecats#
</cfoutput>
</select>
calling the function for the table and the dropdown on the
same page does not work
if the function is first called with the argument for table,
it tries to also output the table formatted code when the function
is called again (even if it is called again with the argument for
dropdown)
is there another way i can have the same function output two
different sets of data based on an argument? what am i doing wrong
thanks for your time

sjlsam2,
Yeah, I think the main problem you had was a scoping one. For
the second function call, the output variable already contained all
of the output code from the first function call. In fact, I
wouldn't be surprised to find that the output string for the second
function call contained the output of the first plus the output of
the second, and that it didn't render correctly on screen. A
View Source would have determined that.
Anyhow, I suggest that you VAR your output variable as
cf_dev2 suggests, and delete the three CFParam lines at the top.
Further, your recursive call would therefore need to return it's
result to the output variable, thus completing the recursive loop.
See below:
<!--- this holds the output_type we need for display
purposes --->
<cfargument name="output_type" type="numeric"
required="yes" default=0 >
<CFSet Var Output = "">
<CFSet Var catNameOutput = "">
<CFSet Var indent= RepeatString("  ",
Arguments.Level)>
<!--- grab the children of the received category --->
<cfquery name="rsCategoryChildren" datasource="webdsn">
SELECT * FROM dbo.BlogCategories
and
<!--- if there are any, call this function recursively
--->
<cfif checkForKids.recordcount GT 0>
<cfset
Output = Output & GenerateCategories(genCatParent=catPK,
level = level +1, output_type = arguments.output_type)>
</cfif>
</cfloop>
This is what I suggest with your code. HTH :)
Swift

Similar Messages

  • Exiting from SQLPLUS on failure returned from a function

    I am working on Oracle 11g (R2). I want to call a function in package and if that function returns zero then I want to quit/exit from SQLPLUS prompt.
    I will be calling that function of package from an .sql file.
    How can i do this?
    I can also call raise_application_error() from that function. Without using WHENEVER SQLERROR EXIT, is there any way of doing this?

    Thanks, but if i am calling that function from a .sql file, can i verify the return value and exit from sqlplus prompt.

  • Doubt in the value return by the function based on given condition

    Hi,
    Below function should return the value based on the value of in_row_number_high variable.
    I have used CASE but it does't return proper value.
    How could I give that condition?
    Please help.
    FUNCTION gen_total_lane_count_pct
        in_lane_id                  edr_rpt_by_ranges_output.lane_id%TYPE,
        in_direction_id             edr_rpt_by_ranges_output.direction_id%TYPE,
        in_interval_start_date_time edr_rpt_by_ranges_output.interval_start_date_time%TYPE,
        in_interval_end_date_time   edr_rpt_by_ranges_output.interval_end_date_time%TYPE,
        in_row_number               edr_rpt_by_ranges_output.range_low%TYPE,
        in_row_number_high          edr_rpt_by_ranges_output.range_high%TYPE,
        in_lane_min                    edr_lane_by_class_report_data.v_lane%TYPE,
        in_lane_max                    edr_lane_by_class_report_data.v_lane%TYPE   
    RETURN NUMBER
    IS
         my_total             NUMBER(18);
         my_count_pct         NUMBER(18);
         my_total_pct         NUMBER(18);
         my_each_count_result NUMBER(18);
         my_count_result            NUMBER(18);
         my_total_count             NUMBER(18);
      lane_start           edr_rpt_tmp_report_lanes.site_lane_id%TYPE;
      lane_end             edr_rpt_tmp_report_lanes.site_lane_id%TYPE;
      row_start            NUMBER(12);
      row_end              NUMBER(12);
    BEGIN
         my_count_pct       := 0 ;
           SELECT MIN(site_lane_id)
             INTO lane_start
          FROM edr_rpt_tmp_report_lanes
         WHERE edr_rpt_tmp_report_lanes.output_lane_id        = in_lane_id
           AND edr_rpt_tmp_report_lanes.output_direction_id   = in_direction_id;
         SELECT MAX(site_lane_id)
              INTO lane_end
           FROM edr_rpt_tmp_report_lanes
          WHERE edr_rpt_tmp_report_lanes.output_lane_id        = in_lane_id
            AND edr_rpt_tmp_report_lanes.output_direction_id   = in_direction_id;  
         SELECT MIN(range_low)
           INTO row_start
           FROM edr_rpt_by_ranges_output;
         SELECT MAX(range_low)
           INTO row_end
           FROM edr_rpt_by_ranges_output;
               my_each_count_result := edr_rpt_lane_by_class_package.gen_total_lane_count (
                                        in_lane_id,
                                        in_direction_id,
                                        in_interval_start_date_time,
                                        in_interval_end_date_time,
                                        in_row_number,
                                        in_row_number_high,
                                        in_lane_min,
                                        in_lane_max             
        my_count_result := edr_rpt_lane_by_class_package.gen_total_lane_count (
                                        in_lane_id,
                                        in_direction_id,
                                        in_interval_start_date_time,
                                        in_interval_end_date_time,
                                        row_start,
                                        row_end,
                                        in_lane_min,
                                        in_lane_max              
         my_total_count :=  edr_rpt_lane_by_class_package.gen_total_lane_count (
                                        in_lane_id,
                                        in_direction_id,
                                        in_interval_start_date_time,
                                        in_interval_end_date_time,
                                        in_row_number,
                                        in_row_number_high,
                                        lane_start,
                                        lane_end               
             IF (my_each_count_result > 0)   THEN                          
                   my_total := edr_rpt_lane_by_class_package.gen_total_lane_count (
                                        in_lane_id,
                                        in_direction_id,
                                        in_interval_start_date_time,
                                        in_interval_end_date_time,
                                        row_start,
                                        row_end,
                                        lane_start,
                                        lane_end              
                CASE
                WHEN in_row_number_high = row_end THEN                       
                     my_count_pct := ROUND((my_each_count_result / my_count_result ) * 100 );     
                WHEN in_row_number_high < row_end THEN                
                        my_count_pct := ROUND((my_each_count_result / my_total ) * 100 ) ;               
                ELSE
         RAISE_APPLICATION_ERROR(-20101, 'The row number specified is not recognized.');                 
                END CASE;     
             END IF;
             return my_count_pct;
    END gen_total_lane_count_pct;          Edited by: Indhu Ram on Jan 5, 2010 11:43 AM

    Hi,
    I have to find out the % value for each column value( For rx if there is only 2 columns).To calculate the % , each column value should get divided by the total of that column value.
    To calculate the % for the total row , each column total should get divide by the sum of column ( sum of column 1 + sum of column 2)values.
    ROUND((my_each_count_result / my_count_result ) * 100 ) ---- This calculaton gives me the % for the total row.
    ROUND((my_each_count_result / my_total ) * 100 ) ------- This calculation gives the % for the data row.
    The condition that I have tried is, if it reaches end of data row (to achieve that condition I have given this condition in_row_number_high < row_end )
    Now my result returns only values based on this condition -- in_row_number_high < row_end .
    It does't look for the first condition.
    CASE
    WHEN in_row_number_high = row_end THEN
    my_count_pct := ROUND((my_each_count_result / my_count_result ) * 100 );     
    WHEN in_row_number_high < row_end THEN
         my_count_pct := ROUND((my_each_count_result / my_total ) * 100 ) ;               
    ELSE
    RAISE_APPLICATION_ERROR(-20101, 'The row number specified is not recognized.');          
    END CASE;
    Hope , you have some good understanding now. Please help me how could I do this?

  • Bug: 1st Date value returned from CF function as an Array

    I am encountering an annoying behavior in Flex.  I call a CF function to return a query into an arraycollection - very basic.  If the SELECT statement in the CF function includes any dates as returned values, the first date in the SELECT statement comes back into Flex as an array object that includes all of the fields in the query.  The other dates are returned normally as Date data types.
    This started happening a month or two ago, and I've reproduced it on several machines.  Needless to say, it is causing numerous errors when my code excpects a Date and gets an Array.
    Do you have any ideas of what might be causing this and what I can do about it?
    Thanks!!

    I'm not sure where to post it, but here are some snippets:
    in the cfc, I have a function as such:
    <CFFUNCTION name="GetPersonLog" returntype="query">
        <CFARGUMENT name="STUDENTID" type="numeric" required="Yes">
        <CFQUERY name="qry" datasource="#connection_string#">
            SELECT tblStudentLog.STUDENTLOGID, tblStudentLog.STUDENTID,
            <!---GETDATE() AS TESTTHIS,--->
            tblStudentLog.LOGDATE,
            tblStudentLog.LASTUPDATED,
            tblStudentLog.LOGENTRY
            FROM  tblStudentLog LEFT OUTER JOIN
            tblStudentDiscipline ON tblStudentLog.StudentDisciplineID = tblStudentDiscipline.StudentDisciplineID
            WHERE tblStudentLog.STUDENTID = <CFQUERYPARAM value = "#studentid#">
            ORDER BY tblStudentLog.LOGDATE DESC
        </CFQUERY>
        <CFRETURN qry>
    </CFFUNCTION>
    You see I have a REMmed out line to get a test date.  If I check the results in CF using cfdump, all dates come back as dates.
    In flex, the handler for the call to this function is simple:
            private function PersonLogHandler(event:ResultEvent):void{
                personlog = event.result as ArrayCollection;
                CursorManager.removeBusyCursor();}  
    If I stop the code here and evaluate the results in debug mode, I find that the LOGDATE result is an array of values, while the LASTUPDATED field is a date.
    If I put back the GETDATE() AS TESTTHIS, statement in the cfc function, then the result includes LOGDATE as a date object, but now the TESTTHIS result is an array.
    I have experienced this on 2 different machines, and it has brought my development to a standstill.  I can't thin of what changed to start these problems, except that I am now using the FlashPlayer 10 (with debugger).  This happens in Firefox and IE.  I am using FlexBuilder 3 and Coldfusion 8.

  • Using jdbc StoredProcedure to return from a function an array of objects

    I am trying to call a stored procedure(function) using jdbcTemplates with no inputs which returns a list of objects.
    I previously used the same function returning a cursor and used the following example:
    http://www.saarathi.com/wiki/Processing_JDBC_ResultSet_from_an_Oracle_stored_procedure_with_Spring#Calling_the_stored_procedure_and_function_from_Spring_JDBC_DAO
    which worked fine.
    I now want to return the same objects which relates to a table but in a list and have tried to follow the example in
    http://forum.springframework.org/archive/index.php/t-10042.html
    But have had no success and did not understand the example GetPersonProc.
    I dont understand why it works for the cursor and not a list.
    I would very much appreciate some help.

    Hi
    Can anybody help me with the code of how to return a resultset from a web service. i have put the resultset data's in an object array and tried to return it, but in the client side no data comes ,,, i mean it is printed as null.... and plz tell me where to specify the return type of a object in the wsdl file....
    thanks..

  • How to compare a boolean value returned from a function in a sql query

    Hi all
    i have a function which return boolean true or false.
    mean while i am writing a sql query which should check this function and will return a result set only when it is true. how will i use a function which returns boolean in a sql query..
    thanks in advance'
    Hari

    I don't think this is possible - i'm not sure. Can you post your function script? The reason why am i asking this is --
    satyaki>set serveroutput on
    satyaki>
    satyaki>
    satyaki>
    satyaki>create or replace function test_satf(emno in number)
      2  return boolean
      3  is
      4    v_cnt   number(5);
      5    v_flg   boolean;
      6  begin
      7    select count(*)
      8    into v_cnt
      9    from emp
    10    where empno = emno;
    11   
    12    if v_cnt = 1 then
    13       v_flg := TRUE;
    14    else
    15       v_flg := FALSE;
    16    end if;
    17   
    18    return v_flg;
    19  exception
    20    when others then
    21      v_flg := FALSE;
    22   return v_flg;
    23  end;
    24  /
    Function created.
    satyaki>
    satyaki>
    satyaki>
    satyaki>
    satyaki>
    satyaki>desc emp;
    Name                                      Null?    Type
    EMPNO                                     NOT NULL NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    satyaki>
    satyaki>
    satyaki>
    satyaki>select count(*) from emp;
      COUNT(*)
            14
    satyaki>
    satyaki>select empno,test_satf(empno)
      2  from emp;
    select empno,test_satf(empno)
    ERROR at line 1:
    ORA-06552: PL/SQL: Statement ignored
    ORA-06553: PLS-382: expression is of wrong type
    satyaki>select to_char(test_satf(empno))
      2  from emp;
    select to_char(test_satf(empno))
    ERROR at line 1:
    ORA-06552: PL/SQL: Statement ignored
    ORA-06553: PLS-382: expression is of wrong type
    satyaki>
    satyaki>create or replace function test_satf(emno in number)
      2  return varchar2
      3  is
      4    v_cnt   number(5);
      5    v_flg   varchar2(10);
      6  begin
      7    select count(*)
      8    into v_cnt
      9    from emp
    10    where empno = emno;
    11   
    12    if v_cnt = 1 then
    13       v_flg := 'TRUE';
    14    else
    15       v_flg := 'FALSE';
    16    end if;
    17   
    18    return v_flg;
    19  exception
    20    when others then
    21      v_flg := 'FALSE';
    22   return v_flg;
    23  end;
    24  /
    Function created.
    satyaki>
    satyaki>
    satyaki>select test_satf(empno)
      2  from emp;
    TEST_SATF(EMPNO)
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TRUE
    TEST_SATF(EMPNO)
    TRUE
    TRUE
    TRUE
    14 rows selected.Or, may be i'm missing something.
    Regards.
    Satyaki De.

  • How to collect returns from recursive function calls without a global var?

    Usually global variables shouldnt be used, I was told. Ok. But:
    How can I avoid using a global var when recursively using a function, when the function returns an object and when I want to have the collection of all these objects as the result?
    For example, I think of determine the users of a group including group nesting. I would write a function that adds the direct group members to a collection as a global var and call itself recusively if a member is another group. This recursively called function
    would do as well: Update the global var and if needed call itself.
    I'm afraid this is no good programming style. What algorithm would be better, prettier? Please dont focus on the example, it is a more general question of how to do.
    Thanks
    Walter

    I rarely needed to create/use recursive functions. Here's one example I did:
    function New-SBSeed {
    <#
    .Synopsis
    Function to create files for disk performance testing. Files will have random numbers as content.
    File name will have 'Seed' prefix and .txt extension.
    .Description
    Function will start with the smallest seed file of 10KB, and end with the Seed file specified in the -SeedSize parameter.
    Function will create seed files in order of magnitude starting with 10KB and ending with 'SeedSize'.
    Files will be created in the current folder.
    .Parameter SeedSize
    Size of the largest seed file generated. Accepted values are:
    10KB
    100KB
    1MB
    10MB
    100MB
    1GB
    10GB
    100GB
    1TB
    .Example
    New-SBSeed -SeedSize 10MB -Verbose
    This example creates seed files starting from the smallest seed 10KB to the seed size specified in the -SeedSize parameter 10MB.
    To see the output you can type in:
    Get-ChildItem -Path .\ -Filter *Seed*
    Sample output:
    Mode LastWriteTime Length Name
    -a--- 8/6/2014 8:26 AM 102544 Seed100KB.txt
    -a--- 8/6/2014 8:26 AM 10254 Seed10KB.txt
    -a--- 8/6/2014 8:39 AM 10254444 Seed10MB.txt
    -a--- 8/6/2014 8:26 AM 1025444 Seed1MB.txt
    .Link
    https://superwidgets.wordpress.com/category/powershell/
    .Notes
    Function by Sam Boutros
    v1.0 - 08/01/2014
    #>
    [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Low')]
    Param(
    [Parameter(Mandatory=$true,
    ValueFromPipeLine=$true,
    ValueFromPipeLineByPropertyName=$true,
    Position=0)]
    [Alias('Seed')]
    [ValidateSet(10KB,100KB,1MB,10MB,100MB,1GB,10GB,100GB,1TB)]
    [Int64]$SeedSize
    $Acceptable = @(10KB,100KB,1MB,10MB,100MB,1GB,10GB,100GB,1TB)
    $Strings = @("10KB","100KB","1MB","10MB","100MB","1GB","10GB","100GB","1TB")
    for ($i=0; $i -lt $Acceptable.Count; $i++) {
    if ($SeedSize -eq $Acceptable[$i]) { $Seed = $i }
    $SeedName = "Seed" + $Strings[$Seed] + ".txt"
    if ($Acceptable[$Seed] -eq 10KB) { # Smallest seed starts from scratch
    $Duration = Measure-Command {
    do {Get-Random -Minimum 100000000 -Maximum 999999999 |
    out-file -Filepath $SeedName -append} while ((Get-Item $SeedName).length -lt $Acceptable[$Seed])
    } else { # Each subsequent seed depends on the prior one
    $PriorSeed = "Seed" + $Strings[$Seed-1] + ".txt"
    if ( -not (Test-Path $PriorSeed)) { New-SBSeed $Acceptable[$Seed-1] } # Recursive function :)
    $Duration = Measure-Command {
    $command = @'
    cmd.exe /C copy $PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed+$PriorSeed $SeedName /y
    Invoke-Expression -Command:$command
    Get-Random -Minimum 100000000 -Maximum 999999999 | out-file -Filepath $SeedName -append
    Write-Verbose ("Created " + $Strings[$Seed] + " seed $SeedName file in " + $Duration.TotalSeconds + " seconds")
    This is part of the SBTools module and is used by the
    Test-SBDisk function. 
    Example use:
    New-SBSeed 10GB -Verbose
    Test-SBDisk is a multi-threaded function that puts IO load on target disk subsystem and can be used to simulate workloads from multiple machines hitting the same SAN at the same time, and measure disk IO and performance.
    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
    Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

  • Building the varchar string to return from a pl sql function

    i'm new with pl/sql and i'm having trouble trying to build the string that i want to return from a function that is inside a package. it seems my problem stems from the fact that i'm trying to incorporate a variable (varchar2) into the string to be returned. below are two attempts that i've made which do not work:
    function test_policy (p_schema_name IN varchar2, p_object_name IN varchar2) return varchar2 as
    predicate_value varchar2(2000);
    user_name varchar2(100);
    begin
    select first_name
    into user_name
    from employees
    where first_name = SYS_CONTEXT('hr_app_context', 'username');
    predicate_value := 'first_name = ' || user_name;
    predicate_value := 'first_name = ' || '' || user_name || '';
    return predicate_value;
    end test_policy;
    Can someone help me with the proper syntax to build my string for the return value? Thanks.

    this function implements the code for a policy i've created. basically, the policy says that when i do a select on the employees table, i should only see a record whose first_name = sys_context('hr_app_context', 'username'). so, when i perform a simple select * from employees, i get an error which says policy predicate has error. i'm pretty sure the error is caused by how i'm building the return value for that function. if i hard code some return value like:
    predicate_value := 'first_name = ''HR''' ;
    the select statement above works fine, and i only see the record from employees where first_name = 'HR'

  • Selecting from a function that returns a sys refcursor or an alternative

    I have a query that returns a resultset of three columns, namely SSN,PAID_YEAR and PAID_TOTAL. From this query I can:
    Create a view and then query it.
    Create a function and return resultset
    If I go the first way a simple query like the following takes more than 20 seconds:
    SELECT PAID_YEAR,PAID_TOTAL FROM VIEW_1 WHERE SSN=12345678912882;
    I know that is because when I query a view the engine first brings all the rows of the view and then it filters the rows for the criteria supplied.
    If I go the second way I can send a parameter and make the engine look only for those rows that match the condition and return the recordset. But I do not know how to then SELECT from that returned resultset. I took a look at pipelined tables but didn't quite get how to benefit them. So my ultimate question is if it's somehow possible to select from the resultset that is returned from a function like this:
    SELECT * FROM FUNCTION_1(12132323232).
    If yes, then how, if no, what would be an alternative way?

    I know that is because when I query a view the engine first brings all the rows of the view and then it filters the rows for the criteria supplied.
    No - you don't 'know that' because it isn't true. Just check the explain plan for yourself. Oracle can still use any appropriate indexes so that only the rows needed are returned.
    So my ultimate question is if it's somehow possible to select from the resultset that is returned from a function like this:
    SELECT * FROM FUNCTION_1(12132323232).
    No - you can't do it like that. You have to use the TABLE function to treat the function result set as a table:
    'SELECT * FROM TABLE(FUNCTION_1(12132323232)).
    -- 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))

  • Creating function-based indexes

    I'm trying to create a function-based index in one of the user's schemas and am getting an insufficient privilege error. Below are the examples:
    connect scott/tiger ;
    CREATE INDEX emp_ename_idx ON ename( emp ) ;
    Index created.
    CREATE INDEX upper_ename_idx ON ename( upper(ename)) ;
    ERROR at line1:
    ORA-01031: insufficient privileges
    The DBA granted the CREATE ANY INDEX privilege to user scott already. Any ideas???
    Thanks,
    SY

    Hi, all.
    I didn't hear about function-based index before, so I did some testing. Instead of using Oracle predefined functions (upper, lower, substr etc.), I created my own function and tried to create an index on it. I received an error that function is not deterministic. The definition of deterministic from Oracle docs:
    DETERMINISTIC
    This hint helps the optimizer avoid redundant function calls. If a stored function was called previously with the same arguments, the optimizer can elect to use the previous result. The function result should not depend on the state of session variables or schema objects. Otherwise, results might vary across calls. Only DETERMINISTIC functions can be called from a function-based index or a materialized view that has query-rewrite enabled.
    So, I put word deterministic in function declaration and everything works OK. Then I modified function to use some of the tables (I used tables across different schemas), recreated the index and it also worked fine.
    Question - is this statement correct: You can use schema objects in function which is in turn used for indexes as long as you put word deterministic in function declaration and all objects (function, index) will be valid, but ORACLE doesn't guarantee that result produced using that index will be correct?
    Thank you.

  • Dynamic Pages: how to overide the default format returned from the oracle query.

    When writing a dynamic page, portal always displays any return from a database query in a default format or grey background table:
    <TABLE border="0" cellspacing=0 cellpadding=2 style="background-color:#E0E0D0">
    <TR>
    <TH ALIGN="LEFT" style="background-color:#C0C0A0" > </TH>
    </TR>
    <TD ALIGN="LEFT" valign="TOP" WIDTH="0">
    Is there anyway to change this or this how the
    function
    PORTAL30.wwv_render_report.show always works?
    Thanks in advance!

    James,
    Please see posting http://technet.oracle.com:89/ubb/Forum70/HTML/000073.html.
    Just a reminder, please search the forum before posting your question. It's quite likely that someone else has already asked the same question.
    Regards,
    Jerry
    null

  • Returning both raise_application_error and return value from db function...

    Hi ,
    I use Oracle 10g and forms10g.
    I have written a db packaged function such as:
    function fnc_ipologismos_xiliometron(code_poleis_apo_var in varchar2,code_poleis_pros_var in varchar2)
       return number
       is
        apostasi_var ref_apostaseis_poleon.apostasi%type;
        onomasia_pol_apo_var ref_poleis.onomasia%type;
        onomasia_pol_pros_var ref_poleis.onomasia%type;
        begin
         begin
            select onomasia into onomasia_pol_apo_var
              from ref_poleis
              where code_poleis=code_poleis_apo_var;
         end;
         begin
            select onomasia into onomasia_pol_pros_var
              from ref_poleis
              where code_poleis=code_poleis_pros_var;
         end;
         begin
          select apostasi into apostasi_var
           from ref_apostaseis_poleon
           where code_poleis_apo=code_poleis_apo_var and code_poleis_pros=code_poleis_pros_var;
          exception
           when no_data_found
    then
    apostasi_var:=0;
    return apostasi_var;
    raise_application_error(-20015,'a message');
    --return apostasi_var;
    end;      return apostasi_var;
        end;The problem is that when the exception written above (in bold) returns 0 and exits the function.... whereas i want this value to be returned as well as the message in the raise_application_error....
    I call this function in WHEN-VALIDATE-ITEM of a block item... such as:
    if pkg_mod3_general.fnc_ipologismos_xiliometron
    (:mod3_entoli_metakinisis.code_poleis_apo_type_id,:mod3_entoli_metakinisis.code_poleis_type_id)=0
                  and :mod3_entoli_metakinisis.seq_code_meso_metakin_type_id=2
                  then
                    raise form_trigger_failure;
      end if;     When the above condition is true then no message is displayed and the cursor sticks to the item(as the raise_application_error in the db packaged function is after the exit of the function) and when the condition is false then no message is displayed again ... as expected.....
    How is it get the desired result.....- get the message from the raise_application_error and the function returns 0.....?????
    Many thanks,
    Simon

    you cannot RETURN and RAISE a function.
    RETURN ends the function immediately
    RAISE ends the program unit and jumps in the EXCEPTION-Handler, if it exists. Else the function ends

  • How to return more than one value from a  function

    hello everybody,
    Can anyone tell me how to return more than a single value from a function, the problem is i have 4 points,
    2 points form one line ,another 2 points form 2nd line ,each point is 3 dimensional(x,y,z coorinates) so i will pass these values to func(x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4), i will find the point of intersecton of two lines and i will get it as x,y,z , now how to return these 3 coordinates,usually the function returns only one value, please help me to solve it out.
    Thanks.

    I think the easiest way or trick here is (easiest isn't always the best as we know, but atleast this one will work) to create simple data array. and pass that. Create an array with:
    <code>
    class justArray {
    int x=0
    int y=0;
    int z= 0;
    ...somewhere
    justArray[] points= new justArray[4];
    points[0].x= ..
    points[0].y= ..
    points[0].z= ..
    points[1].x= ..
    return points[]
    </code>

  • The value returned from the load function is not of type numeric  errors after migration to Coldfusion 11

    I am currently testing our website with CF11. It is currently working with CF8 however after migrating it to a new server running CF11 I have encountered the following error.
    The value returned from the load function is not of type numeric.
    The error occurred in
    D:/Applications/CFusion/CustomTags/nec/com/objects/address.cfc: line 263
    Called from D:/Applications/CFusion/CustomTags/nec/com/objects/contact.cfc: line 331
    Called from D:/Applications/CFusion/CustomTags/nec/com/objects/user.cfc: line 510
    Called from D:/Applications/CFusion/CustomTags/nec/com/objects/user.cfc: line 1675
    Called from D:/website/NECPhase2/action.validate.cfm: line 54
    261 : <cfif isNumeric(get.idCountry)>
    262 : <cfset rc = this.objCountry.setID(get.idCountry)>
    263 : <cfset rc = this.objCountry.load()>
    264 : </cfif>
    265 : <cfset this.sPostcode = get.sPostcode>
    Have there been any changes between CF8 and CF11 that could  cause this error?
    Does anyone have ideas?

    This is the code in file object file country.cfc (nec.com.objects.country):
    <cfcomponent displayname="Country object" hint="This is a Country object, it allows you to access and set values in the Country.">
    <!---
    // Construct this object
    --->
    <cfset this.objFunctions = CreateObject( 'component', 'nec.com.system.functions' )>
    <cfscript>
      this.idCountryID = 0;
      this.sCountryName = "";
      this.sISOCode = "";
      this.sDHLCode = "";
      this.iErrorID = "";
    </cfscript>
    <!---
    // The following functions are the setters and getters. offering us a better way to get
    // at the contents of the object
    --->
    <!---
    // Getters
    --->
    <cffunction name="getID" displayname="Get ID" returntype="numeric" output="false" hint="This returns the ID of the current item.">
      <cfreturn this.idCountryID>
    </cffunction>
    <cffunction name="getsCountryName" displayname="Get sCountryName" returntype="string" output="false" hint="This gets the sCountryName value of this item.">
      <cfreturn this.sCountryName>
    </cffunction>
    <cffunction name="getsISOCode" displayname="Get sISOCode" returntype="string" output="false" hint="This gets the sISOCode value of this item.">
      <cfreturn this.sISOCode>
    </cffunction>
    <cffunction name="getsDHLCode" displayname="Get sDHLCode" returntype="string" output="false" hint="This gets the sDHLCode value of this item.">
      <cfreturn this.sDHLCode>
    </cffunction>
    <cffunction name="iError" displayname="Get iError" returntype="numeric" output="false" hint="This returns the iError of the current item.">
      <cfreturn this.iError>
    </cffunction>
    <!---
    // Setters
    --->
    <cffunction name="setID" displayname="Set ID" returntype="boolean" output="false" hint="This sets the ID value of this item.">
      <cfargument name="idCountryID" required="true" type="numeric" displayname="ID" hint="The ID to use.">
      <cfset this.idCountryID = arguments.idCountryID>
      <cfreturn true>
    </cffunction>
    <cffunction name="setsCountryName" displayname="Set sCountryName" returntype="boolean" output="false" hint="This sets the sCountryName value of this item.">
      <cfargument name="sCountryName" required="true" type="string" displayname="sCountryName" hint="The sCountryName to use.">
      <cfset this.sCountryName = arguments.sCountryName>
      <cfreturn true>
    </cffunction>
    <cffunction name="setsISOCode" displayname="Set sISOCode" returntype="boolean" output="false" hint="This sets the sISOCode value of this item.">
      <cfargument name="sISOCode" required="true" type="string" displayname="sISOCode" hint="The sISOCode to use.">
      <cfset this.sISOCode = arguments.sISOCode>
      <cfreturn true>
    </cffunction>
    <cffunction name="setsDHLCode" displayname="Set sDHLCode" returntype="boolean" output="false" hint="This sets the sDHLCode value of this item.">
      <cfargument name="sDHLCode" required="true" type="string" displayname="sDHLCode" hint="The sDHLCode to use.">
      <cfset this.sDHLCode = arguments.sDHLCode>
      <cfreturn true>
    </cffunction>
    <!---
    // Clear, to empty out the contents of this object
    --->
    <cffunction name="clear" displayname="Clear items Details" returntype="boolean" output="false" hint="Clears out all of the items details.">
      <cfscript>
       this.sCountryName = "";
       this.sISOCode = "";
       this.sDHLCode = "";
       this.iErrorID = "";
      </cfscript>
      <cfreturn true>
    </cffunction>
    <!---
    // The following functions deal with the load, save and deleting of objects
    --->
    <!---
    // Load
    --->
    <cffunction name="load" displayname="Load items details" returntype="numeric" output="false" hint="This loads in all the information about an item.">
      <cfset rc = this.clear()>
      <!---
      // First of all we need to get the name of the data source we are going to be using
      --->
      <cfscript>
      objDS = CreateObject("component","nec.com.system.settings");
      sDatasource = objDS.getDatasource();
    </cfscript>
      <!---
      // Check to see if it exists
      --->
      <cftry>
       <cfquery name="checkID" datasource="#sDatasource#">
        SELECT idCountryID
        FROM tblCountry
        WHERE idCountryID = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("load: checkID: '#this.idCountryID#' #cfcatch.detail#");
        </cfscript>
        <cfset this.iErrorID = iErrorID>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfif not checkID.recordCount>
       <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         if(isDefined("session.afr")){
          whichOne = "#session.afr.getsAFRNumber()#";
         } else {
          whichOne = "";
         iErrorID = objError.addError("A Country with that id doesn't exists.[#this.idCountryID#][#whichOne#]");
        </cfscript>
       <cfset this.iErrorID = iErrorID>
       <cfreturn iErrorID>
      </cfif>
      <!---
      // If we got past all then then load in the details
      --->
      <cftry>
       <cfquery name="get" datasource="#sDatasource#">
        SELECT idCountryID, RTRIM(sCountryName) as sCountryName, RTRIM(sISOCode) as sISOCode, RTRIM(sDHLCode) as sDHLCode
        FROM tblCountry
        WHERE idCountryID = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("load: get: #cfcatch.detail#");
        </cfscript>
        <cfset this.iErrorID = iErrorID>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfset this.idCountryID = get.idCountryID>
      <cfset this.sCountryName = get.sCountryName>
      <cfset this.sISOCode = get.sISOCode>
      <cfset this.sDHLCode = get.sDHLCode>
      <cfset this.iErrorID = "">
      <cfreturn true>
    </cffunction>
    <!---
    // Save
    --->
    <cffunction name="save" displayname="Save items Details" returntype="numeric" output="false" hint="Saves (to some source) the current details for the ID of the item.">
      <!---
      // First of all we need to get the name of the data source we are going to be using
      --->
      <cfscript>
      objDS = CreateObject("component","nec.com.system.settings");
      sDatasource = objDS.getDatasource();
    </cfscript>
      <!---
      // Now check to see if ithat ID exists
      --->
      <cftry>
       <cfquery name="checkID" datasource="#sDatasource#">
        SELECT idCountryID
        FROM tblCountry
        WHERE idCountryID = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("save: checkID: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <!---
      // If it doesn't exist, then add the record, otherwise update the record
      --->
      <cfif not checkID.recordCount>
       <cfreturn this.add()>
      <cfelse>
       <cfreturn this.update()>
      </cfif>
    </cffunction>
    <!---
    // Add
    --->
    <cffunction name="add" displayname="Add Country" returntype="numeric" output="false" hint="This adds a Country.">
      <!---
      // Check to see if that a different item isn't already using the same unique details
      --->
      <cftry>
       <cfquery name="checkUnique" datasource="#sDatasource#">
        SELECT idCountryID
        FROM tblCountry
        WHERE sCountryName = '#this.objFunctions.scrubText(this.sCountryName)#'
        OR sISOCOde = '#this.objFunctions.scrubText(this.sISOcode)#'
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("add: checkUnique: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfif checkUnique.recordCount>
       <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("A Country with that name or ISO code already exists. idCountryID=#checkUnique.idCountryID#");
        </cfscript>
       <cfreturn iErrorID>
      </cfif>
      <cftry>
       <cfquery name="add" datasource="#sDatasource#">
        SET nocount on
        INSERT INTO tblCountry(sCountryName, sISOCode, sDHLCode)
        VALUES('#this.objFunctions.scrubText(this.sCountryName)#','#this.objFunctions.scrubText(t his.sISOCode)#','#this.objFunctions.scrubText(this.sDHLCode)#')
        SELECT @@identity as autoID
        SET nocount off  
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("add: add: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfreturn add.autoID>
    </cffunction>
    <!---
    // Update
    --->
    <cffunction name="update" displayname="Update Country" returntype="numeric" output="false" hint="This updates a Country record.">
      <!---
      // Check to see if that a different item isn't already using the same unique details
      --->
      <cftry>
       <cfquery name="checkUnique" datasource="#sDatasource#">
        SELECT idCountryID
        FROM tblCountry
        WHERE (sCountryName = '#this.objFunctions.scrubText(this.sCountryName)#'
        OR sISOCOde = '#this.objFunctions.scrubText(this.sISOcode)#')
        AND idCountryID <> #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("update: checkUnique: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfif checkUnique.recordCount>
       <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("Another Country with that name already exists. idCountryID=#checkUnique.idCountryID#");
        </cfscript>
       <cfreturn iErrorID>
      </cfif>
      <!---
      // Attempt to update the record to the datasource
      // if this fails for any reason then we submit an error message
      // to the error component and return the ID of the error
      --->
      <cftry>
       <cfquery name="update" datasource="#sDatasource#">
        UPDATE tblCountry
        SET sCountryName = '#this.objFunctions.scrubText(this.sCountryName)#',
        sISOCode = '#this.objFunctions.scrubText(this.sISOCode)#',
        sDHLCode = '#this.objFunctions.scrubText(this.sDHLCode)#'
        WHERE idCountryID = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("update: update: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfreturn this.idCountryID> 
    </cffunction>
    <!---
    // Delete
    --->
    <cffunction name="delete" displayname="Delete Country" returntype="numeric" output="false" hint="This deletes a Country record.">
      <!---
      // First of all we need to get the name of the data source we are going to be using
      --->
      <cfscript>
      objDS = CreateObject("component","nec.com.system.settings");
      sDatasource = objDS.getDatasource();
    </cfscript>
      <!---
      // Now check to see if ithat ID exists
      --->
      <cftry>
       <cfquery name="checkID" datasource="#sDatasource#">
        SELECT idCountryID
        FROM tblCountry
        WHERE idCountryID = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("delete: checkID: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfif not checkID.recordCount>
       <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("A Country with that id doesn't exists, delete failed.");
        </cfscript>
       <cfreturn iErrorID>
      </cfif>
      <!---
      // Now check to see if there are any dependancies, if so we can't delete the item
      --->
      <cftry>
       <cfquery name="checkDependancies" datasource="#sDatasource#">
        SELECT idCountry
        FROM tblAddress
        WHERE idCountry = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("delete: checkDependancies: idCountry: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfif checkDependancies.recordCount>
       <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("That Country is being used by an address, delete failed.");
        </cfscript>
       <cfreturn iErrorID>
      </cfif>
      <!---
      // Now attempt to remove the record.
      // if this fails for any reason then we submit an error message
      // to the error component and return the ID of the error
      --->
      <cftry>
       <cfquery name="delete" datasource="#sDatasource#">
        DELETE FROM tblCountry
        WHERE idCountryID = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("delete: delete: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfreturn this.idCountryID>
    </cffunction>
    </cfcomponent>

  • Can I use the value returned from a Text Function in another Formula?

    I'm writing a report in Hyperion System 9 BI + Financial Reporting Studio version 9.2. I have 2 grids in my report.
    Grid1 Column A is set up as a text function using the function type - <<GetCell("Grid2", 1, a, 1)>>. I would like to use the values returned from this text function in Column A (Grid 1) in a formula in Column B (Grid 1).
    Is it possible to use the values returned in Column A of the text function in another formula? My report does not seem to recognize Column A as numerical values, even though the values to be returned are numerical.
    If so, how do I recognize the values in Column A Grid 1 as numerical values and not text?
    Thanks for any help you can offer!

    Hi Edson,
    Yes you need to use the CALC_ERROR macro function to be able to test whether the last macro function returned an error. CALC_ERROR will return an 'X' if there an error occured during the execution of the last macro function.
    You can use a macro similar to the following:
    IF
      CALC_ERROR( )
      = 'X'
          DO SOMETHING HERE
    ENDIF
    Let me explain how this works internally. The SAP system maintains a global variable g_flg_calc_error during the execution of macros in the planning book. The g_flg_calc_error variable will contain the value of f_calc_error that was set by the last macro function which executed. The ABAP coding of a planning book is something like this:
    data: g_flg_calc_error type /SAPAPO/FLAG.
    * SAP will pass g_flg_calc_error variable to all macro
    * functions. When SAP calls a macro function, it does
    * something like this.
    call function '/SAPAPO/MACRO_FUNCTION_HERE'
            exporting
              plob_values      = i_s_adv_plob_values
              sdp_book         = g_c_advf_sdp_book
              sdp_view         = g_c_advf_sdp_view
            tables
              cols_index       = i_t_cols
              value_tab        = l_t_value_tab
            changing
              f_calc_error     = g_flg_calc_error
    As you can see, the g_flg_calc_error variable
    is passed in the "changing" part of the call. The macro  function being called can then use the f_calc_error
    variable to change the value of the global
    g_flg_calc_error variable. In fact, the macro function being called can also check (by looking at the f_calc_error variable) if the last macro function reported an error.  The CALC_ERROR macro function just checks the value of f_calc_error parameter (w/c in fact is the value of the g_flg_calc_error variable) and returns "true/X" if the f_calc_error was set to true by the last macro function.
    Hope this helps in clearing things out

Maybe you are looking for

  • Please advise - new iMac i7, old iMac G5 PPC, and migration assistant

    I just received my new iMac i7 and am getting ready to use Migration Assistant. However, I have some questions: The logic board on my old machine died, so I pulled out the Hard Drive and put it in an enclosure. This is what I will be using to make th

  • Bullets and list numbers do not render correctly in FF3

    althought bullets and list numbers in my project look fine in IE6 & 7, in FF2 & 3 they show at the left margin - any ideas about what's happening here or is it another "no work with FireFox" item ?

  • Getting iTunes to display old podcasts... WordPress/PodPress

    I recently changed my iTunes feed when I switched to WordPress and PodPress 8.8. After some help from these boards I got it to work, but now it looks like it's broken again. My feed is: http://www.skeptiko.com/feed/ Questions: 1. Anyone have any idea

  • Available balance showing zero balance under utililzation for BED IN J2IUN

    HI EXPERTS, While doing monthly utilization in  J2IUN  Duty amount is showing 1200  under duties, but available balance is showing  as zero under utilization for BED. But in the GL + balance is available. Pelase help me out Thanks in advance KISHORE

  • Need help for an error

    Hi All,            when i run my package i encounting the below error, ERROR at line 1: ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at "NEICDBA.ERA_BILLING_MONTHLY", line 1121 ORA-06512: at line 2    i even