How to use the nocopy with java stored procedures parameters


--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

I'm a PL/SQL programmer, but not a Java programmer. I have the following java function that does what it's supposed to add a pdf at the end of another pdf document:

import oracle.sql.BLOB;
import org.apache.pdfbox.util.PDFMergerUtility;
import oracle.jdbc.OracleConnection;
import oracle.jdbc.driver.OracleDriver;
import java.io.OutputStream;

public class PDFUtilities {
public static BLOB appendPDF(BLOB pdfdoc1, BLOB pdfdoc2) throws Exception {
       
        //create a connection object to the current instance
          OracleConnection conn = (OracleConnection)new OracleDriver().defaultConnection();
        //create the output blob using the connection
          BLOB outPDF = BLOB.createTemporary(conn, true ,BLOB.DURATION_SESSION);
        //create an output stream to the output blob
          OutputStream os = outPDF.setBinaryStream(0);               
        //instantiate the pdf merger utility
          PDFMergerUtility mergerUtility = new PDFMergerUtility();       
        //connect the merger to the output stream
          mergerUtility.setDestinationStream(os);
        //stream from each input blob into the merger utility
          mergerUtility.addSource(pdfdoc1.getBinaryStream());
          mergerUtility.addSource(pdfdoc2.getBinaryStream());
        //merge the 2 input pdfs
          mergerUtility.mergeDocuments();             
        //do not close the output stream
        //return the blob
        return outPDF;
    }

}

CREATE OR REPLACE package PDFTOOLS.pkg_pdf_utilities
as
function f_get_merged_pdf (
          pi_pdf1       blob
        , pi_pdf2    blob
  )
  return blob;
end pkg_pdf_utilities;
/

CREATE OR REPLACE package body PDFTOOLS.pkg_pdf_utilities
as
function f_get_merged_pdf (
          pi_pdf1       blob
        , pi_pdf2    blob
  )
  return blob
  as language java name 
  'com.mycode.pdftools.PDFUtilities.appendPDF(oracle.sql.BLOB, oracle.sql.BLOB) return oracle.sql.BLOB';
end PDFTOOLS.pkg_pdf_utilities;
/

It's very basic, but doesn't seem to work. However, I want to my function from PL/SQL to a procedure that looks like this:

CREATE OR REPLACE package PDFTOOLS.pkg_pdf_utilities
as
procedure sp_append_pdf (
          pio_pdf2append2   IN OUT NOCOPY blob
        , pio_pdf2append   IN OUT NOCOPY blob
  )
end pkg_pdf_utilities;
/

What is important, what I'm trying to do is to NOCOPY the BLOBs. Otherwise, I have to read my PDF files into 2 BLOBs and create a 3rd blob as output. I prefer to be able to keep the pio_pdf2append2 as the final output. What I actually do call thing in a loop to gradually add a PDF file to a big. I'm not linking this in one operation because of concerns over the use of the system and because the pdfbox library java has would have been question after 850 in PDF format, which is not completely unrealistic in my approach.

How could I achieve this?

Post edited by: Pollocks01 only formatted code blocks because atlassian {code} tags didn't work.

Passage of an argument as input/OUTPUT requires the mapping to a Java array.

Simplified example that adds one FOR the other:

create or replace and compile java source named blob_appender_src as
import oracle.sql.BLOB;
import java.sql.SQLException;
import java.io.OutputStream;
import java.io.InputStream;
import java.io.IOException;

public class BLOBAppender {
    public static void run (BLOB[] p1, BLOB p2) throws SQLException, IOException { 

        InputStream is = p2.getBinaryStream();
        OutputStream os = p1[0].setBinaryStream(p1[0].length()+1);                

        byte[] buffer = new byte[1024];
        int len;
        while ((len = is.read(buffer)) != -1) {
            os.write(buffer, 0, len);
        }
        os.close();
        is.close();
    }
}
create or replace procedure blob_append (
  p_lob1  in out nocopy blob
, p_lob2  in            blob
)
as language java name 'BLOBAppender.run(oracle.sql.BLOB[], oracle.sql.BLOB)' ;
/
SQL> declare
  2    p_lob1  blob := utl_raw.cast_to_raw('ABC');
  3    p_lob2  blob := utl_raw.cast_to_raw('DEF');
  4  begin
  5    blob_append(p_lob1, p_lob2);
  6    dbms_output.put_line(utl_raw.cast_to_varchar2(p_lob1));
  7  end;
  8  /

ABCDEF

PL/SQL procedure successfully completed.

Tags: Database

Similar Questions

  • How to use the product with laptop Portege R150 recovery CD?

    How to use the recovery CD product with laptop Portege R150 of Formate and reinstall the operating system?

    Mobile recovery procedure Asian does not for me but may not be very different as on mobile phones produced in Europe or the United States.

    Start your laptop and press F12 to display the boot options
    Place the recovery disc into the optical disc drive
    In the start menu, choose the CD/DVD drive and press ENTER
    The procedure of the facilities is expected to begin
    Follow the menu on the screen

    I do not know what will be shown at this stage, but it is not complicated to install the original recovery image. If you have any other questions please let me know what happens when upgraders begins. What options are displayed?

  • How to use the date with the report parameter format

    Hi all

    How to use the date format with this tag function,

    <? param@begin:P_FROM_DATE? > <? $P_FROM_DATE? >

    This date of form source of report and setting is coming as this 2012/11/01 00:00:00.

    So now I need this in MY-DD-YYYY marker. I tried like this..? param@begin:P_FROM_DATE? > <? $format - date: P_FROM_DATE; ' DD-MON-YYYY '? >

    but its giving error. Can someone pls how to convert to the format of date custom.

    Thanks and greetings
    Srikkanth.M

    Problem solved.

    REF this link

    Date Format of XML

  • Satellite A300 - how to use the recovery with external DVD drive disc?

    Hello

    I bought a toshiba Satellite A300 - 15 d

    FTM the tsscorp drive that is installed in the camera no longer works (does not detect any type of media what so ever). ) need to recover the laptop, so I used a USB DVD drive to boot from the restore disc, but after that the charges of recovery console it says waiting for media in the f: drive, which is the tsscorp drive although I used an external drive to load the disc.

    What files should I edit to make it to load from the drive externally and if this isn't the solution, what do I do?

    Thanks in advance

    Hey Buddy,

    Unfortunately I think that it of not possible to use the recovery with external CD/DVD drive disc. Therefore, place the internal for use the recovery disc.
    You can get a new drive to an authorized service provider.

    But if the original OS from Toshiba is installed, you can use the function of disk recovery HARD reinstall Windows as well. Go to the advanced boot menu (F8) and select Repair my computer :)

  • Satellite A210 - how to use the muldimedia with other than Media Player buttons

    Hello

    is it really not possible to use media keys (Play, Pause, FF) on top of my laptop for an application other than Windows Media Player?
    Is there a reason for this? I would like to control Winamp with this button.

    It seems quite sensless to restrict access to a SINGLE application of HUNDREDS available, a then it is the multimedia player that is not used by most people.

    I have the Satellite A210 Notbook.

    Can you tell my how to control my winamp with these buttons?

    Greetings from Robert

    Hello, Robert

    Unfortunately, there is no solution at the moment. If you check this forum, you will find several very interesting discussions on the multimedia buttons and Winamp player. The fact is that some people have found the solution for older models of laptops running Windows XP Home edition. Winamp has offered the plugin must be installed.

    We now have the new situation. Your laptop is running latest Vista OS and I didn t find any plugin that can help. Problem is that your laptop is designed for Windows Vista preinstalled OS contains all the necessary plugins for Windows media player running under the operating system preinstalled.

    Is any kind of restriction. With preinstalled operating system you can do what you want and if you can find a way to change it for that. You know very well that there are hundreds of different players in the market. You can't wait for Toshiba take a time and create a plugins for each other and satisfy customers around the world.

  • How to use the microphone with a music player

    I did not use the microphone input with any music player for the internet radio show. can it be done with vista on a sony vaio labtop

    Hellotrendsetter,

    Thank you for visiting the Microsoft answers Site.

    Please provide the make and model of your PC. Also, to better help, please relay the program or music player you use.

    You can also view the link below for more information on how to connect a microphone, music player or other audio device to your computer:

    http://Windows.Microsoft.com/en-us/Windows-Vista/connect-a-microphone-music-player-or-other-audio-device-to-your-computer

    Thank you

    Mary
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • How to use the programe of java in oracle

    Hello Expert,

    My Config is: -.

    Forms [32 bit] Version 11.1.1.3.0 (Production)

    JDeveloper - 10.1.3

    I want to use the java programe in the form builder. I create a java class in Jdeveloper.

    package demo;

    import java.net.InetAddress;

    import java.net.NetworkInterface;

    java.net.SocketException import;

    java.net.UnknownHostException import;

    public class get_info {}

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

    ch_add();

    }

    public static ch_add() Sub

    {

    InetAddress ip;

    try {}

    IP = InetAddress.getLocalHost ();

    /*System.out.println ("current IP address:" + ip.getHostAddress ());  */

    NetworkInterface network = NetworkInterface.getByInetAddress (ip);

    Mac Byte [] = network.getHardwareAddress ();

    /*System.out.print ("MAC address current :");   */

    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < mac.length; i ++)

    {

    SB. Append (String.format ("% 02 X %s", mac [i], (I < mac.length - 1)?)) "-" : ""));

    }

    System.out.println (SB. ToString());

    } catch (UnknownHostException e) {}

    e.printStackTrace ();

    } catch (SocketException e) {}

    e.printStackTrace ();

    }

    }

    }

    and Formweb.cfg and default.env and also add in Form_class_path. After that, I import this java in forms.

    Code genertated-

    PACKAGE get_info BODY IS

    --

    -DO NOT EDIT THIS FILE - it is machine generated!

    --

    args NYI. ARGLIST;

    Constructor for signature (V)

    New FUNCTION RETURN ORA_JAVA. JOBJECT IS

    BEGIN

    args: = NULL;

    RETURN (JNI. NEW_OBJECT ("demo/get_info", "(V)", args));

    END;

    -Method: main ([Ljava/lang/String ;) V

    Main PROCEEDINGS)

    A0 ORA_JAVA. JACOB) IS

    BEGIN

    args: = NYI. CREATE_ARG_LIST (1);

    NYI. ADD_OBJECT_ARG (args, a0, ' [Ljava/lang/String ;');)

    NYI. CALL_VOID_METHOD (TRUE, NULL, "demo/get_info', 'hand', ' ([Ljava/lang/String ;)) V ", args);

    END;

    -Method: ch_add (V)

    PROCEDURE ch_add IS

    BEGIN

    args: = NULL;

    NYI. CALL_VOID_METHOD (TRUE, NULL, "demo/get_info", "ch_add", "(V)", args);

    END;

    -Method: wait (J) V

    PROCEDURE to wait)

    obj ORA_JAVA. JOBJECT,

    NUMBER of a0) IS

    BEGIN

    args: = NYI. CREATE_ARG_LIST (1);

    NYI. ADD_LONG_ARG (args, a0);

    NYI. CALL_VOID_METHOD (FALSE, obj, "demo/get_info", "expect", "(J) V", args);

    END;

    -Method: wait (V)

    PROCEDURE to wait)

    obj ORA_JAVA. JOBJECT) IS

    BEGIN

    args: = NULL;

    NYI. CALL_VOID_METHOD (FALSE, obj, "demo/get_info", "expect", "(V)", args);

    END;

    -Method: wait (JI) V

    PROCEDURE to wait)

    obj ORA_JAVA. JOBJECT,

    NUMBER of a0,

    The a1 NUMBER) IS

    BEGIN

    args: = NYI. CREATE_ARG_LIST (2);

    NYI. ADD_LONG_ARG (args, a0);

    NYI. ADD_INT_ARG (args, a1);

    NYI. CALL_VOID_METHOD (FALSE, obj, "demo/get_info", "expect", "V (JI)", args);

    END;

    -Method: equals (Ljava/lang/object ;) Z

    FUNCTION is equal to)

    obj ORA_JAVA. JOBJECT,

    A0 ORA_JAVA. JOBJECT) RETURN BOOLEAN IS

    BEGIN

    args: = NYI. CREATE_ARG_LIST (1);

    NYI. ADD_OBJECT_ARG (args, a0, ' object java/lang / "");

    BACK TO JNI. CALL_BOOLEAN_METHOD (FALSE, obj, "demo/get_info", "equal to", "(Ljava/lang/object ;)) Z', args);

    END;

    -Method: toString () Ljava/lang/String;

    FUNCTION toString)

    obj ORA_JAVA. JOBJECT) RETURN VARCHAR2 IS

    BEGIN

    args: = NULL;

    BACK TO JNI. CALL_STRING_METHOD (obj, "demo/get_info", "toString", "() Ljava/lang/String"; FALSE, args);

    END;

    -Method: hashCode () I have

    FUNCTION (hashCode

    obj ORA_JAVA. JOBJECT RETURN NUMBER) IS

    BEGIN

    args: = NULL;

    BACK TO JNI. CALL_INT_METHOD (FALSE, obj, "demo/get_info", "hashCode", ' () I ", args");

    END;

    -Method: getClass () Ljava/lang/class;

    FUNCTION getClass)

    obj ORA_JAVA. ORA_JAVA RETURN JOBJECT). JOBJECT IS

    BEGIN

    args: = NULL;

    BACK TO JNI. CALL_OBJECT_METHOD (obj, "demo/get_info", "getClass", "() Ljava/lang/class"; FALSE, args);

    END;

    -Method: notify (V)

    Notification PROCEDURE)

    obj ORA_JAVA. JOBJECT) IS

    BEGIN

    args: = NULL;

    NYI. CALL_VOID_METHOD (FALSE, obj, "demo/get_info', 'prevent',"(V)", args);

    END;

    -Method: notifyAll () V

    PROCEDURE notifyAll)

    obj ORA_JAVA. JOBJECT) IS

    BEGIN

    args: = NULL;

    NYI. CALL_VOID_METHOD (FALSE, obj, "demo/get_info", "notifyAll", "(V)", args);

    END;

    BEGIN

    NULL;

    END;

    Now, I want to call the o/p of the Java programe in the oracle text element. Please help me. It is very urgent. I'm not good in Java.

    It is all explained in http://fdtool.free.fr/forms-pjc-bean/first-bean/first_bean.pdf

    In essence, you need:

    -a Java class that extends from oracle.forms.ui.VBean where you must implement getProperty, as stated in article method

    -a unique property of your choice name

    -forms of type point area of bean that should be visible and on a canvas

    -you could then call your method using get_custom_property (, 1, )

    Just adapt the example comes from the tutorial above. You can of course also use the FBean package so you will not need to extend kifani but simply to any class that extends from container. As a first step, maybe you must redo the complete tutorial to get a handle on the how and the why.

    see you soon

  • How to use the import with FDM with adapter ERPI script?

    Hello

    I use FDM and ERPI 11.1.2 to load data of EBS R12 to planning 11.1.2

    Loaded from eBS data for a YEAR.

    I realized I could use an import script to manually calculate the amount with the periodic_net_cr and periodic_net_dr fields.

    But how to use this import script? Because in my import in FDM format, I do not use a file but directly the adapter, if no field "Expression".

    Thanks in advance for your help

    Fanny

    You must use the ImportAction script.

  • How to use the String with an external dispatchEvent event.target.name?

    ... I hope that the question of the title makes sense...

    On my stage, I have an external SWF loaded with a button. When you click the button dispatches the main event scene.

    On the main stage a listener can load a SWF it in a magazine called Gallery.

    The charger of the Gallery is also shared by the buttons on the main stage, who use the event.target.name chain to appeal to sovereign wealth funds with corresponding names.

    I use tweens to fade and, in the content of the Gallery when a key is pressed.

    --

    Loading of the FSV worked until I tried to create a universal function for the dispatchEvent buttons...

    The problem I have is that I don't know how to set the string to indicate to the newSWFRequest where the SWF file when triggered by external buttons.

    (I maybe do this wrong... but thought that the best way to load a SWF on the main stage from an external SWF was using dispatchEvent?)

    My code raises the event and the charger of the Gallery Faints, but then it does not find the new SWF:

    Error #2044: Unmanaged by the IOErrorEvent:. Text = Error #2035: URL not found.

    Please can someone help me understand how to make the point in the chain in the right direction? (I think that the errors only are in bold below)

    Code:

    var myTweenIn2:Tween;

    var myTweenOut2:Tween;

    var nextLoadS2:String;

    Listening external inclinometer shipped external event

    addEventListener ("contactStage", btnClickExtrnl);

    function btnClickExtrnl(e:Event):void {}

    nextLoadS2 =?

    myTweenOut2 = new Tween(gallery,"alpha",None.easeOut,gallery.alpha,0,0.2,true);

    myTweenOut2.addEventListener (TweenEvent.MOTION_FINISH, tweenOutCompleteF2);

    }

    Function universal BTNS

    function tweenOutCompleteF2(e:TweenEvent) {}

    myTweenOut2.removeEventListener (TweenEvent.MOTION_FINISH, tweenOutCompleteF2);

    myTweenOut2 = null;

    var newSWFRequest:URLRequest = new URLRequest ("SWFs /" + nextLoadS2 + ".swf");

    myTweenIn2 = new Tween (Gallery, "alpha", None.easeOut, gallery.alpha, 1, 0.2, true);

    Gallery.Load (newSWFRequest);

    Gallery.x = Xpos;

    Gallery.y = Ypos;

    }

    Thank you.

    If this code is on the timeline of a child of the main timeline of your external swf add parent 3rd in two lines with parent.parent.

  • How to use the Clipboard with some sites

    I use the copy and paste function from the Clipboard frequently to allow access to certain pages. It worked fine until I updated Firefox to the latest version of 29,0. It doesn't work anymore! I followed the usual instructions to create a user.js file and place it in the profile directory. But the problem is still there. Need help with this problem.

    You can do this is through buttons using JavaScript to make the paste.

    You can only do this via the keyboard.

    Use keyboard shortcuts if the buttons on the web page or other methods do not work.

    • Copy: Ctrl + C or Ctrl + insert (Mac: command + C)
    • Paste: Ctrl + V or shift + insert (Mac: command + V)
    • Cut: Ctrl + X or shift + delete (Mac: command + X)

    See also:

  • How to use the user with event loop event

    Hello

    I want to communicate between 2 VI, so I have a global variable (boolean) who gives the order to an event tool to run. The problem comes from the fact that event loop accepts no global variable, I found on the forum that I can use the user event. Of course, the second VI works normally when I push the button (boolean) in there to run the event loop. Please can someone explain me how to do this, I am a chemist.

    Thank you.

    You enter the receiver structure of event for the event you want to receive.

    To do this in two screws, you will have to share the user between them event reference.

  • How to use the zone with the calendar events settings?

    After looking through the questions in the time zones, scheduling and synchronization, I still can't my Palm Centro to exploit the way I think it should.

    I have a Verizon Centro, use Windows XP with Outlook and Hotsync synchronization manager 7.02 via a USB cable.  I do not use Palm Desktop.

    I expect events to pass the time in the calendar when I change the time zone, but they did not.

    I am preparing for a trip.  I enter several events in MS Outlook placing events occur in a different time zone in my calendar at the same time the event happen in my timezone (NY).   For example, a meeting of 9-10 am in Los Angeles is put in my calendar to outlook MS as 12-1 PM on the day of the meeting.  Then I have synced with my Centro and Outlook for New York time zone.  The Centro is set automatically update Date, time, area of the network in New York. The event of the meeting appears as 12-1 PM the correct day.

    Then I turn off the Centro phone (IE unplug the Verizon network), change the update time to 'Nothing' - is to say fully manual, change the time zone in Los Angeles and set the time to the exact time in Los Angeles.   I expect the meeting to 9-10 AM in my Centro calendar, but it's not!  I have try other combinations - let the time on the Date and the automatic time update and change the time zone in Los Angeles, etc..  I think I've tried all combinations.  Overall, I leave the Centro phone out of the Verizon network.  I can not get the meeting to change his time in the new time zone.

    What's the trick? What did I miss?

    You might ask why I'm trying this with the phone turned off - it's because I'm really much further that THE and in a GSM network where I will simply use the Center as a PDA.

    All advice appreciated.

    thepoeta-

    Thanks for the reply.

    In fact my preference was not established "new events use time zones."

    Meanwhile, I had loaded all the applointments of Outlook, about 20 of them,

    thinking that I would just manually move along the way.

    I'll play with time zone preference, but,.

    is it possible to identify the existing appointments in the

    Palm as belonging to a time zone that is different, just by using the Palm Centro?

    Thank you

    Neal

  • How to use the aggregate with Date function

    Hi all

    I have a Group date is it possible of Max and Min to date.

    I tried like this but its out errored <? MIN (current - group () / CREATION_DATE)? >.

    I also tried this, but it does not work
    <? xdoxslt:minimum (CREATION_DATE)? >

    Is it possible to use the function of aggregation with date values.

    Thanks and greetings
    Srikkanth

    You can use
    Ensure that the "date" is in canonical format

  • How to use the AVMenuItemExecute() with an external window

    Hello

    I am using the AVMenuItemExecute() function in an external window. I mean I have a document open in another window (to aid

    AVDocOpenFromASFileWithParams or a feature like this).

    In fact, the problem is that the AVMenuItemExecute() is running on the windows of Acrobat that is emplty in my case, because I opened the PDF file in another window.

    Do you know if it's possible or not? Whethet it is possible how can I do?

    Thanks in advance,

    Joel

    Sorry, but you can't: (.)

    As you can imagine, MenuItemExecute() is on the menu... running items these does ARE menu items that in Acrobat/Reader and NOT in any application based on an external window.

    What menu item you try to run?  Perhaps there is another way to access this feature?

  • The JNI in Java, stored procedure call

    Dear,
    I want to know how to call stored procedure JNI Java. How to configure my java.library.path in Oracle to get a specific directlry containing DLLs file inorder to System.loadLibrary ("< dll_file_name >");

    Not sure if I'm on the right track, but it seems that Oracle does not support JNI.

    http://download.Oracle.com/docs/CD/B19306_01/Java.102/b14187/chthree.htm#CACFCDJF


    Oracle database does not support the use of JNI in Java applications. If you use JNI, then your application is not 100% pure Java and native methods need porting between platforms. Native methods can result in a server crash, violating the security and corrupted data.

Maybe you are looking for