Convert a MySQL function in Oracle PL/SQL


Hello

I'm trying to transfer a MySQL database in Oracle 12 c, there are a number of functions that I need to convert since I am new to Oracle and PL/SQL in particular, I would really appreciate your help for the conversion:

CREATE FUNCTION get_customer_balance()p_customer_id INT p_effective_date DATETIME() RETURNS DECIMAL()5,2( )
DETERMINISTIC
READS SQL DATA
BEGIN

DECLARE v_rentfees decimal PLACES ()5,2) ; #TAXES PAID to RENT VIDEOS INITIALLY
DECLARE v_overfees INTEGER ; #LATE FEES FOR RENTALS PREREQUISITES
DECLARE v_payments decimal PLACES ()5,2) ; #SUM OF PREVIOUSLY MADE PAYMENTS

SELECT IFNULL (SUM(film. rental_rate ),0) INTO v_rentfees
FROM film , inventory , rental
WHERE film . film_id = inventory . film_id
ET inventory . inventory_id = rental . inventory_id
AND rental . rental_date <= p_effective_date
AND rental . Customer_ID = p_customer_id ;

SELECT IFNULL (SUM(IF((TO_DAYS(rental. return_date ) - TO_DAYS(rental. rental_date )) > film. rental_duration ,


((TO_DAYS(rental. return_date ) - TO_DAYS(rental. rental_date )) - film. rental_duration ),0)),0) INTO v_overfees
FROM rental , inventory , film
WHERE film . film_id = inventory . film_id
ET inventory . inventory_id = rental . inventory_id
AND rental . rental_date <= p_effective_date
AND rental . Customer_ID = p_customer_id ;

SELECT IFNULL ()SOMME()paiement. amount ),0) INTO v_payments
FROM payment

payment . payment_date <= p_effective_date
AND payment . Customer_ID = p_customer_id ;

RETURN v_rentfees + v_overfees v_payments ;
END

This means that rental.return_date and rental.rental_date are declared as a TIMESTAMP. Question is why? Return_date/rental_date store fractions of a second? In any case, assuming rental_duration is in days:

WHEN rental.return_date - rental.rental_date > numtodsinterval (film.rental_duration, 'day')

But the question is return_date and rental_date stores it part time too. I assumed that he didn't, and simply omitted TO_DAYS. If so, then TO_DAYS should be translated to TRUNC:

CREATE OR REPLACE

Get_customer_balance FUNCTION)

p_customer_id INT,

p_effective_date DATE)

RETURN NUMBER

DETERMINISTIC

IS

v_rentfees NUMBER (5.2); PAID #FEES RENT VIDEOS INITIALLY

v_overfees INTEGER.    #LATE ADVANCE RENTAL FEES

v_payments NUMBER (5.2); #SUM OF PAYMENTS MADE PREVIOUSLY

BEGIN

SELECT NVL)

Sum (film.rental_rate),

0

)

IN v_rentfees

FROM film,.

inventory,

Rental

WHERE film.film_id = inventory.film_id

AND inventory.inventory_id = rental.inventory_id

AND rental.rental_date<=>

AND rental.customer_id = p_customer_id;

SELECT SUM)

CASE

WHEN TRUNC (rental.return_date) - TRUNC (rental.rental_date) > film.rental_duration

THEN (TRUNC (rental.return_date) - TRUNC (rental.rental_date)) - film.rental_duration

0 OTHERWISE

END

)

IN v_overfees

The RENTAL.

inventory,

film

WHERE film.film_id = inventory.film_id

AND inventory.inventory_id = rental.inventory_id

AND rental.rental_date<=>

AND rental.customer_id = p_customer_id;

SELECT NVL)

Sum (Payment.amount),

0

)

IN v_payments

PAYMENT

WHERE payment.payment_date<=>

AND payment.customer_id = p_customer_id;

RETURN v_rentfees + v_overfees - v_payments;

END;

/

SY.

Tags: Database

Similar Questions

  • Convert the equivalent function stragg columns in oracle sql

    Hello

    Sorry I forgot my version of Oracle:
    SQL> select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 64-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    I searched on google but I have not found the solution.


    I'm looking for a function equivalent to the SQL stragg discoverer.


    Note: stragg function convert columns in lines.

    Thank you
    SELECT   deptno, stragg ('-' || ename)
        FROM emp_test
    GROUP BY deptno;
    
    
        DEPTNO STRAGG_STR                                                  
    ---------- ------------------------------------------------------------
            10 -CLARK-KING-MILLER                                          
            20 -SMITH-FORD-ADAMS-SCOTT-JONES                               
            30 -ALLEN-BLAKE-MARTIN-TURNER-JAMES-WARD                       
    
    
    3 rows selected.
    Published by: Salim champion 2010-01-29 08:32

    Hello Salim
    This feature does not exist inside the discoverer.

    My suggestion would be to create a SQL function, then import it in Finder using the System Administration tool. Now, you will be able to pass the deptno to the function and the function returns a single string containing the concatenated names.

    This isn't a function difficult to write and if you would like some help please let us know.

    Best wishes
    Michael

  • Convert .xls in .csv file using pl/sql or any other method (oracle 9i)

    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit Production

    With partitioning, OLAP and Oracle Data Mining options

    Release 9.2.0.8.0 - Production jserver

    10.1.2.0.2 generator

    ORACLE Server Release 10.1.0.4.2

    Oracle 10.1.2.0.2 procedure generator

    Oracle ORACLE PL/SQL V10.1.0.4.2 - Production

    Oracle 10.1.0.4.0 Production CORE

    Integration Services 10.1.2.0.2 tools Oracle

    Space common tools Oracle 10.1.2.0.2

    Oracle Toolkit 2 for 32-bit Windows, 10.1.2.0.2 platforms

    Resource object 10.1.2.0.2 store

    Oracle Help 10.1.2.0.2

    Oracle Sqlmgr 10.1.2.0.2

    Query Oracle 10.1.2.0.2 - Production Designer

    PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)

    Oracle ZRC 10.1.2.0.2

    Oracle XML Developers Kit 10.1.0.4.2 - Production

    Virtual graphics system Oracle 10.1.2.0.2

    Image of Oracle 10.1.2.0.2

    Widget media Oracle 10.1.2.0.2

    The GUI utility 10.1.2.0.2 tools Oracle

    I had seen a very old post of 2009.

    Convert .xls in .csv file using pl/sql

    I know that it s a long time but just wanted to know if there is a way to convert excel .csv.

    I have a directory say 'F:\purple_top\ '. I'll get the .xls file in this directory. I need to change to .csv and tables load external oracle. Any ideas or advance coding on it since 2009 so far?

    A few other options might be:

    • Java code, which can be used from within Oracle, which makes use of utility libraries (e.g. Aspose.Cells) open source (for example Apache POI) or "save under" CSV, or read the source cells and their output to a CSV file.
    • COM Automation, using available open source (for example, JACOB or j-interop) or commercial libraries, which can automate Excel to open a XLS file and "Save as" a CSV file. In addition, Oracle has a feature of COM Automation (available since version 8 but abandoned after Oracle 11g). I have successfully used this read (non-macro-enabled) Excel files in PL/SQL.
    • Other approaches using Perl or PHP can be found by googling 'convert xls to csv.

    Gerard

  • convert to oracle pl/sql

    Hi all

    can - anybody know how convert transact sql from sql server to oracle pl/sql.is any them tool or whatever is available.

    Kind regards
    Ankur

    Frankly - it's all just stupid to convert T - SQL in PL/SQL.

    There are significant differences between these two. PL is a real procedural and declarative language. It has features of OBJECT-oriented programming. It is absolutely nothing like T - SQL.

    Oracle is also different from SQL-Server. There are conceptual major and fundamental differences. After all, why do you buy Oracle customers? Because it's just like SQL-Server? Or because it is not and is very different from SQL-Server?

    Oracle is a very poor imitation of SQL-Server. It has no sense to treat it as SQL-Server.

    And in this vein, it is meaningless to implement the fundamental concepts of the T - SQL and SQL-Server by converting in PL/SQL. The result will probably happen again worse than what he has done in SQL Server. He will not be able to scale. It will be difficult to maintain. It will not use the features of Oracle that puts a technically superior product of RDBMS of SQL Server to Oracle.

    It only converts SQL Oracle server. A ports. And this is refactoring and redesign to better utilize the features of Oracle. Another thing, how can you only achieve the perceived benefits and the benefits of the passage of the SQL for Oracle Server?

  • Anonymous performer of Oracle PL/SQL in the Production environment leave a residue?

    Hello

    In my project, we have a large PL/SQL in Prod-Replica Envt to generate scripts. However, to reproduce Prod for this Prod-Replica lasts long and is causing a delay to respond to change requests.

    We have READ ONLY access to Prod DB, but we cannot deploy the PL/SQL Package it. We plan to convert the PLSQL in an anonymous block PLSQL and running it in PROD DB to get real data. Alternatively, we can run it directly or via Java and then read the DBMS output later. as mentioned here-> the use of cursors and results in Oracle PL/SQL, Java/JDBC - Stack Overflow

    , However, is not an expert in PL/SQL, I wanted to know, if it leaves residues in PROD outside the additional load a temporary server for read queries. We only select queries in this PL/SQL and so I donot believe we leave triggers or change the DB somehow.

    Can you please let me know the possible consequences of it.

    -Thanks & Regads

    -Scott

    There will be an impact on the server, the conversion of code unit of PL/SQL (procedures and functions) must be encapsulated in a single code PL/SQL anonymous block.

    This anonymous PL/SQL code block needs to be parsed and compiled - burn a lot of CPU (that oppose the use of unit code already compiled PL/SQL).

    This anonymous PL/SQL block is likely to be very large because it contains too many units of PL/SQL source code. This needs memory to the server as the whole code block will be stored in the shared pool (for analysis).

    Another impact on performance would be wise to network. It requires more bandwidth to transfer this big block of code (created by the customer) to the Oracle server. This increases latency. And is not an evolutionary approach.

    So no, there is no "residue" of the code inside the actual physical database code is never stored in the database. However, this approach and the code will affect negatively network and server resources.

    You should consider the problem and determine if this solution you have in mind, justifies this impact.

  • XPath functions in oracle

    Hello

    Is there a function like fn:local - name (.) in oracle XPATH functions. If so help me wit ha simple example.

    I am new to Oracle & SQL server migration procedure to oracle where script XML procedure taken as input.

    I need to convert under Oracle's SQL Server select statement.

    SELECT converseUID,
    "Distributed."
    Cast (ServiceCalls.Query ('fn:local - name (.)') as varchar (100)).
    1,
    WORK IN PROGRESS. ServiceCalls.value ('(TotalTime) [1] ',' int'),
    WORK IN PROGRESS. ServiceCalls.value ('(Status) [1] ',' varchar (100)');
    WORK IN PROGRESS. ServiceCalls.value ('(Primary_deferred) [1] ',' varchar (20)');
    WORK IN PROGRESS. ServiceCalls.value ('(FromCache) [1] ',' bit').
    @DateTimeStamp
    OF @WIP.nodes('//WIP/gatewayServiceCalls/*') as WIP (ServiceCalls)
    WHERE WIP. ServiceCalls.value ('(startTime) [1] ',' int') <>0

    Thanks in advance.

    The path expression is bad and which is based on the XML code you posted earlier, VARCHAR2 (4000) is not large enough to hold the extracted value.

    You can use the CLOB data type:

    SELECT x.response
    FROM XMLTable(
           '//WIP/gatewayServiceCalls/mqdrop'
           passing v_wip
           columns
             response   clob  path 'Response'
         ) x
    ;
    

    or, if you expect a single value then preference:

    SELECT XMLCast(
             XMLQuery('//WIP/gatewayServiceCalls/mqdrop/Response'
               passing v_wip
               returning content
             )
             as clob
           )
    FROM dual;
    
  • Convert the MySQL timestamp into a Unix timestamp field

    I have a process where I want to compare the current date with an expiration date is so many months after the date of registration. The registration date is stored as a MySQL timestamp. I want to convert this to a timestame Unix I can do the comparison with the Time() function. I tried the MySQL UNIX_TIMESTAMP both getTimestamp() PHP functions and can not get to work. I tried UNIX_TIMESTAMP in both the original SELECT statement and a stand one. I also have an error of division by zero with date_default_timezone_set function. I am attaching the screenshots of the code and the result of the echo inside. Thank you!

    Expire Test.jpg

    RegDate error.jpg

    You are far too complicated.

    SELECT TO_DAYS (reg_date) - AS TO_DAYS (CURDATE ()) daysleft

    OF ssregis

    WHERE...

    This will give you the number of days remaining before the expiry of the registration. If it is less than 0, redirect to the renewal page.

    Moreover, you yourself laying wide open to attack by SQL injection by failing to escape at the entrance of the query string. At the very least, you should do this:

    $entered_ss_id = mysql_real_escape_string($_GET['record_id']);

    $entered_email = mysql_real_escape_string($_GET['email_address']);

    However, since it seems that you are hand-coding the script, you must use MySQL improved rather than discouraged PHP MySQL functions. See http://docs.php.net/manual/en/mysqlinfo.api.choosing.php.

  • write a view with function in oracle

    Hi all

    I have a table named border, contains the borders of certain countries.

    and then I did notice, for symmetric data, which means that if I have a folder {ch, OF} I {, ch}.

    so I want another opinion, preferably with the help of functions, to show me that these results, the first view must be used, not the main table, to create this view.

    en, 1

    pl, 1

    UK, 2

    read, 2

    read, 3

    This means between these countries, we have these quantity of bordes, but we just want to see these up to 3 borders, not more.

    Thanks for your reply.

    IM using oracle 10 g and linux ubuntu 12.

    First of all, I have a table illustrating the countries

    {code}

    -File created - Sunday-November-24-2013

    --------------------------------------------------------

    --------------------------------------------------------

    -The DOF for Table BORDERS

    --------------------------------------------------------

    CREATE TABLE 'borders' ('Country1' CHAR (2), 'countries2"TANK (2), the NUMBER of 'LENGTH')

    INSERTION of REM in borders

    TOGETHER TO DEFINE

    Insert into borders (countries1, countries2, LENGTH) values ('from', 'fr', 381);

    Insert into borders (countries1, countries2, LENGTH) values ('from', 'ch', 494);

    Insert into borders (countries1, countries2, LENGTH) values ('from', 'pl', 148);

    Insert in borders (countries1, countries2, LENGTH) values ('ch', 'fr', 608);

    Insert in borders (countries1, countries2, LENGTH) values ('ch', 'it', 318);

    Insert into borders (countries1, countries2, LENGTH) values ("ch", "li", 240);

    Insert into borders (countries1, countries2, LENGTH) values ('he', 'if', 306);

    Insert into borders (countries1, countries2, LENGTH) values ('he', 'DM', 584);

    Insert into borders (countries1, countries2, LENGTH) values ('en', 'read', 549);

    Insert into borders (countries1, countries2, LENGTH) values ('en', 'of', 1000);

    Insert into borders (countries1, countries2, LENGTH) values ('pl', 'ru', 628);

    Insert in borders (countries1, countries2, LENGTH) values ('pl', 'sk', 126);

    Insert into borders (countries1, countries2, LENGTH) values ('UK', 'au', 1800);

    {code}

    and then I have a symmetrical data view:

    {code}

    SELECT B.COUNTRY1, B.COUNTRY2

    BORDERS B

    UNION

    SELECT B.COUNTRY2, B.COUNTRY1

    BORDERS B

    {code}

    Of course you can do it in a function. But why write a function where possible in SQL using the features of Oracle wrote to us ;-)

    'min way' is the key here sentence. You said... for example, we do not want {en, 3, 1000}

    Is it because that {en, a, 2} is already covering en-> of?

    In, this case may be something like this... I am sure that other members may provide the most effective solution.

    But please review these suggested solutions build further and learn SQL/capabilities in Oracle. After all, it's that you should maintain and build on this code. Play with this code and see what makes each step. You will be able to solve the problem that you encounter in yourself. Basically, it is the main objective of these forums.

    > col A30 path format

    > with t as)

    Select the Country1, countries2, lvl level length, SYS_CONNECT_BY_PATH (countries2, ' /') 'Path' of borders

    Start by Country1 = "of" connect by nocycle Country1 = countries2 prior)

    t2 as)

    Select t.*, min (lvl) on Pmin (partition by Country1, countries2) t where lvl<>

    Select * from t2 where Pmin = lvl

    Country1 countries2 LVL PMIN path LENGTH

    -------- -------- ---------- ---------- ------------------------------ ----------

    ch       fr                2        608 /ch/fr                                  2

    ch       it                2        318 /ch/it                                  2

    ch       li                2        240 /ch/li                                  2

    de       ch                1        494 /ch                                     1

    de       fr                1        381 /fr                                     1

    de       pl                1        148 /pl                                     1

    fr       de                2       1000 /fr/de                                  2

    fr       lu                2        549 /fr/lu                                  2

    it       si                3        306 /ch/it/si                               3

    it       sm                3        584 /ch/it/sm                               3

    pl       ru                2        628 /pl/ru                                  2

    pl       sk                2        126 /pl/sk                                  2

    ru       ua                3       1800 /pl/ru/ua                               3

    13 selected lines

    Elapsed time: 00:00:00.018

    I hope this helps.

    VR,

    Sudhakar

  • Why we need to create the package instead of procedure or function in Oracle

    Hello

    Recently, I attended an interview, they asked,
    why we must create the package instead of procedure or function in oracle. Is a specific advantage, if we create together.
    I'm not sure. can u tell me please someone.

    Thank you and best regards,
    Sanjeev.

    Hello

    A part of the oracle documentation.

    What is a PL/SQL Package?
    A package is a schema object which includes subroutines, variables, and logically related PL/SQL types. Packages have two parts: a specification (spec) and a body. Sometimes, the body is unnecessary. The specification is the interface to the package. It declares the types, variables, constants, exceptions, cursors, and subprograms that can be referenced from outside the package. The body defines queries for the sliders and the code for the subprogrammes.

    Benefits of the PL/SQL Packages
    Packages have a long history in software engineering, offering important characteristics for a reliable, maintainable, and reusable code, often in team for large systems development efforts.

    Modularity

    Packages allow you to logically encapsulate Associates types, elements, and subroutines in a module named PL/SQL. Each package is easy to understand, and the interfaces between packages are simple, clear and well defined. This facilitates the development of applications.

    Easier application design

    When you design an application, all you need initially is the interface information in the package specification. You can code and compile a spec without his body. Stored subprograms that reference the package can then be compiled as well. You should not set the package body entirely until you are ready to complete the application.

    Information masking

    With packages, you can specify which types, elements, and subprogrammes are (and accessible) public or private (hidden and inaccessible). For example, if a package contains four subprogrammes, three can be public and one private. The package hides the implementation of the subprogramme private so that only the package (not your application) is affected if the application changes. This simplifies maintenance and improvement. Also, by hiding the implementation details of the users, you protect the integrity of the packaging.

    Feature added

    Sliders and packed public variables persist for the lifetime of a session. They can be shared by all the subprogrammes that are running in the environment. They allow you to manage data in any of the transactions without storing in the database.

    Best performance

    When you call a subprogram packaged for the first time, the whole package is loaded into memory. Subsequent calls to related subprograms in package require no disk i/o.

    Packets stop cascading dependencies and avoid an unnecessary recompilation. For example, if you change the body of a packaged function, Oracle does not recompile other routines that call the function; These routines only depend on parameters and return value that are declared in the specification, so they are recompiled only if the specification changes.

  • Unlike char in ORACLE and SQL SERVER

    Hello gurus,

    I tried to querying data from Oracle to sql server through linked server, but get me an error! set length corresponds to the error! I know there are CHAR data type in sql server and thus as in oracle.

    But when I use the CAST FUNCTION with CHAR it works fine
    -- error code 
    
      select * from openquery( linkoracle11 
               select  col1, col2, col3 from test_table )
    
    
    -- say col3 char(1)   -- data type
    ---

    -- working code 
    
      select * from openquery ( linkoracle 11 
               select  col1, col2, cast (col3 as char(1)) as col_3 from test_table )
    I was wondering, what is the difference between oracle and sql server for the CHAR data type?

    The gurus of the idea?

    Thank you

    What is the error you get?

    What is the characters in database and NLS_LENGTH_SEMANTICS game on your Oracle system?

    SELECT *
      FROM v$nls_parameters
     WHERE name LIKE '%CHARACTERSET';
    
    SQL> SHOW PARAMETER nls_length_semantics;
    

    What is the character set of data in SQL Server?

    If your local database is a variable length character set (like UTF8) and NLS_LENGTH_SEMANTICS is set to (default) BYTES, a char (1) allocate 1 byte of storage which may not be sufficient for a single character. The receiving application may need to allocate a buffer with 3 times more many bytes as there are characters in order to ensure that it will be able to process the result. I don't know why add an implicit CAST that would change, but since we are several levels removed from the code to figure out how large a buffer to allocate, it is not very surprising.

    Justin

  • Any difference between the separate function and aggregation in sql query cost?

    Hello
    I've run many models sql stmts - such as:
    one) using a single table
    (b) using the two tables, using simple joins or outer joins

    but I didn't notice a difference in sql stmts in cost and implementation plan...
    In any case, my colleague insists on only using the aggregate function is less expensive compared to
    separate... (something I've not confirmed, that is why I believe that they are exactly the same...)

    For the situation described above under 1 sql... We could for example use
    select distinct deptno
    from emp
    select count(*), deptno
    from emp
    group by deptno
    select distinct owner, object_type from all_objects
    select count(*), owner, object_type from all_objects
    group by owner, object_type
    Have you ever found no difference between the two...?

    Note: I use Ora DB 10g v2.

    Thank you
    SIM

    Alexandre Gelin says:
    function separate and aggregation are for different uses and can give the same result, but if you use the aggregate function to get the separate records, it will be expensive...

    really? I find them almost identical to 11g. Actually GROUP BY is almost always more fast for me in the old days.

    article about this askTom Re: any difference between the separate function and aggregation in sql query cost?
    This applies mainly to the older oracle versions http://www.oracle.com/technology/products/rdb/pdf/distinct_derivedtables_groupby_sort_tech_article.pdf

  • What is this new SQL Beta - 1z1 - 071 - 2 SQL - Oracle Database SQL 12 c

    Hello

    It's confusing.

    This looks like a 2nd review SQL for Oracle 12 c.

    What is this new SQL Beta - 1z1 - 071 - 2 SQL - Oracle Database SQL 12 c

    Can someone explain.

    Roger

    OK - I guess I should have held off a few hours before my previous answer.  I just got an email in the Certification of Oracle program manager. Now, I have inside information.

    1Z0-071 is a SQL new test and the role it plays is between that of the review of databases SQL and SQL Expert.  Specifically, unlike review of databases SQL, passing it will give proof of the OCA for people who spend. I don't know more than that yet.  The review details page is not available and if the subjects are currently a grey area for me.  I'll probably create a blog on the review, if I can get a few details about it.

  • Oracle PL/SQL Obfuscation replicate 3DES with java

    I have an existing oracle functions that use the function DES3Encrypt and DES3Decrypt.

    I need to write the equivalent of java version to replace the oracle those compatibiliy with encryption legacy system maintenance.

    What are the functions of oracle:

    FUNCTION encr(input_string IN VARCHAR2, key_string IN VARCHAR2)
      RETURN VARCHAR2 IS
      encrypted_string
    := NULL;
      len 
    := lengthb(input_string);
      
    --String must be a multiple of 8-byte length.
      rest
    := len MOD 8;
      IF rest
    > 0 THEN
      decrypted_string
    := rpad(input_string, len + 8 - rest, ' ');
      ELSE
      decrypted_string
    := input_string;
      
    END IF;

      dbms_obfuscation_toolkit
    .DES3Encrypt(input_string  => decrypted_string,
      key_string 
    => key_string,
      encrypted_string
    => encrypted_string);

      
    /* HEX notation to avoid UNICODE chars */
      SELECT RAWTOHEX
    (encrypted_string) INTO encrypted_string FROM DUAL;

      RETURN encrypted_string
    ;
    END;

    //DECRYPTION
    FUNCTION decr
    (input_string IN VARCHAR2, key_string IN VARCHAR2)
      RETURN VARCHAR2 IS
      decrypted_string
    := NULL;
      encrypted_string
    := input_string;

      
    /* HEX to ASCII */
      SELECT utl_raw
    .cast_to_varchar2(encrypted_string)
      INTO encrypted_string
      FROM DUAL
    ;

      dbms_obfuscation_toolkit
    .DES3Decrypt(input_string  => encrypted_string,
      key_string 
    => key_string,
      decrypted_string
    => decrypted_string);

      RETURN rtrim
    (decrypted_string);
    END;

    Given the Decrypt function, for example, I wrote this java code:


    import javax.crypto.Cipher;
    import javax.crypto.SecretKey;
    import javax.crypto.spec.IvParameterSpec;
    import javax.crypto.spec.SecretKeySpec;


    public class DesHelper {
      

       private Cipher _dcipher;
          
    public DesHelper() {
              
    try {

                  
    byte[] tdesKey = new byte[24];
                  
    System.arraycopy("2557133392096270".getBytes(StandardCharsets.US_ASCII), 0, tdesKey, 0, 16);
                  
    System.arraycopy("2557133392096270".getBytes(StandardCharsets.US_ASCII), 0, tdesKey, 16, 8);

                  
    final SecretKey key = new SecretKeySpec(tdesKey, "DESede");
     

                   _dcipher
    = Cipher.getInstance("DESede/CBC/NoPadding");
                  
    final IvParameterSpec iv = new IvParameterSpec(new byte[8]);

                   _dcipher
    .init(Cipher.DECRYPT_MODE, key,iv);

             
    } catch (final Exception e) {
                 
    throw new RuntimeException(e);
             
    }
          }


          public String decrypt(final String str) {
             
    try {

                  final byte[] dec1 = hexToBytes(str);
                 
    final byte[] decryptedBytes = _dcipher.doFinal(dec1);  
                 
    return new String(decryptedBytes, StandardCharacters.US_ASCII);
             
    } catch (final Exception e) {
                 
    System.out.println("decrypting string failed: " + str + " (" + e.getMessage() + ")");
                 
    return null;
             
    }
          }

         private static byte[] hexToBytes(final String hex) {
             
    final byte[] bytes = new byte[hex.length() / 2];
             
    for (int i = 0; i < bytes.length; i++) {
                  bytes
    [i] = (byte) Integer.parseInt(hex.substring(i * 2, i * 2 + 2), 16);
             
    }
             
    return bytes;
         }

    }

    It's the main:

    Public class MainClass {}

    Public Shared Sub main (final String [] args) {}

    String txtToBeDecrypted = "DA67C73756184F20ED92DF1614CB85ED";

    final DesHelper h = new DesHelper();

    String xc = h.decrypt (txtToBeDecrypted);

    System.out.printls (XC);

    }

    }


    But the printed result is still a mess of characters like these:

    lZ5 ????rd      

    where only "rd" is correct (being the last part of the decrypted Word).

    the correct decrypted word should be 'MonMotpasse '.

    If the password is transformed into mypasswordmypass (encrypted: 5543417F4834268A2799D9289D864BFB)... I get: lZ5? rdmypass-> it seems that the first 64 bits are always false.

    What is the problem in my code? is it just a matter of encoding?

    Message modificato da 3136775 added new snippet for completeness

    I found that the tip is in the vector of inialization IV...

    I wrote an algorithm to capture the right bytes value and it worked... it seems not oracle uses to manipulate the first 8 bytes.

  • That means 1z0-117 oracle 11g sql tuning now say it includes v12 addition v11

    Hello

    I did the 1z0-117 sql tuning review once.

    Not too far away.

    I studied under and turned off for a while.

    I anticipate taking in 1 month.

    However, I just noticed that the oracle site says 1z0-117 also said that v12 is also included for consideration:

    Oracle 11g sql tuning.

    It makes no sense at all.

    Roger

    However, I just noticed that the oracle site says 1z0-117 also said that v12 is also included for consideration:

    Oracle 11g sql tuning.

    Unless you are looking for something I'm not, what actually is the 1Z0-117 page says: "validated against: review has been validated against Oracle Database 11g Release 2 version 11.2.0.1.0 and database Oracle 12 c 12.1.0.1.0"

    What they actually mean by it is that someone went through all the issues and and asked the question "is still a relevant issue for the release of 12 c to Oracle?'." "  If they find issues that are not valid because of an update/change, then the question will be removed from review (or changed) so that someone who has used 12 c but not 11 g will not at a disadvantage.

    This is * No * means that Oracle has added questions to the review of the capabilities that were introduced in version 12 c.

  • difference between the incremental update of the IKM oracle and incremental update IKM oracle (PL - SQL)

    Hello

    What is the difference between the incremental update of the IKM oracle and updated incremental IKM oracle (PL - SQL) and incremental update IKM oracle (line by line).

    Thank you

    Papai

    The only difference is that the second using plsql for incremental update. He also to manage clob issues well enough.

    If you need to know more you can read the description of each KM section.

    Incremental update IKM Oracle (PL-SQL)

    -------

    Description:

    -Knowledge integration module

    -Integrates data into an Oracle table from target in incremental update mode using PL/SQL.

    -Non-existent rows are inserted. already existing lines are updated.

    -Data can be controlled. Data invalid are isolated in the error Table and can be recycled.

    -This KM uses PL/SQL to perform the inserts and updates until and blob columns are supported. Please see the restrictions.

    -When you use this module with a source table logged, it is possible to synchronize the deletions.

    Restrictions:

    -When working with the logged data, if the "synchronize destruction of the newspaper" are executed, the lines deleted on the target are engaged

    -The data are updated even if not changed (upgrade from any (e)

    -The number of lines (number of inserts/changes) is not available because the transactions are performed using PL/SQL

    -Comparison of the data is performed using the key to update defined in the interface. It must be set.

    -L'option TRUNCATE does not work if the target table is referenced by another table (foreign key)

    -Options FLOW_CONTROL, and STATIC_CONTROL call the Module knowledge check to isolate invalid data (if no CKM is defined, an error occurs). These two options should be set to NO in the case where an integration Interface meets a TEMPORARY target data store.

    -L' FLOW_TABLE_OPTION option is set by default to NOLOGGING. Set it to a space if the interface is running on an Oracle 7 database

    -Deletions are committed regardless of the VALIDATION option

    Incremental update of the IKM Oracle

    -------------

    DESCRIPTION:

    -Integrates data into an Oracle table from target in incremental update mode.

    -Non-existent rows are inserted. already existing lines are updated.

    -Data can be controlled. Data invalid are isolated in the error Table and can be recycled.

    -When you use this module with a source table logged, it is possible to synchronize the deletions.

    REQUIREMENTS:

    -The update key defined in the interface is required.

    RESTRICTIONS:

    -When working with the logged data, if the "synchronize destruction of the newspaper" are executed, the lines deleted on the target are engaged

    -L'option TRUNCATE does not work if the target table is referenced by another table (foreign key)

    -Options FLOW_CONTROL, and STATIC_CONTROL call the Module knowledge check to isolate invalid data (if no CKM is defined, an error occurs).

    These two options should be set to NO in the case where an integration Interface meets a TEMPORARY target data store.

    -L' FLOW_TABLE_OPTION option is set by default to NOLOGGING. Set it to a space if the interface is running on an Oracle 7 database

    -Deletions are committed regardless of the VALIDATION option

    -L' ANALYZE_TARGET option will allow to assess correct statistics only if the VALIDATION is set to Yes. Otherwise, the IKM gather statistics based on old data.

    -Default UPDATE option is TRUE, which means by default it is assumed that there is at least one column nonkey specified in a target data store.

Maybe you are looking for