DB2 DIGIT  FUNCTION IN ORACLE

What is the DB2 DIGIT FUNCTION equivalent in ORACLE database. We have done a migration from db2 to oracle and many programs just fails where I encounters digit function. Is there any workaroud or function present in oracle database which makes the program working.
Just share your knowledge .
[email protected]

Addendum ...
OK I found what the DIGIT function does.
I am not sure if there is a function in Oracle that maps directly to DIGIT function in DB2
but you can do something like this:
select lpad(replace(to_char(abs(n)),'.'),
(select to_number(data_precision) from user_tab_columns where table_name = 'A' and column_name = 'N'),'0')
from a
In the SQL above n is the column in table A. Data_precision column gets the size of the column.
Option 2:
You could write your own function in Oracle to do what the SQL above does
create or replace function digit (col_val in number, col_name IN varchar2, tab_name IN varchar2) return varchar2
as
v_val varchar2(100);
v_prec number;
begin
select to_number(data_precision) into v_prec from user_tab_columns where table_name = upper(tab_name) and column_name = upper(col_name);
v_val := lpad(replace(to_char(abs(col_val)),'.'),v_prec,'0');
return v_val;
end;
Then use the function as follows:
select digit(n,'N','A') from a
Shakti
http://www.impact-sol.com
Developers of Guggi Oracle - Tool for DBAs and Developers
Message was edited by:
skgoel

Similar Messages

  • Oracle from DB2 federation - function mapping

    I need to map an Oracle function (instr) from an InfoSphere function (postion) from the DB2 database, so this is more of a DB2 question, but never could get an answer out of DB2ools ;-)
    I have created the wrapper, server, user mapping and nicknames in DB2, but need to create a function mapping in DB2 between their "position(search, source, code) to our instr(search, source). This is a mapping of system functions, so I am not sure if it is possible... and their documentation is kludgy at best. The problem is this: POSITION(search, source, code), where code represents UTF-16, UTF-32 or code page translation. I want to force this syntax to pass to Oracle as INSTR(search, source), dropping their 'code'.
    This is the only function that does not work properly from the DB2 side to us. If anyone has the DB2 create function mapping command to do the above, my appreciation for the answer and condolences that you actually had to go thru the reams of IBM documentation.

    Addendum ...
    OK I found what the DIGIT function does.
    I am not sure if there is a function in Oracle that maps directly to DIGIT function in DB2
    but you can do something like this:
    select lpad(replace(to_char(abs(n)),'.'),
    (select to_number(data_precision) from user_tab_columns where table_name = 'A' and column_name = 'N'),'0')
    from a
    In the SQL above n is the column in table A. Data_precision column gets the size of the column.
    Option 2:
    You could write your own function in Oracle to do what the SQL above does
    create or replace function digit (col_val in number, col_name IN varchar2, tab_name IN varchar2) return varchar2
    as
    v_val varchar2(100);
    v_prec number;
    begin
    select to_number(data_precision) into v_prec from user_tab_columns where table_name = upper(tab_name) and column_name = upper(col_name);
    v_val := lpad(replace(to_char(abs(col_val)),'.'),v_prec,'0');
    return v_val;
    end;
    Then use the function as follows:
    select digit(n,'N','A') from a
    Shakti
    http://www.impact-sol.com
    Developers of Guggi Oracle - Tool for DBAs and Developers
    Message was edited by:
    skgoel

  • Equivalent of DB2  functions in ORACLE 11g

    Hi,
    I am trying to convert the SQL queries written in DB2 to ORACLE. There are some db2 specific functions are used in the queries.I am not able to find the equivalent function in ORACLE. The function names are written below:
    1) DateDD()
    2) SELECT @@IDENTITY
    3) SELECT *
    FROM (
    SELECT ROWNUMBER() OVER() AS rowId_1, INNER_TABLE.*
    FROM (----)as innertable
    ) AS Outertable
    Error is: ROWNUMBER is INVALID identifier.
    4) DAYOFWEEK()
    5) DAYS()
    6) dayofyear()
    Please help me in finding the equivalent function in ORACLE.
    Thanks in advance!!

    You probably don't need a DateAdd function in Oracle. You can add a number to a date in Oracle-- that adds the number of days to the date.
    SELECT sysdate today, sysdate+1 tomorrow
      FROM dualWhy are you using DAYS()? If, as in the example, you're just trying to determine the number of days between two dates, you can subtract dates in Oracle and the difference will be a number of days (including a fractional component if applicable)
    SELECT date '2011-09-27' - date '2011-09-25' difference_in_days
      FROM dualIf you really need the number of days since January 1, 0001, you could subtract the date from Jan 1, 0001, i.e.
    SELECT date '2011-09-27' - date '0001-01-01'
      FROM dualI would assume that Oracle and DB2 would return the same number but there could well be some differences since the current calendar didn't exist in the year 1 and I know there were issues in the transition from the Gregorian to the Julian calendar where some days were decreed not to exist. It wouldn't shock me if Oracle and DB2 counted some of the days in the 1500's differently.
    Justin

  • Calling DB2 Stored Proc from Oracle DB

    Hi,
    I am having two different database running (One is oracle on solaris while the other one is db2 on os/390 mainframe) i want to pass the data realtime. Is there any way I can call a DB2 stored procedure from oracle directly. If anyboy can help in this will be really helpful.
    thanks,
    Kishor

    odi version we have is  ODI_11.1.1.6.0, it is not migrated and 'Always Execute' option is checked already.
    tried using variables in capital format but did not worked,
    begin
    schema_name.proc_name(#LV_TABLE_NAME,#LV_SCHEMA_NAME,#LV_START_DATE,#LV_END_DATE);
    end;
    odi is giving error if it finds any bug in stored proc but after fixing its completing successfully without errors in operator but i am not able to see the result.
    Please advise.

  • Subpartition with MOD Function in Oracle 11g

    Hi All,
    Can we create Subpartition based on MOD Function in Oracle 11g ?

    Hi!
    What are you refering with "MTS"? Anybody knows a term like this (except MultiThreaded Server).

  • RANK FUNCTION IN ORACLE 8I

    제품 : PL/SQL
    작성날짜 : 2001-09-11
    RANK FUNCTION IN ORACLE 8I
    ==========================
    EXPLANATION
    oracle 8i(8.1.6) 부터 가능한 rank function 입니다.
    8.1.5 에서는 ora-923 error 가 납니다.
    plsql 내에서는 oracle 9i 부터 가능합니다.
    8.1.6에서는 ora-900 error가 납니다.
    EXAMPLE
    <RANK() OVER ( query_partition_clause ORDER_BY clause) >
    - 중복 rank 값만큼 다음 순위는 생략
    SQL>SELECT deptno, ename, sal, comm,
    RANK() OVER (PARTITION BY deptno ORDER BY sal DESC, comm) as rk
    FROM emp;
    DEPTNO ENAME SAL RK
    10 KING 5000 1
    10 CLARK 2450 2
    10 MILLER 1300 3
    20 3500 1
    20 SCOTT 3000 2
    20 FORD 3000 2
    20 JONES 2975 4
    20 ADAMS 1100 5
    20 SMITH 800 6
    30 BLAKE 2850 1
    30 ALLEN 1600 2
    30 TURNER 1500 3
    30 WARD 1250 4
    30 MARTIN 1250 5
    40 JAMES 777 1
    9 1
    <DENSE_RANK( ) OVER ( query_partition_clause ORDER_BY clause ) >
    - 중복 rank 의 수와 무관하게 numbering
    SQL>SELECT dname, ename, sal, DENSE_RANK()
    OVER (PARTITION BY dname ORDER BY sal) as drank
    FROM emp, dept
    WHERE emp.deptno = dept.deptno
    AND dname IN ('SALES', 'RESEARCH');
    DNAME ENAME SAL DRANK
    RESEARCH SMITH 800 1
    RESEARCH ADAMS 1100 2
    RESEARCH JONES 2975 3
    RESEARCH SCOTT 3000 4
    RESEARCH FORD 3000 4
    RESEARCH 3500 5
    SALES WARD 1250 1
    SALES MARTIN 1250 1
    SALES TURNER 1500 2
    SALES ALLEN 1600 3
    SALES BLAKE 2850 4
    plsql 내에서 사용 가능 :oracle 9i 부터
    SQL> create table
    rank_emp(deptno number(2), ename varchar2(20), sal number(5), rk number(2));
    테이블이 생성되었습니다.
    SQL> create or replace procedure window_plsql AS
    query_str VArchar2(1000);
    begin
    query_str := 'insert into rank_emp
    SELECT deptno, ename, sal,
    RANK() OVER (PARTITION BY deptno ORDER BY sal DESC, comm) as rk
    FROM emp' ;
    Execute Immediate query_str;
    end;
    2 /
    프로시저가 생성되었습니다.
    SQL> exec window_plsql
    PL/SQL 처리가 정상적으로 완료되었습니다.
    SQL> select * from rank_emp;
    DEPTNO ENAME SAL RK
    10 KING 5000 1
    10 CLARK 2450 2
    10 MILLER 1300 3
    20 SCOTT 3000 1
    20 FORD 3000 1
    20 JONES 2975 3
    20 ADAMS 1100 4
    20 SMITH 800 5
    30 BLAKE 2850 1
    30 ALLEN 1600 2
    30 TURNER 1500 3
    DEPTNO ENAME SAL RK
    30 WARD 1250 4
    30 MARTIN 1250 5
    30 JAMES 950 6
    14 개의 행이 선택되었습니다.

    That's correct
    The differences between Standard and Enterprise Edition are listed here:
    http://www.oracle.com/technology/products/oracle8i/pdf/8i_fam.pdf

  • Function in oracle to find number of occurances of a character in a string

    hi,
    is there any function in oracle to find the number of ocurrances of a character in a string ?
    or is there any simple way of doing the same, rather than writting many lines of code as my program is already very complex.
    Maria

    Hi Maria,
    I don't know of such a function in Oracle, but maybe you could use this:
    length(search_string) - length(replace(search_string, character_to_be_found))
    For example: select length('Hello') - length ( replace('Hello', 'l')) from dual;
    Hope this is what you're looking for
    Danny

  • T-SQL functions in ORACLE

    Use T-SQL functions in ORACLE too, so you can write one script version that works in SYBASE, SQLSERVER and ORACLE when need to use the following functions:
    ceiling, charindex, dateadd, datediff, datename, datepart, day, db_id, db_name, getdate, host_id, host_name, left, len, month, replicate, right, space, str, str_replace, stuff, substring, suser_id, suser_name, user_id, user_name and year.
    The file [comp_tsql_ORA_schema.txt|http://forums.databasejournal.com/attachment.php?attachmentid=564&d=1258547015] creates the tablespace and schema to put the objects, and the file [comp_tsql_ORA.txt|http://forums.databasejournal.com/attachment.php?attachmentid=569&d=1259256898] creates the functions into the new schema. They will be avaliable for any schema of the oracle instance.
    Hope this help!
    Any suggestion please contact.
    aklein2003
    Edited by: user1958693 on 26/11/2009 10:16

    jgarry wrote:
    J2EE beta released around 1999. Religious programming wars far preceded that. Here's but [one example|http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/1c50bc13e9302f00/34bb8f3ac77e2388?q=programming+language+religion#34bb8f3ac77e2388] from a quick google. I'm no longer convinced that elegance is a desirable trait for a language. So call me a heretic.
    Ever tried XLISP? :-)
    It's different. Back then it was simply the language itself. And it was not really a religious kind of battle, but more a mine-is-bigger-and-better-than-yours one.
    With Java, it is all about The Acrhitecture and the blessed language of Java. ;-)
    I wouldn't so much blame J2EE believers for that. I think there is a fundamental complexity to web type paradigms that hasn't been described in a precise and encompassing enough manner to enable correct project planning.The basic problem is that the database is treated as a persistent storage layer only. A bit bucket. And that is exactly what a database is not.
    But as it is used that, loads of database features now need to be duplicated in the application layer. Which is done. Very poorly.
    Heck, I've even been told that J2EE's 3-tier architecture is not client server. Such ignorance is really unbelievable. Or is it pure stupidity?Until you just made me look it up, I would have thought that too, I'm sure I saw client/server defined as two-tier in the last century. But I have much more stupid misdefinitions to deal with on a daily basis, simply from the multiplicity of paradigms. I tend to retreat into my shell. Hehehe. Know that feeling... These days I rather run away, or set shields to full power, than try to get in yet another frustrating, fruitless and futile discussion with a Java head about the wonders of the J2EE architecture. Or trying to explain that this "new" architecture is predated with what we used in the 80's on mainframe systems with transaction monitors, block devices (the 80's web browsers) and databases - which software layer for software layer was almost identical to "+The Great Architecture+" of today. (and we did it without buzzwords too) ;-)
    Client-server is a software architecture and in essence describes 3 basic software components. The User Interface (UI), the Application (APP) and the Database (DB). And there are various ways to put these components together in a client-server architecture. The mistake that the Java fanbois make is thinking that client-server means having the client as the UI and APP as a single component (so-called fat client) and then the DB component as the server.
    There are numerous versions of these - including the APP component being a server component (as we now these days more commonly used in over the web).
    My beef with the J2EE "+religion+" always has been that client-server is client-server. The fundamentals stay the same.

  • Using FILTER function in oracle answers

    Gurus,
    I have a question related to using Filter function in oracle answers.
    When trying to insert a Filter (expr) Using (expr) clause in the formula area of a fact table field, It errored out with msg saying about using a wrong measure.
    I know this can be done with a case expression but I tried filter clause since this is available in oracle answers.
    Please help me figuring out this scenario.
    Thanks.

    David / Raghu - Thanks for u'r replies and apologizes for not posting question with proper material.
    Am posting my code and the error message from the screen.
    Code :
    IFNULL(FILTER("Fact - MBS Loan Transactions"."OUTSTANDING PRINCIPAL" USING "Dim - MBS Loan"."LOAN TYPE HPD/HDC/BNK" = 'HDC'),0)
    Error :
    nQSError: 10058] A general error has occurred. [nQSError: 22032] Function FILTER requires at least one measure attribute in its first argument. (HY000)
    SQL Issued: SELECT "Dim - MBS Loan"."LOAN AMOUNT", "Dim - MBS Loan"."LOAN TYPE HPD/HDC/BNK", "Dim - MBS Loan"."LOAN TYPE SEN/SUB", "Dim - MBS Project"."PROJECT NAME", "Dim - MBS Project"."PROJECT NUMBER", "Fact - MBS Loan Transactions"."AR BALANCE INTEREST", "Fact - MBS Loan Transactions"."GL BALANCE INTEREST", IFNULL(FILTER("Fact - MBS Loan Transactions"."OUTSTANDING PRINCIPAL" USING "Dim - MBS Loan"."LOAN TYPE HPD/HDC/BNK" = 'HDC'),0) FROM "Financials - MBS"
    OK (Ignore Error)
    Please continue answering my queries. Since am a newbie your answers won't be just a reply but it's actually learning for me.
    Thanks.

  • How to create SSWA plsql function in Oracle Apps of HTML call .html

    Hello Team,
    I am working on Oracle Apps 11i (11.5.10.2)
    I want to know , what is the process to create a , "SSWA plsql function" in Oracle Apps of type "HTML" and html call tab.
    How to create that Function and how to attach the PL/SQL code to these functions.
    How it works.
    Please help me to understand this concept from basics.
    Kind Regards

    Hi;
    Please review:
    how to setup a forms function in R12 to launch an URL?
    http://www.trutek.com/serendipity/index.php?/archives/15-An-Example-of-How-to-Create-Custom-Functions,-Menus,-and-Responsibilities.html
    Regard
    Helios

  • Need Assistance for VBA function in oracle how to implement

    My very respected and Senior, regards,
    Sir, hope you will in best of health and wealth by the grace of God,
    Sir, i have a request problem as i m very junior against you and you have passed this time before many years ago as i m standing where. Sir i m a very junior developer of oracle and have a problem putting on your desk with the hope that you can help my as a boss.
    Sir me have to calculate yield of Bond using oracle form
    i have tried my best and tired
    there is a formulae in excel which give the Yield() when we provide the parameters
    and i need the excel formulae or the oracle calculation code of PLSQL for this.
    How can i get yield when i have price, coupon rate, frequency, issue and maturity of the coupon , coupon period , next coming coupon , and others detail.
    or tell me how to use EXCEL VBA for this problem ,
    thnx n regards,
    yours student, junior developer youngest brother
    Faraz
    How can I get the solution using Excel VBA function with oracle
    so that move values to excel calculate them and copy the result from excel to oracle forms

    Hi,
    for the Hex-Number-conversion see:
    [url http://psoug.org/snippet/Convert-Hex-to-Decimal-Decimal-to-Hex_78.htm] self-defined Conversion-Functions
    What number format do you have? YYYMMDD
    Or is there a Date corresponding to 1 and a number n represent the date n-1 days after day 1?
    Please describe further.
    Bye
    stratmo

  • Date Migration from IBM DB2/400 V4R3M0 to Oracle 11.2G

    Dear ALL<
    We have a requirement for Date Migration from IBM DB2/400 V4R3M0 to Oracle 11.2g. Can you guys please share your experiences with similar activities done in the past ? We do not have environment at present to try out with Oracle Migration workbench.
    http://www.oracle.com/technetwork/topics/index-095746.html
    You experiece sharing will really help ...!!
    Regards,
    VKMP
    Edited by: 909016 on Jan 31, 2013 5:52 AM

    Hi VKMP,
    As well as reading the documentation thoroughly the following note available in My Oracle Support may be useful -
    Problem To Migrate Table With Table Type P From DB/AS400 With OMWB (Doc ID 466271.1)
    as OMWB does not support migrating physical files.
    Regards,
    Mike

  • Is there any manual about using DB2 as storage of Oracle BPEL Manager?

    Hi
    thank you for reading my post
    Is there any manual about using DB2 as database of ORACLE BPEL manager ?
    any one tried to port and test the system on DB2?
    Thanks.

    Hi,
    as you can read in the manual:
    http://download-east.oracle.com/docs/cd/B31017_01/integrate.1013/b28980/overview.htm#sthref26
    Oracle Database Lite, if you use the SOA Suite Basic installation option
    Oracle Database Lite is configured to support Unicode. DB_CHAR_ENCODING is defaulted to UTF8 in the polite.ini file.
    Oracle9i Database Server
    Oracle Database 10g
    The BPEL schema includes PL/SQL packages. They will not run on DB2...
    The datasources are configured to Oracle. You will have to change them to DB2...
    and it is not supported ;-)

  • How I work with MS-SQL function in oracle

    I’m working in oracle now but I don’t know how can I use following function in oracle.
    convert, dateadd, datediff, fetch_status, isnumeric, reverse, str and stuff

    Also available in 10g, the model clause version, taken from this How to display text in reverse order ?.
    WITH t AS (SELECT 'abcdefg' col1
                 FROM DUAL
                UNION
               SELECT ''
                 FROM DUAL   )
    SELECT col1
         , new_col1
      FROM t       
    MODEL
       PARTITION BY (ROWNUM rn)
       DIMENSION BY (0 dim)
       MEASURES     (col1, CAST ('' AS VARCHAR2(255)) new_col1)
       RULES ITERATE(99) UNTIL (LENGTH(new_col1[0]) = LENGTH(col1[0]))
          (new_col1[0] = SUBSTR(col1[0], ITERATION_NUMBER + 1, 1) || new_col1[0])
    COL1    NEW_COL1
    abcdefg gfedcbaC.

  • Import Functionality in Oracle ADF BC with Jdeveloper 11.1.1.2

    Hi all,
    I am using Jdeveloper 11.1.1.2 and I am trying to import functionality in my application.
    I am following the steps of: http://andrejusb.blogspot.com/2008/07/import-functionality-in-oracle-adf-bc.html
    I have 2 data model and I would like to import the functionality of one data model, in the other.
    My problem is when I tried: myModel2-->right click-->project properties-->deployment-->edit
    I don't see nothing to filter myModel2, I see only Library Dependencies, Connections, JAR Options ADF Validation.
    If I tried : myModel2-->right click-->project properties-->deployment-->new-->filters
    I see only the folders: Merged Contents of this file Group's contributor, .data, 00000000
    But I can't see the folders I have (mypackage.test.model.entities).
    Where I can found them? Is there a workaround?
    Any suggestions?
    Thanks
    Andrea

    Ok, but I taught that after importing myModel2 in myModel1, Jdeveloper realise a merge and it visualizes a unique package, even if it is splitted on two or more projects/models.
    So that, it seems to me this procedure is useful for importing jar file, but not for splitting a very big project in a lot of smaller projects, doesn't it?
    Thanks for your opinion
    Andrea

Maybe you are looking for

  • Connecting a turntable to iMac

    Can I use connect a turntable to my Mac directly in order to use Audio Recorder? I have the Monster Cable lead used to connect iPod to my hifi, this cable could connect the turntable to iMac. Thanks, SB

  • Use of Extract datasets

    Hello, Having seen various instances of the EXTRACT command in some legacy code I've got around to trying out this command but I can't get it to work properly. Here's some condensed test code I've put together: TABLES: VBAK, VBAP. FIELD-GROUPS: HEADE

  • Spend Analytics

    What cube(s) should be used to get actual spend dollars (invoices) for POs?  The main PO cube only shows PO amounts, we want the actual amount spend by invoice.  This is from our R/3 system, not from SRM, so we cannot use the cubes 0BBP_C01 or 0SR_FI

  • Address book to Appleworks list transfer problems

    I am trying to export a list of address book entries into either a spreadsheet or the Address List assistant (in Appleworks). I tried saving the address book entries as a vcard group and then open that in the spreadsheet but didn't work, vcards are n

  • System.out.println in Java Studio Creator 2

    Where do my debugging messages sent to System.out.println go? In my other installations of netbeans they went to a window in the IDE but I can't find them with JSC 2.