Using CAST Function in PL-SQL

Hello guys,
I'm writing a stored procedure which tries to convert a string representing a number to a fixed size number(with 2 positions fraction). For example, if the input was "15,456" the result would become 15.45.
I was able to aschieve this ussing the CAST function within a query as follows:
select cast ('15,456' as number(15,2)) from dual; -- (the comma in my case is configured as fraction separator). The previous query executes OK using a query analyzer like SQL Plus.
However, when I try to use the same function within a stored procedure, it will complain about the number's size (15,2) and wont compile.
v_importe_ingresado := CAST('15,456' AS NUMBER(15,2));
Error output: PLS-00103 found '(' but expected one of the following: .)@%
When removing the (15,2) it compiles ok
¿Any clue?
I will appreciate any help.
Thanks in advance,
Bernabé

¿Any clue?¿¿¿Over complication???
SQL> select round(15.456, 2), trunc(15.456, 2) from dual
  2  /
ROUND(15.456,2) TRUNC(15.456,2)
          15.46           15.45
SQL> Cheers, APC
Blog : http://radiofreetooting.blogspot.com/

Similar Messages

  • ORA-00902: invalid datatype comile error while using CAST function

    Hi everyone,
    I'm getting ORA-00902: invalid datatype compilation error while using CAST function.
    open ref_cursor_list for select empName from TABLE(CAST(part_t AS partnumberlist));
    The partnumberlist and ref_cursor_list is declared in the Package spec as given below.
    TYPE ref_cursor_list IS REF CURSOR;
    TYPE partnumberlist IS TABLE OF emp.empName%TYPE;
    The error points the partnumberlist as invalid datatype in TOAD because of this i'm unable to compile the package.
    Any suggestion
    Thanks and regards
    Sathish Gopal

    Here is my code for
    package Spec
    CREATE OR REPLACE PACKAGE "HISTORICAL_COMMENTZ" AS
    TYPE prior_part_data_record IS RECORD (
    prior_part_row_id PGM_RPLCMNT_PART.PR_PART_ROW_S_ID%TYPE,
    prior_pgm_chng_s_id PGM_RPLCMNT_PART.PR_PGM_CHNG_S_ID%TYPE
    TYPE parts_list IS TABLE OF prior_part_data_record;
    --TYPE parts_list IS TABLE OF NUMBER;
    TYPE partnumberlist IS TABLE OF PGM_RPLCMNT_PART.PR_PART_ROW_S_ID%TYPE;
    TYPE partnumber_cursor IS REF CURSOR;
    TYPE comment_record IS RECORD (
    pgm_s_id                     PGM_PART_CMNT.PGM_S_ID%TYPE,
    part_row_s_id                PGM_PART_CMNT.PART_ROW_S_ID%TYPE,
    pgm_chng_s_id                PGM_PART_CMNT.PGM_CHNG_S_ID%TYPE,
    cmnt_txt                     PGM_PART_CMNT.CMNT_TXT%TYPE,
    cmnt_dt                     PGM_PART_CMNT.CMNT_DT%TYPE,
    updt_rsrc_id                PGM_PART_CMNT.UPDT_RSRC_ID%TYPE
    TYPE comment_list IS TABLE OF comment_record;
    global_pgm_s_id INTEGER := 0;
    global_part_row_s_id INTEGER := 0;
    err_num NUMBER := 999999;
    err_msg VARCHAR2 (250);
    PROCEDURE getComments (
    pgm_s_id IN NUMBER,
    part_row_s_id IN NUMBER,
    partnumber_cursorlist out partnumber_cursor);
    END;
    Package Body
    CREATE OR REPLACE PACKAGE BODY HISTORICAL_COMMENTZ
    AS
    FUNCTION getPriorPart
    (param_prior_pgm_chng_s_id IN PGM_RPLCMNT_PART.PR_PGM_CHNG_S_ID%TYPE,
    return_prior_part_data_record IN OUT prior_part_data_record
    RETURN INTEGER
    IS
    retVal INTEGER;
    prior_part_row_id INTEGER;
    prior_pgm_chng_s_id INTEGER;
    local_prior_part_data_record prior_part_data_record;
    BEGIN
    SELECT PR_PART_ROW_S_ID AS prior_part_row_id, PR_PGM_CHNG_S_ID AS prior_pgm_chng_s_id
    INTO local_prior_part_data_record
    --SELECT PR_PART_ROW_S_ID INTO retVal
    FROM PGM_RPLCMNT_PART
    WHERE PGM_S_ID = global_pgm_s_id AND CUR_PGM_CHNG_S_ID = param_prior_pgm_chng_s_id;
    return_prior_part_data_record := local_prior_part_data_record;
    retVal := 0;
    RETURN retVal;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    err_num := SQLCODE;
    err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
    DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
    retVal := -1;
    RETURN retVal;
    WHEN OTHERS
    THEN
    err_num := SQLCODE;
    err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
    DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
    retVal := -1;
    RETURN retVal;
    END getPriorPart;
    FUNCTION getComment (found_parts_list IN parts_list, comments OUT comment_list)
    RETURN INTEGER
    IS
    CURSOR init_cursor
    IS
    SELECT PGM_S_ID,PART_ROW_S_ID,PGM_CHNG_S_ID,CMNT_TXT,CMNT_DT,UPDT_RSRC_ID
    FROM PGM_PART_CMNT WHERE 1 = 2;
    retVal INTEGER;
    indexNum PLS_INTEGER;
    local_part_record prior_part_data_record;
    local_comment_record comment_record;
    local_part_row_s_id NUMBER;
    i PLS_INTEGER;
    BEGIN
    OPEN init_cursor;
    FETCH init_cursor
    BULK COLLECT INTO comments;
    i := 0;
    indexNum := found_parts_list.FIRST;
    WHILE indexNum IS NOT NULL
    LOOP
    local_part_record := found_parts_list(indexnum);
    local_part_row_s_id := local_part_record.prior_part_row_id;
    SELECT PGM_S_ID,PART_ROW_S_ID,PGM_CHNG_S_ID,CMNT_TXT,CMNT_DT,UPDT_RSRC_ID
    INTO local_comment_record FROM PGM_PART_CMNT
    WHERE PGM_S_ID = global_pgm_s_id
    AND PART_ROW_S_ID = local_part_row_s_id;
    comments(i) := local_comment_record;
    i := i + 1;
    END LOOP;
    RETURN retval;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    err_num := SQLCODE;
    err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
    DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
    RETURN retval;
    WHEN OTHERS
    THEN
    err_num := SQLCODE;
    err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
    DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
    RETURN retval;
    END getComment;
    PROCEDURE getComments
    pgm_s_id IN NUMBER,
    part_row_s_id IN NUMBER,
    partnumber_cursorlist OUT partnumber_cursor)
    IS
    comment_recordlist comment_record;
    retPartnumberlist partnumberlist;
    found_parts_list parts_list;
    local_part_record prior_part_data_record;
    is_more_parts BOOLEAN;
    driver_chng_s_id NUMBER;
    num_parts NUMBER;
    retVal NUMBER;
    comments comment_list;
    returnPartnumberlist partnumberlist;
    iloopCounter PLS_INTEGER;
    inx1 PLS_INTEGER;
    part_t partnumberlist :=partnumberlist(100,200,300);
    CURSOR part_list_init_cursor
    IS
    SELECT PR_PART_ROW_S_ID,PR_PGM_CHNG_S_ID FROM PGM_RPLCMNT_PART WHERE 1 = 2;
    CURSOR inIt_cursor
    IS
    SELECT 0 FROM DUAL WHERE 1 = 2;
    BEGIN
    DBMS_OUTPUT.ENABLE (5000000);
    global_pgm_s_id := pgm_s_id;
    global_part_row_s_id := part_row_s_id;
    SELECT PART_ROW_S_ID AS prior_part_row_id, PR_PGM_CHNG_S_ID AS prior_pgm_chng_s_id
    INTO local_part_record
    FROM PGM_RPLCMNT_PART
    WHERE PGM_S_ID = global_pgm_s_id AND PART_ROW_S_ID = global_part_row_s_id AND
    CUR_PGM_CHNG_S_ID IN (SELECT MAX(CUR_PGM_CHNG_S_ID) FROM PGM_RPLCMNT_PART WHERE
    PGM_S_ID = global_pgm_s_id AND PART_ROW_S_ID = global_part_row_s_id
    GROUP BY PART_ROW_S_ID);
    OPEN part_list_init_cursor;
    FETCH part_list_init_cursor
    BULK COLLECT INTO found_parts_list;
    -- Add the existing part to the found list
    found_parts_list.EXTEND;
    found_parts_list(1) := local_part_record;
    driver_chng_s_id := local_part_record.prior_pgm_chng_s_id;
    num_parts := 1;
    is_more_parts := TRUE;
    WHILE (is_more_parts) LOOP
    retVal := getPriorPart(driver_chng_s_id,local_part_record);
    IF (retVal != -1) THEN
    found_parts_list.EXTEND;
    num_parts := num_parts + 1;
    found_parts_list(num_parts) := local_part_record;
    driver_chng_s_id := local_part_record.prior_pgm_chng_s_id;
    ELSE
    is_more_parts := FALSE;
    END IF;
    END LOOP;
    --num_parts := getComment(found_parts_list,comments);
    OPEN init_cursor;
    FETCH init_cursor
    BULK COLLECT INTO returnPartnumberlist;
    num_parts := found_parts_list.COUNT;
    FOR iloopCounter IN 1 .. num_parts
    LOOP
    returnPartnumberlist.EXTEND;
    returnPartnumberlist(iloopCounter) := found_parts_list(iloopCounter).prior_part_row_id;
    END LOOP;
    retPartnumberlist := returnPartnumberlist;
    open
    *          partnumber_cursorlist for select PR_PART_ROW_S_ID from TABLE(CAST(retPartnumberlist AS historical_commentz.partnumberlist));*                              
    DBMS_OUTPUT.put_line('Done....!');
    EXCEPTION
    some code..............................
    END getComments;
    END HISTORICAL_COMMENTZ;
    /

  • CAST function in PL/SQL

    Hello folks,
    <br>
    has anybody a reasonable explanation for this weird behaviour concerning the CAST function? <br>
    I am using 9iR2. <br>
    Following runs fine eventhough I would expect an error:
    <p>
    SQL> DECLARE
       i   INTEGER;
       x   VARCHAR2 (1) := 'x';
    BEGIN
       i := CAST (1 AS x);
       DBMS_OUTPUT.put_line ('i=' || i);
    END;
    i=1
    PL/SQL procedure successfully completed.<p>
    BUT simply hardcoding the "datatype" raises an error:
    <p>
    SQL> DECLARE
       i   INTEGER;
       x   VARCHAR2 (1) := 'x';
    BEGIN
       i := CAST (1 AS 'x');
       DBMS_OUTPUT.put_line ('i=' || i);
    END;
    Error at line 11
    ORA-06550: line 5, column 20:
    PLS-00103: Encountered the symbol "x" when expecting one of the following:
       <an identifier> <a double-quoted delimited-identifier> LONG_
       double ref char time timestamp interval date binary national
       character nchar
    The symbol "<an identifier> was inserted before "x" to continue.<p>
    Whats going on here?

    It's trying to cast to x%type, which is DATE. But even if you replace it with DATE you get the same error.
      1  DECLARE
      2     i   DATE;
      3     x   DATE;
      4  BEGIN
      5     i := CAST (SYSDATE AS date);
      6* END;
    cmsgpro_user@XOPDEV> /
       i := CAST (SYSDATE AS date);
    ERROR at line 5:
    ORA-06550: line 5, column 15:
    PLS-00382: expression is of wrong type
    ORA-06550: line 5, column 4:
    PL/SQL: Statement ignored
    cmsgpro_user@XOPDEV> ED
    Wrote file afiedt.buf
      1  DECLARE
      2     i   DATE;
      3     x   DATE;
      4  BEGIN
      5     i := CAST (SYSDATE AS VARCHAR2);
      6* END;
    cmsgpro_user@XOPDEV> /
    PL/SQL procedure successfully completed.

  • Using max function in PL/SQL

    VERY URGENT...
    Am new to oracle...
    I've written a package that display gif images in form of histogram/bar chart. using html,
    I need to use max function to display values proportionately.
    please help. i need to complete this assignment by 2/9/00 by 10.00 am at the latest. I've half written a function but I don't know if there's a simpler way fo doing this. html enabled

    First of all Thanks to all gentlemen who replied ..many thanks ...
    Tried the ROW_NUMBER() option but still it is taking time...have given output for the query and tkprof results as well. Even when it doesn't fetch any record ( this is a valid cased because the input header id doesn't have any workflow request submitted & hence no entry in the wf_items table)..then also see the time it has taken.
    Looked at the RANK & DENSE_RANK options which were suggested..but it is still taking time..
    Any further suggestions or ideas as to how this could be resolved..
    SELECT 'Y', 'Y', ITEM_KEY
    FROM
    ( SELECT ITEM_KEY, ROW_NUMBER() OVER(ORDER BY BEGIN_DATE DESC) RN FROM
    WF_ITEMS WHERE ITEM_TYPE = 'xxxxzzzz' AND ROOT_ACTIVITY = 'START_REQUESTS'
    AND SUBSTR(ITEM_KEY,1,INSTR(ITEM_KEY,'-') - 1) = :B1
    ) T WHERE RN <= 1
    call count cpu elapsed disk query current rows
    Parse 0 0.00 0.00 0 0 0 0
    Execute 1 0.00 1.57 0 0 0 0
    Fetch 1 8700.00 544968.73 8180 8185 0 0
    total 2 8700.00 544970.30 8180 8185 0 0
    many thanks

  • Need help in using sleep function in pl/sql

    Hi,
    need help:
    I have a condition where i want to validate total_pass=total_fail and
    I want to use the sleep function in a pl/sql where i want to wait for 2 minutes ie.checking
    whether total_pass=total_fail based upon class_id .
    I have the data in the table as:
    CLASS_ID TOT_PASS TOT_FAIL
    1 10 10
    2 5 4
    3 6 6
    4 7 5
    Any help will be needful for me

    I'm not quite sure what you are lookg for here, but whatever it is, your code as posted won't do it. You will never break out of the WHILE r_Class.Tot_Pass = r_Class.Tot_Fail loop, since these values will never change because you never get the next record form the cursor.
    From your original data, it looks like your cursor will return multiple rows which implies to me that you want to fetch the first row from the cursor, check if tot_pass = tot_fail, if they are equal, sleep for two minutes then get the next row. This does not make sense to me. Once the select in the cursor is executed, the data it returns will not change due to Oracle's read consistency model, so there seems to me no point in the sleep.
    The other alternative I can see is that you want to check all the returned rows, and if tot_pass = tot_fail for one of the rows (or possibly for all of the rows), then you want to sleep and try again.
    If you can explain in words what it is you are trying to accomplish, someone will be able to point you to a solution.
    John

  • How to use CAST function in obiee 11g in rpd

    Hai,
    I am trying to use the cast fucntion in rpd in bmm layer for a new logical column that I have created and is giving me error compile message.
    Can any one please help me out or find out what is wrong in the function I am using.
    The expression I am trying to use is
    ( CAST ( "Chase Card Acquisition"."Fact Deposit"."Base Earn" as decimal(18,0) ) + "Chase Card Acquisition"."Fact Deposit"."Tot Bonus Earn" )

    Decimal is not a supported type in the logical layer. See:
    http://docs.oracle.com/cd/E21764_01/bi.1111/e10540/sqlref.htm#BIEMG559
    for supported types.
    If you are casting as Int then do not specify the precision ('cast x as int' NOT 'cast x as int(y,z)'). Regards,
    Robert

  • Not able to use a function inside a sql in a form, Why ??

    Here SERIAL_NUM is a function, this sql work fine in TOAD and SQLPLUS but inside the form iam getting error saying "function serial_num cannot be used in a sql" Why is it like that ?? Is there anyother way to execute this sql ?
    cursor c1 is
    SELECT msn.ATTRIBUTE7 Order_No,
    SERIAL_NUM(i.SERIAL_NUMBER) Serial_No,
    msn.ATTRIBUTE5 Firmware,
    msn.ATTRIBUTE15 Site_Pref
    FROM atrd.INSTALLER_INFO i,
    mtl_serial_numbers msn
    where SERIAL_NUM(i.SERIAL_NUMBER)=msn.SERIAL_NUMBER

    Here is the process I did. My oim version is 9.1.0.2
    1) Created java program in IBM RAD and compiled it.
    2) Created jar file using jar -cvfm class-files command.
    3) Copied the jar file to javatasks folder.
    4) Tried to use this jar in adapter then got "Failed because null" and sometimes "Server could not load class" messages. most of the time i am getting "failed because null" message.
    Compiled using javac command also without using this tool and created still no luck....

  • Using PowerShell Functions in t-SQL scripts

    experts,
    Can I use a power shell function that gets file size given file path by cross applying it to a table in SQL Server that holds file path of files?
    fileID    filepath
    1         L:\DemoWebPages\About.cshtml.txt
    2         L:\DemoWebPages\default.cshtml.txt.txt
    3         L:\DemoWebPages\Layout.cshtml.txt
    4         L:\DemoWebPages\Site.css.txt
    if the above if the table in SQL Server, can I cross apply a power shell function that gets the file size when file path is passed from the table above?
    Help Much Appreciated!
    ebro

    Make sure that you are running on the machine where you've full permission to access file and 
    Sample data
    create table filelist
    fileid int,
    path varchar(200))
    insert into filelist values(1,'c:\Demystifying tempdb whitepaper.pdf')
    insert into filelist values(2,'C:\Appleton Papers - 23 SQL DM - dani 6.28.13.pdf')
    Powershell Scripts:-
    Add-PSSnapin SqlServerProviderSnapin100 -ErrorAction silentlycontinue
    Add-PSSnapin SqlServerCmdletSnapin100 -ErrorAction silentlycontinue
    Function filesize
    param([String] $path)
    try {
    if(Test-Path $path)
    $size=(Get-Item $path).length/1024
    write-host "$path size is $size KB"
    catch [System.Exception] {
    write-host "File not found"
    $params = @{server='hqvd0026\kat';database='master'}
    $Srv = invoke-sqlcmd @params -Query "SELECT * from dbo.filelist"
    $srv
    foreach ($db in $Srv)
    filesize -path $db.path

  • Using NVL function in Dynamic SQL

    Hi ,
    I have created a procedure using the Dynamic SqL and while using the NVL() getting the following error . ORA-00936: missing expression.
    The query I have written as
    SQL_Txt:=' INSERT INTO VF.tblCData (A, B, C, D, E, F,G,H,I,J)
         SELECT '||l_A||',
         '||l_B||',
         '||l_C||',
              '||l_D||',
              NULL ,
              '||L_F||',
              NVL('||Param1||',''''),
              NVL('||Param2||',''''),
              NVL('||Param3||',''''),
              NULL
              FROM '||ParamTbl1||' WHERE ' ;
    and so on.
    For Param1 I have data for one execution and Param2 and Param3 is null for that execution.
    While executing the same I am getting below
    INSERT INTO VF.tblCData (A, B, C, D, E, F,G,H,I,J)
    SELECT 25,
         1,
         7,
              6,
              NULL ,
              5,
              NVL(PurchaseDate,''),
              NVL(,''),
              NVL(,''),
              NULL
              FROM xyz.PBuyer@pocdb WHERE
    and error ORA-00936: missing expression is popping up for Param2 and Param3 NVL(,'')
    Any suggestion to resolve this issue is highly appreciable.
    Thanks
    Sudipta

    NVL(,''),Where's the first argument to NVL? That's the obvious problem. Empty strings are NULL in Oracle anyway, so just lose the NVL and insert the values...
    C:\>                                                                        
    C:\>sqlplus hr/hr                                                           
    SQL*Plus: Release 11.2.0.3.0 Production on Wed May 8 10:08:53 2013          
    Copyright (c) 1982, 2011, Oracle.  All rights reserved.                     
    Connected to:                                                               
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> set NULL I_AM_NULL                                                     
    SQL> create table x(y varchar2(20));                                        
    Table created.                                                              
    SQL> insert into x values ('');                                             
    1 row created.                                                              
    SQL> select * from x;                                                       
    Y                                                                           
    I_AM_NULL                                                                   
    SQL>                                                                        

  • Using CAST function to convert to timestamp

    I have a select statement that runs via JDBC and is not using any index as timestamp is explicitly used. I would like to be able to convert to Date so the proper index can be used as this column is of Date datatype. I'm having "ORA-25137: Data value out of range" when I use "b.TRAN_DATE BETWEEN CAST(:1 AS DATE) AND CAST(:2 AS DATE) : instead of "b.TRAN_DATE BETWEEN :a and :b.
    Could someone help with this as I really want our indexes to be used and therefore Date datatype should be used in the JDBC connection
    Thanks

    Below is the query that is not using the index b/c of the date datatype. Changing b.TRAN_DATE BETWEEN :1 AND :2 to b.TRAN_DATE BETWEEN CAST(:1 AS DATE) AND CAST(:2 AS DATE) gives "ORA-25137: Data value out of range" error.
    SELECT
    a.CURRENCY_ID D_161,
    a.CURRENCY_NAME D_201,
    b.TRANS_TYPE_NAME D_22,
    UPPER(b.TRANS_TYPE_NAME) S_22,
    REPORT.MASK_CARD(b.CARD_NUMBER, b.TRANS_TYPE_ID) D_142,
    REPORT.MASK_CARD(UPPER(b.CARD_NUMBER), b.TRANS_TYPE_ID) S_142,
    b.TRAN_DATE D_440,
    b.VEND_COLUMN D_54,
    UPPER(b.VEND_COLUMN) S_54,
    c.LOCATION_NAME D_16,
    UPPER(c.LOCATION_NAME) S_16,
    d.EPORT_SERIAL_NUM D_60,
    UPPER(d.EPORT_SERIAL_NUM) S_60,
    b.DESCRIPTION D_58,
    UPPER(b.DESCRIPTION) S_58,
    SUM(b.TOTAL_AMOUNT) D_51_SUM,
    a.CURRENCY_SYMBOL D_181,
    SUM(b.QUANTITY) D_55_SUM,
    a.CURRENCY_CODE D_182
    FROM
    CORP.CURRENCY a,
    REPORT.ACTIVITY_REF b,
    REPORT.EPORT d,
    REPORT.LOCATION c,
    REPORT.TERMINAL f,
    REPORT.VW_USER_TERMINAL e
    WHERE ((b.TRAN_DATE BETWEEN :1 AND :2
    AND b.CARD_NUMBER = :3)
    AND e.USER_ID = :4)
    AND b.CURRENCY_ID = a.CURRENCY_ID
    AND b.EPORT_ID = d.EPORT_ID
    AND b.LOCATION_ID = c.LOCATION_ID
    AND f.TERMINAL_ID = e.TERMINAL_ID
    AND b.TERMINAL_ID = f.TERMINAL_ID
    GROUP BY
    a.CURRENCY_ID,
    a.CURRENCY_NAME,
    b.TRANS_TYPE_NAME,
    UPPER(b.TRANS_TYPE_NAME),
    REPORT.MASK_CARD(b.CARD_NUMBER, b.TRANS_TYPE_ID),
    REPORT.MASK_CARD(UPPER(b.CARD_NUMBER), b.TRANS_TYPE_ID),
    b.TRAN_DATE,
    b.VEND_COLUMN,
    UPPER(b.VEND_COLUMN),
    c.LOCATION_NAME,
    UPPER(c.LOCATION_NAME),
    d.EPORT_SERIAL_NUM,
    UPPER(d.EPORT_SERIAL_NUM),
    b.DESCRIPTION,
    UPPER(b.DESCRIPTION),
    a.CURRENCY_SYMBOL,
    a.CURRENCY_CODE
    ORDER BY
    D_161 ASC,
    D_201 ASC,
    S_22 ASC,
    S_142 ASC,
    D_440 ASC,
    S_54 ASC,
    S_16 ASC,
    S_60 ASC,
    S_58 ASC,
    D_51_SUM ASC,
    D_181 ASC,
    D_55_SUM ASC,
    D_182 ASC

  • How to use document() function in PL/SQL XSLT parser ?

    The "XDB Developers Guide" documentation says on page 12-18
    >
    The application can use DBUriType objects:
    To make references, such as import or include, to related XSL stylesheets. You can encode these references within the XSL stylesheet itself.
    following this i added string like this to my stylesheet
    <xsl:apply-templates select="document('/ORADB/SCOTT/STYLESHEET_TAB/ROW[ID=1]/STYLESHEET/text()')" mode="include"/>
    <xsl:cinclude href="/ORADB/SCOTT/STYLESHEET_TAB/ROW[ID=1]/STYLESHEET/text()"/>
    But when XSLT processor reaches this, it fails.
    I also even tried like this
    <xsl:include href="/ORADB/SCOTT/STYLESHEET_TAB/ROW[ID=1]/STYLESHEET/text()"/>
    but result is the same ;(((
    Generally - is there ANY way XSLT processor can deal with stylesheet which contains
    DBURI references to another stylesheets stored in XMLTYPE columns ?
    I'm currently in charge to develop a content management system for a huge corporate site,
    so i'm VERY interested to know - does this feature really exists on Oracle 9.2 ?
    Please ansver ASAP.

    BTW: following this link
    xsl:include within XSL stylesheet stored in XMLType column
    i've encountered that this theme has been asked but none from Oracle staff has answered on it yet ;(((((((

  • Use percentage function in pl sql

    Hi,
    I want to get the employees that their salary are in top 13% of salaries.
    I learned in this forum that I can get the 10% of top salaries in HR schema by this query:
    WITH     got_tenth     AS
         SELECT     last_name, salary
         ,     NTILE (10) OVER (ORDER BY salary)     AS tenth
         FROM     hr.employees
    SELECT       last_name, salary
    FROM       got_tenth
    WHERE       tenth     = 10
    ORDER BY  salary     DESC
    ;Output:
    LAST_NAME                     SALARY
    King                           24000
    Kochhar                        17000
    De Haan                        17000
    Russell                        14000
    Partners                       13500
    Hartstein                      13000
    Greenberg                      12000
    Errazuriz                      12000
    Higgins                        12000
    Ozer                           11500There is no "TOP" keyword in Oracle.I wondered, What if I want to get, for example, the employees who are in the top 12% of the salaries? here we cannot use deciles (maybe we can but it won't be very nice).
    Thanks a lot to helpers

    CUME_DIST can help:
    http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions035.htm
    WITH  tbl  AS
      SELECT  last_name, salary
      ,  cume_dist() OVER (ORDER BY salary DESC)  AS cumulative_pcnt
      FROM  hr.employees
    SELECT *
    FROM tbl
    WHERE cumulative_pcnt <=0.12;Tie values always evaluate to the same cumulative distribution value, so if you need exact 12% of the rows you can add employee_id in the ORDER BY list.
    Edited by: 1006646 on 19.05.2013 10:14

  • Performance issue with using MAX function in pl/sql

    Hello All,
    We are having a performance issue with the below logic wherein MAX is being used in order to get the latest instance/record for a given input variable ( p_in_header_id).. the item_key is having the format as :
    p_in_header_id - <number generated from a sequence>
    This query to fetch even 1 record takes around 1 minutes 30 sec..could someone please help if there is a better way to form this logic & to improve performance in this case.
    We want to get the latest record for the item_key ( this we are getting using MAX (begin_date)) for a given p_in_header_id value.
    Query 1 :
    SELECT item_key FROM wf_items WHERE item_type = 'xxxxzzzz'
    AND SUBSTR (item_key, 1, INSTR (item_key, '-') - 1) =p_in_header_id
    AND root_activity ='START_REQUESTS'
    AND begin_date =
    (SELECT MAX (begin_date) FROM wf_items WHERE item_type = 'xxxxzzzz'
    AND root_activity ='START_REQUESTS'
    AND SUBSTR (item_key, 1, INSTR (item_key, '-') - 1) =p_in_header_id);
    Could someone please help us with this performance issue..we are really stuck because of this
    regards

    First of all Thanks to all gentlemen who replied ..many thanks ...
    Tried the ROW_NUMBER() option but still it is taking time...have given output for the query and tkprof results as well. Even when it doesn't fetch any record ( this is a valid cased because the input header id doesn't have any workflow request submitted & hence no entry in the wf_items table)..then also see the time it has taken.
    Looked at the RANK & DENSE_RANK options which were suggested..but it is still taking time..
    Any further suggestions or ideas as to how this could be resolved..
    SELECT 'Y', 'Y', ITEM_KEY
    FROM
    ( SELECT ITEM_KEY, ROW_NUMBER() OVER(ORDER BY BEGIN_DATE DESC) RN FROM
    WF_ITEMS WHERE ITEM_TYPE = 'xxxxzzzz' AND ROOT_ACTIVITY = 'START_REQUESTS'
    AND SUBSTR(ITEM_KEY,1,INSTR(ITEM_KEY,'-') - 1) = :B1
    ) T WHERE RN <= 1
    call count cpu elapsed disk query current rows
    Parse 0 0.00 0.00 0 0 0 0
    Execute 1 0.00 1.57 0 0 0 0
    Fetch 1 8700.00 544968.73 8180 8185 0 0
    total 2 8700.00 544970.30 8180 8185 0 0
    many thanks

  • WITHOUT USING ROW_NUMBER FUNCTIONS IN T-SQL

    INPUT:-
    CUST_ID
    GIFT_ID
    100
    10
    100
    20
    100
    30
    200
    10
    200
    20
    200
    30
    300
    20
    OUTPUT:-
    CUST_ID
    GIFT_ID
    SEQ
    100
    10
    1
    100
    20
    2
    100
    30
    3
    200
    10
    1
    200
    20
    2
    200
    30
    3
    300
    20
    1
    santoshbangalore

    THANK YOU SO MUCH FOR YOUR ANS? BUT MY INPUT TABLE A CONTAIN ONLY TWO COLUMN'S 
    CUST_ID,GIFT_ID
    AND IN OUT PUT I NEED THE ABOVE OUTPUT WITH 
    CUST_ID,GIFT_ID,ROW_NUMBER AS SHOWN ABOVE?
    santoshbangalore

  • Using cursor function in sql statement

    hi all
    can anyone plss explain why and when we will use cursor function in a sql statement like this and what is the difference while executing this sql statement with cursor function in comparison of a simple sql statement----
    select
    department_name,
    cursor (
    select last_name
    from employees e
    where e.department_id = d.department_id
    order by last_name
    ) the_employees
    from departments d
    thnx in advance

    RTFM
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#sthref1452
    Cheers
    Sarma.

Maybe you are looking for

  • Delivery Costs - Closing

    Hello, We have a PO with goods received and Invoice posted. Among the delivery costs - we have Insurance, Customs, and Freight conditions. The user accidentally has already paid the delivery costs for Customs & Freight through some other invoce. When

  • Thunderbolt to vga crash

    I have a macbook pro (2012 version) with a thunderbolt to vga adapter. Sometimes it works but most of the time it doesn't. When i connect the adapter (with vga cable to monitor in it) the following problmens occur * Finder hangs * Blue screen (*** i

  • Mandatory custom metadata field with current system date as default value.

    I want to create a custom metadata field of type Date. I want to make it mandatory and want to set its default value as system date. I have already created field of type Date. What expression I should write to make system date as default value? Becau

  • Is there a way to set the amount of time before Messages shows me as idle?

    I ran a script in iChat that allowed me to extend the amount of time before I showed as idle, but I haven't been able to find something comparable for Messages.

  • Photo Import

    only had my imac for 2 days so still learning. I have imported my photo collection of 5500 photo into my Pictures they come to about 9gb. Got them into Iphoto no problem but i now see a file called Iphoto Libary and that is about 9gb is size as well.