Create function for ODD or EVEN (NUMBER) in pls sql

Create the function for ODD or EVEN (NUMBER) also
If number is odd, multiply by 5
If there is an even number, multiply it by 10;

865253 wrote:
Create the function for ODD or EVEN (NUMBER) also
If number is odd, multiply by 5
If there is an even number, multiply it by 10;

create function fn_get_no (n_in in number) return number is
o_num number;
begin
if mod(n_in,2) = 0 then
o_num := n_in*10;
else
o_num := n_in*5;
end if;
return o_num;
end;
select fn_get_no(5) odd, fn_get_no(4) even from dual;
ODD EVEN
25 40 

Vivek L

Tags: Database

Similar Questions

  • I want to create the function for the function create for ODD or EVEN (NUMBER)

    I want to create the function for the function create for ODD or EVEN (NUMBER) also
    If number is odd, multiply by 5
    If there is an even number, multiply it by 10;

    Not tested,

    create or replace function fnc_env_odd(p_number in number)
    return number as
    begin
     if p_number>0  -- Remove if you want to consider negative numbers also
       if mod(p_number,2)=0 --Means even
          return p_number*10;
       else                 --Means odd
          return p_number*5
       end if;
     end if;
    end;
    /
    

    G.

  • How can I recover only odd or even number of records in the table?

    Hello

    How can I recover only odd or even number of records in the table?

    Thank you

    Hi IndiMinds,

    Alternatively, you can use in queries. :

    Odd:

    SELECT *.

    Of

    (SELECT rownum row_count, id, name FROM bigemp

    )

    WHERE mod (row_count, 2) = 1;

    Still:

    SELECT *.

    Of

    (SELECT rownum row_count, id, name FROM bigemp

    )

    WHERE mod (row_count, 2) = 0;

    Thank you

  • Different margins for odd and even pages

    Hi all

    Is there a way that we can change the margins on the PDF based on the number of page. Odd pages say have the margin set to 2.45 cm while the odd pages only to 1.6 cm? Thank you!

    We use Documaker Studio 12.3.

    There is nothing in the Documaker PDF driver that's going to change the margins for you. Assuming that you cannot design forms with desired margins (e.g. for printing of transactional document), then your best bet is to find a third-party tool that will adjust the PDF file after it is generated by Documaker. Personally, I don't know of a tool that does this, but a Google search may help you find a tool that meets your needs. For example, I found the following which suggests to use GhostScript to add margins - pdf - how I automatically add a margin to each pair page?-Graphic Design Exchange of battery

    I hope this helps.

  • 5.6 pages | Different headers for odd and even pages

    My neighbor has 5.6 Pages and may not know how to format the document in order to have even pages and odd different headers. I am using Pages 08 and this version has a parameter "Pages are different." However, I can't find this 5.6 Pages feature.

    Is this possible in 5.6? If so, can someone tell me how, I can help him out?

    Thank you

    N ° feature not supported in any version of v5 Pages.

  • Disable the column key functional for an individual of forms

    Hi all

    I have a block of multiple registration details in my form with fields (type, point, wt, vehicle number etc.). Keys are already scheduled for functional use as f3 to copy.

    In my form, I want to use the copy function to get to the fields as type, point, wt, but not for the vehicle number column. IE type, point, maybe same wt columns but number of vehicle may not be same (according to customer requirement). They will not accidentally copying the same number of vehicle.

    For this I need to disable the copy (F3) function for this vehicle only number column.

    Is there a workaround for this...

    My version of the form is 10g

    Thanks in advance

    Concerning

    JaKes

    the KEY-F3-trigger has nothing to do with the F3 function key. In client-server F3 is associated with the DUPLICATE_ITEM function, so you should use the KEY-DUPITM-trigger.

    Also, if you implement a release BUTTON, it replaces the functionality by default, so you must manage the service for yourself.

    As for the OP functionality should just be deleted at one, the simplest solution is to create KEY-DUPITM-relaxation so precise and simple insert a value that is NULL. inside.

  • Script to crop only odd or even pages in Acrobat

    Someone at - it script to crop the even or odd pages only through batch processing. I use the same settings of harvesting almost every day and would like to be able to define a batch process for this. I copr parameters for odd and even pages, so I can't use the basic crop tool already contained in the batch. Thanks for any help.

    I copr parameters for odd and even pages, so I can't use the basic crop tool already contained in the batch.

    Why not?

  • can I use create valude function for MSSql scalar and table.

    Hello

    (1) can I use create scalar function for MSSql and function table?
    (2) is there how many type of function defined by the user in oracle 11 g express?
    (3) and I can reture 'type' any form user defined function?


    Attract sincerely

    944768 wrote:

    the answer lies in a few cases only,

    The response illustrates the basic concept of how customers need to use cursors created using PL/SQL as a layer of abstraction - SQL and this concepts adapts to ALL cases where the customer wants to Oracle via PL/SQL cursor.

    a case is,
    If my function returns only a single value, then I can use oracle 'create function' with the return type as types predefined as a whole, varchar2 etc?
    with regard to performance.

    With regard to this performance problem? And why now suddenly change the question to want to use a function to return data type number or string? How does this relate to PL/SQL to return a cursor now?

    A function can return scalar values, not scalar. A function may return atomic values (such as a unique number, or a non-scalar list of numbers). A function can return a complex data structure consisting of scalar values, not scalar.

    However, in PL/SQL function must NOT be used to read the lines of the database to cache lines in a memory of the server PL/SQL (PGA), then back to the client.

    He does not. It does not fit. It is too bloody dangerous to the overall health of the server as such code plays silly blighters with very expensive server memory.

    A PL/SQL function can also be used as guideline, returning data via expensive PGA, but via the SQL engine instead and using its slider interface (which allows output data to be "gradual" and not to return all data with a single copy of croustilleur mass of the call stack) directly. IT IS, HOWEVER, AN EXCEPTION. There is very rarely the need to make the functions PL/SQL pipeline table - and is often victims of abuse and bad demonstrated with examples of absurd code here.

  • How to create a function for the function date two

    Hai All

    How can we create a function for the date function two and to return the number of hours between two dates

    For example

    1 January 2010 0815' - '01-jan-2010 1715' and I need to calculate the time between two dates

    How can I create a procedure

    Thanks I advance

    Srikkanth.M

    What have you tried?

    Here is an example (untested):

    CREATE OR REPLACE FUNCTION RETURN_HOURS
    (
            pDateStart      IN DATE
    ,       pDateEnd        IN DATE
    )
    RETURN NUMBER
    DETERMINISTIC
    AS
    BEGIN
            RETURN (pDateEnd - pDateStart) * 24;
    END RETURN_HOURS;
    
  • Create parameters for the WriteData function

    Hello

    How would create parameters for the writedata function to populate the html code?

    CODE:

    Function GetCluster {}
    and {{foreach ($Datacenter (Get-Data Center))
    foreach ($Cluster in (Get-Cluster-location $Datacenter)) {}
    New-Object PSObject-property @ {} TypeName
    vCenter = $Datacenter.Uid.Split("@") [1]. Split(":") [0]
    Datacenter = $Datacenter.Name
    Cluster = $Cluster.Name
    HAEnabled = $Cluster.HAEnabled
    DrsEnabled = $Cluster.DrsEnabled
    DrsMode = $Cluster.DrsMode

    }
    }
    }
    # Function compiles the data transmitted by the GetCluster function in HTML table format
    Function writedata {
    param ($vCenter, $Datacenter, $Cluster, $HAEnabled, $DrsEnabled, $DrsMode)
    # < td > < Center > < b > < of police = "Tahoma" > $Datacenter < / police > < / b > < / center > < table


    {$tableEntry = "< tr > < td > < font ="Tahoma">$vCenter< / fonts > < table > < td > < Center > < b > < of police ="Tahoma">$Datacenter< / font > < / b > < / center > < table > < td > < Center > < b > < of police ="Tahoma">$Cluster< / fonts > < / b > < / center > < table > < td > < Center >"} < b > < of police = "Tahoma" >$HAEnabled< / fonts > < / b > < / center > < table < td > < Center > < b > < font = "Tahoma" >$DrsEnabled< / police > < / b > < / center > < table < td > < Center > < b > < font = 'Tahoma' color 'dark blue' = >$DrsMode< / fonts > < / b > < / center > < table > < /tr ' > '.
    Add-Content, $fileName $tableEntry
    Write-Host $tableEntry}

    Thank you

    You specify when you call the writedata function, so I guess it's in the function Get-Cluster.

    You can pass the object you create in the GetCluster function as a parameter.

    Try something like this

    Function GetCluster {
        & { foreach ($Datacenter in (Get-Datacenter)) {
                foreach ($Cluster in (Get-Cluster -Location $Datacenter)) {
                    $clusObj = New-Object -TypeName PSObject -Property @{
                        vCenter = $Datacenter.Uid.Split("@")[1].Split(":")[0]
                        Datacenter = $Datacenter.Name                    Cluster = $Cluster.Name                    HAEnabled = $Cluster.HAEnabled                    DrsEnabled = $Cluster.DrsEnabled                    DrsMode = $Cluster.DrsMode
                    }
                    writedata $clusObj            }
            }
        }
    }
    
    # Function will compile the data passed from the GetCluster Function into HTML table format
    Function writedata {
        param ($object)
    
        $tableEntry = "$($object.vCenter)" +
            "
    $($object.Datacenter)
    " + "
    $($object.Cluster)
    " + "
    $($object.HAEnabled)
    " + "
    $($object.DrsEnabled)
    " + "
    $($object.DrsMode)
    " Add-Content $fileName $tableEntry Write-Host $tableEntry}
  • Creating shadows of text - is there a function for this?

    I would like to create a shadow effect for my text in my headers.  Is there a function for this?

    In the current version of Muse you can only apply effects to pixelated fonts (fonts). If you need a shadow to the other fonts effect, you can do the following:

    1. create a paragraph style, name it as you need (for example shadow_paragraph) and assign to the text element you need to be affixed.

    2. go in the Page Properties > metadata > HTML customized to(Or insert HTML to a master page)

    3 insert a

  • create the default function for table

    Oracle Erro PLS-00593
    What is this problem?

    Is possible to create?

    exec default_values (51, p_seq_cessao_servidor_canc = > varray_1);
    or
    exec default_values (51, p_seq_cessao_servidor_upd = > varray_2);


    CREATE OR REPLACE TYPE 'SISARR '. "' VARRAYNUMTYP ' is varray (500) number;

    function test (p_seq_debito IN sisarr.debito.seq_debito%TYPE
    p_sig_usuario IN sisarr.deb_cessao_servidores.sig_usuario%type
    p_seq_cessao_servidor_canc IN varraynumtyp by default varraynumtyp()
    (, p_seq_cessao_servidor_upd IN varraynumtyp varraynumtyp() default) return is varchar2

    vMsg Varchar2 (4000);

    Start
    --
    end;

    Thank you!

    Published by: user10830594 on 06/03/2009 05:52

    Hello

    user10830594 wrote:
    Oracle Erro PLS-00593
    What is this problem?

    Oracle error: PLS-00593
    the default value of the parameter 'string' in the body must match spec

    Cause
    Initialization by default value of a parameter in a body of subroutine contained in a package body did not match that of the specification of subprogram corresponding to the corresponding package specification.

    Action
    Change the default initialization of the parameter in the body must match the spec.

    SQL> create or replace type test_v is VARRAY(500) of number;
      2  /
    
    Type created.
    
    SQL> create function test_f (x test_v default NULL)
      2  return number
      3  as
      4  begin
      5  return 1;
      6  end;
      7  /
    
    Function created.
    
  • Error creating function.

    HII All,
    I am currently working on 10 gr 2. I'm trying to move from a column and analyze dynamically, but I met due to error. Please help me.

    Create or replace Function r_return_col
                        (
                         p_table_name          in          varchar2,
                         p_column_name          in          varchar2
                        )return varchar2
    is
    
              l_count                    number;
              l_clob                    clob;
              
              l_count_str               varchar2(32000);
              
              l_column_value          varchar2(32000);
              l_str                    clob;
              l_ret_str               clob;
    begin
              l_count_str := ' select count('||p_column_name||') ' ;
              l_count_str := l_count_str||' from      '||p_table_name ;
    
    
              execute immediate l_count_str into l_count;
              
              
              for i in 1..l_count
              loop
                   
                        
                        l_str := 'select '||p_column_name||' from ' ;
                        l_str := l_str||' ( ';
                        l_str := l_str||' select row_number() over(order by '||p_column_name||') rw,'||p_column_name||'  from '||p_table_name;
                        l_str := l_str||' ) where rw = '||i ;
              
              
                        execute immediate l_str into l_column_value;
                        
                        l_ret_str := l_column_value||','||l_column_value;
              
              
              
              end loop;
              
                   return 'select l_ret_str from dual';
              
    end;
    /
    show err;
    SQL> @D:\raghu\oracle_docs\rows_to_columns.sql
    
    Warning: Function created with compilation errors.
    
    Errors for FUNCTION R_RETURN_COL:
    
    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    34/5     PL/SQL: Statement ignored
    34/23    PLS-00382: expression is of wrong type
    Concerning
    Rambeau.

    I think the problem is the line:

    execute immediate l_str into l_column_value;
    

    run immediately makes does not work with the clob type. You must define the variable l_str as type varchar2.

    Another problem, it's your last line:

    return 'select l_ret_str from dual';
    

    You will always return the text "select l_ret_str from" dual I can't believe that's what you want. Probably you want:

    return l_ret_str;
    

    I suggest to also qualify the variable l_ret_str of type varchar2.

  • create masks for marked particles

    Hello world

    I'm trying to creat masks for each marked by IMAQ label.vi particles. I did use IMAQ labeltoroi, get the return on investment for each particle, and do IMAQ roitomask 2. However, the images of these masks are related images. Do you know how creat masks in the coordination of the original image?

    Best,

    Doogie

    I think that the lable particle simply sets the value of each BLOB in a class to an integer it is IE 1,2,3,4 for 4 groups, (I have LV here right now so it's memory).  You can just itterate through the lable values and use the image to compare or beach threshold function to make masks where you keep the pixels that are equal to this value.  What will a new image with only the PIX = 1 where the value is equal to the value labled, it will have the same size and shape as the original image of lable.

  • BSOD network, related function for Winsock problem driver-related

    I'll give as much detail as possible in order to get the right answer.

    I'm working on HP G70 - 463CL with Vista Home Premium 64 - bit.

    The problem is that whenever we try to use something that would require a network function, I have a BSOD with the IRQL_NOT_LESS_OR_EQUAL.
    This occurs even if I plug in a network cable, try to run a web browser, or right-click on the signal wireless in the bottom task bar.

    When the computer reboots, I get the "Windows has recovered from an unexpected shutdown' with this information.
    Problem event name: BlueScreen
    The system version: 6.0.6002.2.2.0.768.3
    LocaleID: 1033

    More information about the problem:
    BCCode: a
    BCP1: 0000000000000000
    BCP2: 0000000000000002
    BCP3: 0000000000000001
    BCP4: FFFFF80002228C45
    OS version: 6_0_6002
    Service Pack: 2_0
    Product: 768_1

    He then lists the minidump file which I do not know how to open it.

    I went to HP and download the current network for the WLAN and LAN drivers. (I have uninstall the previous)

    I went to Services to see what didn't work and I got these errors when I tried to start them.

    The DHCP Client 1.) -Error 1068: the dependency service or group could start. So I clicked on the dependencies and seen that it relies on the "accessory function for Winsock driver" and the "WinHTTP Web Proxy Auto - Discovery Service" depends on DHCP.

    TCP/IP NetBIOS Helper 2 properties.) -a had the same message according to the 'related function pilot' and it depends on the NETBT.

    I have passed to the command window and tried ping 192.168.1.1, and got the error that transmit failed, error code 1231.

    I have also reset IP address and with the command netsh winsock

    I went to Device Manager and click on devices show hidden.

    Under the pilot no Plug and Play there was a yellow by 'Related function for Winsock driver' symbol when I click Properties, it says under the status it is not working properly or has not all the drivers installed (Code 24).
    I also had a yellow symbol of security processor Loader driver and the same information under properties.

    In searching the Internet, I tried several different things that I found and tried including change something in the registry.  At one point I was able to make wireless work and managed to get on the internet and ran Windows Update and downloaded several items.  After the reboot, I clicked on an Internet Explorer icon on the screen to come back on the internet and I got the blue screen again.

    I ran Malwarebytes and it found nothing.

    I uninstalled AVG 8.5 and was going to install a different virus protection and I have a feeling that this is where the problem started.

    So if anyone can offer help, I'd appreciate it.  I have a feeling that everything hinges on the related function driver but do not know how to reinstall.  The hard drive has a recovery partition, but I don't want to reinstall the OS.

    There are a few issues, including the duplicate property and lack of records relating to the CPU.

    While this can be traced back to file by file, the best way to solve the OS when SFC finds files that it cannot solve is to do a repair of the DVD of the OS installation.

Maybe you are looking for