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

create function for ODD or EVEN(NUMBER) also
if number is odd multiply by 5
if number is even multiply by 10;

865253 wrote:
create function for ODD or EVEN(NUMBER) also
if number is odd multiply by 5
if number is even multiply 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

Similar Messages

  • Function detect odd and even number

    Do you know a function which can detect if a number is an odd number or other.

    if ( number%2 == 1)
    But a method for this? Really doubt that..
    Do you know a function which can detect if a number is
    an odd number or other.

  • Can i use create function for MSSql scalar and table valude function.

    Hi,
    1) Can i use create function for MSSql scalar and table valued function?
    2) How many type of user defined function are there in oracle 11g express?
    3) And can i reture any "type" form user defined function?
    yourse sincerely

    944768 wrote:
    Q1)That means even if i return predefined types like integer, varchar2 then also PGA is used ?The data type does not determine where the variable is stored. A string (called a varchar2 in Oracle) can be stored in stack space, heap space, on disk, in a memory mapped file, in a shared memory, in an atom table, etc.
    It is the who and what is defining and using that string, that determines where and how it is stored.
    The Oracle sever supports 2 languages in PL/SQL. The PL (Programming Logic) language is a procedural/declarative language. It is NOT SQL. SQL is integrated with it. The PL/SQL engine uses private process memory (PGA). So PL/SQL variables exist in the PGA (but there are exceptions such as LOBs).
    Q2) So please suggest me solution in oracle.Sounds to me you are looking at how to implement a T-SQL style function as an Oracle function, and once implemented, do joins on the function.
    Do not use PL/SQL in SQL in place of a SQL select. It is not T-SQL.
    One cannot use PL/SQL to create functions along the style of T-SQL, where the function executes a SQL using some conditional logic, and then return as if the function was a native SQL select.
    T-SQL is an extension to the SQL language - making it a hybrid and very impure language implementation. PL is based on ADA - part of the Pascal family of languages. The E-SQL (embedded SQL) approach used in languages like C/C++, Cobol and Ada, has been transparently done in PL/SQL. You can write and mix PL code and variables with SQL code. And the PL/SQL engine figures out how to make the call from the PL/SQL engine to the SQL engine.
    But PL/SQL is not "part" of the SQL language and does not "extend" the SQL language in a T-SQL fashion.
    So you need to check your SQL-Server preconcepts in at the door, as they are not only irrelevant in Oracle, they are WRONG in Oracle.
    The correct way in Oracle, in a nutshell - Use the SQL language to do data processing. Use PL/SQL to manage conditional process flow and the handling of errors.

  • Creating functions for movie-clips(serious problem)

    Hello,
    This is I think my third thread on these forums and in my
    previous threads I had always got some help.Well, now I have
    another serious problem, can you help me?
    I am unable to create a function that can control movie
    clips. Let me explain:-
    I have 10 movie clips on the stage and I have assigned them
    that whenever they crash to an object, they will go to a random
    position. Writing this code ten times for each movie clip would be
    very tedious, so, I thought about creating a function, but, it
    doesn't work. Here's the function, can you correct it?
    var object:movieClip;
    function position(object) {
    var testnum1:Number;
    testnum1 = random(290)+36;
    _root.object._y = -77.6;
    _root.object._x = testnum1;
    position(nameofmovieclip)
    PLEASE HELP IS REQUIRED!!!!
    Thanking All,
    Chinmaya

    Thanks for the reply,
    I tried that, it worked!
    But, now, I am encountering a really odd problem. This time
    I'll give you my full code.The problem is, that now when the object
    collides with another one, it changes its position according to the
    code but then after a while, it just passes through the object.
    Here's my code:-
    function position(object) {
    var testnum1:Number;
    testnum1 = random(290)+36;
    object._y = -77.6;
    object._x = testnum1;
    metal.onEnterFrame = function() {
    _root.metal._y += speednum;
    if (_root.metal.hitTest(_root.testline)) {
    position(_root.metal);
    speednum = random(6)+1;
    Can you help me out again,
    Thanks,
    Chinmaya
    P.S. I have tried to use the function like this:
    position(metal), but it doesn't work. And yes, I have already
    defines speednum somewhere before, so that isn't the
    problem.

  • Odd or even number comparison?

    Anyone know how to compare an incoming number and tell whether it is odd or even? How about if it is whole or fractional? Thanks
    Kirk

    fabb wrote:
    Anyone know how to compare an incoming number and tell whether it is odd or even? How about if it is whole or fractional? Thanks
    You need to be very careful applying odd/even to floating point numbers. It is only defined for intergers. Especially, if the value is a result of some computations, it could actually be 2.000000001 instead of 2.
    Same with whole vs. fractional. You probably need additional code to ignore small differences from whole numbers. Where does the data come from?
    ODD/EVEN: If you have an integer datatype, do a bitwise AND with "1" and check if the result is zero (even) or not (odd).
    Message Edited by altenbach on 05-27-2008 09:17 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    OddEven.png ‏3 KB

  • Odd or even number

    ok , basically how can I write a line of code which will tell me if a number is odd or even?

    the test for equality with 0 should work for all numbers - the remainder of dividing a negative number by two should be 0 or -1 (I think - and the code bears this out anyway)
    Lee

  • Scalar function For Identity Or Row Number

    Hi
    I need to create a scalar Function that works in the same way as Row Number or a Identity column
    I've not really used functions before so what would be the best way to do this?
    Regards

    Well I'm taking over a ETL process for a OLAP cube which is using SQL scripts and views and Not SSIS, any other logic other than what is available in the design mode of the view are done in functions. If i use the built in one I lose the
    design view.
    If you are making your database design from what you see in some "design mode" you are putting the cart before the horse.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Different margin for odd and even pages

    Hi there,
    I am writing a book which will be printed in 2 sided paper. Therefor I will need different margin (left and right) for the odd and even pages.
    How is it possible in Pages? I am using Pages 5.2 (1860).
    Thank you.
    Sebastian.

    Indesign & Xpress are professional DTP applications. They can layout pages in any order you can imagine with custom margins. They are also complex to learn & expensive in comparison to Pages.
    There is a trial of Indesign IIRC…
    https://www.adobe.com/uk/products/indesign.html
    Quark also has a trial too…
    http://www.quark.com
    I expect there may be cheaper 'layout' software that is capable of arranging facing pages correctly (possibly from a single pages PDF export from Pages), but I just avoid apps like Pages if I need a finer level of output control.

  • Is it possible to have different margin settings for odd and even pages?

    Hi guys.
    I am formatting a book I want to get printed and it would be very helpful to have different margin settings on the odd and even pages so the text won't fall too close to the gutter (as happened in the proof copy I ordered!).
    It's possible to do this on Word, but I can't seem to do it on Pages? Am I missing something?
    Any help would be greatly appreciated. Thank you

    Thanks Peter. I upgraded to Pages 5 a while back. I guess my next question is.....is there any way I can downgrade to Pages 09...anywhere I can still download it from?
    Seems a bit of a backward step, but needs must

  • Creating Functions in SQL server

    HI
    i creating functions for specific purpose in the test database...
    is it against SAP Support policy?
    suggest me...

    if you are just going to start entries then you can .
    But i have posted then Use replace function in SQL
    SQL Syntax:
          REPLACE( string1, string2, string3 ) 
    Parameters:
        string1
    Any character string or binary expression that can contain the string from string2.
    string2
    Any character string or binary expression. This string is searching in string1.
    string3
    Any character string or binary expression. This string replace all occurrence of string2.
    May it will work
    Thanks
    Manvendra Singh Niranjan

  • Error Creating Function in GRC ARA

    Dear Experts,
    I am new to GRC AC,while creating function for standard MM transation code :ME21N and ME51N,
    showing as error:Request submission inconsistent; process &SAP_GRAC_FUNC_APPR&,
    version &000001&, external ID &SOD_FUNCTION/ZF800F1&.please suggest me
    Thanks in advance,
    Varun

    Dear Varun,
    how did you add the tcodes? Like in my example below?
    Make sure that you run the object sync job before you add the tcodes as otherwise they cannot be resolved.
    Let me know if syncing helps.
    Regards,
    Alessandro

  • Hanging "CREATE FUNCTION dbo.fn_ConvertVersionToNumber("

    Hi there
    I am in the process of upgrading from SharePoint 2007 to SharePoint 2013 (via 2010).
    So far all small Content DBs have fully migrated no issues. Then we have one 80GB DB, and one 110GB DB, that are both doing something strange.
    During the migration of these as part of the 2013 Visual Update process (all works with no issues up to here), at seemingly random points, the process hangs when at a SQL level (I have a script to tell me what actions are currently running on SQL at any
    time) it is trying to do the following:
    CREATE FUNCTION dbo.fn_ConvertVersionToNumber(
    I have checked in the SQL DB and this has been created there successfully; yet in SQL the process just hangs there on this item; if left to run, it seems to hang indefinitely (I got to 100 Hours for one run). If I kill that SQL thread when I see it happening,
    then all completes with no issues. However, it seems to happen again after the migration as well; sometimes when users access the site for the first time on a day; the page hangs indefinitely; and in SQL I again see it is trying to run the above CREATE FUNCTION
    command - if I kill the thread again, all works fine.
    While it is hanging, SQL reports no Blocking Locks; and CPU and RAM usage on both SP and DB servers is all very low (all is under 40% usage).
    The environment is:
    SP: SP 2013 with SP1 on Windows 2012 R2.
    DB: SQL 2012 Standard with SP2 on Windows 2012 R2.
    This is happening on DEV, UAT and PROD environments - any thoughts welcome.
    Thanks
    David

    Hi David,
    I have been dealing with similar issues for the past couple of weeks, and actually, we've had the same SQL blocking the migration process in some occastions.
    Our scenario is a migration from SharePoint 2007 to 2013, for which we are using a third-party tool.
    We've performed a couple of changes in an attempt to deal with the issue of blocking SQL transactions and/or processes.
    First, we have disabled the AlwaysOn-configuration which was set to synchronous-commit. If you plan to configure high availability, you might find the follow article interesting: http://technet.microsoft.com/en-us/library/jj841106(v=office.15).aspx. Also,
    we have set the recovery model of SQL Server to 'Simple'. Both changes have been made to unload SQL Server as much as possible.
    For a couple of days, the migration continued without blocking transactions and processes, but then unfortunately every night we were having the same problem again.
    We have now re-scheduled the Timer Jobs 'Microsoft SharePoint Foundation Usage Data Processing' and 'Solution Daily Resource Usage Update' to run in the morning, since we are
    pretty sure that these were the culprit, as they seemed to be stuck when we checked in Central Administration. Also the blocking SQL statements seemed to be related to these timer jobs, judging from this document: http://download.microsoft.com/download/5/0/1/501ED102-E53F-4CE0-AA6B-B0F93629DDC6/SharePoint/[MS-WSSPROG2].pdf.
    The results so far: one night of uninterrupted migration and the Timer Jobs have run without any problems.
    I will post an update if there are any developments which are relevant to this issue.
    Good luck!
    Jacob

  • Rule 11 functionality for India Localization OSP Process

    Hi
    Can Any one tell us How to implement Rule 11 Functionality for India Localization OSP Process.
    Pls let us know how to map this functionality either to incorporate it in Purchasing or Order management module
    Also can any one provide us the document/link to understand and implement it in Oracle Application on 11.5.10.2 with IN60107 localization version
    Thanks in Advance

    Also can any one provide us the document/link to understand and implement it in Oracle Application on 11.5.10.2 with IN60107 localization versionHave a look at Note: 471249.1 - Documentation repository for Oracle Financials for India
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=471249.1

  • How can we create subtypes for om custom infotypes

    hi,
        I want the detailed procedure how to create Subtypes for Organzational management custom infotypes.
        Pls send me the detailed path how to create Subtypes for Org management.
    thanks & regards,
       Sekhar.

    Access transaction SM30/31 for table maintenance. Enter view name V_778U.
    Select maintain and enter the subtype for the custom infotype.
    Also remember to enter the time constraint for the subtypes mainatined in table T777Z.
    SPRO Path
    Personnel Management --> org management --> basic settings --> data model enhancement --> infotype maintenance --> maintain subtypes.
    Regards
    Ravikumar

  • I have a photo of an ice surface and another of a flower. Now I want to create a merged photo with the flower lying under the ice. I understand that I shall use the function "Layer" and have even read in the manual and looked on a video, but that informat

    I have a photo of an ice surface and another of a flower. Now I want to create a merged photo with the flower lying under the ice. I understand that I shall use the function "Layer" and have even read in the manual and looked on a video, but that information is not sufficiently detailed for me. I have tried several options, but I come now way. Generally it seems that your information is only for the ones who can, not for the people who can´t although it is we who really need to learn. Please give me a step by step (click by click) information on how I can get the ice above the flower and then make the ice partly transparent so the flower is seen underneath. Please send me an e-mail Erik Solbu [email protected]

    Open a new document big enough for your image. Then additional open your ice and flower image as well. Copy each and paste it into your blank document. They will be placed on their own separate layers.
    Make sure in your layers panel. (Bottom right) the ice is above the flower, by dragging it in place. In that same layers panel click the ice layer to select in and find the opacity meter above. Drag to the left until you get the effect you desire.

Maybe you are looking for

  • Error while working with hierarchical profiler

    Hi, I am working with hierarchical profiler for the first time in SQL Developer 3.0. When I open a procedure and click the Profile icon, I get the following error "Directory exists;check if /tmp exists on file system, and oracle has permissions to wr

  • I-tunes is crazy

    My library has reproduced itself which means that I have two of everything and I want to know how to get rid of half the songs. I also don't seem to be able to burn disks anymore the instruction is blank. My screen wobbles now - has anyone else had t

  • Some Items for the following product(s) could not be installed successfully

    I had photoshop cs5.1..uninstalled it using adobe uninstaller tool.  When I'm trying to install my creative suite at the end this is what shows. Still able to use the new products but I don't understand what these errors and warnings mean. Thx.  Exit

  • How can i unlock iphone 5 if i forgot my passcode

    how can i unlock my iphone 5

  • Update/upload not working today

    hello update/upload not working today everytime i go on the ipad and try (or resume) it says theres' an error and that i gotta try later, but it's 7 hours now that i try later ... anyone else experiencing this today ?