Calling flex functions from flash swf (AS3)

Hi all, i'm stuck with communication between loaded AS3 SWF
from Flash and Flex3 project. I use SWFLoader for runtime loading
SWF, call functions inside SWF, but cannot find the way to call
functions declared in Flex project. I try to use ExternalInterface
class, but it does not help me, or maybe i use it incorrect. Is
there a method to call Flex user declared functions from Flash SWF?
All i need is a syntax sample, thank you in advance!

Also, application.application will point to the top-level app
scope, even from a loaded swf.
I believe parentApplication will resolve to what you usually
want as well.
For looser coupling, consider using a bubbling event.
Tracy

Similar Messages

  • Calling Flex function from loaded SWF

    Hello,
    I need to load an external SWF file, wity ability to call functions from the base FLEX code script .
    Is that possible ? noting that the loaded SWF can be either in AS2 or AS3
    Thanks in advance ..

    There are some third party ways of talking to an as2 swf.  Google
    as2interface (or maybe as3interface)

  • How to Call a function from FMS to AS3

    Hi,
    I am using Windows operating system, Flash CS3 and FMS 3.5.
    I am new to Action Script 3.0 But I am good in Action Script 2.0.
    I am trying to call a function declared in Action Script 3.0
    from FMS. here I have declared it as follows.
    In FMS I am calling a function as
    application.onConnect(client){
    client.call("informServer");
    In Flash AS 3 I have declared this function as follows.
    var nc = new NetConnection();
    // Now here I declare function
    nc.addEventListener("informServer", informServerHandler);
    nc.connect("rtmp://localhost/abc");
    private function informServerHandler(evt){
    trace(" Till here Done ");
    So When I execute Flash file then it connects to FMS and also
    in NetStatus event of NetConnection I got Connected.
    But Then I got Error in Flash as
    Error #2095: flash.net.NetConnection was unable to invoke
    callback informServer." error=ReferenceError: Error #1069: Property
    informServer not found on flash.net.NetConnection and there is no
    default value.]
    Please tell me Have I not declared the Function in AS 3
    properly or I am doing something wrong. Please Some one help me...
    Thanks in advance.

    You can't add an event listener, as your custom method is not
    a method of the NetConnection class. Instead, you can assign
    methods to the NetConnection's client property:
    nc.client.informServer = function(){
    // do something
    If you want to just define your functions in a class, you can
    make the class the value of nc.client:
    class blah{
    function blah(){
    var nc:NetConnection = new NetConnection()
    nc.client=this;
    //connect, status listener, etc
    private function informServer(){
    // Now this function is invoked, since the class is the
    NetConnection's client.
    }

  • Getting Error while calling Flex function from JavaScript

    Hi,
    I have an aspx page, which shows charts as per dropdown selection,
    I am using flex charts for flex.In aspx page, i am calling an mxml function using javascript.below is the code for javascript in aspx.
    Javascript  code in aspx page:
    <script type="text/javascript">     
    function callApp(formid) {
        try {
                var objectChart = document.getElementById("statisticsChart");
                alert(objectChart.id);               
                objectChart.myFlexFunction(formid,get('<%=HiddenDashboardWS.ClientID %>').value);
        catch (e) {
            alert(e.message);
    function getDropDownListvalue() {
        var IndexValue = $get('<%=FormDropDownList.ClientID %>').selectedIndex;
        var SelectedVal = $get('<%=FormDropDownList.ClientID %>').options[IndexValue].value;
        //  alert(SelectedVal);
        callApp(SelectedVal);
    </script>
    Html code where dropdown control is placed
    <asp:DropDownList CssClass="combo" ID="FormDropDownList" runat="server" AutoPostBack="false"></asp:DropDownList>
    <object id="statisticsChart" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
    height="220" width="680">
        <param name="src" value="../swf/DashboardStatisticChart.swf" />
        <param name="flashVars" value="" />
        <embed name="statisticsChart" src="../swf/DashboardStatisticChart.swf" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" height="220" width="680" flashvars=""></embed>
    </object>
    Mxml code:
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  backgroundColor="white" creationComplete="initApp();" >
    <mx:script>
      public function initApp():void {
    ExternalInterface.addCallback("myFlexFunction",myFunc);
      public function myFunc(s:String,wsurl:String):void {
         Formid.text = s;
         webService.wsdl = wsurl;
         Alert.show("webservice");
    //Getdata calls webservice and gets xml data    
    GetData();
    //showchart() will draw chart
                     ShowChart();
    </mx:script>
    </mx:Application>
    Above code works perfect in ie, but in firefox, it gives An error saying “chartObject.MyFlexFunction is not a function”.
    I am getting the object in javascript in all the browsers, but not the functions!
    Does anyone has worked with this?
    Any help will be highly appreciated.
    Regards,
    Nirav Patel

    Found the solution from here... http://74.125.153.132/search?q=cache:4BC9BY04B5EJ:livedocs.adobe.com/flash/8/main/00002201 .html+externalinterface.addcallback+not+working&cd=1&hl=en&ct=clnk&gl=in
    Hope it will help others...
    Regards,

  • Calling Flex function from javascripty for window.close

    Using a set up in my ActionScript of:
    ExternalInterface.addCallback("tagWithClosed",windowClosed);
    How can I write a JavaScript function that calls
    'tagWithClosed' to Flex when the user closes the window
    (window.close() )?

    Tried something like this:
    <SCRIPT LANGUAGE="JavaScript">
    window.onbeforeunload = closingWindow;
    function closingWindow()
    FXVideo.tagWithClosed();
    </SCRIPT>
    Didn't work though.
    My swf is called FXVideo.swf. Is calling the
    FXVideo,tagWithClosed correct or should be something else?

  • Trying to call a function from a variable in Flex 4.0 ActionScript and need some suggestions

    I am attempting to build a site map in Flex. I have my links (or will have) in a database, along with a "link." On click from a datagrid, I have an event handler where I can get the link. However, everything I have tried to use won't call the function. Ideally, I would like to call a function from from my topLevel application, and I can do that using the mx.core.FlexGlobals.topLevelApplication call. Can anyone point a fairly new Flex coder in the right direction? Thank you.

    Here is the function on the group component (simplified): -- I got this from one of my google searches. The other was using the SWFLoader, but since this is in the same application, I didn't think it was as relevant. Plus, the SWFLoader used some references that I couldn't resolve.
    private function site_click(event:ListEvent):void {
      var sURL:String=list.dataProvider[event.rowIndex].link;
       var sCommand:String="mx.core.FlexGlobals.topLevelApplication." + sURL;
       this.[sCommand]();
    This yields the error message ReferenceError: Error #1059: Property mx.core.FlexGlobals.topLevelApplication.myths_click() not found on sitemap and there is no default value.
    Whereas this works fine:
    mx.core.FlexGlobals.topLevelApplication.myths_click();
    sitemap is my component name.

  • Calling javascript function to open SWF

    When the Captivate presentation ends, I'm trying to open
    another SWF in the same browser window.
    I have put the following code in the HTML document:
    <script type="text/javascript">
    <!--
    function changeMovie(filename)
    document.getElementById('Captivate1').movie=filename;
    alert(document.getElementById('Captivate1').movie);
    //-->
    </script>
    I am able to call the function from the Captivate file
    successfully because the alert window pops up with the name of the
    movie. I just can't get it to play. Can anyone help me on this?
    Not to be rude or anything, but I should note that:
    1) this is not my idea--it is my boss' idea, and any attempts
    to tell me that this is something not worth doing will
    unfortunately fall, not on deaf ears, but on ears connected to
    hands that have no freedom to choose how this project is completed.
    This is my master's bidding, and I must do what he says.
    2) I know very little JavaScript. This code was given to me
    by another guy on the project. So if you have advice for changing
    the code, please be as specific as possible.
    I would be very grateful for any help that you can
    offer.

    Two non javascript methods:
    Movie End Options -> Action ->> Open URL or file
    Button -> On Success ->> Open URL or file
    A method to load a new movie without completly reloading the
    page.
    1. Create two 200x200 movies - m1 and m2 - add some content.
    2. Create a button in m1 set Exectue Javascript ->>
    loadMovie('m2.htm');
    3. Publish html and swfs to the same folder.
    4. Open m1.htm and replace all the code with the following
    (up to and including </html>):
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8">
    <title>m1</title>
    <script type="text/javascript">
    var xmlHttp
    function loadMovie(url)
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    alert ("Browser does not support HTTP Request")
    return
    xmlHttp.onreadystatechange=stateChanged
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    function stateChanged()
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    document.getElementById("movieContainer").innerHTML=xmlHttp.responseText
    function GetXmlHttpObject()
    var objXMLHttp=null
    if (window.XMLHttpRequest)
    objXMLHttp=new XMLHttpRequest()
    else if (window.ActiveXObject)
    objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    return objXMLHttp
    </script>
    </head>
    <body>
    <div id="movieContainer">
    <!-- captivate generated code -->
    <object
    classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="
    http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
    width="200" height="200" id="Captivate1" align="middle">
    <param name="allowScriptAccess" value="sameDomain">
    <param name="movie" value="m1.swf">
    <param name="quality" value="high">
    <param name="menu" value="false">
    <param name="loop" value="0">
    <param name="bgcolor" value="#f3f3f3">
    <embed src="m1.swf" name="Captivate1" quality="high"
    bgcolor="#f3f3f3" width="200" height="200" name="menu"
    align="middle" allowScriptAccess="sameDomain" loop="0"
    type="application/x-shockwave-flash" menu="false" pluginspage="
    http://www.macromedia.com/go/getflashplayer">
    </object>
    <!-- end Captivate code -->
    </div>
    </body>
    </html>
    5. Open m2.htm and replace the code with the following:
    <!-- Captivate generated code -->
    <object
    classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="
    http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
    width="200" height="200" id="Captivate1" align="middle">
    <param name="allowScriptAccess" value="sameDomain">
    <param name="movie" value="m2.swf">
    <param name="quality" value="high">
    <param name="menu" value="false">
    <param name="loop" value="0">
    <param name="bgcolor" value="#f3f3f3">
    <embed src="m2.swf" name="Captivate1" quality="high"
    bgcolor="#f3f3f3" width="200" height="200" name="menu"
    align="middle" allowScriptAccess="sameDomain" loop="0"
    type="application/x-shockwave-flash" menu="false" pluginspage="
    http://www.macromedia.com/go/getflashplayer">
    </object>
    <!-- end Captivate generated code -->
    6. Open m1.htm in you browser, click the button to load m2
    How it works:
    Simply put AJAX lets you load parts of an html file in the
    current window. The code to be replaced is within the div
    id="movieContainer". The code in the file you want to load should
    be only the code you need, not an entire HTML file.
    Call it from Captivate with loadMovie('URL') where URL is the
    name of the html file.

  • How do I call a function from an Itemrenderer?

    Hi, Im new in flex and I wonder if I can call a function from within an AdvancedDataGridRendererProvider
    for example:
      <mx:AdvancedDataGrid>
        <mx:columns>
            <mx:AdvancedDataGridColumn  dataField="id" />
        </mx:columns>  
        <mx:rendererProviders> 
            <mx:AdvancedDataGridRendererProvider 
                dataField="detail"
                renderer="components.myRendererProvider"  
                columnIndex="2" 
                depth="2"                     
                />     
        </mx:rendererProviders>       
      </mx:AdvancedDataGrid>
    <mx:Script>
         <![CDATA[
              public function outerFunction(){
        ]]>
    </mx:Script>
    myRendererProvider
    <?xml version="1.0" encoding="utf-8"?>
    <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" paddingLeft="10" paddingRight="2" horizontalGap="2" paddingTop="0">
    <mx:Script>
        <![CDATA[   
         public function callOuterFunction( ){
              how do I call the outerFunction() from here?
        ]]>
    </mx:Script>
        <mx:LinkButton fontSize="13"  fontWeight="bold" click="callOuterFunction( )" label="label"  />
    </mx:HBox>
    thank you in advance.

    There are two ways to call a function from within an ItemRenderer. One way is to dispatch an event from your ItemRenderer and listen for the event in your main application. This approach has the advantage of creating loosely coupled code which is eaiser to maintain and extend if needed, but it takes a bit more work to set things up than using the second aproach lised below. You could also create a custom event to have greater control over what data is sent with the event.
    private function callOuter():void {
         this.dispatchEvent(new MouseEvent());
    The other approach is to call the main application by using parentDocument.
    private function callOuter():void {
         parentDocument.handleItemRenderer();
    Chris

  • Calling a function from a DLL, exectution in background mode.

    Dear Experts,
    We have created an ABAP report the calls a function from a DLL file. If the report is executed in on-line mode the program calls and executes the function from the DLL, but if the ABAP programa is executed in background mode it doesnt calls the DLL function.
    Do you know a way to solve the problem when executing in background mode?
    Best regards.
    Antonio

    Hi Gabriel,
    Let me explain in details about my DLL function.
    We are importing the business partners from legacy system into the SAP CRM system, so at the moment we created the BP master data via BAPI, I get the name of the BP and this moment I call the function in the DLL file. I export the parameter name and I receive back a simplified string with the name reduced to a code. This code I get back from the dll it is insert in a Z table, so there is no interaction in the screen, all must be executed in background mode, because there are a lot of business partners to be converted in SAP system.
    I am sending my code for your considerations.
    Instancia a DLL
      CREATE OBJECT dll 'MTCODE.CPFONET'.
      IF sy-subrc NE 0.
        RAISE without_dll.
      ENDIF.
    Move para a tabela interna IT_NAME os valores recebidos na TI_NAME
      it_name[] = ti_name[].
    Para cada registro importado
      LOOP AT it_name.
        CLEAR v_string_ret.
        wa_matchcode-zregid     = it_name-zregid.
        wa_matchcode-name1_text = it_name-name1_text.
        v_string = it_name-name1_text.
        CONDENSE  v_string.
        TRANSLATE v_string TO UPPER CASE.
        CALL METHOD  OF dll 'SetNome' EXPORTING #1 = v_string.
        CALL METHOD  OF dll 'ExecMatch'.
        CALL METHOD  OF DLL 'GetMCData' = v_string_ret.
        FREE OBJECT dll.
      Preenche os campos do match-code de acordo com o retorno da DLL
        SPLIT v_string_ret
        AT '|'
        INTO wa_matchcode-zparmcln
             wa_matchcode-zparmcfn
             v_empty
             wa_matchcode-name_first
             wa_matchcode-name_last
             wa_matchcode-namemiddle.
      Adiciona o registro com o match-code correspondente na TE_MATCHCODE
        APPEND wa_matchcode TO te_matchcode.
      ENDLOOP.

  • How can I call a function from a procedure

    I have a function named: f_calc_value which return the variable v_result. This function is part of a package.
    How can I call this function from a new procedure I am creating?
    Thanks

    or refer this theread....calling function from procedure

  • Can I call a function from a dll in LabVIEW that returns:double*string and int.?

    I have a function from a dll that return a double* string and an integer. How can I call this function from LabVIEW? There is a possibility to work in LabVIEW with a double* string?

    pcbv wrote:
    > Hello all,<br><br>The header of the function is:
    >
    > "HRESULT WRAPIEnumerateDevices(WRAPI_NDIS_DEVICE **ppDeviceList, long *plItems);"
    >
    > where WRAPI_NDIS_DEVICE have this form:
    >
    > typedef struct WRAPI_NDIS_DEVICE<br>{<br>
    > WCHAR *pDeviceName;<br>
    > WCHAR *pDeviceDescription;<br><br>}
    > WRAPI_NDIS_DEVICE;<br><br>
    >
    > The function is from WRAPI.dll, used for communication with wireless card.
    > For my application I need to call in LabVIEW this function.
    Two difficulties I can see with this.
    First the application seems to allocate the array of references
    internally and return a pointer to that array. In that case there must
    be another function which then deallocates that array again.
    Then you would need to setup the function call to have a pointer to an
    int32 number for the deviceList parameter and another pointer to int32
    one for the plItems parameter.
    Then create another function in your DLL similar to this:
    HRESULT WRAPIEnumExtractDevice(WRAPI_NDIS_DEVICE *lpDeviceList, long i,
    CHAR lpszDeviceName, LONG lenDeviceName,
    CHAR lpszDeviceDesc, LONG lenDeviceDesc)
    if (!lpDeviceList)
    return ERROR_INV_PARAMETER;
    if (lpDeviceList[i].pDeviceName)
    WideCharToMultiByte(CP_ACP, 0,
    pDeviceList[i].pDeviceName, -1,
    lpszDeviceName, lenDeviceName,
    NULL, NULL);
    if (lpDeviceList[i].pDeviceName)
    WideCharToMultiByte(CP_ACP, 0,
    pDeviceList[i].pDeviceDescription, -1,
    lpszDeviceDesc, lenDeviceDesc,
    NULL, NULL);
    return NO_ERROR;
    Pass the int32 you got from the first parameter of the previous call as
    a simple int32 passed by value to this function (and make sure you don't
    call this function with a higher index than (plItems - 1) returned from
    the first function.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to call javascript function from PL/SQL procedure

    Can anybody advice me how to call javascript function from PL/SQL procedure in APEX?

    Hi,
    I have a requirement to call Javascript function inside a After Submit Process.
    clear requirement below:
    1. User selects set of check boxes [ say user want to save 10 files and ticks 10 checkboxes]
    2. user clicks on "save files" button
    3. Inside a After submit process, in a loop, i want to call a javascript function for each of the file user want to save with the filename as a parameter.
    Hope this clarify U.
    Krishna.

  • Calling user function from Interface mapping

    I am getting error "Bad query:ORA-00904: invalid identifier" while calling function in the mapping of an interface.
    Can some one provide the syntax of calling user function from interface mapping.
    Thanks,
    RP

    user452108 wrote:
    Can some one provide the syntax of calling user function from interface mapping.Oracle's Call Iinterface, the OCI, does not work differently when coding using a Dvorak keyboard, or writing code using a pretty pink font in the editor.. or coding the call from an interface mapping (whatever the hell that that is).
    You have 2 types of calls. SQL and PL/SQL.
    To call a function via SQL, it can be done using a the standard cursor interface. E.g.
    select MyFunkyFunction from dualIt will return the function value via a single row with a single column. The standard cursor fetch and close cursor calls are used.
    To call it via PL/SQL, an anonymous PL/SQL block is needed, and the caller needs to use a bind variable to receive the value from the function. The anon block will look as follows:
    begin
      :bindVar := MyFunkyFunction;
    end;Refer to your client's abstract layer for interfacing with the Oracle Call Interface, on how to deal with bind variables.

  • How to call oracle function from ejb3

    i'm trying to call an oracle query-function from ejb3.
    The oracle function:
    create or replace FUNCTION getSecThreadCount(secId in NUMBER,avai in NUMBER)
    RETURN SYS_REFCURSOR is cur SYS_REFCURSOR;
    m_sql VARCHAR2(250);
    BEGIN
    m_sql:='select count(thrId) from thread where secId='|| secid||'
    and thrAvai='|| avai;
    open cur for m_sql;
    return cur;
    END;
    I'v tried several ways to call it,but all failed:
    1. the calling code:
    public Object getSectionThreadCount(int secId,int avai){
              Query query=manager.createNativeQuery("{call getSecThreadCount(?,?) }");     
              query.setParameter(1, secId);
              query.setParameter(2, avai);
              return query.getSingleResult();
    but i got the exception:
    Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    Caused by: java.sql.SQLException: ORA-06550: row 1, col 7:
    PLS-00221: 'GETSECTHREADCOUNT' not procedure or not defined
    ORA-06550: row 1, col 7:
    PL/SQL: Statement ignored
    2. the calling code:
    @SqlResultSetMapping(name = "getSecThreadCount_Mapping")
    @NamedNativeQuery(name = "getSecThreadCount",
    query = "{?=call getSecThreadCount(:secId,:avai)}",
    resultSetMapping = "getSecThreadCount_Mapping",
    hints = {@QueryHint(name = "org.hibernate.callable", value = "true"),
              @QueryHint(name = "org.hibernate.readOnly", value = "true")})
    public Object getSectionThreadCount(int secId,int avai){
              Query query=manager.createNamedQuery("getSecThreadCount");     
              query.setParameter("secId", secId);
              query.setParameter("avai", avai);
              return query.getSingleResult();
    but i run into the exception:
    Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    Caused by: java.sql.SQLException: lost in index IN or OUT parameter:: 3
    By the way, i have successfully called the function from hibernate. And i use oracle 11g, JBoss5 RC1.
    Could anyone tell me how to call the function from EJB3?
    Thanks.

    Here's a working model:
    package.procedure: (created in example schema scott)
    CREATE OR REPLACE package  body data_pkg as
      type c_refcursor is ref cursor;
      -- function that return all emps of a certain dept
      function getEmployees ( p_deptId in number
      return c_refcursor
      is
        l_refcursor c_refcursor;
      begin
         open l_refcursor
        for
              select e.empno as emp_id
              ,        e.ename as emp_name
              ,        e.job   as emp_job
              ,        e.hiredate as emp_hiredate
              from   emp e
              where  e.DEPTNO = p_deptId;
        return l_refcursor;
      end getEmployees;
    end data_pkg;
    /entity class:
    package net.app.entity;
    import java.io.Serializable;
    import java.util.Date;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.NamedNativeQuery;
    import javax.persistence.QueryHint;
    import javax.persistence.SequenceGenerator;
    import javax.persistence.Table;
    @SuppressWarnings("serial")
    @Entity
    @Table (name="emp")
    @SequenceGenerator(name = "EmployeeSequence", sequenceName = "emp_seq")
    @NamedNativeQuery( name = "getEmpsByDeptId"
                   , query = "{ ? = call data_pkg.getEmployees(?)}"
                   , resultClass = Employee.class
                   , hints = { @QueryHint(name = "org.hibernate.callable", value = "true")
                          , @QueryHint(name = "org.hibernate.readOnly", value = "true")
    public class Employee implements Serializable
        @Id
        @Column(name="emp_id")
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EmployeeSequence")
        private int id;
        @Column(name="emp_name")
        private String name;
        @Column(name="emp_job")
        private String job;
        @Column(name="emp_hiredate")
        private Date hiredate;
        // constructor
        public Employee (){}
        // getters and setters
        public int getId()
         return id;
    etc...session bean:
    package net.app.entity;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    import net.app.entity.Employee;
    import net.app.iface.ScottAdmin;
    @Stateless
    public class ScottAdminImpl implements ScottAdmin
        @PersistenceContext
        private EntityManager entityManager;
        @SuppressWarnings("unchecked")
        public List<Employee> getEmployeesByDeptId(int deptId)
         ArrayList<Employee> empList;
         try
             Query query = entityManager.createNamedQuery("getEmpsByDeptId");
             query.setParameter(1, deptId);
             empList = (ArrayList<Employee>) query.getResultList();
             return empList;
         catch (Exception e)
             e.printStackTrace(System.out);
             return null;
    }client:
    package net.app.client;
    import java.util.List;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import net.app.entity.Employee;
    import net.app.iface.ScottAdmin;
    public class ScottClient
        public static void main(String[] args)
         try
             // create local interface
             InitialContext ctx = new InitialContext();
             ScottAdmin adminInterface = (ScottAdmin) ctx.lookup("ScottAdminImpl/remote");
             // select employees by deptno
             int deptno = 20;
             List<Employee> empList = adminInterface.getEmployeesByDeptId(deptno);
             // output
             System.out.println("Listing employees:");
             for (Employee emp : empList)
              System.out.println(emp.getId() + ": " + emp.getName() + ", " + emp.getJob() + ", " + emp.getHiredate());
         catch (NamingException e)
             e.printStackTrace(System.out);
    }Basically you just ignore the refcursor outbound parameter.
    This is a stored function, have yet to try outbound refcursor parameters in stored procedures...
    Edited by: _Locutus on Apr 2, 2009 2:37 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Calling a function from SQL prompt that returns a record

    Hi,
    I've been trying to execute a function that is present on a different database. for eg. I am loged on to a database say 'A' and trying to execute a function present in database 'B'. this function is present in a package 'X' which has 2 functions and two procedures. From the packages i am able to execute the two procedures and one of the function.
    So i guess it is not a problem with the access permissions. The function that i am trying to call say function I has got 3 OUT
    parameters and 1 IN parameter. the Function returns a record. When i try to execute this function i get an error. Can you please let me know as to how exactly i need to call this function from the SQL prompt...
    thanx in advance
    null

    Hi Anand,
    As your function has 3 OUT parameters and it returns a record you can not just call it from SQL Plus. You need to write small PL/SQL program and use variables to hold the OUT values and the returned record.
    Good Luck,
    RajKiran
    null

Maybe you are looking for

  • AfContext.launchDialog not working with upgrade to 11.1.1.2.0

    I recently upgraded my project to latest version and now some code stopped working correctly...here is the code which is suppose to show a new dialog via backing bean (there is code setting a bunch of parameters dynamically and why I'm using backing

  • M2A_DBLINK and A2M_DBLINK in oracle apps ASCP

    what is the use of the M2A_DBLINK and A2M_DBLINK. why do we use it ? how do we set up these db links and on which instance. and how do you see the data flow from ASCP2OLTP during data pull from ERP and data load to ASCP instance. Thanks & regards, Kr

  • Publish an InDesign file as a SCORM package

    What is the fastest/easiest way to take an InDesign file and publish it as a SCORM package that can be loaded to our LMS as a reference book?  I don't have/need interactions - I just want the LMS to track which users opened/viewed the file.  I need a

  • Method for backing up connection data?

    I am moving to a new workstation. I need a way to back up my connection data, because I manage multiple sites using Contribute and it's a pain to reestablish the dialing directory. Contribute does not appear to have an easy "export connections direct

  • I keep getting this error and it keeps shutting down my computer, does anyone know what it is?

    Interval Since Last Panic Report:  66618 sec Panics Since Last Report:          20 Anonymous UUID:                    1058C204-08BC-45BD-BAF4-8FF9D4972CE2 Sat Sep 22 19:48:57 2012 panic(cpu 0 caller 0xffffff80002c473a): Kernel trap at 0xffffff800055a