Built-in SQL Functions?

What are the built-in SQL functions in Oracle? I already know: COUNT, SUM, AVG, MAX, and MIN. Are there any more?
Thanx

http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions2a.htm

Similar Messages

  • Built in SQL Function for Sum of Geometric Progression

    Hi all,
    Please let me know if there is any availble built in SQL function for
    SUm of Geometric Progression.
    Thanks in Advance,
    Kaushik B.

    and also relatively simple to write:
    s = a*(1-power(r,n+1))/(1-r)
    assuming you have a row with values of a,r and n (and that's the sum you need)
    Jon

  • How to distinguish built-in SQL functions of PL/SQL?

    I m having a hard time to figure out which functions are used ONLY in SQL statements and which are used in regular expr(ie, variable assignment,). Can anyone show me a list of each or perhaps a URL to look for?
    I have searched through either the developer's guide and reference but couldn't find any appropriate indication in one place that make it clear.
    For instance, I thought I can use CAST function in a variable assginment like the following:
    declare
    cursor myCur is SELECT Value_varchar2(1) FROM table WHERE id = 1;
    myRec myCur%ROWTYPE;
    var_a NUMBER(1);
    begin
    OPEN myCur;
    FETCH myCur INTO myRec;
    CLOSE myCur;
    var_a := CAST(myCur.Value_varchar2(1) AS NUMBER(1));
    DBMS_OUTPUT.PUT_LINE('var_a = ' || TO_CHAR(var_a));
    end;
    . It seems like CAST function can ONLY be used in SQL statement, but no doc so far states that?!
    Edited by: HappyJay on 2010/05/12 12:05

    Sorry to bother you, Bob!
    I think I might already found the list. Is it the following list?
    ---------------------- QUOTED FROM Oracle® Database PL/SQL Language Reference 11g Release 2 (11.2)Part Number E10472-06
    SQL Functions in PL/SQL Expressions
    In PL/SQL expressions, you can use all SQL functions except:
    Aggregate functions (such as AVG and COUNT)
    Analytic functions (such as LAG and RATIO_TO_REPORT)
    Data mining functions (such as CLUSTER_ID and FEATURE_VALUE)
    Encoding and decoding functions (such as DECODE and DUMP)
    Model functions (such as ITERATION_NUMBER and PREVIOUS)
    Object reference functions (such as REF and VALUE)
    XML functions (such as APPENDCHILDXML and EXISTSNODE)
    These conversion functions:
    BIN_TO_NUM
    These miscellaneous functions:
    CUBE_TABLE
    DATAOBJ_TO_PARTITION
    LNNVL
    NVL2
    SYS_CONNECT_BY_PATH
    SYS_TYPEID
    WIDTH_BUCKET
    PL/SQL supports an overload of BITAND for which the arguments and result are BINARY_INTEGER.
    When used in a PL/SQL expression, the RAWTOHEX function accepts an argument of data type RAW and returns a VARCHAR2 value with the hexadecimal representation of bytes that comprise the value of the argument. Arguments of types other than RAW can be specified only if they can be implicitly converted to RAW. This conversion is possible for CHAR, VARCHAR2, and LONG values that are valid arguments of the HEXTORAW function, and for LONG RAW and BLOB values of up to 16380 bytes.
    ----------------------

  • Improve built in SQL MAX function

    Hi
    I am trying to improve the performance of the built in SQL max function. right now searching through over 500,000 rows takes lot of time which can be reduced. Can anyone suggest me something which would be helpful in this or may be give me a link if it has been discussed before?
    Anything is appreciated.
    Thanks

    Tolls wrote:
    Um...considering you were planning on improving on the MAX function, I sort of thought you might actually know how to use it. Otherwise how would you know it was running slowly?thanks Tolls i'd figured it out right after i posted it. i guess i was too excited after reading (you got it in milliseconds) that posted right away without doing anything myself..but yeah it did make it super fast..thanks a lot for your help and time..
    cotton.m wrote:
    d_khakh wrote:
    hi tolls thanks for getting back
    could u explain how did u do that? i found out how to create index..i have the following statement:
    create index col on table2 (col2);
    cud u tell me how to go from here and find the max in col2..thanks again for ur help?
    sigh
    Where to go from here? Just execute your damn query. If you really did create the index on the right column and your database isn't stupid and there isn't a lot more to this problem then you told us about like some where clauses then that's it. She's as fast as she's going to get.
    And remember, it's impolite to converse in a public forum while chewing your cud. Unless of course you actually meant "could" but were just too lazy to type it. Don't be lazy, use full words. Thanks.like i said above..i figured it out after some time.
    i wasn't being lazy ..thats msn talk..i thought people understood that..anyways your point noted too.

  • Equivalent Sql function for Forms NAME_IN() built in

    Please let me know, is there any equivalent Sql function equivalent to Forms Name_in() built in. Thanks.

    What would such a function do in pure SQL? Or are you asking if you can refer to Forms variables in SQL that you issue from Forms?
    The answer to the first question I will delay until you define what it is that you want to do. The answer to the second question is that there is no way to do that. The database has no way of knowing how to resolve references to variables defined in client side PLSQL.

  • SQL Functions Sintax

    LabVIEW 8.5 and Database Connectivity Toolkit and Microsoft Jet 4.0 OLE DB Provider
    I have built the DB structure using the MS ACCESS 2003. One of it´s fileds, I have defined as Short Date, as I had beleived that I was going to get just the date, for instance, 06/07/2007, but instead of this I get the day, 06/07/2007 plus the time, 12:24:34, all together 06/07/2007 12:24:34
    My two questions :
    1) how to store in the date base, just the date, no the time
    2) the SQL Function syntax to display just the date. I thought the correct sintax was : Select SUBSTR(xxx,0,10) from Table. Where xxx is the name of the field in the Table, 0 is the first character of the string xxx and it´s length
    Thanks
    Simbani

    To answer your direct questions:
    1) The "Date/Time" data type is similar to the smalldatetime data type in SQL Server. This stores time information. Can't change this. If you only want to store date information then you need to make your column's datatype to be of character-type. I think "Text" is what Access 2003 uses. Of course, this means you lose anything related to dealing with that column as a date.
    2) If Access 2003 follows the same syntax as SQL Server's T-SQL, the SUBSTR won't work with a column that is a date/time data type. That function would only work with strings. This means you have to first convert the column value to a string. I know that in SQL Server's T-SQL the CAST and CONVERT functions would be used. Have no idea what they would be in Access 2003, so you'll need to check the manual.

  • Pass a list of number values to a pl/sql function

    I would like to pass a list of number values to a pl/sql function where the list will be used in an IN clause. Ideally I would like to do the following:
    CREATE OR REPLACE FUNCTION ( dept_list in varchar2) is
    begin
    select ... where dept in (dept_list) ;
    usage: process_list ( '7730,7735,7740,7745') ;
    I can not find an example of doing this in pl/sql function but it seems feasible.
    Is there a way to do this?

    user12088323 wrote:
    I would like to pass a list of number values to a pl/sql function where the list will be used in an IN clause.
    usage: process_list ( '7730,7735,7740,7745') ;The first thing is you need an appropriate data type to store a list of numbers. A single character value that looks to you like a list of numbers, is not in fact a list of numbers but a single character value.
    This example uses the built in data type odcinumberlist in a procedure, you can do the same in function
    Re: Passing an array to an Oracle stored procedure
    If you have an old version of the database you may need to create your own type with the same definition of odcinumberlist.

  • Wild card searching in sql squery (pl/sql function body returning......)

    Hi,
    I've a report based on a sql query (pl/sql function body returnin a sql query).
    One of the statements is
    select .. from ...
    where name_of_person = :P17_NAAM
    I like to built a wild card possibility (with like '%l%m%') to show all persons with in their name an l, and an m (after the l)
    how to modify this statement?
    any reaction will be appreciated.
    Leo

    Leo,
    If I understand you correctly, you want to let the user type the value without wild cards, and than to add them programmatically. If that's the case, here is what you can do:
    1. Create a new item, say P17_HIDDEN_NAAM, that will contain the actual search criteria
    2. Modify your pl/sql to:
    begin
      :p17_hidden_naam := null;
      for l_i in 1..length(:P17_NAAM)
      loop
        :p17_hidden_naam := :p17_hidden_naam || '%' || substr(:P17_NAAM, l_i, 1);
      end loop;
      :p17_hidden_naam := :p17_hidden_naam || '%';
      return
        'select ..
           from ...
          where name_of_person like :p17_hidden_naam';
    end;By the way, I think that it's much better to train your users to use wild cards than to do it in the program.
    Sima

  • Interactive Reports and PL/SQL Functions

    Hi,
    Am new to the interactive reports, and it appears to be I can only use a single SELECT statement to populate the report.
    I need to convert some older reports to the new interactive reports, but these are populated using PL/SQL functions, as the WHERE clause is built up depending on the selection of items on the web page.
    How can I replicate this with the new interactive reports? Have used CASE statements within a SELECT statement before, can I also use these in a WHERE clause as well?
    Regards
    Simon

    To my knowledge, currently the only way to use Interactive Reports is on a static query. And unfortunately you can't use CASE statements in the WHERE clause of a query, only in the select list.
    The way I would (and have) attacked this is to:
    1. Write the base static query as the basis of the interactive report
    2. Access the interactive report in while logged in as a developer
    3. Build a filter (or set of filters) and save the report. You have the choice of saving it as a named report or as the default report.
    This gives the user one to many filter sets they can use as a starting point and tweak, and gives them examples as to how they can and should use the interactive filtering.
    Doug

  • Are Sql functions different from user defined functions ?

    Hello,
    SQL functions are built into Oracle Database and are available for use in various appropriate SQL statements. Do not >confuse SQL functions with user-defined functions written in PL/SQL.according to first paragraph of this document Sql functions are different from user defined functions . How is that ?
    Is they really differ from each other ?

    bootstrap wrote:
    If you don't know what compilation is, please use Wikipedia or other online resources.I know what is compilation . But i was confused whether those sql functions are compiled in my machine when i install Oracle Database in my machine or they are pre-compiled .
    As you said these Sql functions are pre-compiled , it is clear now that they are pre-compiled platform dependent code .
    Can you provide actual source code of any SQL function , say SUM function .
    I want to see it, how they have defined . Eagerly waiting for any reply. please help .
    Edited by: bootstrap on Aug 19, 2011 11:50 AMYou can ask oracle if they give you their code. I doubt they will. However if you want to write you own user-defined aggregation function, there are examples in the documentation how to do that.
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17125/adfns_packages.htm#i1008575
    Edited by: Sven W. on Aug 19, 2011 9:24 AM

  • Report- Pl/sql function returning sql query parsing page items as text?

    Hi Team,
    I am facing a strange issue .
    I have four page items namely
    1)JOB_CODE
    2)MIN_EXP
    3) MAX_EXP
    4) SOURCES1
    I have a report of the type "Pl/sql function returning sql query"
    declare
    v_sql varchar2(4000);
    begin
    if (:JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql:= 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:JOB_CODE IS NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:MIN_EXP IS NULL and :JOB_CODE IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years <= :MAX_EXP and V_REQUIREMENT = :JOB_CODE and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:MAX_EXP is null and :JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    end if;
    insert into query_list values (v_sql);
    insert into debug values (:JOB_CODE , :MIN_EXP , :MAX_EXP , :SOURCES1);
    return v_sql;
    end;
    Please not that I am insertin the query into a table called Query_list and the page item values into the table called Debug thru the pl/sql function which returns teh query.
    Now I select the data from the debug tables.
    select unique(query) from query_list;
    select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like '%:SOURCES1%'
    select * from debug;
    JOBCODE     MINEX     MAXEX     SOURCE
    21     1     10     donkeyHire
    And if I run the query in sql I get some records returned
    select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = 21 and v_experience_years >= 1 and v_experience_years <= and source like 'donkeyHire'
    V_CANDIDATE_ID     V_FNAME     V_CURRENT_EMPLOYER     V_EXPERIENCE_YEARS
    2     Vengu     Andale Tech     4
    But the record does not show up in the report!
    does this type of report parse page items as text?
    Why is it so?
    Waiting for an early reply.
    Thanks,
    venkat

    Venkat - You don't want to put ':SOURCES1' in quotes like that.
    Scott

  • Passing Multiple Values from a worksheet to PL/SQL function.

    Hi All,
    Is there any way to pass multiple values selected in a worksheet to a PL/SQL function ?
    I will try to explain the scenario:
    We have a crosstab report that showing all the customer details, deposit sum of a customer in each date in a date range selected. With the customer details we are showing the Rank of a customer based on the deposit in the latest date selected. Filtering is based on the rank, ie Top50 or Top60 etc.( As I said rank is calculating based on the deposit in the latest date).This is working fine.
    Now the new requirement is to : For example, in Top50 report, list all the customers, who were in the Top50 list, in any of the dates selected. We are able to display the daywise rank, but when giving a condition like daywiserank <= 50, the result becomes uncertain. Some blank lines, wrong amounts etc..
    As a work around we tried to find out the rank in a PL/SQL function. But the issue there is : we have some multiple value parameters used in the worksheet.
    Is there any way to pass multiple values selected in a worksheet to a PL/SQL function ?
    Or any other work arounds for the scenario explained?
    Reagrds,
    Jeneesh

    Hi Russ,
    Thanks for the response.
    Russ Proudman wrote:
    1. I thought there was an analytical function similar to rank - or maybe an option of rank - that if there are duplicate records to have them all considered the same rank. So if you had 3 records all the same as rank=2 then a condition saying where rank=2 would return the 3 records. You could check into this.
    We are already using DENSE_RANK. But the issue is the output contains incorrect null values nd repeated rows.
    We got it solved as I explained in the previous post. But will that AGGREGATION MODE setting ( Which discoverer says - not recommended) have any issue? I mean side effects?
    Russ Proudman wrote:
    2. Another thought is that you can create a PL/SQL routine - that's called from a SQL function registered in Discoverer - where a table is created that does the first part of your query. Then a worksheet is created to use the data from that table. So, in essence, the table would have your top50 ranked customers. Then you can write any kind of worksheet against that table. However, DBAs are loath to allow tables - that they didn't create! - many times in a PROD environment.
    Here also the same problem will occur: as the top 50 will depend upon the parameters. I cannot pass those parameters to PL/SQL Function.And storing the top50 ( itmay be top100 or to 150 also) for all combinations of the parameters is impossible
    Russ Proudman wrote:
    3. Finally, are you sure you're rank function is correct in that if you're getting blank lines, maybe the 'over' part is not considering all columns needed to determine the rank?
    Yes the query we are using is correct. The output QUERY of discoverer gives correct results in Sqlplus.
    Regards,
    Jeneesh

  • Show refcursor returned by a PL/SQL function ?

    Is it possible to show the results returned by a
    PL/SQL function that returns a refcursor ?
    In sqlplus it goes like this:
    SQL> variable a refcursor;
    SQL> execute :a := p_front.get_invoice_list;
    PL/SQL procedure successfully completed.
    SQL> print a;
    INVOICE_ID CLIENT_ID INVOICE_D
    101 100 01-APR-06
    100 100 06-APR-06
    If not, this would be on the top of my wishlist...
    By the way: you did a good job on this tool!
    Regards,
    Willem

    Is it possible to show the results returned by a
    PL/SQL function that returns a refcursor ?
    In sqlplus it goes like this:
    SQL> variable a refcursor;
    SQL> execute :a := p_front.get_invoice_list;
    PL/SQL procedure successfully completed.
    SQL> print a;
    INVOICE_ID CLIENT_ID INVOICE_D
    101 100 01-APR-06
    100 100 06-APR-06
    If not, this would be on the top of my wishlist...
    By the way: you did a good job on this tool!
    Regards,
    Willem

  • Application Report Missing PL/SQL Functional Area

    All,
    I just wanted to bring to the ApEx developers something I just noticed... I use the Shared Components > Database Object Dependencies report to make sure all is well before moving applications into production.
    The Parsing Errors feature of that report is WONDERFUL! But it seems to be overlooking buttons that use a conditional display based on PL/SQL Function Body Returning a Boolean.
    Dan

    Hi Dan,
    I think the place is perfect, but I read once somewhere that "Bug" or "Bug Report" should be in the subject so that's easier to find for the Oracle guys.
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

  • Interactive report from PL/SQL function

    Hello All,
    i have a pl/sql function that dynamically builds up a sql query and returns it as a varchar2.
    when i create a new report then i can use this function in the report like
    return f_function(param1,param2,v('APP_ID'), v('APP_SESSION'));
    and this works fine.
    Except i cannot create an interactive report for this function, because it is not allowed !!!!
    So how can i use the function in an interactive report ?
    Thanks in advance,
    Marco

    Marco,
    Another rather extreme approach would be to go all the way and make your function pipelined (that is not only build but also execute the query) and then select from it in your interactive report.
    The disadvantage here would be that any supplementary filtering would act on the result set of the function (not as an addition to the where clause of the original query). But if you can live with that...
    The advantage would be that there's less fiddling with column headers.
    Regards,
    Iulian

Maybe you are looking for

  • Is there a way to change the color of your calendars in the calendar app when it has been synced with multiple calendars?

    I have just purchased an iPad 2 and I have gotten it setup to sync with my multiple calendars on Google Calendar.  But the colors I have chosen for displaying my calendars in Google Calendar are not being used when the info comes over to the iPad.  T

  • ICMERR-EDISPATCHERR.html not working after i place icm/HTTP/error_templ_pat

    Hello all, I'm trying to change the default error page on the webdispatcher when the connection to the portal/j2ee is lost. I succesfully created a page called ICMERR-EDISPATCHERR.html and put it into a webdispatcher subfolder and set the parameter i

  • Problem with file name r�servation.txt

    I am facing a strange problem. I have a file named r�servation.txt. File.isFile() method returns true for this file on Windows, but on linux it returns false. I am using SUSE Linux 10 version. As you can see, there is an extended character (�) in the

  • Blank screen instead of photo

    Taken photos with phone which show in album but when I click specific photos or try to send them it's just blank white screen?checked in photo stream and it's white blank screen there too

  • Macbook and imac sharing

    Ok so i have an imac in my kitchen (core 2 duo) and i use a macbook in my room. Is there a way i can transfer files to my macbook wirelessly? Like if there is a file on my imac and i want it on my macbook i can just connect wirelessly and get it? thx