Conversion in Oracle function.

Hello

So here's the scenario I have. I was wondering if there is any oracle function provides or is it possible that I could achieve this goal.
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 don't have the ability to change anything about how to TestB.Process.

There are therefore two problem I am trying to solve in this scenario.

First, the input parameter - ll_inputpartnum in TestB.Process takes input of only of number type. So I need to convert somehow the concatenated in full ll_inputpartnum.

Second problem, procedure TestB.Process - after completing his treatment, goes from ll_inputpartnum to the third procedure. Let's say TestC procedure. TestC procedure, so I need to break in again value concatenated in original partnumber and partsubnum.

The value concatenated - ll_inputpartnum does not change through this process.

So, I'm trying to understand the best way to approach this situation.

Thank you

Published by: Ramses on May 25, 2010 13:18

with a function like (using also the package of William)

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 connected to the appropriate process
you will need another function to find partnum and partsubnum in another process, because it will be 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;

Concerning

Etbin

p.s. features are not tested (no database home)

Tags: Database

Similar Questions

  • Failed to open oracle functions after R12 installation on windows 2008 64 bit

    Hi guys
    I installed oracle R12.1.1 on windows server 2008 R2 64-bit, then the application opens but all forms of oracle functions cannot open, the message appear frm-92101, I try the solutions in the net, but no effect and I get another windows which and this message appears when trying to open an another oracle functions
    ""
    program currently running on this computer is attempting to display a message, then
    title of the message:
    E:\oracle\VIS\apps\tech_st\10.1.3\appsutil\jdk\bin\java '-serv ".


    This problem come when a program is not completely compatible with windows
    ""
    This message when you start windows too, but the path of java inside files of oracle applications, please help me if oracle r12.1.1 compatible with win 2008 64 bit or not?

    I installed oracle R12.1.1 on windows server 2008 R2 64-bit, then the application opens but all forms of oracle functions cannot open, the message appear frm-92101, I try the solutions in the net, but no effect and I get another windows which and this message appears when trying to open an another oracle functions

    Direct installation of R12 on Windows 2008 64 bit is not supported. You install it on a Windows 32-bit operating system, and then migrate to Windows 64 - bit.

    Oracle E-Business Suite installation and upgrade version Notes 12 (12.1.1) for Microsoft Windows Server (32-bit) [ID 761567.1]
    Migration Oracle E-Business Suite R12 to Microsoft Windows Server 2008 R2 [ID 1188535.1]

    Thank you
    Hussein

  • The HTML that is returned by an Oracle function...

    What is the best way to view the HTML code that is returned by an Oracle function (Apex 3.2.1.00.10)?

    I tried in many ways...

    I don't want to have a visible, but even when I do that, the first returned row Editor:

    < b > text < /b >

    It shows in "BOLD", but for some reason, it escapes from the second < \b > and the fact like that "& lt;" \b & gt; "so it's show < \b > and everything is"BOLD"...

    tward wrote:
    What is the best way to view the HTML code that is returned by an Oracle function (Apex 3.2.1.00.10)?

    I tried in many ways...

    I don't want to have a visible, but even when I do that, the first returned row Editor:

    a text

    It shows in "BOLD", but for some reason, it escapes from the second <\b>and done like this '< \b >"so he showed <\b>and everything is"BOLD"...

    you have the backslash "close tag"... it should be
    < b > text < /b >

    Note the slash!

  • Why is conversion of procedures &amp; functions due to lack of MySQL to Oracle?

    Hi all

    I'm trying to migrate a database from MySQL to Oracle using the Migration Workbench data in SQL Developer 1.5.4.
    I ran both the quick Migration Wizard and the Manual Migration process as described in the documentation.

    I get through the process very well, even if not everything is successfully migrated. Namely, stored procedures and functions of the database of third parties are not correctly migrated.
    The following text is listed in the Migration log for each of the stored procedures and functions:

    * "Limitation of the translation"procedure_audit requires a translation of the manual"met on the column of the stored procedure fse.procedure_audit line 0-0."

    If I look at the 'converted' model the procedure has been created and is set to NULL. The procedure of 'captured the model' original is commented out in the body of the procedure in the "convert" template Does anyone have any ideas as to why it's a failure? And how do I fix it?


    In addition, there seems to be a problem with the conversion of the index, particularly those that are 'MAJOR' indexes in MySQL not appear in models 'captured' or 'converted '.


    In addition, the migration log provides the following:

    * "Index 'customer_customer_id' on the 'customer' table ' has been ignored, because it is a duplicate of a constraint" * "

    Looking at the index in the original third party database, it does appear that an index on that column on the respective table. The ides why this happens?


    Here, any help would be immensely appreciated.

    Thank you
    Amedeo.

    Mysql stored procedure to PL/SQL function is not available, or in the direction sqldeveloper statement:

    http://www.Oracle.com/technology/products/database/sql_developer/files/sqldeveloperstatementofdirection.htm

    -Turloch

  • DB2 code: today's date and the day to ORACLE function?

    Please help me to convert this code oracle...

    DB2 code:

    [code] ((Current date) - day (date (current date))) [/ code]

    I tried to use the functions of default in PL date timestamps, but it won't work. Help, please.

    As told by BluShadow and rp0428, you can execute the following statement:

    Select current_date, trunc(current_date,'MM')-1 day of double;

    The output will be today's date and the month last, last day.

  • UNIX_TIMESTAMP and FROM_UNIXTIME from MySQL to ORACLE functions

    Hi all

    I'm migrating some functions and stored procedures in MySQL to ORACLE, and I the next instruction

    Set valuedat = FROM_UNIXTIME (valor + UNIX_TIMESTAMP ('2000-1-01 00:00:00 '));

    Since MySQL.

    Look, I found that:

    UNIX_TIMESTAMP ('2000-1-01 00:00:00 ')

    can be equivalent to the following query:

    SELECT (to_date (January 1, 2000 "," MON-DD-YYYY')-to_date('01-jan-1970','DD-MON-YYYY')) * (86400) as dt FROM dual;

    but testing the numbers is not the same

    Please can someone help me!

    Specifically, I need to know how to build the equivalent in oracle for FROM_UNIXTIME and UNIX_TIMESTAMP functions

    Thank you and best regards!

    CRGM

    Hello

    These are functions that I built to solve the original requirement, thanks for all your comments.

    ************************************************************************************************************************************

    CREATE OR REPLACE FUNCTION FROM_UNIXTIME

    (

    TIMESTAMP_ NUMBER

    ) AS OF DATE OF RETURN

    NUMBER OF SECONDS_PER_DAY: = 86400;

    MASK (50 CHAR) VARCHAR2: = 'DD-Mon-YYYY HH24:MI:SS ";

    DATE OF REF_DATE;

    BEGIN

    REF_DATE: = TO_DATE ('01 - ENE - 1970 00:00:00 ', MASK);

    RETURN REF_DATE + (TIMESTAMP_/SECONDS_PER_DAY);

    END FROM_UNIXTIME;

    **********************************************************************************************************************************

    CREATE OR REPLACE FUNCTION UNIX_TIMESTAMP

    (

    DATE_ IN DATE

    ) RETURN AS NUMBER

    NUMBER OF SECONDS_PER_DAY: = 86400;

    NUMBER OF DIFF_BETWEEN_DATES;

    MASK (50 CHAR) VARCHAR2: = 'DD-Mon-YYYY HH24:MI:SS ";

    DATE OF REF_DATE;

    BEGIN

    REF_DATE: = TO_DATE ('01 - ENE - 1970 00:00:00 ', MASK);

    DIFF_BETWEEN_DATES: = TO_DATE (TO_CHAR (SYS_EXTRACT_UTC (DATE_), MASK), MASK)

    -REF_DATE;

    RETURN DIFF_BETWEEN_DATES * SECONDS_PER_DAY;

    END UNIX_TIMESTAMP;

    ******************************************************************************************************************************

    Concerning

  • Oracle function

    Hi all

    I know it would be a very basic question but need some clarification.

    In oracle, we use the function, what is the meaning of return type because by using the output parameter, we can also return the value.

    Thank you

    Hello

    Ask yourself "why do we need to use function values?  Why can't we always use THE arguments instead? »

    One of the reasons is that functions with arguments OUT cannot be called from SQL, the SQL statements used in PL/SQL statements.

    Another is the convenience of use of multiple functions in a single statement.  With function values, you can do things like

    SUPERIOR (SUBSTR (LTRIM (str), 1, 4))

    Using only THE values, would need you 3 separate instructions for it; one for each function.

  • Oracle function to retrieve the records randomly

    I need function to select a random DB folder.

    For example, we have 500 records and an input to the function value is 5 ways, it must display the records randomly between 1 to 5

    Thank you

    Question is not clear, I thought that Oracle has always returned entries in random order... Do you expect the number of records between 1 & 5?

    Kind regards

  • Query regarding oracle functions

    Hi all

    I tried to work with decode them and output of NVL to get the following:

    Output value
    1 NULL
    0 1
    1 1
    2 2
    3 3


    to do this, I wrote the following query:
    SELECT DECODE (NVL(high_value,1), 0.1, NVL(high_value,1)) in tab1.

    Can there be a replacement of this using other functions?

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    AMT for Solaris: release 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

    Thank you
    Nikhil

    Can be with decoding

    with t_data as
    (
    select null as val from dual union all
    select 0 from dual union all
    select 1 from dual union all
    select 2 from dual union all
    select 3 from dual
    )
    SELECT
         val,decode(val,null,1,0,1, val) output
    from t_data
    
  • some doubts in the conversion of oracle query

    I have to convert the following query in ms access to oracle.

    INSERT INTO the Bill (Reffacture, InvoiceDesc)
    Select a_Invoices! [Ref provider] & "-" & Trim (a_Invoices! [invoice No.]) & "Q" & DatePart ("q", [invDate]) & "-" & DatePart("yyyy",[invDate]) & "SB" as Reffacture.
    Trim (a_Invoice_Desc! [Invoice line Description]) AS a Expr4
    Of a_Invoices a_Invoice_Desc INNER JOIN
    WE (a_Invoices. [Ref provider] is a_Invoice_Desc. [Ref provider])
    AND (a_Invoices. [Invoice No.] is a_Invoice_Desc. [Invoice No.)]
    WHERE (((a_Invoices. [<>ACK GL account]) »--- »)) ;

    for the quarter, I tried with select to_char (to_date ("PRVBTOT", "dd/mm/yy '"), 'Q') as quarterdate of "a_Invoices" - it worked, but how to combine all the

    Hello

    882431 wrote:
    Thanks for the input... I have another doubt based on the date

    I have a date stored in a field of type varchar, n'm copy in the date field

    For example: ' 18/4/2011 0:0:0.0' varchar field is, I tried with "' 2011/4/18 as yyyy/mm/dd ', I can add hh: mm: for the moment (I wasn't looking this), but there is one.0, can someone please tell me how shud convert it..." Sorry if asking a basic question, I already searched but to no avail.

    DATEs do not include fractions of a second. If you don't mind losing fractions of a second, you can simply remove them before pass the string to TO_DATE, like this

    TO_DATE ( REGEXP_REPLACE ( varchar2_column
                    , '\.[0-9]*$'
                    )
         , 'YYYY/MM/DD HH24:MI:SS'
         )
    

    REGEXP_REPLACE will remove the decimal point and any numbers after him. If the string does not contain a decimial, it is correct: REGEXP_REPLACE returns the immutable string in this case.

    If the fraction of a second is important, use a TIMESTAMP instead of a DATE column (and use the TO_TIMESTAMP instead of TO_DATE function).

  • You must return the value of the Oracle function in VB Code

    Hi all

    I have the oracle APPTIDFUN (WHO RETURN NUMBER) function, I need to call in the VB Code. (Here's the code)

    --------------------------------
    If Msg2 = 6 Then
    Dim RS As New ADODB. Recordset
    Dim SQL As String
    RS. Open "appointments", CN, adOpenDynamic, adLockPessimistic
    RS. Find ' patient_id = ' "& str1 &" "'". "
    If RS. When the EOF
    RS. Find ' Appt_start_Date = ' "& str3 &" "'". "
    If RS. When the EOF
    RS. AddNew
    RS ("patient_id") = str1
    RS ("Appt_type") = str2
    RS ("Appt_start_Date") = str3
    RS ("Appt_end_date") = str4
    RS ("Num_days") = str5
    RS ("Total_Amount") = str6
    RS ("Inv_Number") = str7
    RS ("Approval_status") = str8
    RS ("NUM_WATCHER") = str9
    RS. Update

    ------------------------------------------------------------
    I want to call the function from oracle here that in the above code

    RS ("Appt_id") = < value of function >


    Please do the needful.

    Abdul,

    You need to change the line

    RS("Appt_Id") = RS1
    

    TO

    RS("Appt_Id") = RS1(0)
    

    Kind regards

    Manu.

    If my answer or the answer to another person has been useful or appropriate, please mark accordingly

  • T - SQL in ORACLE functions

    Use the T - SQL functions in ORACLE too, so you can write a script version that works in SYBASE, SQL SERVER 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, tips, 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 scheme to place objects and file [comp_tsql_ORA.txt | http://forums.databasejournal.com/attachment.php?attachmentid=569 & d = 1259256898] create the features in the new schema. They will be available for any diagram of the oracle instance.

    I hope this helps!
    Any suggestion, please contact.
    aklein2003

    Published by: user1958693 on 11/26/2009 10:16

    This makes sense if you migrate an application from sql server, oracle, and if a lot of t - sql functions is used in the application code that you don't want to bother with...

  • Conversion to Oracle - PL/SQL resources?

    Any suggestions on good online resources about stored procedures in Oracle? I come from a background with many SQL Server T - SQL programming and I want to "convert" me to Oracle, but I can't seem to find as much information as I did for MS SQL. Suggestions?

    Something I want to know the answers correspond to the difference between T - SQL and PL/SQL such as:

    How can you do the following in Oracle:

    If it exists (select 1 from anyTable where myVal = "xxx")
    Start
    Returns 1
    end

    I can't find the right resources in this respect at all?

    Hi Filip,

    Two major books for PL/SQL:

    the PL/SQL language reference: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/toc.htm
    and the PL/SQL Packages and Types reference: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10577/toc.htm

    Regarding your exists construct: you'll want to create a function for it. That way your code is modular and reusable.
    An example:

    SQL> create function emp_exists(p_empno in emp.empno%type) return boolean
      2  is
      3    l_dummy pls_integer;
      4  begin
      5    select 1
      6      into l_dummy
      7      from emp
      8     where empno = p_empno
      9    ;
     10    return true
     11    ;
     12  exception
     13  when no_data_found then
     14    return false;
     15  end emp_exists;
     16  /
    
    Functie is aangemaakt.
    
    SQL> begin
      2    if emp_exists(7839)
      3    then
      4      dbms_output.put_line('7839 exists');
      5    else
      6      dbms_output.put_line('7839 does not exist');
      7    end if
      8    ;
      9    if emp_exists(7777)
     10    then
     11      dbms_output.put_line('7777 exists');
     12    else
     13      dbms_output.put_line('7777 does not exist');
     14    end if
     15    ;
     16  end;
     17  /
    7839 exists
    7777 does not exist
    
    PL/SQL-procedure is geslaagd.
    

    Kind regards
    Rob.

  • Problem with form of Oracle function

    Hi all

    I built various forms in Oracle Financials, but when I click in the menu option this error "is not available to this responsibility functions. Change responsibilities. or contact your system administrator. I can't see the form on the screen.

    Please, I need your help.

    Cordially Mariano. -.

    Hello

    Did you register this custom responsibility a custom form?

    You are able to access other forms customized to the same responsibility? If this is not the case, make sure that your CUSTOM_TOP is defined in the application env file and bounce application services.

    Note: 305792.1 - feature is not available for this error of responsibility after creating and saving a new form
    https://metalink2.Oracle.com/MetaLink/PLSQL/ml2_documents.showDocument?p_database_id=not&P_ID=305792.1

    Note: 553014.1 - R12 error "Feature is not available this responsibility" when trying to access Custom Form
    https://metalink2.Oracle.com/MetaLink/PLSQL/ml2_documents.showDocument?p_database_id=not&P_ID=553014.1

    Kind regards
    Hussein

  • error to the oracle function?

    Hello:

    Parameter of the week # of months in function to_char failed when I try to get the week # 14/01/2008. I use "select to_number (to_char (to_date ('01-14-2008', ' dd/mm/yyyy'), 'W')) from dual;" and I get 2 instead of 3

    Any idea? ...

    I am running oracle 8i database

    Any help would be much appreciated.

    Thank you

    Maybe you are looking for this?

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select to_date('01/01/2008','DD/MM/YYYY') + (rownum-1) as dt from dual connect by rownum <= 80)
      2  -- end of test data
      3  select dt
      4        ,to_char(dt,'D') as day_num
      5        ,to_char(dt,'DAY') as day_of_week
      6        ,trunc(to_char(dt,'DD')/7)+1 as week
      7* from t
    SQL> /
    
    DT          D DAY_OF_WE       WEEK
    ----------- - --------- ----------
    01-JAN-2008 2 TUESDAY            1
    02-JAN-2008 3 WEDNESDAY          1
    03-JAN-2008 4 THURSDAY           1
    04-JAN-2008 5 FRIDAY             1
    05-JAN-2008 6 SATURDAY           1
    06-JAN-2008 7 SUNDAY             1
    07-JAN-2008 1 MONDAY             2
    08-JAN-2008 2 TUESDAY            2
    09-JAN-2008 3 WEDNESDAY          2
    10-JAN-2008 4 THURSDAY           2
    11-JAN-2008 5 FRIDAY             2
    12-JAN-2008 6 SATURDAY           2
    13-JAN-2008 7 SUNDAY             2
    14-JAN-2008 1 MONDAY             3
    15-JAN-2008 2 TUESDAY            3
    16-JAN-2008 3 WEDNESDAY          3
    17-JAN-2008 4 THURSDAY           3
    18-JAN-2008 5 FRIDAY             3
    19-JAN-2008 6 SATURDAY           3
    20-JAN-2008 7 SUNDAY             3
    21-JAN-2008 1 MONDAY             4
    22-JAN-2008 2 TUESDAY            4
    23-JAN-2008 3 WEDNESDAY          4
    24-JAN-2008 4 THURSDAY           4
    25-JAN-2008 5 FRIDAY             4
    26-JAN-2008 6 SATURDAY           4
    27-JAN-2008 7 SUNDAY             4
    28-JAN-2008 1 MONDAY             5
    29-JAN-2008 2 TUESDAY            5
    30-JAN-2008 3 WEDNESDAY          5
    31-JAN-2008 4 THURSDAY           5
    01-FEB-2008 5 FRIDAY             1
    02-FEB-2008 6 SATURDAY           1
    03-FEB-2008 7 SUNDAY             1
    04-FEB-2008 1 MONDAY             1
    05-FEB-2008 2 TUESDAY            1
    06-FEB-2008 3 WEDNESDAY          1
    07-FEB-2008 4 THURSDAY           2
    08-FEB-2008 5 FRIDAY             2
    09-FEB-2008 6 SATURDAY           2
    10-FEB-2008 7 SUNDAY             2
    11-FEB-2008 1 MONDAY             2
    12-FEB-2008 2 TUESDAY            2
    13-FEB-2008 3 WEDNESDAY          2
    14-FEB-2008 4 THURSDAY           3
    15-FEB-2008 5 FRIDAY             3
    16-FEB-2008 6 SATURDAY           3
    17-FEB-2008 7 SUNDAY             3
    18-FEB-2008 1 MONDAY             3
    19-FEB-2008 2 TUESDAY            3
    20-FEB-2008 3 WEDNESDAY          3
    21-FEB-2008 4 THURSDAY           4
    22-FEB-2008 5 FRIDAY             4
    23-FEB-2008 6 SATURDAY           4
    24-FEB-2008 7 SUNDAY             4
    25-FEB-2008 1 MONDAY             4
    26-FEB-2008 2 TUESDAY            4
    27-FEB-2008 3 WEDNESDAY          4
    28-FEB-2008 4 THURSDAY           5
    29-FEB-2008 5 FRIDAY             5
    01-MAR-2008 6 SATURDAY           1
    02-MAR-2008 7 SUNDAY             1
    03-MAR-2008 1 MONDAY             1
    04-MAR-2008 2 TUESDAY            1
    05-MAR-2008 3 WEDNESDAY          1
    06-MAR-2008 4 THURSDAY           1
    07-MAR-2008 5 FRIDAY             2
    08-MAR-2008 6 SATURDAY           2
    09-MAR-2008 7 SUNDAY             2
    10-MAR-2008 1 MONDAY             2
    11-MAR-2008 2 TUESDAY            2
    12-MAR-2008 3 WEDNESDAY          2
    13-MAR-2008 4 THURSDAY           2
    14-MAR-2008 5 FRIDAY             3
    15-MAR-2008 6 SATURDAY           3
    16-MAR-2008 7 SUNDAY             3
    17-MAR-2008 1 MONDAY             3
    18-MAR-2008 2 TUESDAY            3
    19-MAR-2008 3 WEDNESDAY          3
    20-MAR-2008 4 THURSDAY           3
    
    80 rows selected.
    
    SQL>
    

Maybe you are looking for