Call C++ programs from PL/SQL

Can someone give me an example of how to call C++ programs from PL/SQL ASAP please?
Thanks
Chitra

Hello,
You can use External Procedure facility of of PL/SQL (Assuming your DB is 8 or 8i)
Please refer the doc at http://oradoc.photo.net/ora8doc/DOC/server803/A54654_01/10_procs.htm
James

Similar Messages

  • Calling Cobol program from PL/SQL

    What is the caling convention for PL/SQL to call a Cobol program?

    You cannot do it directly from PL/SQL. PL/SQL is.. well, kind of abstract ito the actual platform it runs on. PL/SQL cannot talk directly to operating system. It cannot (itself) do socket calls, file I/O calls, use the printer, etc.
    <p>
    All this has to be done using a lower level implementation library - like UTL_FILE for example that wraps internal C written modules that does file I/O. PL/SQL can call these to do I/O on its behalf. Ditto for wrappers like UTL_TCP and others.
    <p>
    There is no default wrapper for calling external processes from PL/SQL. It can however be done indirectly using the external procedure (EXTPROC) feature, or using Java to do it.
    <p>
    The latter is the easiest. You create a Java stored proc that can access the operating system and run external programs and commands. You punch a big hole in the Oracle Java security to allow this Java stored proc access to the operating system. Next you create a PL/SQL wrapper for this Java proc which then in turn can be called from PL/SQL.
    Just remember that you MUST secure this hole you've punched into Oracle security. If any Oracle user can access this PL/SQL wrapper, they can hack, compromise, trash or simply destroy your entire Oracle account on that server.
    Here is the basic code:
    create or replace and compile Java Source named "OSCommand" as
    -- java:        OS COMMAND
    -- descr:       Executes an Operating System Command using the JAVA RTS
    -- IN parameter:        os command to execute (including fully qualified path names)
    -- OUT parameter:       returncode [\nstring]
    --                      where string a max of 32000 chars of the output of the command
    --                      (note that \n is used as separators in the string)
    --                      returncode=-1   Java RTS error occurred (e.g. command does not exist)
    --                      returncode=255  o/s command failed (e.g. invalid command params)
    import java.io.*;
    import java.lang.*;
    public class OSCommand{
            public static String Run(String Command){
                    Runtime rt = Runtime.getRuntime();
                    int     rc = -1;
                    try{
                            Process p = rt.exec( Command );
                            int bufSize = 32000;
                            int len = 0;
                            byte buffer[] = new byte[bufSize];
                            String s = null;
                            BufferedInputStream bis = new BufferedInputStream( p.getInputStream(), bufSize );
                            len = bis.read( buffer, 0, bufSize );
                            rc = p.waitFor();
                            if ( len != -1 ){
                                    s = new String( buffer, 0, len );
                                    return( s );
                            return( rc+"" );
                    catch (Exception e){
                            e.printStackTrace();
                            return(  "-1\ncommand[" + Command + "]\n" + e.getMessage() );
    show errors
    create or replace function OSexec( cCommand IN string ) return varchar2 is
    -- function:    OS EXEC
    -- descr:       PL/SQL wrapper for the Java OSCOMMAND stored proc
    language        JAVA
    name            'OSCommand.Run(java.lang.String) return java.lang.String';
    show errors
    -- Punching a hole into the Java VM sandbox. The following must be run as
    -- sysdba. Substitute SCOTT with the applicable schema that owns the OSEXEC
    -- and OSCOMMAND stored procs.
    declare
            SCHEMA  varchar2(30) := 'SCOTT';
    begin
            dbms_java.grant_permission(
                    SCHEMA,
                    'SYS:java.io.FilePermission',
                    '<<ALL FILES>>',
                    'execute'
            dbms_java.grant_permission(
                    SCHEMA,
                    'SYS:java.lang.RuntimePermission',
                    'writeFileDescriptor',
            dbms_java.grant_permission(
                    SCHEMA,
                    'SYS:java.lang.RuntimePermission',
                    'readFileDescriptor',
    commit;
    end;
    -- example: running the Unix/Linux date command to get the current date and time
    SQL> select OSexec('/usr/bin/date') as STDOUT from dual;
    STDOUT
    Fri Sep  1 08:09:34 SAST 2006
    1 row selected.
    SQL>Edited by: Billy Verreynne on Sep 4, 2008 6:26 PM to make the code snippet readable with the new Jive forum s/w.

  • Calling java program from PL/SQL code

    Dear,
    How to develop and call a java program from PL/SQL code?
    What about if this program will call other java programs?

    Perhaps the Java Developer's Guide would be a good place to start
    http://download.oracle.com/docs/cd/B19306_01/java.102/b14187/toc.htm
    Justin

  • Calling java program from PL/SQL

    I already have a java program that encrypts/decrypts data.
    How can I use or rather call this program in PL/SQL?

    Please refer [url http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14261/subprograms.htm#sthref1814]Calling External Subprograms on PL/SQL User's Guide and Reference.

  • Calling external program from PL/SQL

    Does anyone know whether it's possible to call an external program living outside of Oracle from PL/SQl eg. a from a stored procedure?
    Specifically i want to call back into my java appserver (ejb server) when a trigger/stored proc. is executed.
    The call does not have to be synchronous, some sort of queue will do - eg JMS??
    Any help greatly appreciated.
    null

    Hi
    Which version of oracle you are using.
    If it 8i, you can use external procedures/libraries. REfer to ORacle PLSQL documentation.
    If you are using Oracle 7+ you can use dbms pipes to post your command string and a cron job to read the pipe and execute the string.
    An alternate ugly way is to write to a file and some process reading the file at a regular interval.
    HTH
    Arvind Balaraman

  • Scenario to call c programs from pl/sql

    I know that c routines can be called from Oracle pl/sql. But, I would like to know that anybody has the realtime scenario where it is unavoidable.
    Please let me know if anybody has any specific scenarios.
    Thanks in advance
    Sudhir

    There are numerous scenarios - as Oracle is operating system agnostic (mostly) and do not provide numerous 3rd party interfaces.
    For example, you want to use MAPI (Microsoft's <i>Mail API</i>). You can write a C dll that provides an easy and basic interface into MAPI - and then define this C dll as external procedure that enables you to perform PL/SQL calls to logon to a Microsoft Exchange Server, verify and get users, send mail, enumerate the contents of a mail box's folder, read a mail, and so on.
    Or something more complex. Oracle is used by an application server that provides automated telephonic call centre support. You know - the automated system that answers your support call, asks numerous questions, gets input from you and attempts to troubleshoot your problem. Modern systems like these use speech recognition interfaces - where the caller can (using plain English) state the problem, instead of pushing tone buttons on the phone.
    Such a system will need XML templates defining the speech recognition interface context - these templates with define the basic sentence structures the caller will use, words used, assign values to the words for processing and so on. These XML templates (together with the troubleshooting data and rules) can be stored in Oracle.
    One function needed will be to verify the XML template with the speech recognition system used. Again, this can be done from PL/SQL. When a new template is entered into the database, PL/SQL can make an external proc call to a C dll that interfaces with SAPI v5 (Microsoft's <i>Speech API</i>) to compile the XML template and determine whether it is valid or not.
    There are literally 1000's upon 1000's of such scenarios that requires one to call external services and interfaces from PL/SQL - and the external proc feature of Oracle is often the technical solution that can be used to address the requirement.

  • How to call VB program from PL/SQL ?

    hi, i use oracle8i and i would like to call program VB from Stored procedur or PL/SQL program.
    Is it possible and how?
    thanks

    If you are trying to invoke a WebService, it shouldn't matter what under what platform that WebService compiled or where it is executing, as long as it is on a shared network. That is the very "definition" of a WebService. You should be able to invoke the webservice via TCP sockets, streaming XML message content.
    If your VB WebService isn't, in reality, a WebService and you need to invoke it as an ActiveX dll that is possible with Oracle COM Automation. The 8i/9i data server must be running on the win32 platform that has the ActiveX dll installed. I'm not sure if there is any DCOM possibilities (though I suspect not). In all circumstances, if you data server is running on a non-win32 platform, you are out of luck.
    If you are trying to invoke an ActiveX application (not a dll) from the 8i/9i data server, you are pretty much out of luck, too.
    Hope that helps,
    Michael

  • Calling Java programs from Oracle Stored Procedure

    Is it possible to call Java programs from Oracle stored procs? If possible Can this be used to exchange data from other applications? Is there a better method/feature in oracle for doing data exchange with other apps?

    If what you mean by Oracle stored procedures is pl/sql then yes.
    You can create a "wrapper" this way:
    CREATE OR REPLACE FUNCTION xmlXform
    in_mapUrl IN VARCHAR2,
    in_inputUrl IN VARCHAR2
    RETURN VARCHAR2
    AS
    LANGUAGE JAVA NAME
    'com.yourcompany.xml2any.xform(java.lang.String,java.lang.String)
    RETURN java.lang.String';
    Then load the java as:
    loadjava -user youruser/youruserpasswd -resolve -verbose lib/xmlparserv2.jar classes/com/yourcompany/xform.class classes/com/yourcompany/xml2any.class
    The java, given the correct permissions, can do anything java can do including communicate with outside applications.
    Is this the "best" way... depends on what you are trying to accomplish.

  • Call HOST cmd from PL/SQL Block

    Hi ,
    I'm trying to call the HOST command from stored procedure
    declare
    cmd varchar2(100):='c:\file.bat';
    begin
    execute immediate 'host('c:\file.bat')';
    dbms_output.put_line('Executed');
    end;
    but,It gives an error msg on execute immediate stmt.
    Plz resolve this problem.
    Rgrds,
    Anand

    You are confusing SQL*Plus's command (a client) with that of PL/SQL.
    Just as you cannot code C# commands, or Perl commands, or PHP commands in PL/SQL, you cannot code SQL*Plus commands in PL/SQL.
    SQL*Plus runs on your client platform. It has a couple of commands.
    PL/SQL is a server side programming language. This runs inside the Oracle server process servicing the client.
    This server process does not know your client language commands. Nor can this server process hack across the network, break into your computer, and access your local file called c:\file.bat.
    Yes, you can execute server o/s commands and execute server programs from PL/SQL via a Java stored procedure or via the EXTPROC interface. Refer to the sample code in [url http://forums.oracle.com/forums/thread.jspa?messageID=1439836#1439836]this thread on how to call server o/s commands and server programs.

  • I want to submit a concurrent program from pl/sql. Please help me.

    Dear all,
    I want to submit a concurrent program from pl/sql. But I failed. Please help me.
    Detail:
    I create a concurrent program in 'Cash Management, Vision Operations (USA)' responsibility. <strong>And it be submitted success in EBS</strong>.
    Then
    I create a test script in pl/sql. And use 'FND_GLOBAL.APPS_INITIALIZE' to initialize ebs, then use 'FND_REQUEST.SUBMIT_REQUEST' to submit
    the consurrent program, But the procedure aways return <strong>0</strong>.
    I cannot found the reason. Please help me.Thanks.
    <em>Attached informations may describe the problem:
    1.The concurrenct submitted success in EBS.</em>
    request_id = 4750655 (Sorry, I dont know how to add pictures.)
    <em>2.The initialize informations which from SQL</em>.
    SELECT FCR.REQUESTED_BY USER_ID
    ,FCR.RESPONSIBILITY_ID
    ,FCR.RESPONSIBILITY_APPLICATION_ID
    ,FA.APPLICATION_SHORT_NAME
    ,FCP.CONCURRENT_PROGRAM_NAME
    FROM FND_CONCURRENT_REQUESTS FCR
    ,FND_APPLICATION FA
    ,FND_CONCURRENT_PROGRAMS FCP
    WHERE FCR.PROGRAM_APPLICATION_ID = FA.APPLICATION_ID
    AND FCR.CONCURRENT_PROGRAM_ID = FCP.CONCURRENT_PROGRAM_ID
    AND FCR.REQUEST_ID = 4750655;
    Result: user_id = 1318;
    responsibility_id = 50579;
    application_id = 260;
    application_short_name = 'CE';
    program_short_name = 'CALLK009';
    <em>3.The test script code.</em>
    <p>
    -- Created on 2008/10/22 by ERIC
    declare
    -- Local variables here
    Wv_conc_req_id VARCHAR2(10) DEFAULT NULL;
    BEGIN
    FND_GLOBAL.APPS_INITIALIZE(
    1318
    ,50579
    ,260
    Wv_conc_req_id := FND_REQUEST.SUBMIT_REQUEST(
    'CE'
    ,'CALLK009'
    ,NULL
    ,SYSDATE
    ,FALSE
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    , CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
    DBMS_OUTPUT.PUT_LINE(Wv_conc_req_id);
    COMMIT;
    end;
    <em>4.The concurrent program code.</em>
    create or replace package body CALLTEST is
    PROCEDURE T1(PvO_errbuf OUT VARCHAR2
    ,PvO_retcode OUT VARCHAR2)
    IS
    BEGIN
    FND_FILE.PUT_LINE(fnd_file.log, 'TEST');
    END;
    end CALLTEST;
    </p>

    Can you check from which schema you are executing FND_REQUEST? You can try as follows;
    Connect to your required schema, create a synonym on apps.fnd_request, connect from apps and finally execute grant all on apps.fnd_request to all.
    You can check for relevance from Doc ID: Note:147495.1
    Please do keep in the mind the soultion above should be applied to a test/dev EBS instance first.
    I hope this would be of help.
    Saad

  • Calling a report from pl/sql

    Is it possible to call a report from pl/sql. I want to create a package which when invoked by dbms_jobs will create parameters and then call a report.
    Thanks in advance,
    Mark.

    Mark,
    cf: http://download-uk.oracle.com/docs/cd/B10464_05/bi.904/b13673/pbr_evnt.htm#sthref1477
    Patrick.

  • How to call a program from FM which acts as popup?

    Hi,
    I need to call a program from FM and once the program is called it needs to be opened as a popup. Maybe we need to assign size when we call from FM or do we need to give size in the program it self?
    I know i can either use the Submit command or Call Transaction command. But that it self will open a full screen which i dont want. It needs to be of a smaller size.
    Any help will be appreciated.
    Thanks

    Hi,
    Try this,
    REPORT ZEX_POPUPSCREEN .
    *&  POPUP SCREEN
    * Table Declaration
    TABLES VBAK.
    * Start of Selection
    START-OF-SELECTION.
      SELECT * FROM VBAK.
        WRITE / VBAK-VBELN HOTSPOT ON.
      ENDSELECT.
    * Display the screen
    AT LINE-SELECTION.
      WINDOW STARTING AT 10 10
             ENDING   AT 40 25.
      WRITE:/ 'VBAK-VBELN, VBAK-KUNNR'.
    Regards,
    Nikhil.

  • Problem regarding calling a program from another program

    Hi,
    I have a requirement that i need to call a program from another program and in that case the called program should be executed with a value in the selection screen coming from the first program..i.e.
    a standard report to view the user Notes for annual leave is RPTARQDBVIEW. Can we create a report to display all the users under a manager as a hyperlink and run the report(RPTARQDBVIEW), with the pernr of the employee selected
    Regards,
    saumik

    Submitting a report using ranges for select-options
    * Define range for ltak-tanum
    RANGES: r_tanum FOR ltak-tanum.                                                                               
    * Read values from database tabel into the range
    * These values are later used for select-options in the report
    SELECT * FROM ltak                                                   
      WHERE lgnum =  w_lgnum AND           "Warehouse number/complex    
            vbeln = w_screen1000-io_vbeln.       "Transfer order number
      MOVE ltak-tanum TO r_tanum-low.                                    
      MOVE 'I' TO r_tanum-sign.                                          
      MOVE 'EQ' TO r_tanum-option.                                       
      APPEND r_tanum.                                                    
    ENDSELECT.                                                                               
    * Submit report with range                  
    SUBMIT zmm00100 WITH p_tanum IN r_tanum.   
    or
    Submitting a report from ABAP with selection criterias
      TYPES: tt_selection TYPE STANDARD TABLE OF rsparams.
      DATA: l_iblnr        TYPE st_iblnr,
    *     Define internal table and work area for select-options
            l_selection    TYPE rsparams,
            li_selection   TYPE tt_selection.
    * Create selectIon table
      LOOP AT gi_iblnr INTO l_iblnr.
        CLEAR l_selection.
        l_selection-selname  = 'IM_IBLNR'.    "Option name
        l_selection-kind     = 'S'.           "S= select options P=Parameters
        l_selection-sign     = 'I'.           "Sign
        l_selection-option   = 'EQ'.          "Option
        l_selection-low      = l_iblnr-iblnr. "Value
        APPEND l_selection TO li_selection.
      ENDLOOP.
    * Submit report
      SUBMIT rm07idif WITH SELECTION-TABLE li_selection AND RETURN.
    Regards,
    Prabhudas

  • Error while calling java program from ABAP

    Hi Experts,
    We are trying for RFC inbound scenario.
    We followed the below blog
    /people/gregor.wolf3/blog/2004/08/26/setup-and-test-sap-java-connector-outbound-connection
    We are working with SAP JCO 3.0.2
    We are getting the error : 'STFC_CONNECTION' could not be found in the server repository.
    After I run the Java server program if I execute the RFC destination directly from SM 59 it is showing successful messages.
    If I stop the java program then this RFC is failing. Based on this we concluded that RFC to Java connection is working fine.
    But as mentioned in blog if we call the RFC Destination from ABAP program it is giving the below error,
    'STFC_CONNECTION' could not be found in the server repository.
    If we test the RFC destination using RFC_TRUSTED_CHECK standard FM we are getting the below error.
    'RFCPING' could not be found in the server repository.
    We create the RFC destination of Type : TCP/IP as exactly mention in the blog.
    Please help us in resolving this issue.
    Thanks
    Prince

    Pabi,
    Using the RFC connection,we can establish a link between Java and SAP.
    Afterwards,hope we can call Java program from ABAP.
    Below is the sample piece of code to establish RFC connection(link) between Java and SAP.
    DATA: REQUTEXT LIKE SY-LISEL,
          RESPTEXT LIKE SY-LISEL,
          ECHOTEXT LIKE SY-LISEL.
    DATA: RFCDEST like rfcdes-rfcdest VALUE 'NONE'.
    DATA: RFC_MESS(128).
    REQUTEXT = 'HELLO WORLD'.
    RFCDEST = 'JCOSERVER01'. "corresponds to the destination name defined in the SM59
    CALL FUNCTION 'STFC_CONNECTION'
       DESTINATION RFCDEST
       EXPORTING
         REQUTEXT = REQUTEXT
       IMPORTING
         RESPTEXT = RESPTEXT
         ECHOTEXT = ECHOTEXT
       EXCEPTIONS
         SYSTEM_FAILURE        = 1 MESSAGE RFC_MESS
         COMMUNICATION_FAILURE = 2 MESSAGE RFC_MESS.
    IF SY-SUBRC NE 0.
        WRITE: / 'Call STFC_CONNECTION         SY-SUBRC = ', SY-SUBRC.
        WRITE: / RFC_MESS.
    ENDIF.
    Regards,
    Sree

  • How to call  java program from ABAP

    Hi Experts,
         My requirement is to call java programs from ABAP. For that i have set up SAP JCO connection by using this link http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/739. [original link is broken] [original link is broken] [original link is broken] Connection gets sucessfully. After this how to call java program from ABAP as per our requirement. Please help me out.
      Also i tried this way also.. but while executing the DOS Command line appear & disappear in few seconds. So couldnt see the JAVA output. Please help me out to call java programs in ABAP..
    DATA:command TYPE string VALUE 'D:Javajdk1.6.0_20 injavac',
    parameter TYPE string VALUE 'D:java MyFirstProgram'.
    CALL METHOD cl_gui_frontend_services=>execute
    EXPORTING
    application = command
    parameter = parameter
    OPERATION = 'OPEN'
    EXCEPTIONS
    cntl_error = 1
    error_no_gui = 2
    bad_parameter = 3
    file_not_found = 4
    path_not_found = 5
    file_extension_unknown = 6
    error_execute_failed = 7
    OTHERS = 8.
    Thanks.

    This depends on the version of your Netweaver Java AS. If you are running 7.0, you will have to use the Jco framework. The Jco framework is deprecated since 7.1 though. If you want to build a RFC server in 7.1 or higher, it is adviced that you set it up through JRA.
    Implement an RFC server in 7.0:
    http://help.sap.com/saphelp_nw04/helpdata/en/6a/82343ecc7f892ee10000000a114084/frameset.htm
    Implement an RFC server in 7.1 or higher:
    http://help.sap.com/saphelp_nwce72/helpdata/en/43/fd063b1f497063e10000000a1553f6/frameset.htm

Maybe you are looking for

  • Downloaded new version of iTunes, more than half of library disappeared.  Can I get it back??

    We haven't used the iTouch in a few months, and it's probably close to a year since I've downloaded anything from the iTunes Store.  Today, when I opened iTunes on my computer it stated that a new version was available for download.  I downloaded it.

  • Dba_index_name and dba_ind_columns showing different results

    Hi All, I am confused why it is showing different results: [email protected]#>select index_name from dba_indexes where table_name='CRBTPROV_FINAL'; INDEX_NAME CRBTPROV_INDX1 [email protected]#>select index_name from dba_IND_COLUMNS where table_name='

  • Plays in Win Media Player, but won't import in iTunes

    I have some quite large MP3 files that play fine in Windows Media Player, but I iTunes won't import them. What could be reason for that? TIA Gert iTunes 6 Windows XP iTunes 6   Windows XP  

  • Look & Feel of Applet

    I have a static initializer in my Applet: public class ObjectEditApplet extends JApplet implements ActionListener { static { try { UIManager.setLookAndFeel (UIManager.getSystemLookAndFeelClassName()); }catch(Exception e) { Do something... It shows al

  • Help about the definition of new task.

    Hi, I can start successfully a Bex Query via FM abap4_call_transaction but I see two queries defining this call: CALL FUNCTION 'ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'ZTRX' EXPORTING TCODE = 'ZTRX' EXCEPTIONS TCODE_INVALID = 1 OTHERS = 2. My test