Creating a Record structure and passing this to a Procedure

Hi there
I have a query please.
Can I create a Record Structure composed of fields
from different tables and then pass this record structure
to a procedure.?
ie Create Procedure ProcedureTest(empRec empStructCreated%ROWTYPE)
where empStructCreated is the RECORD STRUCTURE created
and composed of fields from different tables.
Please can some one help me on this.
Assume that I have 3 tables and I am creating a record structure
composed of 6 fields (2 fields from each of the 3 tables),and then
once this record structure is created,I will be passing this to
a procedure.

SQL> create or replace package my_package as
  2  type my_rec is record (empno number,deptno number,dname varchar2(10),hiredate date);
  3  end;
  4  /
Package created.
SQL> create or replace procedure my_proc(rec1 my_package.my_rec) is
  2  begin
  3  dbms_output.put_line(rec1.empno||' '||rec1.dname||' '||rec1.hiredate);
  4  end;
  5  /
Procedure created.
SQL> declare
  2  rec1 my_package.my_rec;
  3  begin
  4  select empno,emp.deptno,dname,hiredate into rec1
  5  from emp,dept where  emp.deptno = dept.deptno and rownum =1;
  6   my_proc(rec1);
  7  end;
  8  /
7369 RESEARCH 17-DEC-80
PL/SQL procedure successfully completed.
SQL>

Similar Messages

  • How to create a record structure dynamically

    Hi,
    I would like to create a record structure dynamically in the body of my pl/sql procedure.
    I don't want to create the structure in the declaration because my record structure depends on some parameters that the procedure will receive.
    Thank you

    > I would like to create a record structure dynamically in the body of my pl/sql procedure
    Terrible idea. Why? Because if the structure is dynamic then you need to write pretty complex code to handle this structure that could be anything. Complex code means buggy code. Inconsistent code. Weird run-time errors. Etc.
    Yes, you can create dynamic "structures" - for example, you can create a user defined type that at execution time can decide what properties it has. Similar to a an object in an o-o language that has a RTTI (Run Time Type Information) interface.
    But this is complex. And what did I say about complex code above? Not the best of ideas most of the time.
    There is however a very easy way to deal with dynamic data via a "dynamic" structure that is in fact a statically defined structure. Arrays aka collections aka associative arrays.
    E.g.
    create or replace type TStrings as table of varchar2(4000);
    Using this I can create a SQL statement (cursor) on any table, with any predicates, and pass the results (dynamic list of columns) to a procedure for processing:
    select TStrings(object_id,object_type,object_name) as DYNAMIC_LIST from user_objects order by object_type, object_name
    Using this I can create a procedure that accepts a dynamic list of values and process these:
    create or replace procedure DynamicProcess( list TStrings ) as ...
    So when thinking "dynamic structures" - think it through carefully. There is a difference between an UNKNOWN structure and a DYNAMIC structure.
    The former needs a RTTI interface. You have no idea what the structure contains. You need an interface to call in order for it to describe the structure for you. This is complex stuff.
    The latter means that you know the structure as it is pre-defined (statically defined). At run-time, it can contain any number of elements - thus making the structure dynamic. This is easy stuff.
    I would rather go for the easy stuff than the complex stuff any time of the day - even when on my 3rd cup of coffee...

  • How create a record type and a pl/sql table of that record type in database

    Hi
    I want to create a record type and then I want to create a PL/SQL table in the oracle 9i database.
    I have done it in PL/SQL block.
    But when I am trying to do it in database it is throwing me some error.
    Could you please tell me how can I do that?
    Regards

    user576726 wrote:
    Hi
    I want to create a record type and then I want to create a PL/SQL table in the oracle 9i database.
    I have done it in PL/SQL block.
    But when I am trying to do it in database it is throwing me some error.
    Could you please tell me how can I do that?
    RegardsRECORD type is supported only in PL/SQL for SQL you need to use OBJECT type.

  • How to create a content profile and Why this need

    how to create a content profile and Why this need

    Hi,
    You will need profiles to control the following behavior:
    - Which metadata to be shown in the checkin form and search form
    - Define default values to certain metadata
    - Make metadata editable, hidden, info only etc
    - Allow the user to see only relevant metadata, for example you could have 50 metadata defined, but all you need for the user to input is 10 for say HR documents, you can show only these 10 metadata for the user to contribute
    HTH
    Regards,
    - Anand

  • How to assign Values to nested table and pass as parameter to procedure?

    How to assign Values to nested table and pass as parameter to procedure?
    Below is the Object and its type
    create or replace type test_object1 as object
    val1 varchar2(50),
    val2 varchar2(50),
         val3 varchar2(50)
    create or replace type test_type1 is table of test_object1;
    create or replace type test_object2 as object
    val1 varchar2(50),
    val2 varchar2(50),
         val3 varchar2(50)
    create or replace type test_type2 is table of test_object2;
    GRANT ALL ON test_object1 TO PUBLIC;
    GRANT ALL ON test_type1 TO PUBLIC;
    GRANT ALL ON test_object2 TO PUBLIC;
    GRANT ALL ON test_type2 TO PUBLIC;
    here is the table made of object type:
    create table test_object_tpe
    sl_num NUMBER,
    description VARCHAR2(100),
    main_val1 test_type1,
    main_val2 test_type2
    NESTED TABLE main_val1 STORE AS tot1
    NESTED TABLE main_val2 STORE AS tot2;
    here is the procedure which inserts values into nested table:
    PROCEDURE INSERT_TEST_DATA(sl_num IN NUMBER,
    description IN VARCHAR2,
    p_main_val1 IN test_type1,
    p_main_val2 IN test_type2
    IS
    BEGIN
    FOR rec in p_main_val1.first..p_main_val1.last
    LOOP
    INSERT INTO xxdl.test_object_tpe
    sl_num,
    description,
    main_val1,
    main_val2
    VALUES
    sl_num
    ,description
    ,test_type1 (test_object1(
    p_main_val1(rec).val1,
                                       p_main_val1(rec).val2,
    p_main_val1(rec).val3
    ,test_type2 (test_object2( p_main_val2(rec).val1,
                        p_main_val2(rec).val2,
                        p_main_val2(rec).val3
    END LOOP;
    commit;
    END INSERT_TEST_DATA;
    here is the anonymoys block which assigns values to the object type and pass values into the procedure:
    set serveroutput on;
    declare
    p_sl_num NUMBER := 1001;
    p_description VARCHAR2(50) := 'Testing Val1';
    inval1 test_type1 := test_type1();
    inval2 test_type2 := test_type2();
    begin
    inval1(1).val1 := 'testx1';
    inval1(1).val2 := 'testx2';
    inval1(1).val3 := 'testx3';
    inval2(1).val1 := 'testy1';
    inval2(1).val2 := 'testy2';
    inval2(1).val3 := 'testy3';
    CSI_PKG.INSERT_TEST_DATA(sl_num => p_sl_num,
    description => p_description,
    p_main_val1 => inval1,
    p_main_val2 => inval2
    end;
    Can anybody correct me.
    Thanks,
    Lavan

    Thanks for posting the DDL and sample code but whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
    >
    How to assign Values to nested table and pass as parameter to procedure?
    >
    Well you are doing almost everything wrong that could be done wrong.
    Here is code that works to insert data into your table (the procedure isn't even needed).
    declare
    p_sl_num NUMBER := 1001;
    p_description VARCHAR2(50) := 'Testing Val1';
    inval1 test_type1 := test_type1();
    inval2 test_type2 := test_type2();
    begin
    inval1.extend();
    inval1(1) := test_object1('testx1', 'testx2', 'testx3');
    inval2.extend();
    inval2(1) := test_object2('testy1', 'testy2', 'testy3');
    INSERT INTO test_object_tpe
    sl_num,
    description,
    main_val1,
    main_val2
    VALUES
    (p_sl_num, p_description, inval1, inval2);
    commit;
    end;
    /See Example 5-15 Referencing a Nested Table Element in Chap 5 Using PL/SQL Collections and Records in the PL/SQL doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/collections.htm#CJABEBEA
    1. You don't even need the procedure since all it does is a simple INSERT into the table which you can do directly (see my code above)
    inval1(1).val1 := 'testx1';There is no element one (1) of 'inval1' since you haven't created any elements yet. You need to EXTEND the collection to add an element
    inval1.extend();And then there is an empty element but 'inval1' is a container for objects of type 'test_object1' not for scalars like 'val1', 'val2', and 'val3'.
    So you can't do
    inval1(1).val1 := 'testx1';You have to create an instance of 'test_object1'
    inval1(1) := test_object1('testx1', 'testx2', 'testx3');And so on for the other collection
    You don't need the procedure (as my sample code shows) but once you populate the variables properly it will work.

  • Creating a Display View and passing back the selected items

    Hello All,
    I will like to create the below scenario and will like to seek feedbacks and suggestions on how to do so in the best way.
    <u><b>Scenario</b></u>
    1) User enters his lastname and press a submit button (this is done in the initial window which contains UI elements that needes to be populated with the search results),
    2) The submited name is passed to the backend for searching,
    3) Results is then thrown back to the user in <b>ANOTHER</b> window in the form of a selection table. Here, the window will display a list of all matching lastnames.(Even if there is only 1 search result)
    4) User is required to select his own last name from the table and his info will be populated in the respective UI elements in the view of the initial window.
      Feedbacks and suggestion will be greatly appreciated. Thnak you very much.
    from
    Kwok Wei

    Define 2 views, "Search" and "Result", define a custom controller (or use the component controller) with a context containing all relevant data (entered name, result list). Define a controller usage from both view controllers to the custom controller, map both view contexts to the custom controller context.
    This will allow both view controllers to access the data entered in "Search" and the results from the backend displayed in "Result".
    For the navigation between "Search" and "Result", use the navigation modeller to define plugs and navigation links. In the event handler of the "search" action, navigate to the "Result" view, in the event handler of the result selection (e.g. a handler for IWDTable.onLeadSelect), navigate back to the "Search" view.
    Armin

  • Create OutputFile in jsp and write this file to response

    Hello
    Please can you help me
    I need to dynamically create a file in jsp and send this file to user
    Please help

    Don't forget to set the contentLength. Some clients/applications will refuse to run/open the file otherwise.
    At the bottom of this article you can find several reuseable downloadFile() utility methods: http://balusc.xs4all.nl/srv/dev-jep-pdf.html
    I'll copypaste them here:
    package net.balusc.util;
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.ByteArrayInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.net.URLConnection;
    import javax.servlet.http.HttpServletResponse;
    public class HttpServletUtil {
         * Send the given file as a byte array to the servlet response. If attachment
         * is set to true, then show a "Save as" dialogue, else show the file inline
         * in the browser or let the operating system open it in the right application.
         * @param response The HttpServletResponse to be used.
         * @param bytes The file contents in a byte array.
         * @param fileName The file name.
         * @param attachment Download as attachment?
        public static void downloadFile(HttpServletResponse response, byte[] bytes, String fileName, boolean attachment) throws IOException {
            // Wrap the byte array in a ByteArrayInputStream and pass it through another method.
            downloadFile(response, new ByteArrayInputStream(bytes), fileName, attachment);
         * Send the given file as a File object to the servlet response. If attachment
         * is set to true, then show a "Save as" dialogue, else show the file inline
         * in the browser or let the operating system open it in the right application.
         * @param response The HttpServletResponse to be used.
         * @param file The file as a File object.
         * @param attachment Download as attachment?
        public static void downloadFile(HttpServletResponse response, File file, boolean attachment) throws IOException {
            // Prepare stream.
            BufferedInputStream input = null;
            try {
                // Wrap the file in a BufferedInputStream and pass it through another method.
                input = new BufferedInputStream(new FileInputStream(file));
                downloadFile(response, input, file.getName(), attachment);
            } catch (IOException e) {
                throw e;
            } finally {
                // Gently close stream.
                if (input != null) {
                    try {
                        input.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                        // This is a serious error. Do more than just printing a trace.
         * Send the given file as an InputStream to the servlet response. If attachment
         * is set to true, then show a "Save as" dialogue, else show the file inline
         * in the browser or let the operating system open it in the right application.
         * @param response The HttpServletResponse to be used.
         * @param input The file contents in an InputStream.
         * @param fileName The file name.
         * @param attachment Download as attachment?
        public static void downloadFile(HttpServletResponse response, InputStream input, String fileName, boolean attachment) throws IOException {
            // Prepare stream.
            BufferedOutputStream output = null;
            try {
                // Prepare.
                int contentLength = input.available();
                String contentType = URLConnection.guessContentTypeFromName(fileName);
                String disposition = attachment ? "attachment" : "inline";
                // Init servlet response.
                response.setContentLength(contentLength);
                response.setContentType(contentType);
                response.setHeader("Content-disposition", disposition + "; filename=\"" + fileName + "\"");
                output = new BufferedOutputStream(response.getOutputStream());
                // Write file contents to response.
                while (contentLength-- > 0) {
                    output.write(input.read());
                // Finalize task.
                output.flush();
            } catch (IOException e) {
                throw e;
            } finally {
                // Gently close stream.
                if (output != null) {
                    try {
                        output.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                        // This is a serious error. Do more than just printing a trace.
    }

  • Create Oracle BLOB and Pass to Oracle Stored Procedure

    Hi All,
    I am using Oracle 10g and am dealing with a requirement where I have to upload a file to Oracle Portal from the client's local machine using a JSP.
    I am planning to convert the text file to a BLOB and pass it to an Oracle stored procedure which does the rest.
    I am unable to create a BLOB object. Can anybody help me with this please.
    Is there a better alternative to do it?
    Thanks in advance,
    Shardul

    u can create blob as below...
    java.sql.Blob blob=new Blob();
    File file=new File(fullPathTo UrFile);
    FileInputStream fInSteam = new FileInputStream(file);
    BufferedInputStream bInputStream = new BufferedInputStream(fInSteam);
    ByteArrayOutputStream bOutputStream = new ByteArrayOutputStream();
    int nextByte;
    while (( nextByte = bInputStream.read() ) != - 1)
    bOutputStream.write(nextByte);
    byte[] byteContent = bOutputStream.toByteArray();
    blob.setBytes(byte[]);
    i think it should work for u...

  • How to create a Regional Structure and how to use it

    Hi can anyone help me in creating the postal and political regional  structures with T-CODES if u have any documents or screen shots
    THANK YOU IN ADVANCE

    **Postal Code     **
    SR30     Create
    SR31     Change
    SR32     Display
    **City     **
    SR10     Create
    SR11     Change
    SR12     Display
    **Street     **
    SR20     Create
    SR21     Change
    SR22     Display
    **Political          **
    ER30     Maintain Hierarchy
    ER3D     Display Hierarchy
    ER31     Maintain Elements
    ER32     Display Elements
    Regards,
    Siva Bontha
    Edited by: Siva Bontha on Sep 4, 2009 12:38 PM

  • Multi row checking in advance table and passing this to other OAF page...

    Hello,
    I have an advance table on my OAF custom page, this table have checkbox column. I need to implement the solution when user selects some rows in this table and then press submit button on the page. So new OAF page is opened and on that page i need to show those lines which user selected in previous step.
    The problem is that right now i have this selection checkbox tight to VO attribute which updates table and then on submit do commit and on another page i'm just selecting rows which have this flag set. But what i'm looking for is - do not make commit and changes on database data, but pass the selected rows as kind of parameter to other page or something like this.
    Could you please give me any suggestions of how is the better way to implement this solution?
    thanks in advance...

    Make a transient VO, and insert all the lines the user has checked.Share the same AM in other page and while redirecting retain AM. On this page show the lines from the transient VO.Another option could be utilizing session.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Was trying to update my ITunes and get this error: The procedure entry point AVCFPlayerItemDurationChangedNotification could not be located in the dynamic link library AVFoundationCF.dll. Just got the new IPhone and am trying to share music files. Can any

    I have Windows Vista computer. I am trying to upgrade my ITunes so can share files with other home computer. (Just got the new IPhone). I get this system error: The procedure entry point AVCFPlayerItemDurationChangedNotification could not be located in the dynamic link library AVFoundationCF.dll. Tries system restore and redownloaded...NOW Itunes will not even open. Can anyone help?

    I uninstalled Apple Application Support, opened iTunesSetup with WinRar, and went down the list of msi's. AppleApplicationSupport was an install, all the others I did Repair.  Did not have to reboot. Works okay now.
    HTH

  • How do I create and download an XML document and insert this into a BLOB

    I need to create an XMLDOM document and download this onto a users PC. Any ideas about how to do this?
    I would prefer to first insert this into a Table (into a BLOB) to allow users to download it later.
    I can create an XMLDOM document, I can upload a file into wwv_flow_files and then download this later.
    Any suggestion would be appreciated.

    Douglas,
    did you manage to solve this, I am trying to upload an xml file from a page item into the database using a custom pl/sql insert but it won't insert.
    Andrew

  • PO item Condition Record number and delivery address of PO - Need a table n

    Hello Experts,
    I need some help as I have searched enough but did not find any solution.
    I need a table name where I can find Condition Record number for PO line item.
    As I have to create a new PO Layout in which I have to mention each & every condition type with value for line item.
    I need to know one more thing that from which table I will get delivery address number so on the basis of that I can read entries from table ADRC.
    Thanks in advance.
    Bhagat

    HI,
    The First Question is regarding the PO Conditions.
    For Extracting the same. we have to Go to The Table EKKI and in this table pass the PO Number and after entering the PO NUmber ,at each item level we will have a condition record number KNUMV created,
    collect the condition record number and pass the value in KONV table ,in that table we will get all the conditions and its values maintained.
    The second question is the delivery Address
    the Delivey address comes from four ways
    Plant
    EKPO -Pass PO NUmber - collect the plant and pass in table T001W  to get the address number
    and pass the address number to ADRC table
    Customer (third party)
    IN table EKPO -collect the customer Number-KUNNR and pass that value to KNA1 table and then get the address number and then get the address from ADRC table.
    Direct address number ( created by t code MEAN- Type ME01)
    This adress number-ADRNR can be taken from EKPO table and pass this value to adrc table to get the address.
    Vendor ( subcontracting)
    In this IN EKPO we will have the vendor field -LIFNR and this field collect the vendor number and pass in LFA1 and get the address number and then pass the address number to ADRC table
    If in EKPO,the address number and customer vendor field are blank then it picked from the plant and we have to default the Plant Address
    Hope so it helps
    Regards
    Anjanna.

  • How to create a tree structure using forms.

    Hi,
    How do i create a tree structure using oracle forms,i have a table named Functions and a specific column 'Function Name' should be displayed in the tree nodes.Can anyone help me out on how to create a tree structure and populating the nodes??
    thanks in advance
    Regards
    Karthik

    The FTree package provides functions to populate the tree - look for the topic "Manipulating a hierarchical tree at runtime
    " in the online help this point to all the functions and triggers

  • Getting "java.lang.NullPointerException" error message when trying to run an OATS OpenScript file from Eclipse to Create a record in Oracle EBS

    Hello,
    I'm trying to run a simple OpenScript script in Eclipse that creates a record (a Supplier in this case) in Oracle E-Business Suite. So I copied the the script file from OpenScript and created it as a Class in Eclipse.  Then I created a main class to call the methods within the script class but no matter what method I call (initialize, run or finalize) I'm getting the java.lang.NullPointerException message. The error doesn't seem to be related with any specific line in the script but with the way that I'm calling it.
    Should I call the OpenScript class from my main class in a different way? (see my examples below)
    BTW, all external .jar files coming with OATS have been added to my project in Eclipse.
    1) Here's the main class I created to call the OpenScript method (Eclipse auto-corrected my main class adding a Try and Catch around the method call):
    public class Test {
        public static void main(String[] args) {
            nvscript nvs = new nvscript();
            try {
                nvs.initialize();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
    2) Here's the script from OpenScript (the actual script has more steps but I'm just using the first one for a proof of concept):
    import oracle.oats.scripting.modules.basic.api.*;
    import oracle.oats.scripting.modules.browser.api.*;
    import oracle.oats.scripting.modules.functionalTest.api.*;
    import oracle.oats.scripting.modules.utilities.api.*;
    import oracle.oats.scripting.modules.utilities.api.sql.*;
    import oracle.oats.scripting.modules.utilities.api.xml.*;
    import oracle.oats.scripting.modules.utilities.api.file.*;
    import oracle.oats.scripting.modules.webdom.api.*;
    import oracle.oats.scripting.modules.formsFT.api.*;
    import oracle.oats.scripting.modules.applet.api.*;
    public class nvscript extends IteratingVUserScript {
        @ScriptService oracle.oats.scripting.modules.utilities.api.UtilitiesService utilities;
        @ScriptService oracle.oats.scripting.modules.browser.api.BrowserService browser;
        @ScriptService oracle.oats.scripting.modules.functionalTest.api.FunctionalTestService ft;
        @ScriptService oracle.oats.scripting.modules.webdom.api.WebDomService web;
        @ScriptService oracle.oats.scripting.modules.applet.api.AppletService applet;
        @ScriptService oracle.oats.scripting.modules.formsFT.api.FormsService forms;
        public void initialize() throws Exception {
            this.getSettings().set("formsft.useformsonly",true);
            browser.launch();
        public void run() throws Exception {
            beginStep(
                    "[1] E-Business Suite Home Page Redirect (/ebs12cloud.winshuttle.com:8000/)",
                    0);
                web.window(2, "/web:window[@index='0' or @title='about:blank']")
                        .navigate("http://ebs12.xxxxxxx.com:8000/");
                web.window(4, "/web:window[@index='0' or @title='Login']")
                        .waitForPage(null);
                    think(4.969);
                web.textBox(
                        7,
                        "/web:window[@index='0' or @title='Login']/web:document[@index='0']/web:form[@id='DefaultFormName' or @name='DefaultFormName' or @index='0']/web:input_text[@id='usernameField' or @name='usernameField' or @index='0']")
                        .setText("winshuttle_user");
                    think(2.0);
                web.textBox(
                        8,
                        "/web:window[@index='0' or @title='Login']/web:document[@index='0']/web:form[@id='DefaultFormName' or @name='DefaultFormName' or @index='0']/web:input_password[@id='passwordField' or @name='passwordField' or @index='0']")
                        .click();
                    think(1.109);
                web.textBox(
                        9,
                        "/web:window[@index='0' or @title='Login']/web:document[@index='0']/web:form[@id='DefaultFormName' or @name='DefaultFormName' or @index='0']/web:input_password[@id='passwordField' or @name='passwordField' or @index='0']")
                        .setPassword(deobfuscate("kjhkjhkj=="));
                    think(1.516);
                web.button(
                        10,
                        "/web:window[@index='0' or @title='Login']/web:document[@index='0']/web:form[@id='DefaultFormName' or @name='DefaultFormName' or @index='0']/web:button[@id='SubmitButton' or @value='Login' or @index='0']")
                        .click();
            endStep();
        public void finish() throws Exception {       
    3) Here's the error messages I'm getting based on the method I call from my main class:
    3.a) when calling Initialize():
    java.lang.NullPointerException
        at oracle.oats.scripting.modules.basic.api.IteratingVUserScript.getSettings(IteratingVUserScript.java:723)
        at nvscript.initialize(nvscript.java:22)
        at Test.main(Test.java:9)
    3 b) when calling Run():
    java.lang.NullPointerException
        at oracle.oats.scripting.modules.basic.api.IteratingVUserScript.beginStep(IteratingVUserScript.java:260)
        at nvscript.run(nvscript.java:30)
        at Test.main(Test.java:9)
    Any help and/or constructive comment will be appreciated it.
    Thanks.
    Federico.

    UPDATE
    Compiling from command line I found out that the class definition for oracle.oats.scripting.modules.basic.api.IteratingVUserScript is missing. Do you know what .jar file contains this class?
    Thanks.
    Fede.

Maybe you are looking for