Table return function set IN OUT

Hello

I have a function that returns a table
CREATE OR REPLACE FUNCTION myfunc (
     p_id      number,
     p_cid      number,,
     p_no      number,,
        datearray          IN OUT dates
)
     RETURN dates
Function, I have 3 as input parameters and I would do back table as a parameter out. However when I compile I get errors

How can I set the function to have output as 4th parameter, something like datearray table?

Thank you

Published by: ponic on May 28, 2012 18:10

You validate version. You post type dates statement. You post function code. You post errors. So, how can we answer your question? In any case, here is an example:

SQL> create or replace
  2    type dates
  3      as table of date
  4  /

Type created.

SQL> CREATE OR REPLACE
  2    FUNCTION myfunc (
  3                     p_id      number,
  4                     p_cid     number,
  5                     p_no      number,
  6                     datearray IN OUT dates
  7                    )
  8      RETURN dates
  9      IS
 10      BEGIN
 11          IF datearray IS NULL
 12            THEN
 13              datearray := dates();
 14          END IF;
 15          datearray.EXTEND;
 16          datearray(1) := sysdate;
 17          datearray.EXTEND;
 18          datearray(2) := sysdate + 1;
 19          datearray.EXTEND;
 20          datearray(3) := sysdate + 2;
 21          RETURN datearray;
 22  END;
 23  /

Function created.

SQL> 

SY.

Tags: Database

Similar Questions

  • PL/SQL Query return function, adding the column links

    Hi all

    I'm working on a SQL report with the area type = function from PL/SQL Query to return
    All columns are generated dynamically based on my mapping table and a column of ID.
    So whenever the page is loaded, according to the ID mapping table returns a set of columns in a particular order.
    So not only the columns are dynamic, but the order of the columns varies also.
    But the first 1 column is standard (it doesn't come from the mapping table) and is coded in my pl/sql block hard.

    I'm fighting with the addition of a link to this column. The link must be a Javascript function which takes the parameters in the form of 2 columns in the mapping table.
    My pl/sql block is something like that...
    v_select := 'SELECT <g href=javascript:f_report1(#map_id#,#comments#)><img src=""></a> as report1, ';  // g=a
    v_cols := 'contains all columns from the mapping table based on a ID(hidden item)';
    v_from := 'FROM table';
    v_where := 'where condition is put in here';
    v_query := v_select||v_from||v_where;
    return v_query;
    Now, I'm not able to transmit the values of this #map_id # and #comments # correctly. I tried so many different combinations of channels, but could not make it work.

    I'm not sure that the order of this map_id and commentscolumn and therefore cannot connect through the report attributes.
    How can I go to a column value to the function?



    Thank you
    Dippy

    This should work if all goes well:

    v_select := q'[ SELECT '' as chart, ]';
    

    Published by: Dimitri Gielis on May 20, 2010 20:10

  • Table of functions and direct requests for NUMBER data types database

    Hello. I call a number of functions table of our Enterprise BI server, and I chose to do this by using direct database requests (I believe you can also call functions table in the physical layer of the repository, but is not what I do). The problem is that whenever I go back any number of the table function which is not a whole number (1.23, for example), BI assigns the INTEGER data type to the field rather than the data type DOUBLE, rounded so my number to the nearest integer. Here is a short example:

    Create these 3 database objects:

    CREATE or REPLACE TYPE my_row AS OBJECT (my_num NUMBER);

    CREATE or REPLACE TYPE my_tab AS TABLE OF THE my_row;

    FUNCTION to CREATE or REPLACE my_table_function RETURN my_tab
    PIPELINED IS
    BEGIN
    PIPE ROW (my_row (1.23));
    END;
    /


    Make this your request at your request Direct to database:

    SELECT my_num FROM table (my_table_function);


    This query returns correctly '1.23' when it is called from the database. In BI, on the other hand, it returns a value of '1' (and the field of labels an INTEGER rather than data type DOUBLE). If at the request of data Direct you change column properties-> data-> decimal from 0 to 2 Format, then it displays is not surprising "1.00". I then tried to change MY_ROW. Data type of MY_NUM by explicitly specifying the precision and no luck. BI still labels this field as an INTEGER. Then I started to try to deceive BI massaging the SQL statement itself. None of the following worked:

    SELECT to_number (my_num) as my_num2 FROM table (my_table_function);
    SELECT my_num2 + 0.01 as my_num3 FROM (SELECT my_num - 0.01 AS my_num2 FROM table (my_table_function));
    SELECT to_number (to_char (my_num)) as my_num2 FROM table (my_table_function);
    SELECT to_number (substr (to_char ('x' | my_num), 2)) as my_num2 FROM table (my_table_function);

    Now, I found a solution, but I'm surprised that I have to resort to that:

    SELECT * FROM (SELECT / * + NO_MERGE * / table my_num (my_table_function));

    Is anyone out there knows a better way to do it? The above is a hack in my opinion. :)

    Thanks in advance for any input.

    -Jim

    Yes, it's really amazing.
    But I got it.

    CREATE OR REPLACE TYPE my_row AS OBJECT (my_num NUMBER(10,2));
    

    and in your SQL:

    SELECT cast(my_num as double precision) as my_num2 FROM table(my_table_function);
    

    I have the good result and I see the numbers after the decimal point.
    Very delicate!

    Published by: gerardnico on July 7, 2009 14:55 change number (10.2) in double precision... pffff

  • I've updated to Firefox. No Norton toolbar compatible. I want the Identity Safe return function.

    I've updated to Firefox. No Norton toolbar compatible. I want the Identity Safe return function. I used to be able to go back to an earlier date that loose the update, but have not used this in Vista and can not remember where. Is there no alternative to retrieve my Norton task bar?

    sallybok, you probably have an older version of the Norton toolbar extension. Have you tried to do the Live update with Norton as suggests?

  • How can I cerate a table with a set of numbers saying 1 to 12 random order but no recurrence.

    How can I cerate a table with a set of numbers saying 1 to 12 random order but no recurrence.

    I know it should be easy, but my brain doesn't work right now


  • PLSQL text validation error return function

    Hello

    I use the PLSQL text validation error return function

    that works fine

    DECLARE

    v_error varchar (1000);

    BEGIN

    IF condition = 1 THEN

    v_error: =' < span style = "color: red;" make-weight: bold; ' > You can not update dates you are not allow to update the dates </span > ';

    END IF;

    Return v_error;

    END;

    can someone tell what I can use APEX to display the v_error message in one line on the region of html

    as I use displayed element so it is wrapping the text

    Selection_004.png

    Selection_005.png

    Hi ReemaPuri,

    Change the settings for the grid of the element of error message (which is only point display) from the rest of the elements in the region so that the error message is contained in a grid and other elements are in the new grid.

    Kind regards

    Kiran

  • How can I change my CS6 Master Collection when the "Update" function is grayed out?

    I bought a used iMac (mid-2009) in 2012/13. It had pre-installed CS6 Master Collection. I thought I was getting updates for the software, but I'm wrong apparently. I have to update the applications to meet the requirements of security and anti-fraud PCI/DSS for my B & B business. If I don't respect I can't use my machine credit card to take payments from customers. In each application, the "Update" function is grayed out, then how can I update the software? Adobe support is the only place where I can get an answer on the Forums. I bought and for more than 20 years of Adobe products used but no serial number doesn't appear in my Adobe ID

    If the software is installed with an opportunity machine that was purchased, the software is not for you unless that seller officially transferred ownership of the procedure defined in the information below.

    Transfer an Adobe product license

    As far as updates go try direct updates
    https://www.Adobe.com/downloads/updates/

  • PRINT FUNCTION IS GRAYED OUT IN PSE11

    Sometimes the print function is grayed out.  When it is not and I click on it I get the error message: there is AN ERROR OPENING YOUR PRINTER. PRINT FUNCTIONS WILL BE UNAVAILABLE UNTIL YOU HAVE SELECTED A PRINTER AND REOPEN ALL DOCUMENTS.  Do not even get an option to select a printer?

    It feels OK now.  I restarted my computer. Thank you.

  • Create a view which limits a large table, but also allows an outer join?

    Oracle 10.2.0.4

    CREATE TABLE MY_PAY_ITEMS

    (EMP VARCHAR2 (8) NOT NULL)

    , PAY_PRD VARCHAR2 (8) NOT NULL

    , KEY1 VARCHAR2 (8) NOT NULL

    , KEY2 VARCHAR2 (8) NOT NULL

    , LN_ITEM VARCHAR2 (4) NOT NULL

    , ITEM_AMT NUMBER (24.2) NOT NULL

    VARCHAR2 (100) FILL NON-NULL)

    INSERT INTO MY_PAY_ITEMS

    SELECT A.EMP

    B.PAY_PRD

    C.KEY1

    D.KEY2

    E.LN_ITEM

    F.ITEM_AMT

    , '                      '

    FROM (SELECT TO_CHAR (ROWNUM, ' 00000000') 'EMP' FROM DUAL CONNECT BY LEVEL < = 50) has

    , (SELECT '2010-' |) To_char(rowNum,'00') 'PAY_PRD' FROM DUAL CONNECT BY LEVEL < = 52) B

    , (SELECT TO_CHAR (ROWNUM, ' 000') 'KEY1' FROM DUAL CONNECT BY LEVEL < = 8) C

    , (SELECT TO_CHAR (ROWNUM, ' 000') 'Key2' FROM DUAL CONNECT BY LEVEL < = 5) D

    , (SELECT TO_CHAR(ROWNUM,'000') 'LN_ITEM' FROM DUAL CONNECT BY LEVEL < = 20) E

    (round (DBMS_RANDOM. VALUE * 400.2) "ITEM_AMT" of the double) F

    CREATE A UNIQUE INDEX MY_PAY_ITEMS ON MY_PAY_ITEMS (MEP, PAY_PRD, KEY1, KEY2, LN_ITEM)

    CREATE TABLE MY_ITEM_DISPLAY

    (THE VARCHAR2 (4) OF DISPLAY_CODE NOT NULL)

    , NUMBER (2) SEQUENCE NON-NULL

    , COLUMN_ITEM1 VARCHAR2 (4) not null

    , COLUMN_ITEM2 VARCHAR2 (4) not null

    , COLUMN_ITEM3 VARCHAR2 (4) not null

    COLUMN_ITEM4 VARCHAR2 (4) not null)

    INSERT INTO MY_ITEM_DISPLAY VALUES ('01 ', 10, '001', '003', '004',' 005');

    INSERT INTO MY_ITEM_DISPLAY VALUES ('01 ', 20 '007', '013', '004',' 009');

    INSERT INTO MY_ITEM_DISPLAY VALUES ('01', 30 ' 001', '004', '009',' 011');

    INSERT INTO MY_ITEM_DISPLAY VALUES ('01', 40, '801 ', ' 304 ', 209',' 111');

    INSERT INTO MY_ITEM_DISPLAY VALUES ('02 ', 10, '001', '003', '004',' 005');

    INSERT INTO MY_ITEM_DISPLAY VALUES ('02 ', 20 '007', '013', '004',' 009');

    INSERT INTO MY_ITEM_DISPLAY VALUES ('02', 30 ' 001', '004', '009',' 011');

    MY_PAY_ITEMS is a table that stores line of payslip items.  It has a total area of 500,000,000 lines.

    PEM is the unique id, we have about 200,000 employees (with about 50,000 being active today).

    PAY_PRD is a weekly pointer (2010-01, 2010-02, 2010-52), we have the 2004 data and add a new pay period each week.  2010 01 is defined as the first Monday in 2010 for the first Sunday in 2010, etc.

    Key1 is an internal key, it follows the chronology in the pay period.

    KEY2 is a child of KEY1, there follows the sequence of events in KEY1.

    LN_ITEM is the component of actual compensation resulting from the event, on average, a person produces 20 lines per event.  Note that in this example, everyone gets the same LN_ITEM values, but in practice it is selected 20 of 300

    ITEM_AMT is the net salary per command line.

    FILLING is a set of fields that are unrelated to this issue, but act as a brake on the charges of the line.

    MY_ITEM_DISPLAY is an array that describes how some screens should display items.  The screen itself is a grid of 4 poles, with the content of each cell is defined as a LN_ITEMS search to retrieve the relevant LN_AMT.

    We have an application that receives a DISPLAY_CODE and an EMP.  It automatically creates an sql statement in the sense of

    SELECT * FROM MY_VIEW WHERE DISPLAY_CODE =: 1 AND EMP =: 2

    and returns the output to the user.

    My challenge is that I need to rewrite MY_VIEW as follows:

    (1) (select the relevant lines from MY_ITEM_DISPLAY where DISPLAY_CODE =: 1)

    (2) select the relevant all MY_PAY_ITEMS lines that meet the criteria

    (a) EMP =: 2

    (b) PAY_PRD = (a more recent for EMP and sysdate, so if he got last paid 2010-04, return 2010-04)

    (c) KEY1 = (highest key1 in EMP and PAY_PRD)

    (d) KEY2 = (highest key2 in KEY1, PAY_PRD and EMP)

    (3) I then need to cross reference to create tabular output

    (4) Finally, I have to return a 0 line where there is no LN_ITEMs (DISPLAY_CODE 01, 40 sequence contains possible values for this scenario)

    The following query is part of it (but not the PAY_PRD, KEY1, KEy2)

    Select * from)

    SELECT A.DISPLAY_CODE

    B.EMP

    A.SEQUENCE

    , MAX (DECODE (B.LN_ITEM, A.COLUMN_ITEM1, B.ITEM_AMT, 0)) 'COL1 '.

    , MAX (DECODE (B.LN_ITEM, A.COLUMN_ITEM2, B.ITEM_AMT, 0)) 'COL2 '.

    , MAX (DECODE (B.LN_ITEM, A.COLUMN_ITEM3, B.ITEM_AMT, 0)) 'COL3 '.

    , MAX (DECODE (B.LN_ITEM, A.COLUMN_ITEM4, B.ITEM_AMT, 0)) 'COL4 '.

    OF MY_ITEM_DISPLAY A, MY_PAY_ITEMS B

    WHERE B.PAY_PRD = ' 2010-03'

    GROUP OF A.DISPLAY_CODE, B.EMP, A.SEQUENCE)

    WHERE DISPLAY_CODE = '01'

    AND EMP = '0000011'

    SEQUENCE ORDER

    My questions

    (1) how I do PAY_PRD, KEY1, KEY2 forced, can I use a form any of ROW_NUMBER() FUNCTION?

    (2) how can I deal with the fact that none of the 4 LN_ITEMS column can exist (see sequence 40, none of these can exist)...  Ideally the SQL above should return

    01, 0000011, 10, < a digit - > < number > - < a digit - > < some number >

    01, 0000011, 20, < a digit - > < number > - < a digit - > < some number >

    01, 0000011, 30, < a number--> < number > - < number > - < number > -

    01, 0000011, 40, 0, 0, 0, 0

    I tried a UNION, but it prevented the view to eliminate most of the MY_PAY_ITEMS lines, because it solves ALL MY_PAY_ITEMS instead of simply retrieve lines for the EMP passed to the view.  The same seems to be true for outer joins.

    Hi Paula,

    It does not handle SEQNUM 40, it's just that your second set of test data did not SEQNUM 40. When I put in the first set of values MY_ITEM_DISPLAY, I get:

    DISP EMP SEQUENCE COL1 COL2 COL3 COL4

    ---- -------- ---------- ---------- ---------- ---------- ----------

    01 00000011 10 101.1 103.1 105.1 104.1

    01 00000011 20 107.1 113.1 104.1 109,1

    01 00000011 30 101.1 104.1 109.1 99.99

    01 00000011 40 0 0 0 0

    If this isn't the issue, you will need to explain the requirement of "outer join" and what you want more. Apart from his return nothing if there is absolutely no element of remuneration of the employee, this query will always return a line for each line MY_ITEM_DISPLAY for the display_code. If there is absolutely no data, no return line seems reasonable.

  • WITH or CONNECT BY on several tables and function call

    Hi all

    I saw several post, documentation and several tutorials and cant' wrap your head around the query. I am creating a hierarchy of hosts in a model parent child and for each parent, I need to generate html code. I now have the id of the top most parent but has difficulty to get the logic to generate the output I need.

    In short, I have 1 parent with children and some of these children may be parents themselves and the parent over the top of the PAGE is always-1

    I need to call the pl/sql function to generate the code (only and only if it is a parent)

    I've been at this for awhile and only have the basics but are struggling to try to get what I need. I'im so confused at this point I don't know even how to explain it.

    So bear with me, I have included the test data for all who can help:

    -STEP 1-> OK

    -STEP 2-> DON'T know what I'm doing, but I'm generating an output of hierarchy

    -STEP 3-> paths are a bit inaccurate. DB1 and DB2 are repeated and their correct path is/LOCALHOST/RT1/SVR-DEV-01/DB1

    -STEP 4-> I'm so confused, I could not explain other then I have to call my function in reverse order of STEP2 so that more "host_object" really is a child and therefore function should not be called.

    -- Heis my query my base query
    
    SELECT DISTINCT h.id,
                    h.host_object_id,
                    h.display_name,
                    COALESCE(h3.host_object_id, -1) AS parent_id,
    
    FROM hosts h
    LEFT JOIN host_parenthosts h4 ON (h.id = h4.host_id)
    LEFT JOIN hosts h3 ON h3.host_object_id = h4.parent_host_object_id;
    

    It may be easier to do using PL/SQL. Here is an example that you may be able to take as a starting point. It uses recursion to write lines in a simple table, then writes the table at the end.

    SET SERVEROUTPUT ON
    DECLARE
    
      g_lines_list SYS.ODCIVarchar2List := SYS.ODCIVarchar2List();
      CURSOR c_top IS
      SELECT hst.id, hst.host_object_id, hst.display_name
        FROM hosts hst
       WHERE NOT EXISTS (SELECT 1
                           FROM host_parenthosts par
                          WHERE par.host_id     = hst.id
                  );
      l_id     PLS_INTEGER;
    
      FUNCTION Write_Log (p_line VARCHAR2, p_level PLS_INTEGER) RETURN PLS_INTEGER IS
      BEGIN
    
        g_lines_list.EXTEND;
        g_lines_list (g_lines_list.count) := LPad ('.', 2*(p_level+1), '.') || p_line;
        RETURN g_lines_list.count;
    
      END Write_Log;
    
      FUNCTION JSON_Expand (p_level PLS_INTEGER, p_parent_id PLS_INTEGER) RETURN VARCHAR2 IS
        l_chi_str          VARCHAR2(30);
        l_id             PLS_INTEGER;
        CURSOR c_chi IS
        SELECT hst.id, hst.host_object_id, hst.display_name
          FROM host_parenthosts          par
          JOIN hosts               hst
            ON hst.id               = par.host_id
         WHERE par.parent_host_object_id     = p_parent_id;
    
      BEGIN
    
        FOR r_chi IN c_chi LOOP
    
          IF l_chi_str IS NOT NULL THEN
            g_lines_list(g_lines_list.COUNT) := g_lines_list(g_lines_list.COUNT) || ',';
          END IF;
          l_id := Write_Log ('{Id: ' || r_chi.id || ', Name: ' || r_chi.display_name, p_level);
          g_lines_list(l_id) := g_lines_list(l_id) || JSON_Expand (p_level + 1, r_chi.host_object_id);
          l_chi_str := ', Children: [';
    
        END LOOP;
    
        IF l_chi_str IS NOT NULL THEN
    
          l_id := Write_Log (']}', p_level - 1);
    
        ELSE
    
            g_lines_list(g_lines_list.COUNT) := g_lines_list(g_lines_list.COUNT) || '}';
    
        END IF;
        RETURN l_chi_str;
    
      END JSON_Expand;
    BEGIN
    
      FOR r_top IN c_top LOOP
        l_id := Write_Log ('{Id: ' || r_top.id || ', Name: ' || r_top.display_name, -1);
        g_lines_list(l_id) := g_lines_list(l_id) || JSON_Expand (0, r_top.host_object_id);
      END LOOP;
    
      DBMS_Output.Put_Line ('Stored lines...');
      FOR i IN 1..g_lines_list.COUNT LOOP
        DBMS_Output.Put_Line (g_lines_list(i));
      END LOOP;
    
    END;
    /
    

    Strategic outcome on your data:

    Stored lines...
    {Id: 2604, Name: LOCALHOST, Children: [
    ..{Id: 2580, Name: VRT-42, Children: [
    ....{Id: 2597, Name: solaris},
    ....{Id: 2598, Name: dell-2},
    ....{Id: 2600, Name: acer-3}
    ..]},
    ..{Id: 2581, Name: RT1, Children: [
    ....{Id: 2591, Name: SVR-DEV-01, Children: [
    ......{Id: 2577, Name: DB1},
    ......{Id: 2578, Name: DB2}
    ....]}
    ..]},
    ..{Id: 2590, Name: VMHOST-01},
    ..{Id: 2591, Name: SVR-DEV-01, Children: [
    ....{Id: 2577, Name: DB1},
    ....{Id: 2578, Name: DB2}
    ..]},
    ..{Id: 2592, Name: VMHOST-02},
    ..{Id: 2594, Name: SRV-ORA-77},
    ..{Id: 2594, Name: SRV-ORA-77},
    ..{Id: 2607, Name: winserver2008}
    ]}
    
    PL/SQL procedure successfully completed.
    
  • Dynamic table returns only a line

    Hello world

    I try to use a Recordset:

    "SOME concerts. EventDate, concerts. Location, concerts. Notes

    CONCERTS

    WHERE the concerts. "EventDate > = CURRENT_DATE.

    When I test the Recordset, I get 3 of the 5 records returned, which is exactly as it should.

    However, when I try to create a dynamic table to display the results - if I choose to show all records, or the default of 10 at a time, it shows the first line results from the Recordset.

    When I try to create a master-detail table and ask him to show one record at a time, it's there for that, but using the next/back navigation links, it takes me to other records, though one at a time.  That tells me that he doesn't know that there should be three records, but it only shows one.

    What am I doing wrong with the dynamic table, here?

    Thank you!

    I suggest that you start the page completely from scratch, because it seems that you made the rookie mistake classic to remove a dynamic object in Design view without realizing that any other PHP code is connected with it. When you work with dynamic objects, keep an eye on what is listed in the server behaviors panel. To remove a server behavior, select the referencing in the Panel and click the button "-" to remove it properly.

    In fact, you have two sets of records on the same page, that do the same thing. One is called to come, the other is called UpcomingShows. You get only a line showing in your table is because you use the recordset "to come". The Dreamweaver recordset code automatically retrieves the first record and then uses a do... while loop to create the region repeated in the table. What has happened is that your changes to the page have resulted in this line who appear before the repeat region:

    mysql_free_result($upcoming);
    

    This destroys the rest of the result of database before using it again. Therefore, only trace never appears.

    Dreamweaver always puts mysql_free_result() after the closing tag. Thus, it seems that your changes caused Dreamweaver to lose track of all the relevant parts of the server behavior. If you move this line to the bottom of the page, your table should work. However, as I said before, I think that it is better to start from scratch.

    One last thing: your SQL query contains the following WHERE clause:

    WHERE gigs.EventDate >= CURRENT_DATE
    

    It is an incorrect syntax for MySQL. It should be like this:

    WHERE gigs.EventDate >= CURRENT_DATE()
    

    CURRENT_DATE() is a MySQL function, not a constant.

    If all goes well, a little less head banging.

  • Select a table returned in the result of the query

    Hi, I'm trying to find a way to query a table name that I'm back to a different query. I am doing this in pure SQL and PL/SQL, if I can.

    Here's the situation. I have a table called FILES, a table called TYPE and an unknown number of different reference tables with different names.

    Each entry in the FILE has a reference to a TYPE id, and each entry type is a varchar that contains the name of a table reference, such as PHOTO_INFORMATION, PDF_INFORMATION or XML_INFORMATION.

    I want to be able to extract the data from the reference table for any data file. So with a file id, I question TYPE to get the name of the reference table (IE, "PHOTO_INFORMATION" back) then the request it is at this table for all of its columns, using the reference id in the FILE table.

    The thing is that I wish it were generic, so that I can just add an entry to AA_TYPE and a new table for this type, and then I can ask her but I want, through the FILE table. The reason is that there are some data that is common for all files, and I would like to that data in one place.

    Here is my paintings, I have two reference tables of the sample to the bottom "AA_FILETYPE1" and "AA_FILETYPE_PHOTO".
    CREATE TABLE  "AA_FILES" 
       (     "FILE_ID" NUMBER, 
         "FILE_NAME" VARCHAR2(4000), 
         "FILE_TYPE" NUMBER, 
         "REFERENCE_ID" NUMBER, 
          CONSTRAINT "AA_TEST_FILE_PK" PRIMARY KEY ("FILE_ID") ENABLE
       )
    /
    
    CREATE TABLE  "AA_TYPE" 
       (     "TYPE_ID" NUMBER NOT NULL ENABLE, 
         "REFERENCE_TABLE" VARCHAR2(4000), 
          CONSTRAINT "AA_TYPE_PK" PRIMARY KEY ("TYPE_ID") ENABLE
       )
    /
    
    CREATE TABLE  "AA_FILETYPE1" 
       (     "REFERENCE_ID" NUMBER, 
         "DATE_MODIFIED" DATE, 
         "SUMMARY" VARCHAR2(4000), 
         "TOTAL_VALUE" NUMBER(5,2), 
          CONSTRAINT "AA_FILETYPE1_PK" PRIMARY KEY ("REFERENCE_ID") ENABLE
       )
    /
    
    CREATE TABLE  "AA_FILETYPE_PHOTO" 
       (     "REFERENCE_ID" NUMBER NOT NULL ENABLE, 
         "DATE_TAKEN" DATE, 
         "CAMERA_NUMBER" VARCHAR2(4000), 
         "WEATHER_CONDITIONS" VARCHAR2(4000), 
         "CONSULTANT_NAME" VARCHAR2(4000), 
          CONSTRAINT "AA_FILETYPE_PHOTO_PK" PRIMARY KEY ("REFERENCE_ID") ENABLE
       )
    /
    Here's an example query I would use:
    select * from (select REFERENCE_TABLE from AA_TYPE where TYPE_ID = AA_FILES.FILE_TYPE) where REFERENCE_ID = AA_FILES.REFERENCE_ID;
    So who withdrew all the columns in the reference given in AA_TYPE table based on an entry in AA_FILES.

    I'm not entirely sure how to do this, or if this is possible even without using PL/SQL.

    I'm open to suggestions on how to achieve what I want with a different design of table, I am a student and I'm not really experienced in database design. (My first design of database class isn't until next year!)

    Thank you very much!

    Hello

    [email protected] wrote:
    Sorry about the confusion about file_id = 3, I meant the insert in the third I've included. I did not indicate the id_fichier in my inserts since it is the main key and it auto increments.

    It is important to post of the CREATE TABLE and INSERT statements that work. All those who want to help you to will want to recreate the problem and test solutions. Also, do not use strings for all entries. If the column is a NUMBER, use a NUMBER in the INSERT statement. If the column is a DATE, use a DATE or a function that returns a DATE.
    So you should post something like:

    insert into AA_FILES(FILE_ID, FILE_NAME, FILE_TYPE, REFERENCE_ID) values (1, 'test-photo-1.jpg',  1,  1);
    insert into AA_FILES(FILE_ID, FILE_NAME, FILE_TYPE, REFERENCE_ID) values (2, 'test-xml-1.jpg',    2,  2);
    insert into AA_FILES(FILE_ID, FILE_NAME, FILE_TYPE, REFERENCE_ID) values (3, 'test-photo-2.jpg',  1,  2);
    -- The value file_type=1 immediately above was not in your original data, but seems to be what you meant.
    
    prompt =====  AA_TYPE Table:  =====
    
    insert into AA_TYPE(TYPE_ID, REFERENCE_TABLE) values (1, 'AA_FILETYPE_PHOTO');
    insert into AA_TYPE(TYPE_ID, REFERENCE_TABLE) values (2, 'AA_FILETYPE1');
    
    prompt =====  AA_FILETYPE1 Table:  =====
    
    insert into AA_FILETYPE1 (REFERENCE_ID, DATE_MODIFIED,                 SUMMARY,                                    TOTAL_VALUE)
           values           (1,           TO_DATE ('01-01-02', 'MM-DD-RR'), 'An XML file that has some information about something', '14');
    
    prompt =====  AA_FILETYPE_PHOTO Table:  =====
    
    insert into AA_FILETYPE_PHOTO (REFERENCE_ID, DATE_TAKEN,                 CAMERA_NUMBER, WEATHER_CONDITIONS, CONSULTANT_NAME)
                    values            (1,          TO_DATE ('01-01-01', 'MM-DD/RR'), 'abc123',      'rainy!',         'John Smith');
    insert into AA_FILETYPE_PHOTO (REFERENCE_ID, DATE_TAKEN,                 CAMERA_NUMBER, WEATHER_CONDITIONS, CONSULTANT_NAME)
                    values            (2,          TO_DATE ('01-01-02', 'MM-DD/RR'), 'def456',      'slightly cloudy',  'Jane Jones');
    commit;
    

    To give you my workplace, I'm applying in Application Express. A user has entered the number '3' the file_id (I'm not worried about the distinction between passing in the id_fichier and the name of the file, I just my application one application or the other).

    Now, run a query that will get related data which table it is stored in. I don't know the name of the table at design time, as that particular file may be of any type (each of which has a different table name). However, with a the file_id, I have a file_type (in aa_files) which refers to an entry in aa_type.

    I see. You could add even add new tables after this query is written. As long as the new table has a column named reference_id, and there is a line for the new table in aa_files, the following query should work.

    >

    select FILE_TYPE
    from AA_FILES
    where FILE_ID = 3
    

    I stored the name of the table, I need to ask for the rest of the data in aa_type at design time, so using the file_type value, I can get the name of reference_table:

    select REFERENCE_TABLE from AA_TYPE where FILE_TYPE = 1
    

    In the sample data, you have validated, Type_de_fichier = 2 on the 3rd row. I've changed that in my example 1 revised data.
    Be very careful that your explanation fits your data. You talk to people who know about your application, and it is very easy for them to be induced in error or confusion.

    Now the '1' is here that the first query would return. I would like to use a subquery to combine these two queries into a single (I think?). This second query would return "AA_FILETYPE_PHOTO", which is the reference table.

    So I have the reference table, which is a name of table to another table in my database. It contains the data that I'm actually looking for. I want it for this particular file (file_id 3), and in aa_files, I have a value of "reference_id", which refers to the respective line in the reference table. File_id 3, the reference_id is 2.

    select * from AA_FILETYPE_PHOTO
    where reference_id = 2
    

    If the above query gets me my final data.

    Now, I've been watching substitution values and bind variables, here's another way to explain what I want:

    Explanation step by step below is very useful. It would be more useful if each step uniquely and gavce movement results given the sample data and an example of setting (3 in this case)

    -- get the file_type from aa_files for the desired file
    EXEC :file_type := (select file_type from aa_files where file_id = 3);
    

    That we will call the step step (a) above.
    Step (a) sets: Type_de_fichier 1 (given my corrected sample data)

    -- get the reference table from aa_types using the file_type
    EXEC :reference_table := (select reference_table from aa_type where type_id = :file_type);
    

    That we will call the step step (b) above.
    (B) sets the stage: reference_table to 'AA_FILETYPE_PHOTO '.

    -- get the reference_id from aa_files for the desired file
    EXEC :reference_id := (select reference_id from aa_files where file_id = 3);
    

    That we will call the step step (c) above.
    (C) sets the stage: reference_id 2

    -- using the reference table and reference id for the desired file, get the rest of the data
    select * from :reference_table where reference_id = :reference_id;
    

    Not sure if this makes it more clear or not.

    Yes, it helps a lot.

    Basically I have a table full of table names. How do I write a query that pulls one of these table names and it then queries?

    You need SQL dynamic, because you can't hardcode a table name in the query that you normally would be.
    How dynamic SQL works normally (and the functioning of this example) are that the query is built by using a variable. In SQL * more (as shown below), you can simply use a variable substitution instead an identifier hardcoded, and that's what it takes to make the dynamic query from SQL * more resolves the substitution variables before sending the code for the compiler. I don't know much on the Apex, but I bet there's some way to do dynamic SQL in the Apex, too.
    So the dynamic part here should include step d, since you can't hardcode the name of the table in the query.
    Until we can step (d), then, did they to us to do the steps (a) and (b) to obtain this file name. In the example blelow, I used a separate, preliminary request to get the & table_name...
    Step (c) could be made in the main query, using a subquery or a join. However, I chose to step (c) in the preliminary motion, as well as steps (a) and (b), since it's the same table same step (a). In this way, step (d) must refer to a table.

    Here's (finally) how to make this work in SQL * more:

    ACCEPT     file_id     PROMPT     "Enter the file_id (a number, e.g. 3): "
    
    -- Preliminary Query, to set table_name
    
    COLUMN     reference_id_col     NEW_VALUE     reference_id
    COLUMN     table_name_col           NEW_VALUE     table_name
    
    SELECT  f.reference_id          AS reference_id_col
    ,     t.reference_table       AS table_name_col
    FROM      aa_files     f
    JOIN     aa_type          t     ON     f.file_type     = t.type_id
    WHERE     f.file_id     = &file_id
    ;
    
    --     Main Query
    
    SELECT  *
    FROM     &table_name
    WHERE      reference_id     = &reference_id
    ;
    

    The results, account required to the data from the sample I posted above, and the & file_id 3, are:

    `                      CAMERA_    WEATHER_        CONSULTANT_
    REFERENCE_ID DATE_TAKE NUMBER     CONDITIONS      NAME
    ------------ --------- ---------- --------------- ---------------
               2 01-JAN-02 def456     slightly cloudy Jane Jones
    
  • Problem when calling a return function of SQL BOOLEAN in package type

    Hi all

    I'm having a problem when you try to call a SQL function in a package with the return BOOLEAN type
    The SQL function signature is
    ####

    CREATE OR REPLACE PACKAGE RMSOWNER. ORDER_ATTRIB_SQL *.

    FUNCTION GET_PO_TYPE_DESC (O_error_message IN OUT VARCHAR2,
    I_PO_TYPE IN VARCHAR2,
    O_PO_TYPE_DESC IN OUT VARCHAR2)
    RETURN A BOOLEAN VALUE;

    ####


    Here is my java code

    ####
    + Cs3 CallableStatement = conn.prepareCall ("{?}") = call ORDER_ATTRIB_SQL. GET_PO_TYPE_DESC(?,?,?)} ");" +
    + CS3.registerOutParameter (1, java.sql.Types.BOOLEAN) +;
    + CS3.registerOutParameter (2, java.sql.Types.VARCHAR) +;
    + CS3.registerOutParameter (4, java.sql.Types.VARCHAR) +;
    + CS3. SetString (2, ""); +
    + CS3. SetString (3, "ST"); +
    + CS3. SetString (4, ""); +
    + ResultSet rs3 = cs3.executeQuery (); +
    ####

    I get the following exception, I tried to change the (registerOutParameter) boolean sql type bit, but I've always found this exception.
    But when I call all other functions with a return type other than boolean, they work perfectly well.

    Please can someone help me solve this problem, I don't know if its something to do with classes of JDBC providers?

    #####
    + java.sql.SQLException: ORA-06550: line 1, column 13: +.
    + PLS-00382: expression is of the wrong type.
    + ORA-06550: line 1, column 7: +.
    + PL/SQL: statement ignored +.

    + oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) +.
    + oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) +.
    + oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) +.
    + oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743) +.
    + oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:215) +.
    + oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:954) +.
    + oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168) +.
    + oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3316) +.
    + oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3422) +.
    + oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4394) +.

    #####

    Looks like it's a Limitation of the jdbc drivers. Please visit the following link:
    http://www-Camden.Rutgers.edu/help/documentation/Oracle/Java.815/a64684/typesup1.htm

    Here is an excerpt from above:
    ==========================================================
    PL/SQL BOOLEAN, RECORD and the Types of TABLES of packing

    Oracle JDBC drivers support the argument of appeal or return values of PL/SQL TABLE types (now known as indexed arrays by), REGISTRATION or BOOLEAN.

    To work around the problem, you can create wrapper procedures that manage data like types supported by JDBC. For example, to wrap a stored procedure that uses PL/SQL Boolean values, you can create a stored procedure that takes a character or a number of JDBC and passes to the original procedure as BOOLEAN or, for an output parameter, accepts a BOOLEAN of the original procedure argument and pass it as a TANK or a NUMBER to JDBC. Similarly, to wrap a stored procedure that uses PL/SQL records, you can create a stored procedure that maintains a record in its individual components (such as CHAR and NUMBER). To wrap a stored procedure that uses PL/SQL tables, you can divide the data into components or perhaps use Oracle collection types.

  • Need some tips to merge the two table-manipulation functions

    Hi guys!

    Thanks to Johnsold, Helmut O'Brian and Jcarmody, who helped me through a string function complicated (for me, the noob of LV), I got away with my project and I'm very close to its end.

    As I've described it here I wanted to explore an array of words combined with-, i.e. C1 - C10. Help, when I arrived, I was able to do. I also learned a few things and was able to do the following:

    Original array: new table:

    R1                                                       R1

    R2                                                       R2

    C1-C3                                                  C1

    K1                                                       C2

    C3

    K1

    I have this:

    Original array: new table:

    R1                                                       R1

    R2,R4,R7                                             R2

    C1                                                       R4

    K1                                                       R7

    C1

    K1

    I was also able to combine these two functions

    Now, back to my problem.

    Until now, it was just a 1 d array that I worked with. In fact, it's a 2D array, I read a. CSV file:

    As you can see there are a few places where things is combined with either - or by commas. I need to widen the first column as described above and as resolved in the thread I mentioned. Fact! No problem. I extracted the first column in table 1 d. Then expand it. Now, I need to replace in the original array and also expand all.

    It should then look like this:

    Then I only need to copy the position of the R6 line and paste it in the empty fields:

    I enclose below two screws. Start by opening the main.vi. Then copy.vi. I tried to describe the problem here too. You can see what I've accomplished and what is missing.

    Tasks:

    1. replace the column expanded in the original array and expand all.

    2 copy the needed lines.

    In the main.vi, I do the 1 d expansion, but I have the problem with the expansion of table 2D. In copy.vi, I managed to copy the lines. If this part is done.

    Basically, I need some advice on enlargement that I do and how do I get the 2D table also expanded. Because I have not much experience, I feel more comfortable working with 1 d arrays. But I can't seem to get any further with this 1 d-> expansion 2D.

    I also really can't seem to find a smart way to implement my function of copy-line-in the main.vi.

    P.S the joint screws are manufactured in LV2010.

    Fortunately, I can attend some courses of basic home OR here in Norway, but so far, I'm still learning and I think that sometimes, I try to do things that are way out of my League

    I don't know what I did but it works now

    Thanks for the help, same!

    You are even welcome!

    Have attached the file if anyone wants to see what I did.

  • How to use the rpad, lpad or substr function in the out put files in oracle plsql?

    Hi all

    Declare
       v_account varchar2(30) := '01-000-000-0000-000-0000 ';
       v_WIP varchar2(30) := '123435';
       v_code varchar2(30) := 'PURCHASE_PRICE_VARIANCE';
       v_dr number:=248.8;
       v_cr number:=248.8;
    Begin
     dbms_output.put_line('        Account Segments          '||'   '||' WIP Entity Name      '||'   '||'       Accounting class code          '||'  '||' Accounted DR '||'  '||' Accounted CR ');
     dbms_output.put_line('----------------------------------'||'   '||'----------------------'||'   '||'--------------------------------------'||'  '||'-------------------'||'  '||'------------------- ');
     dbms_output.put_line(rpad(v_account,30)||rpad(v_WIP,25)||rpad( v_code,34)||' '||rpad(v_dr,20)||rpad(v_cr,20));
    End;
    

    Out to

           Account Segments                  WIP Entity Name             Accounting class code               Accounted DR          Accounted CR 
    ----------------------------------   ----------------------   --------------------------------------  -------------------  ------------------- 
    01-000-000-0000-000-0000                  123435                   PURCHASE_PRICE_VARIANCE               248.8                    248.8               
    

    But if I v_code value is "ABCDGE" then

            Account Segments                  WIP Entity Name             Accounting class code                 Accounted DR      Accounted CR 
    ----------------------------------   ----------------------   --------------------------------------  -------------------  ------------------- 
    01-000-000-0000-000-0000                     123435            ABCDGE                             248.8               248.8               
    

    can you please help me how to solve this type of questions?

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production

    Thank you

    Rajesh123,


    If you do not have it still works, you can use the code below.

    This is based on the details below, you have given

    Account Segments--> left-aligned--> to 26 characters

    Entity name WIP--> Center--> 18 characters length

    Accounting--> left-aligned class--> character length 28 code

    NTS DR--> Center--> 15 character length

    NTS-> Center CR--> 15 character length

    I used the function line given by Karthick_Arp.

    Add the function below to your package:

    function align(p_str in varchar2, p_justify varchar2, p_size integer)
      return varchar2
      is
        l_str    varchar2(4000);
        l_temp   number;
        l_temp_1 number;
        l_left   number;
        l_right  number;
      begin
        case p_justify
          when 'RIGHT' then
            l_str := lpad(p_str, p_size);
          when 'LEFT' then
            l_str := rpad(p_str, p_size);
          when 'CENTER' then
            l_temp   := p_size - length(p_str);
            l_temp_1 := l_temp/2;
            l_left   := floor(l_temp_1);
            l_right  := ceil (l_temp_1);  
    
            l_str := lpad(' ', l_left) || p_str || rpad(' ', l_right);
          else
            raise_application_error(-20001, 'Invalid parameter for p_justify specified -- ' || p_justify);
        end case;  
    
        return l_str;
    end;
    

    Then copy the Sub lines to your code.

     fnd_file.put_line(fnd_file.output,align('Account Segments','CENTER',26)||'   '||align('WIP Entity Name','CENTER',18)||'   '||align('Accounting class code','CENTER',28)||'   '||align('Accounted DR','CENTER',15)||'   '||align('Accounted CR','CENTER',15));
     fnd_file.put_line(fnd_file.output,'--------------------------'||'   '||'------------------'||'   '||'----------------------------'||'   '||'---------------'||'   '||'---------------');
     fnd_file.put_line(fnd_file.output,align(nvl(v_account,' '),'LEFT',26)||'   '||align(v_WIP,'CENTER',18)||'   '||align(v_code,'LEFT',28)||'   '||align(v_dr,'CENTER',15)||'   '||align(v_cr,'CENTER',15));
    

    Once the above code 2 is added to your code, please compile the package and run the concurrent program. Check your output.

    See you soon

    AJ

Maybe you are looking for

  • How to disable the banner?

    For the last few days or so since I've upgraded to Firefox 42 every time I open Firefox on the desktop after a few minutes while I'm already deep in reading a web page, a white slide the top of the tab banner telling my I can synchronize the bookmark

  • VS394AA #ABU - HARD DRIVE REPLACEMENT

    WOULD BE A WDBH2D0010HNC INTEGRATE A HDD INTERNAL 3.5-1 TB SATA III 6 GB/S INTERFACE SUITABLE FOR MY COMPUTER? Thank you

  • That means "cell watch" using the battery?

    "If I don't use my phone much, I usually see my battery to use split ~ 50-50 between" ' standby cell ' and 'Idle phone.' " I have a strong signal here, so I doubt that I'm not getting a signal of 50% of the time. Anyone know what this means?

  • Equium L40 - 17 M PSL49E - collapsed Wlan work after BIOS update

    Hi all I have problem with my laptop.The laptop Equium L40 - 17 M, model PSL49E-00C005KS. For a few days, I am updating my BIOS after update, with the version P20B200 (bios 20080617131309), internal wireless stop working.Show me device is turned on b

  • Silverlight ERROR KB26668562

    Update of security for MICROSOFT Silverlight KB26668562 has not, no response