Conversion function in Oracle.

Hi,
So below is the scenario I have. I was wondering if there is any function oracle provides or is there any way I could achieve this.
CREATE OR REPLACE procedure TestA
      partnumber               IN  number,
      partsubnum               IN  varchar2,
      errstring             OUT varchar2
) as
--  Declare local variables
ll_inputpartnum varchar2(100);
Begin
    ll_inputpartnum := partnumber || partsubnum; -- Concatinate partnumber and partsubnum
  -- Will need to convert this variable to number.
    TestB.Process(ll_inputpartnum,parameter2, s_errstring, errnum); --ll_inputpartnum must be of type number
     if  errnum <> compkg.success then
       errstring := s_errstring;
       return;
     end if;
Exception
    When others then
    Null;   
End;
/I do not have option to change anything on TestB.Process Procedure.
So there are two problem I am trying to solve in this scenario.
First, the input parameter - ll_inputpartnum in TestB.Process takes input of only number type. So i need to somehow convert the concatenated ll_inputpartnum into Integer.
Second problem is, Procedure TestB.Process - after completing its processing, passes ll_inputpartnum to the Third procedure. Let's say Procedure TestC. So in Procedure TestC, I need to again break down the concatenated value into original partnumber and partsubnum.
The concatenated value - ll_inputpartnum does not change through out this process.
So, i am trying to figure out the best way to approach this situation.
Thank you
Edited by: ARIZ on May 25, 2010 1:18 PM

with a function like (using William's package too)
function combine_parts(p_partnum in integer,p_partsubnum in varchar2) return integer is
  l_length pls_integer := 5;  /* adjust to the maximum possible length of partsubnum */
  hex_val  varchar2(5) := '';
begin
  if length(p_partsubnum) > l_length then
    return 0;
  end if;
  for i in 1 .. l_length loop
    hex_val := hex_val || to_base(ascii(substr(lpad(p_partsubnum,l_length,chr(0)),i,1)),16)
  end loop;
  return p_partnum * power(256,l_length) + to_decimal(hex_val,16);
end;you can simply
ll_inputpartnum := combine_parts(partnum,partsubnum);and finally the parameter ll_inputpartnum can be fed to the appropriate process
you'll need another function to regain partnum and partsubnum in another process because it will just ll_inputpartnum
function concatenated_parts(p_number in integer,p_separator in varchar2 default '|') return varchar2 is
  l_length pls_integer := 5;  /* adjust to the maximum possible length of partsubnum */
  hex_val  varchar2(5);
  chr_val  varchar2(5) := '';
  l_partnum integer;
begin
  l_partnum := trunc(p_number / power(256,l_length));
  hex_val := to_base(p_number - l_partnum * power(256,l_length),16);
  if length(hex_val) > l_length then
    return '';
  end if;
  for i in 1 .. l_length loop
    chr_val := chr_val || chr(to_decimal(substr(hex_val,i,1),16));
  end loop;
  return to_char(l_partnum) || p_separator || chr_val;
end;Regards
Etbin
p.s. the functions are not tested (no database at home)

Similar Messages

  • Need help for Conversion Function in Oracle

    Hi, Can Any One help me Please.
    I need a Oracle conversion script for converting from decimal to hex. and decimal to datetime.
    Thanks In Advance.

    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

  • Conversion functions in Oracle 11g Express;HEXTORAW &RAWTOHEX

    hi everybody !
    hextoraw ('0041') must return A but it doesn't return this value ,,it returns 0041
    I'm using Oracle 11g Express
    select hextoraw('0041') from dual; --> 0041 ? but must return A
    why is that ?
    please help me
    thank you

    Hextoraw takes your hexadecimal 41 and transforms to a single byte containing the decimal value 65 in a RAW datatype.
    But a RAW datatype can contain anything - it can be binary data, it can be text data.
    So your client cannot safely just show it as text - it performs an implicit rawtohex for you and displays the RAW data in hexadecimal form:
    SQL> select hextoraw('414243') val from dual;
    VAL
    414243You need to explicitly tell Oracle that this particular RAW value is actually text and not something binary.
    For that you can use a casting function:
    SQL> select utl_raw.cast_to_varchar2(hextoraw('414243')) val from dual;
    VAL
    ABCWhen cast to a varchar2, Oracle now knows it is text data and can display it.

  • Conversion functions

    Can anyone suggest a reading on conversion functions in Oracle 9i?
    how to convert a varchar to a number?

    look into doc
    http://download-east.oracle.com/docs/cd/A91202_01/901_doc/server.901/a90125/functions142.htm#1003400
    SQL> select to_number('12'), to_char(12) from dual;
    TO_NUMBER('12') TO
                 12 12added query
    Message was edited by:
    devmiral

  • Conversion of Informix functions to Oracle

    Hi,
    Can anyone help me in the conversion of the following informix functions to Oracle
    dtcvasc()
    rftmtdate()
    deccvasc()
    rdefmtdate()
    dttoasc()
    rtoday()
    These functions exists in ESQL/c(informix). Please help in converting the aboue functions to oracle .
    regards,
    gopu

    Can you explain what these functions do? There are probably Oracle analogs already.
    Justin

  • 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

  • Table-Valued function in oracle

    Hi All,
    I have a table-valued function in MS SQL Server, that I want to convert it.
    How can I create table-valued function in Oracle 9.2.0.1.0
    Thanks for your thoughts

    Just so we are talking the same language, array-type constructs in Oracle are generally known as "collections", while "table" generally refers to a database table. Having said that, you may see references to "PL/SQL Tables" which was the old name for collections when they first came out, although this term has been mostly withdrawn as it's somewhat misleading and causes confusion (that's marketing for you).
    Now I think about it we also have table functions, the official name for functions that return collections although IMO almost as misleading. Anyway my rambling point is that "function that returns a table" may cause confusion in Oracle circles. Or maybe it's just me.
    There are loads of String To Table examples around:
    * www.williamrobertson.net/documents/comma-separated.html
    * www.oracle-developer.net/display.php?id=412
    Couldn't you have the procedure accept an array in the first place and have something else do the string conversion before it reaches the procedure?
    Edited by: William Robertson on Aug 29, 2008 5:39 PM

  • Any financial Functions in oracle?

    I need some statistical and financial formulas such as NPV, IRR etc and many more such functions to handle financial applications. Does oracle provide such builtin functions as in excel?????
    Plz help me .....

    Hi, Suman
    There are several statistical functions in Oracle (you can check the documentation), but not those you mention.
    You can create your own functions using PL/SQL (and Java, I believe), or you can invoke Excel from Oracle Forms using OLE2 methods or DDE conversation. You can find examples in the Forms Demos CD.
    Hope this helps,
    Pedro

  • Informix Date Conversion Functions

    I am converting some Informix ESQL/C programs to Oracle Pro*C.
    I was wondering if there are any libraries out there that do the same thing as the Informix Date conversion functions(to avoid re writting them).
    Thank You
    null

    Hi ,
    Please try this one.
    if ITAB_DTL-date   <> ''.
                       CONCATENATE ITAB_DTL-date+6(2) '.'
                                   ITAB_DTL-date+4(2) '.'
                                   ITAB_DTL-date+0(4)
                              INTO ITAB_DTL-w_date.
    endif
    Thanks
    Karthik

  • 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

Maybe you are looking for

  • Cash Management - AutoRecon without errors, but still unreconciled?

    Hi guys, Pretty interesting question: I have multy period's bank file (transactions for 3 accounting periods), all settings are according the manual on AP and CM sides done. Statement's Import finished without errors, AutoReconciliation finished with

  • PSE 7 e-mail problems

    Until 2 months ago, I could send my pictures through the share portion of PSE 7 by photo mail or e-mail attachments.  Now it will not send the pictures.  The circle keeps turning as though the pictures are being sent, but it never stops and the pictu

  • Find item in zip file without extracting

    Hi Guys! Weird question today! I'm looking for files like sin*.dat into a specific file-server folder that may contain subfolders and zip/7z folders. With powershell i'm not able to find this files into zip/7z folders and i can't unzip those folders

  • Screen spanning emac 700 MHz

    Hello all, I presume this is a quite stupid question, but here goes; is it possible to do screen spanning with a 700 MHz eMac? I've got a Iiyama Vision Mater Pro 455 here - and I'd like to span the screen instead of mirror it completely. That way I c

  • Change teststand post actions from labview

    Hi, Is there a way to change the post action of a test in teststand from Labview. At the moment, if one of the tests fail out of limits then the post action is set to 'ON FAIL - GO TO NEXT STEP' but if the unit does not run then a diagnostics labview