How to call a function in one .js file from another .js file

Hello Techies,
I am trying to call a function in two.js file from one.js file.
Here is my code
one.js
<script>
document.write("<script type='text/javascript' src='/htmls/js/two.js'> <\/script>");
     function one()
                    var a;
                   two(a);
          }two.js
              function two(a)
                      alert("two");
                  }But the function two() is not working.
How can I do this one??
regards,
Krish

I think there is a syntax error in line
document.write("<script type='text/javascript' src='/htmls/js/two.js'> <\/script>");
end tag <\/script> is wrong.

Similar Messages

  • How to call inner class method in one java file from another java file?

    hello guyz, i m tryin to access an inner class method defined in one class from another class... i m posting the code too wit error. plz help me out.
    // test1.java
    public class test1
         public test1()
              test t = new test();
         public class test
              test()
              public int geti()
                   int i=10;
                   return i;
    // test2.java
    class test2
         public static void main(String[] args)
              test1 t1 = new test1();
              System.out.println(t1.t.i);
    i m getting error as
    test2.java:7: cannot resolve symbol
    symbol : variable t
    location: class test1
              System.out.println(t1.t.geti());
    ^

    There are various ways to define and use nested classes. Here is a common pattern. The inner class is private but implements an interface visible to the client. The enclosing class provides a factory method to create instances of the inner class.
    interface I {
        void method();
    class Outer {
        private String name;
        public Outer(String name) {
            this.name = name;
        public I createInner() {
            return new Inner();
        private class Inner implements I {
            public void method() {
                System.out.format("Enclosing object's name is %s%n", name);
    public class Demo {
        public static void main(String[] args) {
            Outer outer = new Outer("Otto");
            I junior = outer.createInner();
            junior.method();
    }

  • How to call a specific method in a servlet from another servlet

    Hi peeps, this post is kinda linked to my other thread but more direct !!
    I need to call a method from another servlet and retrieve info/objects from that method and manipulate them in the originating servlet .... how can I do it ?
    Assume the originating servlet is called Control and the servlet/method I want to access is DAO/login.
    I can create an object of the DAO class, say newDAO, and access the login method by newDAO.login(username, password). Then how do I get the returned info from the DAO ??
    Can I use the RequestDispatcher to INCLUDE the call to the DAO class method "login" ???
    Cheers
    Kevin

    Thanks for the reply.
    So if I have a method in my DAO class called login() and I want to call it from my control servlet, what would the syntax be ?
    getrequestdispatcher.include(newDAO.login())
    where newDAO is an instance of the class DAO, would that be correct ?? I'd simply pass the request object as a parameter in the login method and to retrieve the results of login() the requestdispatcher.include method will return whatever I set as an attribute to the request object, do I have that right ?!!!!
    Kevin

  • How to call c functions that expects c structs from java program?

    i need to call from my java program to c functions that get
    c structs as a parameters in their prototype.
    as you probablly know java is not working with structs (classes only), so my question is how can i do it , i mean call the c functions that gets structs as parameters form java????

    i believe your c function can accept a jobject and then inside your c function you have to translate that jobject into a c struct by using the jni methods.
    the only reason your c function cant accept structs from java is because java does not have such structures. your c function can accept any data type that has been defined and a jobject has been defined.
    if you have no control over the c functions that are being called, you need to write a wrapper function for those c function. the wrapper functions do the translation from jobject to a struct...then call the c other c functions.

  • How to call a static method of a class from another class?

    Hello,
    I have two classes in a package. The first one
    package my package;
    public class class1
    protected static ImageIcon createIcon(String path)
    The second one
    package my package;
    public class class2
    private ImageIcon image1;
    image1 = class1.createIcon("/mypath");
    This does not work since class2 cannot load the appropriate image. Where do I have to define the ImageIcon variables in class one or two and do they have to be static variables?
    Thanks in advance
    Christos

    If the two classes are in the same package, that will work, in fact. A trivial example:
    package foo;
    public class Foo1 {
         protected static String getString() {
              return "World";
    // Note: Member of the same package
    package foo;
    public class Foo2 {
         public static void main(String[] argv) {
              System.out.println("Hello "+ foo.Foo1.getString());
    }However, if they are in different packages that won't work - the protected keyword guarantees that only classes derived from the class with the protected method can access it: Therefore this will not work:
    package foo;
    public class Foo1 {
         protected static String getString() {
              return "World";
    package foo.bar;
    public class Foo2{
         public static void main(String[] argv) {
              System.out.println("Hello "+ foo.Foo1.getString());
    }But this will:
    package foo;
    public class Foo1 {
         protected static String getString() {
              return "World";
    package foo.bar;
    public class Foo2 extends foo.Foo1 {
         public static void main(String[] argv) {
              System.out.println("Hello "+ foo.Foo1.getString());
    }I think you should read up a bit more about packages and inheritance, because you're going to have a lot of trouble without a good understanding of both. Try simple examples first, like the above, and if you hit problems try to produce a simple test case to help you understand the problem rather than trying to debug your whole application.
    Dave.

  • Setting JTree in one class file from another class file

    Hello,
    I'm new to java. I recently created a project in netbeans and here is one of the java files. I used the IDE to make a split pane, with a tree structure and panel in it.
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * AmplifierDesignGUI.java
    * Created on Jun 20, 2010, 1:18:52 PM
    package AmplifierDesign;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    * @author Bugz
    public class AmplifierDesignGUI extends javax.swing.JFrame {
    /** Creates new form AmplifierDesignGUI */
    public AmplifierDesignGUI() {
    initComponents();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
    jSplitPane1 = new javax.swing.JSplitPane();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTree1 = new javax.swing.JTree();
    jPanel1 = new javax.swing.JPanel();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenu2 = new javax.swing.JMenu();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jScrollPane1.setViewportView(jTree1);
    jSplitPane1.setLeftComponent(jScrollPane1);
    org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
    jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(0, 475, Short.MAX_VALUE)
    jPanel1Layout.setVerticalGroup(
    jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(0, 274, Short.MAX_VALUE)
    jSplitPane1.setRightComponent(jPanel1);
    jMenu1.setText("File");
    jMenuBar1.add(jMenu1);
    jMenu2.setText("Edit");
    jMenuBar1.add(jMenu2);
    setJMenuBar(jMenuBar1);
    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(layout.createSequentialGroup()
    .add(8, 8, 8)
    .add(jSplitPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 571, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(32, Short.MAX_VALUE))
    layout.setVerticalGroup(
    layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(layout.createSequentialGroup()
    .add(8, 8, 8)
    .add(jSplitPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 278, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    pack();
    }// </editor-fold>
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new AmplifierDesignGUI().setVisible(true);
    try {
    new JTreeStructure().setVisible(true);
    } catch (Exception ex) {
    Logger.getLogger(AmplifierDesignGUI.class.getName()).log(Level.SEVERE, null, ex);
    // Variables declaration - do not modify
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JTree jTree1;
    // End of variables declaration
    So once this was done I wanted to link the JTree to a mysql database. So I found a sample .java file on the net:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package AmplifierDesign;
    import java.awt.*;
    import java.sql.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    public class JTreeStructure extends JFrame {
    Connection con = null;
    Statement st = null;
    ResultSet rs = null;
    //public static void main(String args[]) throws Exception {
    // new JTreeStructure();
    public JTreeStructure() throws Exception {
    super("Retrieving data from database ");
    String driver = "com.mysql.jdbc.Driver";
    String url = "jdbc:mysql://localhost:8889/";
    String db = "icons";
    ArrayList list = new ArrayList();
    list.add("Laser Objects");
    Class.forName(driver);
    con = DriverManager.getConnection(url + db, "root", "root");
    try {
    String sql = "Select * from fiberComponents";
    st = con.createStatement();
    rs = st.executeQuery(sql);
    while (rs.next()) {
    Object value[] = {"Fiber Components",rs.getString(2) };
    list.add(value);
    } catch (Exception e) {
    System.out.println(e);
    rs.close();
    st.close();
    con.close();
    Object hierarchy[] = list.toArray();
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    DefaultMutableTreeNode root = processHierarchy(hierarchy);
    JTree tree = new JTree(root);
    content.add(new JScrollPane(tree), BorderLayout.CENTER);
    setSize(275, 300);
    setLocation(300, 100);
    setVisible(true);
    private DefaultMutableTreeNode processHierarchy(Object[] hierarchy) {
    DefaultMutableTreeNode node = new DefaultMutableTreeNode(hierarchy[0]);
    DefaultMutableTreeNode child;
    for (int i = 1; i < hierarchy.length; i++) {
    Object nodeSpecifier = hierarchy;
    if (nodeSpecifier instanceof Object[]) // Ie node with children
    child = processHierarchy((Object[]) nodeSpecifier);
    } else {
    child = new DefaultMutableTreeNode(nodeSpecifier); // Ie Leaf
    node.add(child);
    return (node);
    The problem is when I run my program two windows open up. The original one with JTree1, and the panel and horizontal splitplane and another window with a new tree component that did get its objects from the database. My question is how do I "replace" the JTree1 with the new tree created from the second java file?
    Or additionally, maybe I could set the data for JTree1 from within the second java file?

    zmoddynamics wrote:
    ....Please excuse my post as I am not sure what is meant by code tags?To use code tags, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.
    Another way to do this is to manually place the tags into your code by placing the tag [cod&#101;] above your pasted code and the tag [cod&#101;] below your pasted code like so:
    [cod&#101;]
      // your code goes here
      // notice how the top and bottom tags are different
    [/cod&#101;]Luck.

  • How can call a function module(RFC)in one server to another sever in my rep

    How can call a function module(RFC)in one server to another sever in my report program.
    What i am know whenever rfc enabled immediately radio button checks then only it will come.
    please justify.

    Syntax
    CALL FUNCTION func DESTINATION dest [EXPORTING p1 = a1 p2 = a2 ...]
    [IMPORTING p1 = a1 p2 = a2 ...]
    [CHANGING p1 = a1 p2 = a2 ...]
    [TABLES t1 = itab1 t2 = itab2 ...]
    [EXCEPTIONS [exc1 = n1 exc2 = n2 ...]
    [system_failure = ns [MESSAGE smess]]
    [communication_failure = nc [MESSAGE cmess]]
    [OTHERS = n_others]].
    http://help.sap.com/saphelp_47x200/helpdata/en/22/042537488911d189490000e829fbbd/frameset.htm

  • How to call external functions without a .DLL (just using a .H and .LIB file)?

    Hello everyone,
    actually I'm facing little difficulties on how to get an external function getting called from within CVI (Version 2009).
    I was supplied with a .H file and a .LIB file to call an external function from within my CVI project. The .H file looks like this:
    void exportedFunction(double *parameter);
    As far as I know, the external function was written with MS Visual C++ 6.
    So I tried to statically link to the extern al function like this:
    - Add the .H file and the .LIB file to the CVI project
    - #include the .H file where I needed to call the external function
    - do the external function call
    When building I get an unresolved external function call error from CVI so this seems not to be working.
    I made some searches around and got up with two possible issues. Maybe one of you can help me get a bit further and get things working.
    1) The "real" function code is located in the DLL file which was not delivered to me. Or is there a way to get things done (call external functions) just with a .H and a .LIB file (without any .DLL file included)?
    2) The external function does not export according to "C-Style" rules. The function signature in the .H file shows no things like
    extern "C" __declspec(dllexport) void __stdcall ...
     Or maybe it's a combination of both issues (missing .DLL + wrong export style of function)?
    I guess I could get around the wrong export style of the function when I manage to write a wrapper around the original function that actually uses C-Style exporting. But I guess I need the .DLL file for this try as well.
    Thank you for your answers.
    Best regards,
    Bernd
    Solved!
    Go to Solution.

    There is no need  for the dllexport stuff. There is also the option for a static library without any DLL.  But the 'extern "C"' is essential, because it forces the C++  compiler, which was probably used to compile the library , to use C calling convention.
    If you can't ask the provider of the library to provide a version which was compiled using C calling convention the way to go is to write a wrapper with VC++6 around that library which reexports the functions using C calling convertion. Something like
    extern "C" type0 myfunc1(type1 arg1, ...) {
           return func1( arg1,...);
    for every function , you need to use.
    BTW. "unresolved symbol" is the linker error message, you can expect if you try to link C code against a library build with C++ calling convention.

  • How to call a function in a class from the main timeline?

    Hey Guys
    I have a project in Flash with four external AS files, which are linked to items in the library using AS linkage.
    What I want to do is call a function in one of these files from the main timeline, how would I go about doing this? I'm not currently using a document class, most of the code is in Frame 1 of the main timeline.
    Thanks

    // change type to the class name from the instance
    ClassNameHere(this.getChildByName('instance_name')).SomeFunction();

  • How to call java function from PL/sql in oracle applications

    I am trying to call a java function from plsql procedure. Can any one explain how to call java function, and in which directory I have to store my java function in oracle applications. Do I need to register that java function from Application developer.
    Thanks
    Kranthi

    http://www.oracle.com/technology/tech/java/jsp/index.html
    Good Luck,
    Avi.

  • 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.

  • How to call stored function in my jsp

    how to call stored function in my jsp?
    please give me a example.

    Hi,
    think we need mor einformation, like JDeveloper release and the how you do access the database (JDBC, BC4J, EJB,ADF...)
    Frank

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to call java function in javascript

    Hello Everyone,
    Can anyone tell me solution that:
    How to call java function in javascript?
    Thanks,
    VIDs

    You can't since Java is running on the server and javascript is running in the browser long after the Java side of things has finished executing. Assuming you're not talking about an applet here.
    But you can make calls back to the server through Ajax. All you need is something like a servlet on the receiving end which you can invoke through Ajax; from that point you can execute any Java code you want.

  • How to call a function having OBJECT type as Return type

    Hi,
    I've the following function returning OBJECT type.
    Pease advice me how to call this function
    CREATE OR REPLACE TYPE GET_EMP_OBJ is object
       ( emp_name varchar2(50) ,
         mgr_id   number,
         dept_id  number
    CREATE OR REPLACE FUNCTION get_emp(P_emp_no NUMBER )
      RETURN GET_EMP_OBJ  IS
      t_emp_info GET_EMP_OBJ ;
      v_ename  EMP.ename%TYPE;
      v_mgr    EMP.mgr%TYPE ;
      v_deptno EMP.deptno%TYPE;
      v_ename1  EMP.ename%TYPE;
      v_mgr1    EMP.mgr%TYPE ;
      v_deptno1 EMP.deptno%TYPE;
    BEGIN
      FOR rec IN ( SELECT ename , mgr , deptno
                     FROM emp )
      LOOP
         v_ename := rec.ename ;
         v_ename1 := v_ename1||'|'||v_ename ;
         v_mgr   := rec.mgr   ;
         v_mgr1  := v_mgr1||'|'||v_mgr ;
         v_deptno:= rec.deptno;
         v_deptno1 := v_deptno1||'|'||v_deptno ;
      END LOOP ;
      t_emp_info  := GET_EMP_OBJ (v_ename,v_mgr,v_deptno ) ;
      RETURN t_emp_info ;
    EXCEPTION WHEN OTHERS THEN
      DBMS_OUTPUT.put_line ('Error'||SQLCODE||','||SQLERRM ) ;
    END;The above function got created successfully.
    And i'm confused how to call this functions. I tried like below but didn't work
    DECLARE
      t_emp_info_1  GET_EMP_OBJ ;
    BEGIN
       t_emp_info_1 := get_emp(7566) ;
       for i in 1..t_emp_info_1.COUNT
          LOOP
             DBMS_OUTPUT.put_line ('Values are'||i.emp_name ) ;
         END LOOP;
    END;  

    SQL> CREATE OR REPLACE TYPE GET_EMP_OBJ is object
      2     ( emp_name varchar2(50) ,
      3       mgr_id   number,
      4       dept_id  number
      5     );
      6  /
    Type created.
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE OR REPLACE FUNCTION get_emp(empno NUMBER )
      2    RETURN GET_EMP_OBJ  IS
      3    t_emp_info GET_EMP_OBJ ;
      4  BEGIN
      5    begin
      6      select get_emp_obj(ename, mgr, deptno) into t_emp_info
      7      from emp
      8      where empno = get_emp.empno;
      9    exception
    10      when no_data_found then
    11        t_emp_info := new get_emp_obj(null,null,null);
    12    end;
    13    return t_emp_info;
    14* END;
    SQL> /
    Function created.
    SQL> set serverout on
    SQL>
    SQL> declare
      2    t_emp_info  GET_EMP_OBJ ;
      3  BEGIN
      4     t_emp_info := get_emp(7566);
      5     DBMS_OUTPUT.put_line ('Values are: '||t_emp_info.emp_name||', '||t_emp_info.mgr_id||', '||t_emp_info.dept_id);
      6  END;
      7  /
    Values are: JONES, 7839, 20
    PL/SQL procedure successfully completed.
    SQL>

Maybe you are looking for

  • 10.6.8 combo & 10.6.7 pdf fonts problem

    Does the 10.6.8 update combo correct the pdf fonts problem that was inherent to 10.6.7?  After a couple days of stress I had to do the lengthy 10.6.7 uninstall process in order to refine my doctoral dissertation.  This has made me gun-shy & fearful o

  • What limitations are you finding in FormsCentral? What are the solutions?

    1. There's no way to reduce the height of the fields. 2. There's limited formatting options. This form has more formatting options than FormsCentral. No Styles, Bullets, numbering, etc. 3. When in Design mode, there is no way to increase the view. If

  • File / Folder encryption

    I would like to enquire about how to encrypt one file or folder in Mac OS X and not the entire home folder, as in the concept of FileVault. Is this possible either through the Terminal or Aqua? Thanks for the help here. Cheers, Jason Ellis

  • Router-to-PIX VPN Tunnels fade in and out

    Does anyone know of any problems with Router-to-PIX vpn tunnels? For a number of months we've had about 35 831Routers vpn'd into our PIX515 and the tunnel has been stable. Recently, however, the tunnel has been dropping out at a number of sites. When

  • Errors 8008 and 100000

    Hello, I am getting both 8008 and 100000 at the moment.  Error 8008 is for a movie I rented, and error 100000 is for one song of an album I bought. All the other songs of the album downloaded fine. I've looked through the discussions and there does n