Returns the Collection using the table function

Hello

I'm trying to return a collection with registration type using the function table but face some problems.

Could someone help me with this.
SUNNY@11gR1> create or replace package test_pack as
  2  type rec_typ is record (
  3  empname varchar2(30),
  4  empage number(2),
  5  empsal number(10));
  6  type nest_typ is table of rec_typ;
  7  function list_emp return nest_typ;
  8  end;
  9  /

Package created.

Elapsed: 00:00:00.01
SUNNY@11gR1> create or replace package body test_pack is
  2  function list_emp return nest_typ is
  3  nest_var nest_typ := nest_typ();
  4  begin
  5  nest_var.extend;
  6  nest_var(nest_var.last).empname := 'KING';
  7  nest_var(nest_var.last).empage := 25;
  8  nest_var(nest_var.last).empsal := 2500;
  9  nest_var.extend;
 10  nest_var(nest_var.last).empname := 'SCOTT';
 11  nest_var(nest_var.last).empage := 22;
 12  nest_var(nest_var.last).empsal := 3500;
 13  nest_var.extend;
 14  nest_var(nest_var.last).empname := 'BLAKE';
 15  nest_var(nest_var.last).empage := 1;
 16  return nest_var;
 17  end;
 18  end;
 19  /

Package body created.

Elapsed: 00:00:00.01
SUNNY@11gR1> select * from table(test_pack.list_emp);
select * from table(test_pack.list_emp)
                    *
ERROR at line 1:
ORA-00902: invalid datatype


Elapsed: 00:00:00.01
SUNNY@11gR1>
Kind regards
Sunny

Hello

I had to look, because I didn't know the difference. If you use a function in the pipeline, then Oracle will create the implicit type. Take a look at the types:

select object_name from user_objects where object_type ='TYPE';

There are now objects that you create yourself, having PLSQL in name.

If you try your first example, you will see it will be no object created by implicit Oracle, so you must declare yourself in SQL.

Herald tiomela
Superconsult.nl

Tags: Database

Similar Questions

  • Display with the Table function in pipeline object

    I try to use a read only View object with a pipeline function table which takes in and defined by the user returns the objects. I work with an OraclePreparedStatement, but want to use a view object.

    This is the query:
    SELECT test_pkg.test_function(?,?) FROM DUAL;

    How can I configure the input parameters of the View object? The only method I can find available is setWhereClauseParam, but there is no where clause.
    Is it possible to use an object view in this situation?

    Any help is greatly appreciated. Thank you.
    S

    This can be done very easily. The query of your view object should be:

    SELECT *
      FROM TABLE(test_pkg.test_function(:bind1, :bind2))
    

    Then create variable bind for both parameters.
    You will set the bind variable in the same way that you define bind variables for any other question.

    Published by: jflack on April 9, 2013 16:28

  • Integrate the Table function in the package

    Hey everybody,

    I had a problem with my table function. I don't have it created in a package as a function table on the database. Now I have to integrate it in my package,

    but it does not work. What I have to put the type and Assembly in the package_spec? I always get the error: "each cursor or subprogramm in the package_spec statement must have a corresponding definition in the package body.

    But I already joined the funtion in the body. Maybe someone can help me? I would be very grateful!

    It's my spec package: (sorry, I don't know how to insert the code in this forum, maybe you can tell me)

    The search_type is declared, but so far not in the package:

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

    create or replace package test is

    TYPE search_set IS TABLE OF THE schema.search_type;

    function search (.)

    Return search_set;

    end test;

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

    create or replace package test body is

    function search (.)

    return search_set

    pipelined is

    ..

    search for late;

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

    create or repplace type search_type as object

    (..);

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

    If I lump the search_type package specifications, it will not accecpt the 'object '.

    It would be great if you can help me! I would also like to update my post I have someone tell me how to integrate the code correctly in this post.

    Many thanks!

    In your message the definition of function in the SPECIFICATION does not PIPELINED keyword, but your BODY plan has it.

  • Debug the 'Table function'

    Hello

    This question might be already on the forum, but I couldn't find anything about him.

    My question is: how to debug the service table.

    For example I have function in package

    Function Get_States (P_Parameter_1 In Number , P_Parameter_2 In Number ) Return Collection_type Pipelined ;
    

    And inside the function that I have piping line algorithms say some calculations. When I try to debug, it gives me error.

    Sql_Error.PNG

    Please guide me how to debug this function.

    Here, I found the solution.

    When I start debugging. It shows like this.

    So I just change

    DECLARE
      P_OWNER VARCHAR2(200);
      v_Return BIAS.DEBUG_TEST_PKG.T_PIPEROW;
    BEGIN
      P_OWNER := NULL;
    
        SELECT *
               bulk collect into v_Return
      FROM TABLE(DEBUG_TEST_PKG.DEBUG_PIPELINED_FUNCTION(
        P_OWNER
      ));
      /* Legacy output:
    DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
    */
      --:v_Return := v_Return;
    --rollback;
    END;
    

    But before that, I noticed a few points.

    1 - whenever I update to the new version, I simply import preferences from the previous version (but this time, I DID NOT import. just do fresh install and configure the debugger on step.). I don't know but this import was somehow me gives error.

    2. just after the creation of new features in the package, it is not in the list of choices debugging functions, so I restart SQL developer.

    Thank you.

  • Dial the stored function return array

    Hi all

    I have a function as follows:
    create or replace TYPE string_table IS the TABLE OF VARCHAR2 (2000);
    create or replace TYPE ARRAYTYPE is VARRAY (20) OF VARCHAR2 (30);
    create or replace FUNCTION getEmpArray (s varchar2, varchar2, st string_table t) RETURN ARRAYTYPE AS
    ARRAYTYPE l_data: = ARRAYTYPE();
    BEGIN
    l_data.extend; l_data (l_data. (Count): = s; l_data.extend; l_data (l_data. (Count): = t; l_data.extend; l_data (l_data. (Count): = St (1); L_data RETURN;
    END;

    I want to call this function from StoredFunctionCall
    Code:
    Fun StoredFunctionCall = new StoredFunctionCall();
    fun.setProcedureName ("getEmpArray".toUpperCase ());

    Object [] arr = new Object() {"aa", "Valentine", "bbb"};

    ArrayDescriptor = arrDescriptor
    ArrayDescriptor.createDescriptor ("string_table".toUpperCase (),
    connection);
    ARRAY arrayToPass = new ARRAY (arrDescriptor, arr);

    fun.addUnamedArgumentValue ("a");
    fun.addUnamedArgumentValue ("b");
    fun.addUnamedArgumentValue (arrayToPass);

    fun.setResult ("FUNCTION_RESULT"); to get result by this name

    List of vector < DatabaseRecord > = session.executeSelectingCall (fun);

    But the Exception
    PLS-00382: expression is of the wrong type
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    Error code: 6550
    Call: START? : = GETEMPARRAY (?,?,?); END;
    link = > [= > FUNCTION_RESULT, a, b, oracle.sql.ARRAY@21fbc01]


    Please help me

    Published by: fbg on 26/04/2010 21:52

    A few questions,

    1 JDBC does not support the type of TABLE PLSQL, you must use a type VARRAY, or wrap the TABLE function call in a function that takes a VARRAY.
    TopLink also has support for PLSQL types in his PLSQLStoredProcedureCall class, but no support is currently available for StoredFunctions.
    You can pass the VARRAY type for the argument of the TABLE.

    2. your function returns a VARRAY, so you must set the type in the result of StoredFunctionCall.
    We are currently the API to set a table for the result type, so you must directly access first parameter of the call or use a StoredProcedureCall (and convert your function of a procedure).

    You can also investigate a cursor of returning from a procedure stored instead of the varray.

    You can also directly access the JDBC connection and make the call using JDBC code.

    Feel free to connect these issues EclipseLink.

    ---
    James: www.eclipselink.org

  • duplicates of records in the table

    Hello
    I have the following type and I need to delete duplicate records
         declare
              type x_object_type is table of number
              index by binary_integer;
              x_table x_object_type;
              idx number;
         begin
               select manager_id bulk collect into x_table
              from employees
              where rownum <= 6;
              idx := x_table.first;
              for i in x_table.first..x_table.last loop
                   if idx = x_table.next(i) then
                     dbms_output.put_line('it is a duplicate');
                   else 
                     dbms_output.put_line('no duplicate '||x_table(i));     
                   end if;
              idx := x_table.next(i);
              end loop;
         end;
    
    the result is:
    no duplicate 207
    no duplicate 124
    no duplicate 101
    no duplicate 100
    no duplicate 201
    no duplicate 101
    as you can see I have duplicated lines. This is an example, the values in the table are not stored in a table to eliminate using rowid.

    Thank you

    Hi coco problem already solved?
    In my view, that there are some problems in comparison. Try this:

    declare
              type x_object_type is table of number
              index by binary_integer;
              x_table x_object_type;
              idx number;
        dup boolean;
    
         begin
               select manager_id bulk collect into x_table
              from hr.employees
              where rownum <= 6;
              --idx := x_table.first;
              for i in x_table.first..x_table.last-1 loop
        idx := x_table(i);
        --dbms_output.put_line('Now checking '||idx||' for duplicates.');
        dup := false;
            for a in x_table.first..x_table.last loop
              if idx = x_table(a) and a != i then
                dup := true;
              end if;
            end loop;
           IF dup then
             dbms_output.put_line('it is a duplicate: '||x_table(i));
            else
             dbms_output.put_line('no duplicate: '||x_table(i));
           END IF;
        end loop;
         end;
    /
    

    You choose the first value and then wrap well than all the others. If you need 2 loops and this "idx: = x_table.first;" the nr of the table not returns.

    But, as a suggestion, use a table function. It's more fun:

    CREATE TYPE numset_t IS TABLE OF NUMBER;
    
    CREATE OR REPLACE FUNCTION GET_manager_id RETURN numset_t PIPELINED
    IS
    BEGIN
    
    FOR i in (select manager_id
         from employees
         where rownum <= 6 AND manager_id IS NOT NULL) LOOP
           PIPE ROW(i.manager_id );
         END LOOP;
      RETURN;
    END;
    /
    
    select a.column_value,count(*) from
    (SELECT DISTINCT column_value FROM table(GET_manager_id())) a
    INNER JOIN table(GET_manager_id()) b
    ON a.column_value = b.column_value
    group by a.column_value
    order by a.column_value;
    

    If the code is much easier and you have total flexibility, SQL.

    -andy

  • Hi I have a problem of xml with xsd validation and insert into the table...

    I use this function to validate the XML with xsd, but it gives-31000 error related to xdb

    and I also try to recover data from the xml file, but it is fetching nullability of him.

    while I was trying to recover data after removing the tablenamespace, url and other additional field or can tell

    from a simple xml file than it is to get him.

    Please help me with this!

    FUNCTION to CREATE or REPLACE ALI$ XML_VALID (P_xml IN xmltype
    P_xsd IN xmltype)
    RETURN NUMBER
    is


    l_status NUMBER;
    l_xml xmltype.
    l_xsd XMLTYPE.
    l_v_schemaURL VARCHAR2 (256): = "NewBusinessApplication.xsd";
    schema_doesnt_exist exception;
    pragma exception_init (schema_doesnt_exist,-31000);

    BEGIN
    l_xsd: = p_xsd;
    Start
    DBMS_XMLSCHEMA.deleteSchema (l_v_schemaURL, dbms_xmlSchema.DELETE_CASCADE_FORCE);
    exception
    When schema_doesnt_exist then
    null;
    end;

    DBMS_XMLSCHEMA. REGISTERSCHEMA)

    schemaurl = > l_v_schemaURL

    , schemadoc = > l_xsd

    local = > TRUE

    , genTypes = > FALSE

    , genbean = > FALSE

    , genTables = > FALSE

    );
    l_xml: = p_xml;

    If l_xml.isSchemaValid () = 1 then

    dbms_output.put_line ("' scheme is valid");
    l_status: = 1;
    RETURN l_status;
    on the other
    l_xml.schemaValidate ();
    l_status: = 0;
    RETURN l_status;
    end if;
    END;

    -call to above function

    DECLARE

    l_xml xmltype: = xmltype (' <? xml version = "1.0" encoding = "UTF - 8"? >)

    "" < NewBusinessApplication xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"

    "" xsi: schemaLocation = "http://www.example.org NewBusinessApplication.xsd.

    xmlns ="http://www.example.org" > ".

    < TransactionHeader >

    < TR_REF_NO > 000009812681 < / TR_REF_NO >

    < EFF_DT > 20140703094140.572 [-4:US / Eastern] < / EFF_DT >

    < SRC_SYS_CD dmnSRC_SYSTEM = "TSS" > Support of TV system < / SRC_SYS_CD >

    < / TransactionHeader >

    < ApplicationRq >

    < ApplInfo >

    < APPLNO > A00018L < / APPLNO >

    < MED_NONMED dmnMED_NONMED = "M" > medical < / MED_NONMED >

    < APPL_DT > 20140714 < / APPL_DT >

    < EFF_DT > 20140714 < / EFF_DT >

    < APPL_RECV_DT > 20140714 < / APPL_RECV_DT >

    < / ApplInfo >

    < AgentInfo >

    <! – repeat the nodes below for more than one agent - >

    <>Agent

    < AGT_CD > AGN0000001 < / AGT_CD >

    James < FIRSTNAME > < / NAME >

    < NAME > Whorphin < / LASTNAME >

    BKK1010090009 < AGT-LICNO > < / AGT-LICNO >

    the Warriors < TEAM > < / TEAM >

    Suriya Thapa < TEAMLEADER > < / TEAMLEADER >

    BKK909988999 < TEAMLEADER-LICNO > < / TEAMLEADER LICNO >

    < / agent >

    < / AgentInfo >

    < InsuredInfo >

    < dmnPERS_NAMEPREFIX PREFIX-TH = "XX" > Dr. < / PREFIX-TH >

    XXXXXXX < FIRSTNAME-TH > < / FIRSTNAME-TH >

    XXXXXX < MIDNAME-TH > < / MIDNAME-TH >

    XXXXXX < LASTNAME-TH > < / LASTNAME-TH >

    XXXXXX < FORMERNAME > < / FORMERNAME >

    < PREFIX-dmnPERS_NAMEPREFIX-EN = "XX" > Dr. < / PREFIX-EN >

    YYYYYY < FIRSTNAME-EN > < / FIRSTNAME-EN >

    YYYYYY < MIDNAME-EN > < / MIDNAME-FR >

    YYYYYY < LASTNAME-EN > < / LASTNAME-EN >

    < BIRTH_DT > 19800101 < / BIRTH_DT >

    < 33 YEARS > < / AGE >

    < dmnPERNSEXCD = "XX" SEX > male < / TYPE >

    < DmnPERC_MAR_STAT_CD MARITAL_STATUS = "XX" > single < / MARITAL_STATUS >

    < dmnRACE = "XX" RACE > ZZZ < / RACE >

    < dmnRELIGION RELIGION = "H" > HINDU < / RELIGION >

    < dmnNATIONALITY NATIONALITY = an' TH' > THAI < / NATIONALITY >

    < dmnIDTYPE ID-TYPE = "TI" > Thai National ID < / ID-TYPE >

    > ID < AJMPK0001J < / ID >

    < ID-XPIR_DT > 20200101 < / ID-XPIR_DT >

    < dmnOCCUP_CD OCCUPATION = "XX" / >

    < OCCUP_CLASS dmnOCCUP_CLASS_CD = 'XX' / >

    < ANNUAL_INCOME > 100000 < / ANNUAL_INCOME >

    < HEIGHT > 175 < / HEIGHT >

    < WEIGHT > 80 < / WEIGHT >

    < / InsuredInfo >

    < ProposerInfo >

    < dmnPERS_NAMEPREFIX PREFIX-TH = "XX" > Dr. < / PREFIX-TH >

    XXXXXXX < FIRSTNAME-TH > < / FIRSTNAME-TH >

    XXXXXX < MIDNAME-TH > < / MIDNAME-TH >

    XXXXXX < LASTNAME-TH > < / LASTNAME-TH >

    XXXXXX < FORMERNAME > < / FORMERNAME >

    < PREFIX-dmnPERS_NAMEPREFIX-EN = "XX" > Dr. < / PREFIX-EN >

    YYYYYY < FIRSTNAME-EN > < / FIRSTNAME-EN >

    YYYYYY < MIDNAME-EN > < / MIDNAME-FR >

    YYYYYY < LASTNAME-EN > < / LASTNAME-EN >

    < BIRTH_DT > 19800101 < / BIRTH_DT >

    < 33 YEARS > < / AGE >

    < dmnPERNSEXCD = "XX" SEX > male < / TYPE >

    < DmnPERC_MAR_STAT_CD MARITAL_STATUS = "XX" > single < / MARITAL_STATUS >

    < dmnRACE = "XX" RACE > ZZZ < / RACE >

    < dmnRELIGION RELIGION = "H" > HINDU < / RELIGION >

    < dmnNATIONALITY NATIONALITY = an' TH' > THAI < / NATIONALITY >

    < dmnIDTYPE ID_TYPE = "TI" > Thai National ID < / ID_TYPE >

    AJMPK0001J < ID_NUMBER > < / ID_NUMBER >

    < ID_XPIR_DT > 20200101 < / ID_XPIR_DT >

    < dmnOCCUP_CD OCCUPATION = "XX" / >

    < OCCUP_CLASS dmnOCCUP_CLASS_CD = 'XX' / >

    < ANNUAL_INCOME > 100000 < / ANNUAL_INCOME >

    < / ProposerInfo >

    < ContactInfo >

    < AddressInfo >

    <! – repeat the nodes below for each address type - >

    < address >

    < dmnADDR_ADDRTYPE ADDRTYPE = "01" > home < / ADDRTYPE >

    < PRIMARY_CONTACT > 0 < / PRIMARY_CONTACT >

    < / address >

    < address >

    < dmnADDR_ADDRTYPE ADDRTYPE "02" = > Office < / ADDRTYPE >

    < PRIMARY_CONTACT > 1 < / PRIMARY_CONTACT >

    < / address >

    < / AddressInfo >

    < PhoneInfo >

    <! – repeat the nodes below for each type of phone - >

    < Phone >

    < dmnADRP_PHONETYPE PHONETYPE "01" = > Mobile < / PHONETYPE >

    < PHONENUM > 9887666789 < / PHONENUM >

    < PRIMARY_CONTACT > 1 < / PRIMARY_CONTACT >

    < / Phone >

    < Phone >

    < dmnADRP_PHONETYPE PHONETYPE "02" = > home < / PHONETYPE >

    < PHONENUM > 9887666789 < / PHONENUM >

    < PRIMARY_CONTACT > 0 < / PRIMARY_CONTACT >

    < / Phone >

    < / PhoneInfo >

    < EmailInfo >

    <! – repeat the nodes below for each type of email - >

    < email >

    < EMAILTYPE dmnADRO_EMAILTYPE = "01" > e-mail1 < / EMAILTYPE >

    < EMAILDATA > [email protected] < / EMAILDATA >

    < PRIMARY_CONTACT > 0 < / PRIMARY_CONTACT >

    < / email >

    < email >

    < EMAILTYPE dmnADRO_EMAILTYPE "02" = > Email2 < / EMAILTYPE >

    < EMAILDATA > [email protected] < / EMAILDATA >

    < PRIMARY_CONTACT > 1 < / PRIMARY_CONTACT >

    < / email >

    < / EmailInfo >

    < / ContactInfo >

    < PolicyInfo >

    STG102 < BASE-PLAN_CD > < / BASE-PLAN_CD >

    < BASE-PLAN_NM > Smart term 10 gold < / BASE-PLAN_NM >

    < MODEOFPAYMENT dmnZZFREQUENCY = "M" > monthly < / MODEOFPAYMENT >

    < BASE - ITS > 100000.00 < / BASE - SA >

    < BASE-PREMIUM > 12000.00 < / BASE-PREMIUM >

    < BASE-MODALPREMIUM > 1000.00 < / BASE-MODALPREMIUM >

    < AYFP > 13200.00 < / AYFP >

    < RiderInfo >

    < rider >

    RIDER < CODE > ME < / RIDER-CODE >

    Medical costs < RIDER-NAME > < / RIDER-NAME >

    < RIDER - HIS 20000.00 > < / RIDER - SA >

    < RIDER-PREMIUM > 600.00 < / RIDER-PREMIUM >

    < RIDER-MODALPREMIUM > 50.00 < / RIDER-MODALPREMIUM >

    < / rider >

    < rider >

    RIDER HAB < CODE > < / RIDER-CODE >

    < NAME-RIDER > Admission hospitalization < / RIDER-NAME >

    < RIDER - HIS 20000.00 > < / RIDER - SA >

    < RIDER-PREMIUM > 600.00 < / RIDER-PREMIUM >

    < RIDER-MODALPREMIUM > 50.00 < / RIDER-MODALPREMIUM >

    < / rider >

    < / RiderInfo >

    < / PolicyInfo >

    < PaymentInfo >

    < borde >

    < TMP_RECEIPT_NO > TEMP0001 < / TMP_RECEIPT_NO >

    < TOTAL_PYMT_AMT > 13200.00 < / TOTAL_PYMT_AMT >

    <! – repeat the nodes below for payment through several channels - >

    < payment >

    < dmnPAYRTYPE PAYER "01" = > secured < / PAYER >

    credit card < dmnPaymentType PYMT TYPE = "01" > < / PYMT-TYPE >

    < PYMT-AMT > 13200.00 < / PYMT-AMT >

    < PYMT-Channel >

    credit <>card

    Visa < dmnCardType CARD-TYPE = "01" > < / CARD-TYPE >

    < BADGE - N ° > 9890989098909877 < / CARD-NOT >

    < HOLDERNAME-CARD > RICKY WHORPHIN < / CARD-HOLDERNAME >

    < BANKNM-CARD > Standard Chartered Bank < / MAP-BANKNM >

    < MAP SHOWED > 08/14 < / CARD-SHOW >

    < MAP-AUTHCODE / >

    < CARD-AUTHDATE / >

    < / credit card >

    < / PYMT-Channel >

    < / payment >

    < payment >

    < dmnPAYRTYPE PAYER "01" = > secured < / PAYER >

    < dmnPaymentType PYMT-TYPE = '02' > account < / PYMT-TYPE >

    < PYMT-AMT > 13200.00 < / PYMT-AMT >

    < PYMT-Channel >

    < Bank >

    < BANK CODE / >

    < BANK BRANCH / >

    < BANK-ACCNO / >

    < BANK-ACCNAME / >

    < / Bank >

    < / PYMT-Channel >

    < / payment >

    < payment >

    < dmnPAYRTYPE PAYER "01" = > secured < / PAYER >

    < dmnPaymentType PYMT TYPE = "03" > check < / PYMT-TYPE >

    < PYMT-AMT > 13200.00 < / PYMT-AMT >

    < PYMT-Channel >

    < check >

    < CHQ - n / >

    < CHQ-DATE / >

    < CHQ-ISSUEBANK / >

    < / cheque >

    < / PYMT-Channel >

    < / payment >

    < / shell >

    < RenewalPayment >

    < dmnPAYRTYPE PAYER "01" = > secured < / PAYER >

    < DDCHANNEL dmnPaymentType "01" = > SDC < / DDCHANNEL >

    < DDCDetails >

    Visa < dmnCardType CARD-TYPE = "01" > < / CARD-TYPE >

    < BADGE - N ° > 9890989098909877 < / CARD-NOT >

    < HOLDERNAME-CARD > RICKY WHORPHIN < / CARD-HOLDERNAME >

    < BANKNM-CARD > Standard Chartered Bank < / MAP-BANKNM >

    < MAP SHOWED > 08/14 < / CARD-SHOW >

    < / DDCDetails >

    < DDADetails >

    < dmnBNK_TYP_CD BANK-ACCTYPE = "01" > save < / BANK-ACCTYPE >

    < BANK-ACCNO / >

    < BANK-ACCNAME / >

    < BANK BRANCH / >

    < / DDADetails >

    < / RenewalPayment >

    < / PaymentInfo >

    < BeneficiaryInfo >

    <!--repeat the nodes below for each beneficiary and the sum of the pct should be 100-->

    < recipient >

    Joint < dmnBENE_RELT_CD RELATIONSHIP = "01" > < / RELATIONSHIP >

    XXXX < FIRSTNAME > < / NAME >

    XXXXX < MIDNAME > < / MIDNAME >

    XXXX < NAME > < / LASTNAME >

    < PERCENT > 50 < / PERCENTAGE >

    < BIRTH_DT > 19800101 < / BIRTH_DT >

    < dmnPERNSEXCD SEX = "XX" > female < / TYPE >

    < NATLIDNO > TH000001 < / NATLIDNO >

    < / recipients >

    < recipient >

    < dmnBENE_RELT_CD RELATIONSHIP "02" = > child < / RELATIONSHIP >

    XXXX < FIRSTNAME > < / NAME >

    XXXXX < MIDNAME > < / MIDNAME >

    XXXX < NAME > < / LASTNAME >

    < PERCENT > 50 < / PERCENTAGE >

    < BIRTH_DT > 19800101 < / BIRTH_DT >

    < dmnPERNSEXCD = "XX" SEX > male < / TYPE >

    < NATLIDNO > TH000002 < / NATLIDNO >

    < / recipients >

    < / BeneficiaryInfo >

    < survey >

    < HealthDeclaration >

    < question >

    Q001 < QUESTION_ID > < / QUESTION_ID >

    < dmnZZYESNO_NUM RESPONSE = "N" > n < / ANSWER >

    < / question >

    < question >

    Q002 < QUESTION_ID > < / QUESTION_ID >

    < dmnZZYESNO_NUM RESPONSE = "N" > n < / ANSWER >

    < / question >

    < question >

    Q003 < QUESTION_ID > < / QUESTION_ID >

    < dmnZZYESNO_NUM RESPONSE = "N" > n < / ANSWER >

    < / question >

    < question >

    Q004 < QUESTION_ID > < / QUESTION_ID >

    < dmnZZYESNO_NUM RESPONSE = "N" > n < / ANSWER >

    < / question >

    < question >

    Q005 < QUESTION_ID > < / QUESTION_ID >

    < dmnZZYESNO_NUM RESPONSE = "N" > n < / ANSWER >

    < / question >

    < / HealthDeclaration >

    < / questionnaire >

    < / ApplicationRq >

    < ApplicationRs >

    <-reason for the rejection / >

    < / ApplicationRs >

    < / NewBusinessApplication >

    ');

    l_xsd xmltype: = xmltype (' <? xml version = "1.0" encoding = "windows-1252"? >)

    "< xsd: Schema container ="http://www.w3.org/2001/XMLSchema"xmlns ="http://www.example.org"

    targetNamespace ="http://www.example.org" elementFormDefault = "qualified" > "

    < xsd: element name = "NewBusinessApplication" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "TransactionHeader" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "TR_REF_NO" type = "xsd: Integer" / >

    < xsd: element name = "EFF_DT" type = "xsd: String" / >

    < xsd: element name = "SRC_SYS_CD" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnSRC_SYSTEM" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "ApplicationRq" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "ApplInfo" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "APPLNO" type = "xsd: String" / >

    < xsd: element name = "MED_NONMED" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnMED_NONMED" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "APPL_DT" type = "xsd: Integer" / >

    < xsd: element name = "EFF_DT" type = "xsd: Integer" / >

    < xsd: element name = "APPL_RECV_DT" type = "xsd: Integer" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "AgentInfo" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "The Agent" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "AGT_CD" type = "xsd: String" / >

    < xsd: element name = "FIRSTNAME" type = "xsd: String" / >

    < xsd: element name = "NAME" type = "xsd: String" / >

    < xsd: element name = "AGT-LICNO" type = "xsd: String" / >

    < xsd: element name = "TEAM" type = "xsd: String" / >

    < xsd: element name = "TEAMLEADER" type = "xsd: String" / >

    < xsd: element name = "TEAMLEADER-LICNO" type = "xsd: String" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "InsuredInfo" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = 'PREFIX-TH' >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPERS_NAMEPREFIX" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "NAME-TH" type = "xsd: String" / >

    < xsd: element name = "MIDNAME-TH" type = "xsd: String" / >

    < xsd: element name = "LASTNAME-TH" type = "xsd: String" / >

    < xsd: element name = "FORMERNAME" type = "xsd: String" / >

    < xsd: element name = "PREFIX-FR" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPERS_NAMEPREFIX-EN" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "NAME-IN" type = "xsd: String" / >

    < xsd: element name = "MIDNAME-EN" type = "xsd: String" / >

    < xsd: element name = "LASTNAME-IN" type = "xsd: String" / >

    < xsd: element name = "BIRTH_DT" type = "xsd: Integer" / >

    < xsd: element name = "ÂGE" type = "xsd: Integer" / >

    < xsd: element name = "GENDER" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPERNSEXCD" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "MARITAL_STATUS" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPERC_MAR_STAT_CD" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "RACE" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnRACE" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "RELIGION" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnRELIGION" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "NATIONALITY" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnNATIONALITY" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "ID-TYPE" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnIDTYPE" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "ID" type = "xsd: String" / >

    < xsd: element name = "ID-XPIR_DT" type = "xsd: Integer" / >

    < xsd: element name = "OCCUPATION" >

    < xsd: complexType >

    < xsd: attribute name = "dmnOCCUP_CD" type = "xsd: String" / >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "OCCUP_CLASS" >

    < xsd: complexType >

    < xsd: attribute name = "dmnOCCUP_CLASS_CD" type = "xsd: String" / >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "ANNUAL_INCOME" type = "xsd: Integer" / >

    < xsd: element name = "HEIGHT" type = "xsd: Integer" / >

    < xsd: element name = "WEIGHT" type = "xsd: Integer" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "ProposerInfo" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = 'PREFIX-TH' >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPERS_NAMEPREFIX" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "NAME-TH" type = "xsd: String" / >

    < xsd: element name = "MIDNAME-TH" type = "xsd: String" / >

    < xsd: element name = "LASTNAME-TH" type = "xsd: String" / >

    < xsd: element name = "FORMERNAME" type = "xsd: String" / >

    < xsd: element name = "PREFIX-FR" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPERS_NAMEPREFIX-EN" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "NAME-IN" type = "xsd: String" / >

    < xsd: element name = "MIDNAME-EN" type = "xsd: String" / >

    < xsd: element name = "LASTNAME-IN" type = "xsd: String" / >

    < xsd: element name = "BIRTH_DT" type = "xsd: Integer" / >

    < xsd: element name = "ÂGE" type = "xsd: Integer" / >

    < xsd: element name = "GENDER" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPERNSEXCD" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "MARITAL_STATUS" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPERC_MAR_STAT_CD" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "RACE" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnRACE" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "RELIGION" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnRELIGION" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "NATIONALITY" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnNATIONALITY" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "ID_TYPE" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnIDTYPE" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "ID_NUMBER" type = "xsd: String" / >

    < xsd: element name = "ID_XPIR_DT" type = "xsd: Integer" / >

    < xsd: element name = "OCCUPATION" >

    < xsd: complexType >

    < xsd: attribute name = "dmnOCCUP_CD" type = "xsd: String" / >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "OCCUP_CLASS" >

    < xsd: complexType >

    < xsd: attribute name = "dmnOCCUP_CLASS_CD" type = "xsd: String" / >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "ANNUAL_INCOME" type = "xsd: Integer" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "ContactInfo" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "AddressInfo" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "Address" maxOccurs = "unbounded" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "ADDRTYPE" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnADDR_ADDRTYPE" type = "xsd: Integer" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "PRIMARY_CONTACT" type = "xsd: Integer" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "PhoneInfo" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "Phone" maxOccurs = "unbounded" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "PHONETYPE" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnADRP_PHONETYPE" type = "xsd: Integer" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "PHONENUM" type = "xsd: Integer" / >

    < xsd: element name = "PRIMARY_CONTACT" type = "xsd: Integer" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "EmailInfo" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "Email" maxOccurs = "unbounded" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "EMAILTYPE" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnADRO_EMAILTYPE" type = "xsd: Integer" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "EMAILDATA" type = "xsd: String" / >

    < xsd: element name = "PRIMARY_CONTACT" type = "xsd: Integer" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "PolicyInfo" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "BASE-PLAN_CD" type = "xsd: String" / >

    < xsd: element name = "BASE-PLAN_NM" type = "xsd: String" / >

    < xsd: element name = "MODEOFPAYMENT" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnZZFREQUENCY" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "BASE - SA" type = "xsd: float" / >

    < xsd: element name = "BASE-PREMIUM" type = "xsd: float" / >

    < xsd: element name = "BASE-MODALPREMIUM" type = "xsd: float" / >

    < xsd: element name = "AYFP" type = "xsd: float" / >

    < xsd: element name = "RiderInfo" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "Rider" maxOccurs = "unbounded" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "RIDER-CODE" type = "xsd: String" / >

    < xsd: element name = "RIDER-NAME" type = "xsd: String" / >

    < xsd: element name = "RIDER - SA" type = "xsd: float" / >

    < xsd: element name = "RIDER-PREMIUM" type = "xsd: float" / >

    < xsd: element name = "RIDER-MODALPREMIUM" type = "xsd: float" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "PaymentInfo" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "Bordered" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "TMP_RECEIPT_NO" type = "xsd: String" / >

    < xsd: element name = "TOTAL_PYMT_AMT" type = "xsd: float" / >

    < xsd: element name = "Payment" maxOccurs = "unbounded" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "PAYER" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPAYRTYPE" type = "xsd: Integer" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "TYPE PYMT" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPaymentType" type = "xsd: Integer" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "PYMT-AMT" type = "xsd: float" / >

    < xsd: element name = "PYMT-Channel" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "CreditCard" minOccurs = "0" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "CARD TYPE" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnCardType" type = "xsd: Integer" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "CARD-NO" type = "xsd: Integer" / >

    < xsd: element name = "CARD-HOLDERNAME" type = "xsd: String" / >

    < xsd: element name = "CARD-BANKNM" type = "xsd: String" / >

    < xsd: element name = "CARD-DISPLAYED" type = "xsd: String" / >

    < xsd: element name = "CARD-AUTHCODE" / >

    < xsd: element name = "CARD-AUTHDATE" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "Bank" minOccurs = "0" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "BANK CODE" / >

    < xsd: element name = "BANK-BRANCH" / >

    < xsd: element name = "BANK-ACCNO" / >

    < xsd: element name = "BANK-ACCNAME" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "Cheque" minOccurs = "0" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "CHQ - NO" / >

    < xsd: element name = "CHQ-DATE" / >

    < xsd: element name = "CHQ-ISSUEBANK" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "RenewalPayment" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "PAYER" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPAYRTYPE" type = "xsd: Integer" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "DDCHANNEL" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPaymentType" type = "xsd: Integer" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "DDCDetails" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "CARD TYPE" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnCardType" type = "xsd: Integer" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "CARD-NO" type = "xsd: Integer" / >

    < xsd: element name = "CARD-HOLDERNAME" type = "xsd: String" / >

    < xsd: element name = "CARD-BANKNM" type = "xsd: String" / >

    < xsd: element name = "CARD-DISPLAYED" type = "xsd: String" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "DDADetails" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "BANK-ACCTYPE" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnBNK_TYP_CD" type = "xsd: Integer" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "BANK-ACCNO" / >

    < xsd: element name = "BANK-ACCNAME" / >

    < xsd: element name = "BANK-BRANCH" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "BeneficiaryInfo" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "Recipient" maxOccurs = "unbounded" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "RELATIONSHIP" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnBENE_RELT_CD" type = "xsd: Integer" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "FIRSTNAME" type = "xsd: String" / >

    < xsd: element name = "MIDNAME" type = "xsd: String" / >

    < xsd: element name = "NAME" type = "xsd: String" / >

    < xsd: element name = "PERCENTAGE" type = "xsd: Integer" / >

    < xsd: element name = "BIRTH_DT" type = "xsd: Integer" / >

    < xsd: element name = "GENDER" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnPERNSEXCD" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "NATLIDNO" type = "xsd: String" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "Questionnaire" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "HealthDeclaration" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "Issue" maxOccurs = "unbounded" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "QUESTION_ID" type = "xsd: String" / >

    < xsd: element name = "ANSWER" >

    < xsd: complexType >

    < xsd:simpleContent >

    < xsd:extension base = "XSD: String" >

    < xsd: attribute name = "dmnZZYESNO_NUM" type = "xsd: String" / >

    < / xsd:extension >

    < / xsd:simpleContent >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: element name = "ApplicationRs" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "Reason for rejection" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: SEQUENCE >

    < xsd: attribute name = "xsi" type = "xsd: String" / >

    < xsd: attribute name = "schemaLocation" type = "xsd: String" / >

    < / xsd: complexType >

    < / xsd: element >

    < / xsd: Schema >

    ');

    BEGIN

    dbms_output.put_line (Ali$ XML_VALID (l_xml, l_xsd));

    END;

    and please do not confused, you don't need to answer if I do not any sense.

    BUT I STILL HAVE ONE LAST QUESTION

    do you know how to use namespaces in the exctractvalue().

    I'm not "troubled", just frustrated that you don't seem to understand what I've explained so far.

    Why do you insist on the use of extractvalue? Don't use extractvalue, it is deprecated, use XMLTABLE instead.

    If you feel compelled to use extractvalue of certain grounds, just the curiosity to seek it in the documentation, you can find the syntax to use the namespaces:

    http://docs.Oracle.com/CD/E11882_01/server.112/e41084/functions061.htm#SQLRF06173

    in your last code, you first insert the XML and extract data from it. I can do it too, but it's not my requirement. I'm supposed to read the first xml (if it is valid) as I do in my code using the table function and make the continuation of the procedure.

    Look, I'll ask you one last time:

    What problem are you having? What prevents you from first reading, certain values before inserting, as you need. Just use the same query XMLTABLE that I showed in my example, except you will not query the table, but directly from the XMLType variable:

    PASSAGE v_xml

    COLUMNS...

  • To return the rows

    Dear members
    I need a function to return the lines

    This is my sample data
    ID     DESC               UNI          CODE
    1     BO_USER               40352          A
    2     BO_USER1          40353          D
    3     BUSINESS_PARTNER1     40353          F
    4     BUSINESS_PARTNER2     40354          R
    5     BUSINESS_PARTNER3     40354          N
    If I pass the id and United as an input value, that I need to get all of the line as well

    Create or replace function ((ID en varchar2, UNI en varchar2))
    return
    l_val;


    Itry to serve table tpe
    and the type as object and call that function, but when I try to call this value, I am not able to
    use of the name of the function instead of this I need to use
    slect * form the name of the table function

    If somene post a few syntax how to I will follow

    regads

    Hello

    You can create the function with the return type as table % rowtype. And even you can call this function in a block anonymous plsql and display the desired value.
    But in sqlplus, you won't be able to use it as a sql statement since it is the unsupported data type.

    This was based on my understanding of the declared scénarion. Let us know if its different

    SBH

  • parallel in pipeline table function

    Hi all

    To "allow the parallel pipeline" table function, what I need to turn a query parallel session first?

    I read a few white papers or web pages on map and reduce implemented with function table Oracle and see that, based on the table.

    Use the cursor in the loop to get a line, run out! This replaces SQL pl/sql.

    What is the cost that must be paid according to the table?

    Finally, how can I confirm that Oracle has put the table function in parallel?

    Best regards

    Leon

    user12064076 wrote:

    In my application, I wrote stored procedures that return a collection of user-not of the types of objects to Java.

    Flawed approach using memory expensive private server (PL/SQL PGA) caching SQL data and then push this data to the client - when the customer can use instead the more scalable and higher shared cache buffer memory instead.

    With the types of objects, we can remove most of the redundent data.

    This statement makes no sense that it is the same for SQL and sliders. And remove redundant data is preferable to the SQL itself - through partitioning engine pruning, predicates, only by selecting the columns there is place for the projection of SQL and so on.

    This OO design reduces the load on the network and makes it easy for Java to parse.

    Incorrect answer. It does not reduce network load - it can actually increase. Regarding Java 'parsing' - it's wrong from the beginning approach if the customer is required to analyze the data it receives from the server database. The analysis requires time CPU. Many average general processor muscle which will degrade the performance of analysis.

    You may be using the analysis out of context here? Find it me hard to believe that one could design an application and use a server database in this way. The analysis of means for example to receive XML data (text) and then he analysis in an object - like structure for use.

    Data of the database must be recovered by the customer in a binary structured format and not in a free format that requires the client to analyze in a structured format.

    But the problem is that we accumulate all data in memory first and push them to the client as a whole. If it's too huge, ORA-22813 occurs.
    This is why I intend to use the table of piplelined function.

    How that will solve the problem?

    As I followed your logic:
    (1) you do not use the cursor for some obscure (and probably completely unjustified) reason.
    (2) you may not return large collection PL/SQL variables without significantly dent PGA (process private memory) on the server and running into errors (this approach is conceptually incorrect anyway)
    (3) you are now using an array of pipeline that executes PL/SQL code to execute SQL code - and in turn must be executed by the client as a SQL using a slider

    So why put all the other moving parts (the pipeline code) between the two when the customer
    (a) must use SQL to access?
    (b) create a cursor?

    If, as you say, I returned a cursor, it would be very difficult for Java organize data.

    A table of pipeline must be able to be used through a cursor. All the DML statements from a client by Oracle are analyzed as cursors.

    Read the language PL/SQL Oracle® Database reference guide section on ' + chaining Pipelined Table Functions for Multiple Transformation + ".

    The format using a pipeline is (from the manual):

    SELECT * FROM TABLE(table_function_name(parameter_list))
    

    The "+ pipeline + ' is created by the SQL engine-, he need SQL to execute the PL/SQL code via the function TABLE() SQL.

    You said that the reason to use a pipeline transforms a structure of relational data stored in a structure of the object. You don't need a pipeline for it. Plain vanilla SQL can do the same thing, without the fixed costs of use PL/SQ, SQL data recovery and change within the pipeline between PL/SQL and SQL context engines.

    You simply call the constructor of the class of object in the projection of SQL and the cursor SQL returning the instantiated objects. For example

    create or replace type TEmployee is object(
     .. property definitions ...
    );
    
    create or replace type TEmployeeCollection is table of TEmployee;
    
    select
      TEmployee( col1, col2, .., coln ) as EMP_COLLECTION
    from emp
    where dept_id = :0
    and salary > :1
    and date_employed >= :2
    order by
      salary, date_employed
    

    No need for PL/SQL code. No need for a pipeline. The client will open the cursor and extraction of objects in a collection. The same approach that the customer would have used during extraction of a cursor on a table of pipeline function.

    Pipelines are best used as a process of transformation of data where only SQL cannot perform the transformation. I never in many years of design and writing applications used Oracle PL/SQL pipeline into production on a SQL table. Simply because the SQL itself is capable and powerful enough to do the job - and do it faster and better.

    I used pipeline is to transform the data from external sources into sets of SQL data. For example, a pipe on a web service. When the code PL/SQL of the constructions of the SOAP envelope, the HTTP call, analyzes the XML and returns the content in form of lines and columns - that allows to run a SQL SELECT on web-service-turned-into-a-SQL-table.

    If you'd told me that Leon - it seems to me that your approach is a typical approach to Java that has very little understanding of the concepts of database and Oracle databases. You can't deal with Oracle as a simple persistence layer. You can't treat SQL and PL/SQL as a simple i/o interface for the extraction of data from Oracle and grinding that in Java. Not if you think that your system to run Java and scaling.

    Rethink the Oracle layer, use properly - and your application will occur and will scale. Guaranteed.

    However, from my experience, many J2EE developers choose to treat the Oracle as a black box, not further that a kind of file system loaded to store structured data and try to do it in the Java layer. And this fail. And I saw him failing - of the jaw dropping kind epic failures (knocking all the national newspapers and media as a result and an impact on ordinary people who have to deal with the Government).

    And it's a shame... SQL and PL/SQL are superior to Java in this regard and are the layers much more able to cope and a power of data in the database. Example of the real world - largest table in our busiest database develops between 350 and 450 million lines per day and all our calculations of the data in this table is inside the database layer - and not in a layer of Java. Oracle performs and scales beautifully... when used correctly.

  • Having trouble selecting from a table function

    Need a function to return an array in the following format:
    WEEK_NBR               START_DATE END_DATE  
    ---------------------- ---------- --------- 
    0                      29-JAN-09  25-NOV-09 
    1                      26-NOV-09  02-DEC-09 
    2                      03-DEC-09  09-DEC-09 
    3                      10-DEC-09  16-DEC-09 
    6                      26-NOV-09  16-DEC-09 
    7                      29-JAN-09  16-DEC-09 
    The following error after the selection of a function that returns the table:
    select * from table(get_cwsr_ranges)
    Error from the 1 in the command line:
    Select * from table (get_cwsr_ranges)
    Error report:
    SQL error: ORA-06504: PL/SQL: return variables of the game results or the query types do not match
    ORA-06512: at "GET_CWSR_RANGES", line 23
    06504 00000 - "PL/SQL: return of the variable result set or query types do not match.
    * Cause: Numbers or types of columns in a query is not declared
    return type of a variable result is defined or declared two result types
    Set of variables do not match.
    * Action: Change the program or the declaration statement. Verify that the query variable
    actually we want during execution.
    >

    DDL:
    CREATE TYPE typ_date_range AS OBJECT
           (week_nbr                number,
            start_date              date,
            end_date                date   
          );
    /
    
     CREATE TYPE typ_tbl_date_ranges AS TABLE OF typ_date_range;
    /
    
    
    CREATE OR REPLACE FUNCTION get_cwsr_ranges()
    RETURN typ_tbl_date_ranges PIPELINED IS
    v_dates_table  typ_tbl_date_ranges;
    
    p_cursor     sys_refcursor;
    rec  typ_date_range := typ_date_range(NULL,NULL,NULL); 
    
    BEGIN
           
         open p_cursor for
         with sample_data as 
         (
             select 0 as  week_nbr , '29-JAN-09' as  start_date , '25-NOV-09' as end_date from dual union all                                         
             select 1 as  week_nbr , '26-NOV-09' as  start_date , '02-DEC-09' as end_date from dual union all                                         
             select 2 as  week_nbr , '03-DEC-09' as  start_date , '09-DEC-09' as end_date from dual union all                                         
             select 3 as  week_nbr , '10-DEC-09' as  start_date , '16-DEC-09' as end_date from dual union all                                         
             select 6 as  week_nbr , '26-NOV-09' as  start_date , '16-DEC-09' as end_date from dual union all                                         
             select 7 as  week_nbr , '29-JAN-09' as  start_date , '16-DEC-09' as end_date from dual  
       )
       select * 
       from sample_data;
        
    LOOP
        FETCH p_cursor INTO rec;
        EXIT WHEN p_cursor%NOTFOUND;
        PIPE ROW(Rec);
    END LOOP;
    CLOSE p_cursor;
    RETURN;
    
    END get_CWSR_Ranges;
    Any suggestions?
    create or replace FUNCTION get_cwsr_ranges
    RETURN typ_tbl_date_ranges PIPELINED
    IS
    
    BEGIN
    
      for rec in
      (
         with sample_data as
         (
             select 0 as  week_nbr , to_date('29-JAN-09', 'dd-mon-yy') as  start_date , to_date('25-NOV-09', 'dd-mon-yy') as end_date from dual union all
             select 1 as  week_nbr , to_date('26-NOV-09', 'dd-mon-yy') as  start_date , to_date('02-DEC-09', 'dd-mon-yy') as end_date from dual union all
             select 2 as  week_nbr , to_date('03-DEC-09', 'dd-mon-yy') as  start_date , to_date('09-DEC-09', 'dd-mon-yy') as end_date from dual union all
             select 3 as  week_nbr , to_date('10-DEC-09', 'dd-mon-yy') as  start_date , to_date('16-DEC-09', 'dd-mon-yy') as end_date from dual union all
             select 6 as  week_nbr , to_date('26-NOV-09', 'dd-mon-yy') as  start_date , to_date('16-DEC-09', 'dd-mon-yy') as end_date from dual union all
             select 7 as  week_nbr , to_date('29-JAN-09', 'dd-mon-yy') as  start_date , to_date('16-DEC-09', 'dd-mon-yy') as end_date from dual
        )
       select typ_date_range(week_nbr, start_date, end_date) the_type
       from sample_data
      )
      loop
        pipe row (rec.the_type);
      end loop;
    
    END get_CWSR_Ranges;
    

    and then...

    select *
    from table(cast(get_cwsr_ranges as typ_tbl_date_ranges))
    

    Published by: Tubby on December 26, 2009 19:05

    Remove the implicit conversion using explicit TO_DATE... you should always do :)

  • Oracle Table function

    I want to extract certain age using the TABLE function.
    declare
    type is rendered
    (
    name varchar2 (20).
    sex varchar2 (10),
    number (5) age
    );

    type emp_table is table of SheikYerbouti;

    var emp_table: = emp_table();

    number of l_age;
    Start

    var.extend;
    var (1) .name: = "test1";
    var (1) .sex: = 'male ';
    var (1) .age: = 19;

    var.extend;
    var (2) .name: = "test2."
    (2) var .sex: = 'female ';
    var (2) .age: = 20;

    Select age
    IN l_age
    table (var)
    where var.name = "test1";

    dbms_output.put_line (l_age);
    end;

    I was expection here.

    Can you help me solve this problem.

    Thank you!

    Local types are not allowed in the SQL statement. This means that you said

    type emp_rec is record
    (
    name varchar2(20),
    *** varchar2(10),
    age number(5)
    );
    
    type emp_table is table of emp_rec;
    

    locally. Instead the defined in the database.

  • Using the function PLSQL return Record Type Index of Tables in ADF

    I have a PLSQL function, a return type. My ultimate goal is to take this binary integer index Table and print it on the screen...

    CREATE OR REPLACE PACKAGE my_pkg IS
     
    TYPE t_col IS RECORD(
     
    i NUMBER,
     
    n VARCHAR2(30));
     
    TYPE t_nested_table IS TABLE OF t_col;
     
      FUNCTION return_table RETURN t_nested_table ;
    END my_pkg;


    OPTION 1:

    1) has anyone got best practices to accept plsql RECORDS returned by a function?

    Here is an example.

    http://adfpractice-Fedor.blogspot.SG/2013/01/working-with-PLSQL-procedures-in-ADF-BC.html

    But it will be a lot of work... first of all accept the results in a loop... then store in a temporary storage can be a few VO or global temporary table and then display them on the page


    OPTION 2:

    Using the functions PIPLELINED and use in the select statement.  While I can use this select statement in the SQL query to create VO... and drag and drop the VO...

    CREATE OR REPLACE PACKAGE my_pkg IS
     
    TYPE t_col IS RECORD(
     
    i NUMBER,
     
    n VARCHAR2(30));
     
    TYPE t_nested_table IS TABLE OF t_col;
     
      FUNCTION return_table RETURN t_nested_table PIPELINED;
    END my_pkg;


    select * from table(my_pkg.return_table);


    Wow... I'm so smart! .. really possible?  who is the best/possible/recommended option?

    I'm sure that will be the question most read by many who wants to use PLSQL instead of JAVA to the treatment and CHOSEN to use only to display the output of the PLSQL functions or procedures.


    Thank you

    Rahul


    Dario

    Do you mean the scope of the defined Type pkg will be finished?

    I created guy outside the pkg as 'Create Type' if it works in this case?

    Yes, level objects schema (created with "create or replace type...") can be used in java and this can work.

    I think that then the scope of this TYPE will remain until the user session passes.

    Object definitions is not worn, but have their bodies.

    So, if you instantiate the data level object type schema in a plsql function, scope of this object is this function.

    Of course, if you instantiate the object as a variable package, then life of this object is equal to the lifetime of the package (which usually equals life of session db).

    Dario

  • I am trying to create a function that would be on the table type returns.

    Gurus,

    I am trying to create a function that returns a table nested with 3
    columns in a table as a guy.

    my query is like

    Select col1, col2, col3 from table_1;

    I am a bit newbie in Oracle and have never used collections.
    Can you please guide?

    >
    I am a bit newbie in Oracle and have never used collections.
    >
    Then you should start with the documentation
    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/TOC.htm

    Chapter 5 is all about collections using PL/SQL and examples
    >
    I am trying to create a function that returns a table nested with 3
    columns in a table as a guy.
    >
    This isn't enough of a description to know what you're trying to do, or how you plan to use the service. The query you provided is completely irrelevant to the question you are asking.

    You ask about functions in pipeline? Here is an example of this

    -- type to match emp record
    create or replace type emp_scalar_type as object
      (EMPNO NUMBER(4) ,
       ENAME VARCHAR2(10),
       JOB VARCHAR2(9),
       MGR NUMBER(4),
       HIREDATE DATE,
       SAL NUMBER(7, 2),
       COMM NUMBER(7, 2),
       DEPTNO NUMBER(2)
      )
      /
    
    -- table of emp records
    create or replace type emp_table_type as table of emp_scalar_type
      /
    
    -- pipelined function 
    
    create or replace function get_emp( p_deptno in number )
      return emp_table_type
      PIPELINED
      as
       TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
        emp_cv EmpCurTyp;
        l_rec  emp%rowtype;
      begin
        open emp_cv for select * from emp where deptno = p_deptno;
        loop
          fetch emp_cv into l_rec;
          exit when (emp_cv%notfound);
          pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
              l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
        end loop;
        return;
      end;
      /
    
    select * from table(get_emp(20))
    
  • Function returning the tree used with the object type

    Hi guys!

    I'm fighting for some time now of a function that should return the tree structure of the employees. Let me clarify...
    I have a table say Manager and employees (two columns for an example)
    MANAGER_ID
    EMPLOYEE_ID

    Example:

    MAN_ID - 1; EMPLOYE_ID - 2;
    MAN_ID - 2; EMPLOYE_ID - 3;
    MAN_ID - 2; EMPLOYE_ID - 4;
    MAN_ID - 4; EMPLOYE_ID - 5

    The purpose of my function is back for a specified MAN_ID everyone in the tree...

    Example:

    RETURN_TREE (1) return {2,3,4,5};
    RETURN_TREE (2) returns {3,4,5};
    RETURN_TREE (4) returns {5};

    How to get there?

    With respect,

    PsmakR

    And use BULK COLLECT or the COLLECT function to build the collection:

    create type emp_table as table of number(6);
    /
    
    DECLARE
     v_emp_list emp_table;
    BEGIN
     select cast(collect(employee_id) as emp_table)
     into v_emp_list
     from employees
     connect by prior employee_id = manager_id
     start with manager_id = :p_man_id
    
     -- or
     /*
     select employee_id
     bulk collect into v_emp_list
     from employees
     connect by prior employee_id = manager_id
     start with manager_id = :p_man_id
     */
    END;
    /
    
  • using the function - how to use the values of the input variables on the table select statement names

    Hello community, I have a problem when creating a function. The purpose of this function is to check the table of weather gave yesterday or not. We must check this on different tables on different sachems. We are creating a function with input variables.

    CREATE OR REPLACE FUNCTION IN_SCHEMA.IS_YDAYDATA_TO_TABLE

    (

    in_schema IN VARCHAR2,

    in_tablename IN VARCHAR2,

    in_datefield IN VARCHAR2,

    )

    RETURNS INTEGER

    AS

    -Declaring variables

    v_is_true INTEGER.

    BEGIN

    SELECT

    CASE

    WHEN MAX (in_datefield) = TRUNC(SYSDATE-1)

    THEN 1

    ON THE OTHER

    0

    END

    IN

    v_is_true

    Of

    in_schema.in_tablename

    ;

    RETURN v_is_true;

    END;

    /

    When creating, I got error: [error] ORA-00942 (44:19): PL/SQL: ORA-00942: table or view does not exist

    How to use the values of the input variables on the table select statement names?

    Hello

    Here's a way you can use dynamic SQL statements for this task:

    CREATE OR REPLACE FUNCTION IS_YDAYDATA_TO_TABLE

    (

    in_schema IN VARCHAR2,

    in_tablename IN VARCHAR2,

    in_datefield IN VARCHAR2,

    in_first_date DATE DEFAULT SYSDATE - 1,.

    in_last_date DATE by DEFAULT NULL

    )

    RETURNS INTEGER

    AS

    -IS_YDAYDATA_TO_TABLE returns 1 if in_schema.in_tablename.in_datefield

    -contains all the dates in the in_first_date of the range through included in_last_date

    - and it returns 0 if there is no such lines.

    -If in_last_date is omitted, the search only the data on in_first_date.

    -If in_first_date is omitted, it defaults to yesterday.

    -Time parts of the in_first_date and in_last_date are ignored.

    -Declaring variables

    sql_txt VARCHAR2 (1000);

    v_is_true INTEGER.

    BEGIN

    sql_txt: = 'SELECT COUNT (*).

    || 'FROM ' | in_schema | '.' || in_tablename

    || 'WHERE ' | in_datefield | ' > =: d1'

    || «AND» | in_datefield | '< >

    || 'AND ROWNUM = 1';

    dbms_output.put_line (sql_txt |) '= sql_txt in IS_YDAYDATA_TO_TABLE");  -For debugging

    Sql_txt EXECUTE IMMEDIATE

    IN v_is_true

    With the HELP of TRUNC (in_first_date) - d1

    TRUNC (NVL (in_last_date

    in_first_date

    )

    ) + 1                -- d2

    ;

    RETURN v_is_true;

    END is_ydaydata_to_table;

    /

    DISPLAY ERRORS

    If you must use dynamic SQL statements, put all the SQL statement in a single string variable, such as sql_txt in the example above.  In this way, you can easily see exactly what will be executed.  Comment out the call to dbms_output under test is completed.

    Try to write functions that will address not only the question that you have now, but similar questions that you may have in the future.  For example, now that interest you only to the verification of the data of yesterday, but later, you might want to check another day or range of days.  The above function combines the convenience of a function simple (looks like yesterday data if you don't tell him otherwise) with the power of a more complex function (you can use the same function to check any day or range of days).

Maybe you are looking for