Sys_context procedure not return ip address

Hello,
db 11gr1
what would be the reason that this query not return an ip_address?
select sys_context('userenv', 'ip_address') from dual;
Thanks,

what would be the reason that this query not return an ip_address?USERENV does not know what the IP# is.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select sys_context('userenv', 'ip_address') from dual;
SYS_CONTEXT('USERENV','IP_ADDRESS')
--------------------------------------------------------------------------------It could be because you are logged in locally & not via SQL*Net
Edited by: sb92075 on Oct 27, 2010 12:53 PM

Similar Messages

  • Oralce Store Procedure not returning values in out parameters

    I am goig to execute an oracle store procedure using C# through through ODP.NET. The store procedure executes succsfully but it does not return any value in the out parameter.
    When I execute the same store procedure with the same input parameteres from within SQL*Plus. It does return values.
    This is to be clearify here that in the oracle store procedure the data type for the out parameter is number and in the c# the variavle that will hold its value is Integer. I also tried using Long on the C# side but it is still not working. After the successfull execution of the store procedure the C# variable contains nulll value.

    I am goig to execute an oracle store procedure using C# through through ODP.NET. The store procedure executes succsfully but it does not return any value in the out parameter.
    When I execute the same store procedure with the same input parameteres from within SQL*Plus. It does return values.
    This is to be clearify here that in the oracle store procedure the data type for the out parameter is number and in the c# the variavle that will hold its value is Integer. I also tried using Long on the C# side but it is still not working. After the successfull execution of the store procedure the C# variable contains nulll value.

  • Procedure Does not return expected new rows unless I ALTER the procedure it self

    Procedure Does not return expected new rows !!!   unless I ALTER the procedure it self

    And what exactly do you alter, the code / where clause / or ...?
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Fsbtodb macro in ufs_fs.h does not return correct disk address

    I'm using fsbtodb to translate the file inode block address to file system block address.
    What I've observed is fsbtodb returns corretct disk address for all the files if file system size < 1 TB.
    But, if ufs file system size is greater than 1 TB then for some files, the macro fsbtodb does not return correct value, it returns -ve value
    Is this a known issue and is this been resolved in new versions
    Thanks in advance,
    dhd

    returns corretct disk address for all the files if file system size < 1 TB.and
    if ufs file system size is greater than 1 TB then for some files, the macro fsbtodb does not return correct value, it returns -ve valueI seem to (very) vaguely recall that you shouldn't be surprised at this example of a functional filesize limitation.
    Solaris 9 was first shipped in May 2002 and though it was the first release of that OS to have extended file attributes I do not think the developers had intended the OS to use raw filesystems larger than 1TB natively.
    That operating environment is just too old to do exactly as you hope.
    Perhaps others can describe this at greater length.

  • How Do I Call PL/SQL Stored Procedure That Returns String Array??

    I Have Problem Calling An Oracle(8i) Stored Procedure That Returns Array Type (Multi Rows)
    (As Good As String Array Type..)
    In This Fourm, I Can't Find Out Example Source.
    (Question is Exist.. But No Answer..)
    I Want An Example,, Because I'm A Beginner...
    (I Wonder...)
    If It Is Impossible, Please Told Me.. "Impossible"
    Then, I'll Give Up to Resolve This Way.....
    Please Help Me !!!
    Thanks in advance,

    // Try the following, I appologize that I have not compiled and run this ... but it is headed in the right direction
    import java.sql.*;
    class RunStoredProc
    public static void main(String args[])
    throws SQLException
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    catch(Exception ex)
    ex.printStackTrace();
    java.util.Properties props = new java.util.Properties();
    props.put("user", "********"); // you need to replace stars with db userid
    props.put("password", "********"); // you need to replace stars with userid db password
              // below replace machine.domain.com and DBNAME, and port address if different than 1521
    Connection conn =
    DriverManager.getConnection("jdbc:oracle:thin:@machine.domain.com:1521:DBNAME", props);
    // replace "Your Stored Procedure" with your stored procedure
    CallableStatement stmt = conn.prepareCall("Your Stored Procedure");
    ResultSet rset = stmt.execute();
    while(rset.next())
    System.out.println(rset.getString(1));

  • CLR Procedure and returning large number of rows

    I have a CLR stored procedure coded in C# that retrieves data from a web service, and returns that data using SendResultsStart/SendResultsRow/SendResultsEnd. This all works fine, except when the data from the web service is tens or even thousands of records.
    The code itself takes about 3 minutes on average to do all it's work with around 50000-60000 records, but the procedure does not return in SSMS for about another 10-15 minutes, during which time the CPU and memory usage go up significantly.
    To rule out any of the CLR code as the culprit, I created a very simple CLR procedure that just loops to return 100000 records with int and nvarchar(256) fields with the current count, and "ABC" followed by the count.  Here is the code:
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void ABC()
    System.Diagnostics.Stopwatch ExecuteTimer = System.Diagnostics.Stopwatch.StartNew();
    SqlMetaData[] ResultMetaData = new SqlMetaData[2];
    ResultMetaData[0] = new SqlMetaData("count", SqlDbType.Int);
    ResultMetaData[1] = new SqlMetaData("text", SqlDbType.NVarChar, 256);
    SqlContext.Pipe.SendResultsStart(new SqlDataRecord(ResultMetaData));
    for (int x = 0; x < 100000; x++)
    SqlDataRecord ResultItem = new SqlDataRecord(ResultMetaData);
    ResultItem.SetValue(0, x);
    ResultItem.SetValue(1, "ABC" + x.ToString());
    SqlContext.Pipe.SendResultsRow(ResultItem);
    SqlContext.Pipe.SendResultsEnd();
    TimeSpan ExecTime = ExecuteTimer.Elapsed;
    SqlContext.Pipe.Send("Elapsed Time: " + ExecTime.Minutes.ToString() + ":" + ExecTime.Seconds.ToString() + "." + ExecTime.Milliseconds.ToString());
    I then executed procedure ABC in SSMS, and it took 21 minutes to return.  All of the data rows were visible after just a couple of seconds, but the query continued to run as the CPU and memory went up again.
    Is this really how long it should take to return 100000 rows, or am I missing something?  Is there a better approach than using SendResultsStart/SendResultsRow/SendResultsEnd?
    I've googled this to death and haven't found anything that helped or even explained why this is.
    I would greatly appreciate any suggestions or alternate methods to achieve this faster.
    Thanks!
    Alex

    When you create a new object, space on the garbage-collected heap is allocated for that object, and the address will be stored in a reference. Some time later, there will no longer be any references that hold the address of the allocated object. It doesn't
    matter whether the reference count went to 0 because the reference was set to null or because the reference was on the stack and is no longer in lexical scope, the end result is the same: the garbage collector will, at some point in time, have to perform the
    book-keeping operations necessary to identify that the space allocated for that now-unreferenced object can be re-used. When, on the other hand, you only create a single SqlDataRecord object and hold onto the reference, all of the book-keeping operations
    associated with creating 100,000 objects are eliminated. This is why the documentation for the SqlDataReader class advises that:
    When writing common language runtime (CLR) applications, you should re-use existing
    SqlDataRecord objects instead of creating new ones every time. Creating many new
    SqlDataRecord objects could severely deplete memory and adversely affect performance.

  • UTL File not return any values in .CSV oracle plsql hrms

    Hello experts,
    We want to extract employee details from Core hrms with output as .csv file :
    i have created below package for utl but not return any values in csv file pls help me on this.:::
    CREATE OR REPLACE PACKAGE BODY APPS."XXPER_PAYROLL_XIR_PKG"
    AS
    procedure payroll_main (
    in_from_date IN date,
    in_to_date IN date,
    p_errbuf OUT VARCHAR2,
    p_retcode OUT NUMBER
    ) is
    cursor c_person is
    SELECT distinct ppf.person_id
    FROM per_person_types ppt,
    pay_payrolls_f pp,
    per_person_type_usages_f pptu,
    per_all_people_f ppf,
    per_all_assignments_f ppa
    WHERE ppf.person_id = pptu.person_id
    AND pptu.person_type_id = ppt.person_type_id
    AND ppt.user_person_type in ('Employee', 'Ex-employee' ,'Intern')
    AND ppf.person_id = ppa.person_id
    AND ppa.assignment_type = 'E'
    AND ppa.primary_flag = 'Y'
    AND ppa.payroll_id = pp.payroll_id
    -- and nvl(ppa.ass_attribute10, 'N') = 'Y' -- this is in Production
    AND pp.payroll_name = 'Calendar Payroll'
    AND trunc( ppf.last_update_date) between in_from_date and in_to_date
    AND trunc( ppa.last_update_date) between in_from_date and in_to_date
    AND trunc( ppt.last_update_date) between in_from_date and in_to_date
    AND trunc( pptu.last_update_date) between in_from_date and in_to_date
    AND trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
    AND trunc(sysdate) between ppa.effective_start_date and ppa.effective_end_date
    AND trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
    AND trunc(sysdate) between pptu.effective_start_date and pptu.effective_end_date
    AND ppf.employee_number <> 'NONE';
    v_person_id number;
    v_dom_eff_dt date;
    io_err_flag varchar2(1);
    io_err_desc varchar2(2000);
    io_record_update boolean;
    BEGIN
    dbms_output.put_line('in_from_date-' || in_from_date);
    dbms_output.put_line('in_to_date-' || in_to_date );
    open c_person;
    loop
    fetch c_person into v_person_id;
    exit when c_person%NOTFOUND;
    get_person_information( v_person_id ,
    in_from_date ,
    in_to_date ,
    io_err_flag ,
    io_err_desc );
    dbms_output.put_line('Per_id-' || v_person_id || ': ' || 'Payroll_main' || sqlcode || sqlerrm );
    end loop;
    close c_person;
    end payroll_main;
    PROCEDURE get_person_information(in_person_id IN number,
    in_from_date IN date,
    in_to_date IN date,
    io_err_flag IN OUT varchar2,
    io_err_desc IN OUT varchar2) is
    --v_service_date        DATE;
    v_data_file UTL_FILE.FILE_TYPE;
    v_record VARCHAR2(1000);
    v_header VARCHAR2(1000);
    v_record_mail VARCHAR2(1000);
    v_file_name VARCHAR2(100);
    v_file_name_mail VARCHAR2(100);
    v_ser_name VARCHAR2(50);
    v_dir VARCHAR2(100) :='XX_XIR_HR_PAY';
    v_con_req_id NUMBER;
    v_user_id NUMBER;
    v_resp_id NUMBER;
    v_resp_appl_id NUMBER;
    p_request_id NUMBER;
    P_status VARCHAR2(100);
    cursor c1 is
    SELECT ppf.person_id per_id,
    ppf.employee_number emp_num,
    ppf.first_name f_name,
    ppf.last_name l_name,
    ppf.national_identifier nat_id,
    ppf.date_of_birth dat_birth,
    ppf.sex sex_g,
    -- TO_DATE(ppf.attribute1,'DD-MON-YYYY') att_date,
    ppt.user_person_type per_type,
    ppf.email_address email_id,
    ppf.last_update_date last_upd_date
    FROM per_person_type_usages_f pptu,
    per_person_types ppt,
    per_people_f ppf
    WHERE ppf.person_id = in_person_id
    AND ppf.person_id = pptu.person_id
    AND pptu.person_type_id = ppt.person_type_id
    and trunc(ppf.last_update_date) between in_from_date and in_to_date
    and trunc( pptu.last_update_date) between in_from_date and in_to_date
    AND trunc( ppt.last_update_date) between in_from_date and in_to_date
    AND trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
    AND trunc(sysdate) between pptu.effective_start_date and pptu.effective_end_date
    AND ppt.user_person_type in ('Employee', 'Ex-employee' ,'Intern')
    and ppt.system_person_type in ('EX_EMP', 'EMP') ;
    cursor c2 is
    SELECT substr(pa.address_line1, 1, 60) address_line1,
    substr(pa.address_line2, 1, 60) address_line2,
    pa.town_or_city city,
    pa.region_2,
    pa.postal_code,
    pa.region_1,
    pa.country,
    pa.date_from,
    nvl(pa.date_to, to_date('12/31/4712', 'mm/dd/yyyy')),
    pa.creation_date,
    pa.last_update_date
    FROM per_addresses pa
    WHERE pa.person_id = in_person_id
    AND pa.last_update_date between in_from_date and in_to_date
    AND trunc(sysdate) between date_from and nvl(date_to, to_date('12/31/4712', 'mm/dd/yyyy'))
    AND pa.primary_flag = 'Y';
    cursor c3 is
    SELECT pp.phone_number pnum
    FROM per_phones pp
    WHERE pp.parent_id = in_person_id
    AND pp.last_update_date between in_from_date and in_to_date
    AND trunc(sysdate) between date_from and nvl(date_to, to_date('12/31/4712', 'mm/dd/yyyy'))
    AND phone_type = 'H1';
    cursor c4 is
    SELECT ppos.period_of_service_id,
    ppos.date_start start_date,
    ppos.adjusted_svc_date,
    ppos.actual_termination_date,
    TO_DATE(ppos.attribute1,'yyyy/mm/dd hh24:mi:ss') last_day
    FROM per_periods_of_service ppos
    WHERE ppos.person_id = in_person_id
    AND ppos.last_update_date between in_from_date and in_to_date
    AND ppos.date_start = ( select max(date_start)
    from per_periods_of_service
    where person_id = in_person_id
    and trunc(date_start) <= trunc(sysdate) );
    Begin
    dbms_output.put_line('Directory:'||v_dir);
    BEGIN
    v_header := 'Employee Number'||CHR(9)
    ||'Fore Name'||CHR(9)
    ||'Sur Name'||CHR(9)
    ||'PPS'||CHR(9)
    ||'Date of birth'||CHR(9)
    ||'Gender'||CHR(9)
    ||'Person Type'||CHR(9)
    ||'Email Address'||CHR(9)
    ||'Last Update Date'||CHR(9)
    ||'Address1'||CHR(9)
    ||'Address2'||CHR(9)
    ||'Phone_Number'||CHR(9)
    ||'Start Date'||CHR(9)
    ||'Last Day';
    v_file_name :='XIR_DATA.xls';
    dbms_output.put_line('Excel_file_name:'||v_file_name);
    v_data_file :=UTL_FILE.FOPEN(v_dir,v_file_name, 'W');
    UTL_FILE.PUT_LINE(v_data_file,v_header);
    FOR i IN c1 LOOP
    FOR j IN c2 LOOP
    FOR k IN c3 LOOP
    FOR m IN c4 LOOP
    dbms_output.put_line(' excel file loop ');
    v_record:=i.emp_num||CHR(9)
    ||i.f_name||CHR(9)
    ||i.l_name||CHR(9)
    ||i.nat_id||CHR(9)
    ||i.dat_birth||CHR(9)
    ||i.sex_g||CHR(9)
    ||i.per_type||CHR(9)
    ||i.email_id||CHR(9)
    ||i.last_upd_date||CHR(9)
    || j.address_line1||CHR(9)
    ||j.address_line2||CHR(9)
    ||k.pnum||CHR(9)
    ||m.start_date||CHR(9)
    ||m.last_day;
    UTL_FILE.PUT_LINE(v_data_file,v_record);
    END LOOP;
    END LOOP;
    END LOOP;
    END LOOP;
    UTL_FILE.FCLOSE(v_data_file);
    dbms_output.put_line(' close excel file');
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line('unable to create data excel file in proc1'||SUBSTR(SQLERRM,1,25));
    END;
    end get_person_information;
    END xxper_payroll_xir_pkg;
    EE Number     Forename     Surname     Dept     effective Start Date_dept     Start Date     Leave Date     effective Start Date_leave_Dt     Date of Birth     Address1     
    Thanks
    Edited by: 981527 on Feb 12, 2013 5:59 AM
    Edited by: 981527 on Feb 12, 2013 6:05 AM

    Did you make sure that the queries are returning values in the first place? From the last few lines, it looks like you have the header written to the file. Is that correct?
    -Karthik

  • ExtractValue not returning the data after dbms_xmlschema.CopyEvolve

    Hi ,
    I am facing the problem while selecting the value from the XMLTYPE table using extractValue.
    Here address field is newly added to schema and evolved . But unable to get the address field value .
    My procedures are like this
    SQL> declare
    2 res boolean;
    3 xmlschema xmltype := xmltype(
    4 '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb">
    5 <xsd:complexType name="t_person" xdb:SQLType="PERSONDT_T">
    6 <xsd:sequence>
    7 <xsd:element name="persondetails" type="persondetailsType"/>
    8 <xsd:element name="companyinfo" type="companyinfoType"/>
    9 <xsd:element name="salaryinfo" type="salaryinfoType"/>
    10 </xsd:sequence>
    11 </xsd:complexType>
    12 <xsd:complexType name="persondetailsType" xdb:SQLType="PERSONDETAILS_T">
    13 <xsd:sequence>
    14 <xsd:element name="personname" type="xsd:string" />
    15 <xsd:element name="personexperience" type="xsd:decimal" />
    16 </xsd:sequence>
    17 </xsd:complexType>
    18 <xsd:complexType name="companyinfoType" xdb:SQLType="COMPANYINFO_T">
    19 <xsd:sequence>
    20 <xsd:element name="companystartdate" type="xsd:date" />
    21 <xsd:element name="companystandard" type="xsd:decimal" />
    22 </xsd:sequence>
    23 </xsd:complexType>
    24 <xsd:complexType name="salaryinfoType" xdb:SQLType="SALARYINFO_T">
    25 <xsd:sequence>
    26 <xsd:element name="salary" type="xsd:decimal" />
    27 <xsd:element name="paymonth" type="xsd:string" />
    28 </xsd:sequence>
    29 </xsd:complexType>
    30 <xsd:element name="person" type="t_person" />
    31 </xsd:schema>');
    32 begin
    33 if (dbms_xdb.existsResource('/public/personDetails.xsd')) then
    34 dbms_xdb.deleteResource('/public/personDetails.xsd');
    35 end if;
    36 res := dbms_xdb.createResource('/public/personDetails.xsd',xmlschema);
    37 end;
    38 /
    PL/SQL procedure successfully completed.
    SQL> begin
    2 dbms_xmlschema.registerSchema ('www.PersonInfoUrl.com',xdburitype('/public/personDetails.xsd'),TRUE,TRUE,FALSE,TRUE);
    3 end;
    4 /
    PL/SQL procedure successfully completed.
    SQL> CREATE TABLE PERSON_COMP_TABLE
    2 (empId VARCHAR2(100) CONSTRAINT pk_PERSONCOMP PRIMARY KEY
    3 ,comments VARCHAR2(20)
    4 ,joindate DATE
    5 ,personjoininfo xmltype)
    6 XMLTYPE COLUMN personjoininfo XMLSCHEMA "www.PersonInfoUrl.com" element "person"
    7 /
    Table created.
    SQL> insert into PERSON_COMP_TABLE (empId ,comments ,joindate ,personjoininfo )
    2 values ('2006NEW312','RDDEPT','15-jan-2006',
    3 sys.XMLType.createXML(
    4 '<?xml version="1.0" encoding="UTF-8"?>
    5 <person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="www.PersonInfoUrl.com">
    6 <persondetails>
    7 <personname>Robert </personname>
    8 <personexperience>4.5</personexperience>
    9 </persondetails>
    10 <companyinfo>
    11 <companystartdate>2004-07-24</companystartdate>
    12 <companystandard>3.9</companystandard>
    13 </companyinfo>
    14 <salaryinfo>
    15 <salary>2444.3</salary>
    16 <paymonth> june </paymonth>
    17 </salaryinfo>
    18 </person>'))
    19 /
    1 row created.
    SQL> select count(*) from PERSON_COMP_TABLE;
    COUNT(*)
    1
    SQL> declare
    xmlschema xmltype := xdburitype('/public/personDetails.xsd').getXML();
    res boolean;
    begin
    select insertChildXML(
    xmlschema,
    '/xsd:schema/xsd:complexType[@name="companyinfo"]/xsd:sequence',
    'xsd:element',
    xmltype('<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="address" type="xsd:string"
    'xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
    into xmlSchema
    from dual;
    if (dbms_xdb.existsResource('/public/personDetails.xsd')) then
    dbms_xdb.deleteResource('/public/personDetails.xsd');
    end if;
    res := dbms_xdb.createResource('/public/newpersonDetails.xsd',xmlschema);
    end;
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.74
    SQL> commit;
    Commit complete.
    Elapsed: 00:00:00.56
    SQL> begin
    dbms_xmlschema.CopyEvolve
    xdb$string_list_t('www.PersonInfoUrl.com'),
    XMLSequenceType(xdburitype('/public/newpersonDetails.xsd').getXML()),
    null
    end;
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:08.49
    SQL> commit;
    Commit complete.
    Elapsed: 00:00:00.52
    SQL> select count(*) from PERSON_COMP_TABLE;
    COUNT(*)
    1
    SQL> insert into PERSON_COMP_TABLE (empId ,comments ,joindate ,personjoininfo )
    values ('1234PTR','DTSDDEPT','12-jan-2006',
    sys.XMLType.createXML(
    '<?xml version="1.0" encoding="UTF-8"?>
    <person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="www.PersonInfoUrl.com">
    <persondetails>
    <personname>Julie </personname>
    <personexperience>3.5</personexperience>
    </persondetails>
    <companyinfo>
    <companystartdate>2005-11-21</companystartdate>
    <companystandard>3.9</companystandard>
    <address>santaclara</address>
    </companyinfo>
    <salaryinfo>
    <salary>2444.3</salary>
    <paymonth> june </paymonth>
    </salaryinfo>
    </person>'))
    1 row created.
    SQL> select count(*) from PERSON_COMP_TABLE;
    COUNT(*)
    2
    SQL> SELECT empid, extractValue(personjoininfo,'/person/companyinfo/address') FROM PERSON_COMP_TABLE
    2 /
    empid
    E
    1234PTR
    Here "address " is not returned. it has return the value "santaclara".
    How to solve this ?. Please advise
    Thanks
    Govinda

    After chasing down couple of silly mistakes I was able to get your example to work
    SQL> call dbms_xmlschema.deleteSchema ('www.PersonInfoUrl.com',4)
      2  /
    Call completed.
    SQL> declare
      2    res boolean;
      3    xmlschema xmltype := xmltype(
      4  '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb">
      5     <xsd:complexType name="t_person" xdb:SQLType="PERSONDT_T">
      6             <xsd:sequence>
      7                     <xsd:element name="persondetails" type="persondetailsType"/>
      8                     <xsd:element name="companyinfo" type="companyinfoType"/>
      9                     <xsd:element name="salaryinfo" type="salaryinfoType"/>
    10             </xsd:sequence>
    11     </xsd:complexType>
    12     <xsd:complexType name="persondetailsType" xdb:SQLType="PERSONDETAILS_T">
    13             <xsd:sequence>
    14                     <xsd:element name="personname" type="xsd:string"/>
    15                     <xsd:element name="personexperience" type="xsd:decimal"/>
    16             </xsd:sequence>
    17     </xsd:complexType>
    18     <xsd:complexType name="companyinfoType" xdb:SQLType="COMPANYINFO_T">
    19             <xsd:sequence>
    20                     <xsd:element name="companystartdate" type="xsd:date"/>
    21                     <xsd:element name="companystandard" type="xsd:decimal"/>
    22             </xsd:sequence>
    23     </xsd:complexType>
    24     <xsd:complexType name="salaryinfoType" xdb:SQLType="SALARYINFO_T">
    25             <xsd:sequence>
    26                     <xsd:element name="salary" type="xsd:decimal"/>
    27                     <xsd:element name="paymonth" type="xsd:string"/>
    28             </xsd:sequence>
    29     </xsd:complexType>
    30     <xsd:element name="person" type="t_person"/>
    31  </xsd:schema>');
    32  begin
    33    if (dbms_xdb.existsResource('/public/personDetails.xsd')) then
    34      dbms_xdb.deleteResource('/public/personDetails.xsd');
    35    end if;
    36    res := dbms_xdb.createResource('/public/personDetails.xsd',xmlschema);
    37  end;
    38  /
    PL/SQL procedure successfully completed.
    SQL> begin
      2    dbms_xmlschema.registerSchema ('www.PersonInfoUrl.com',xdburitype('/public/personDetails.xsd'),TRUE,TRUE,FALSE,TRUE);
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> DROP TABLE PERSON_COMP_TABLE
      2  /
    Table dropped.
    SQL> CREATE TABLE PERSON_COMP_TABLE
      2  (
      3    empId VARCHAR2(100) CONSTRAINT pk_PERSONCOMP PRIMARY KEY
      4    ,comments VARCHAR2(20)
      5    ,joindate DATE
      6    ,personjoininfo xmltype
      7  )
      8  XMLTYPE COLUMN personjoininfo XMLSCHEMA "www.PersonInfoUrl.com" element "person"
      9  /
    Table created.
    SQL> insert into PERSON_COMP_TABLE (empId ,comments ,joindate ,personjoininfo )
      2  values ('2006NEW312','RDDEPT','15-jan-2006',
      3  XMLType(
      4  '<?xml version="1.0" encoding="UTF-8"?>
      5  <person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="www.PersonInfoUrl.com">
      6     <persondetails>
      7             <personname>Robert </personname>
      8             <personexperience>4.5</personexperience>
      9     </persondetails>
    10     <companyinfo>
    11             <companystartdate>2004-07-24</companystartdate>
    12             <companystandard>3.9</companystandard>
    13     </companyinfo>
    14     <salaryinfo>
    15             <salary>2444.3</salary>
    16             <paymonth> june </paymonth>
    17     </salaryinfo>
    18  </person>'))
    19  /
    1 row created.
    SQL> select count(*) from PERSON_COMP_TABLE
      2  /
      COUNT(*)
             1
    SQL> declare
      2    xmlschema xmltype := xdburitype('/public/personDetails.xsd').getXML();
      3    res boolean;
      4  begin
      5    select insertChildXML
      6           (
      7             xmlschema,
      8             '/xsd:schema/xsd:complexType[@name="companyinfoType"]/xsd:sequence',
      9             'xsd:element',
    10             xmltype('<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="address" type="xsd:string"/>'),
    11             'xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
    12           )
    13      into xmlSchema
    14      from dual;
    15
    16    if (dbms_xdb.existsResource('/public/newPersonDetails.xsd')) then
    17      dbms_xdb.deleteResource('/public/newPersonDetails.xsd');
    18    end if;
    19
    20    res := dbms_xdb.createResource('/public/newPersonDetails.xsd',xmlschema);
    21  end;
    22  /
    PL/SQL procedure successfully completed.
    SQL> commit
      2  /
    Commit complete.
    SQL> begin
      2    dbms_xmlschema.CopyEvolve
      3    (
      4       xdb$string_list_t('www.PersonInfoUrl.com'),
      5       XMLSequenceType(xdburitype('/public/newPersonDetails.xsd').getXML()),
      6       null
      7     );
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    SQL> select count(*) from PERSON_COMP_TABLE
      2  /
      COUNT(*)
             1
    SQL> insert into PERSON_COMP_TABLE (empId ,comments ,joindate ,personjoininfo )
      2  values ('1234PTR','DTSDDEPT','12-jan-2006',
      3  XMLType(
      4  '<?xml version="1.0" encoding="UTF-8"?>
      5  <person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="www.PersonInfoUrl.com">
      6     <persondetails>
      7             <personname>Julie </personname>
      8             <personexperience>3.5</personexperience>
      9     </persondetails>
    10     <companyinfo>
    11             <companystartdate>2005-11-21</companystartdate>
    12             <companystandard>3.9</companystandard>
    13             <address>santaclara</address>
    14     </companyinfo>
    15     <salaryinfo>
    16             <salary>2444.3</salary>
    17             <paymonth> june </paymonth>
    18     </salaryinfo>
    19  </person>'))
    20  /
    1 row created.
    SQL> commit
      2  /
    Commit complete.
    SQL> select count(*) from PERSON_COMP_TABLE
      2  /
      COUNT(*)
             2
    SQL> SELECT empid, extractValue(personjoininfo,'/person/companyinfo/address') FROM PERSON_COMP_TABLE
      2  /
    EMPID
    EXTRACTVALUE(PERSONJOININFO,'/PERSON/COMPANYINFO/ADDRESS')
    2006NEW312
    1234PTR
    santaclara
    SQL>The mistakes included the XPath used to insert the new element into the XML Schema
    You had
    '/xsd:schema/xsd:complexType[@name="companyinfo"]/xsd:sequence',
    where as the correct XPath is
    '/xsd:schema/xsd:complexType[@name="companyinfoType"]/xsd:sequence',
    and then you had
    if (dbms_xdb.existsResource('/public/personDetails.xsd')) then
    dbms_xdb.deleteResource('/public/personDetails.xsd');
    end if;
    res := dbms_xdb.createResource('/public/newpersonDetails.xsd',xmlschema);
    end;
    which means that once the document newpersonDetails.xsd had been created once a subsequent execution of the testcase would fail as the document would already exist.
    I'm also a little confused... Your testcase implies that you were able to insert the second document, but the number of rows in the table is still shown as 1 after the insert apparently succeeded. Since you did not correctly update the XML Schema before the calling copyEvolve I do not understand how your output shows that the second insert succeeded.

  • The simplest way for plsql procedure to return multiple rows

    Hi,
    What is the simplest way for plsql procedure to return multiple rows (records). There are many combination of ways to do it but I am looking for a solution that is appropriate for plsql beginners. Many solutions use cursors, cursor variables, collections and more that kind of things that are complex on the face of it. Is it somehow possible to achieve the same with less effort?
    Sample query would be: SELECT * FROM EMPLOYEES;
    I want to use returned rows in APEX to compose APEX SQL(in that context plsql) report.
    It is enough to use just SELECT * FROM EMPLOYEES query in APEX but I want to use plsql procedure for that.
    Thank you!

    Hi,
    It depends :-).
    With +...that is appropriate for plsql beginners...+ in mind... it still depends!
    The list of techniques (ref cursors, cursor variables, collections, arrays, using explict SQL) you have referenced in your post can be made to work. but...
    +Is it somehow possible to achieve the same with less effort?+ Less effort : That needs to be defined (measured). Especially in the context of pl/sql beginners (who is a beginner?) .
    What is the level of "programming experience" ?
    What is the level of understanding of "Relational Result set" as processible in Oracle?
    If you are looking for
    Process_the_set_of rows_in APEX () kind of capabilitywhich "abstracts/hides" relation database from developers when working on relation database, it may not be the best approach (at least strategically). Because I believe it already is abstracted enough.
    I find REF CUROSOR most effective for such use, when the "begginer" has basic understanding of processing SQL result set .
    So in a nut shell, the techniques (that you already are familiar with) are the tools available. I am not aware of any alternative tools (in pure Oracle) that will simplify / hide basics from develpers.
    vr,
    Sudhakar B.

  • T-SQL: SET Statement Using a Case Statement is not returning a value

    SQL VER:  2008
    Please see the attached screenshot from SSMS.  The Set statement  below is not returned a value or may be returning a zero value.  The AllocPercent field is set to zero in code preceeding this Update Statement:
    AllocPercent
    =
    CASE
    WHEN AllocBase
    IS
    NULL
    OR AllocBase
    = 0
    THEN 0
    ELSE PM_Input/AllocBase
    END
    As you can see by the screen shot from the Select Statement that is displaying the results after the Update Statement is completed, the value of AllocPercent is = 0 even though all the values necessary for it to compute a value > 0 are present in the
    table.  Incidentally, the values in both the AllocBase and PM_Input fields are the same before the Update Statement is ran, as shown in the Select ran after the Update Statement.
    I have ran this type of code several times with never a problem.  This seems really simple, but I just can't seem to get it to compute. 
    Any help would be greatly appreciated.
    Regards,
    bob sutor
    Bob Sutor

    Yep--This statement is running in a Stored Procedure and inside its own block statement.
    I did get a response that suggested I change the SET statement as follows, that worked:
    AllocPercent
    = CASE WHEN AllocBase IS NULL OR AllocBase = 0 THEN 0.00 ELSE cast(PM_Input*1.0/AllocBase*1.0
     as decimal(6,2)) END
    Your response did get me thinking which was great!  I appreciate your help.
    Regards,
    ...bob sutor
    Bob Sutor

  • Read from sql task and send to data flow task - [OLE DB Source [1]] Error: A rowset based on the SQL command was not returned by the OLE DB provider.

    I have created a execut sql task -
    In that, i have a created a 'empidvar' variable of string type and put sqlstatement = 'select distinct empid from emp'
    Resultset=resultname=0 and variablename=empidvar
    I have added data flow task of ole db type and I put this sql statement under sql command - exec emp_sp @empidvar=?
    I am getting an error.
    [OLE DB Source [1]] Error: A rowset based on the SQL command was not returned by the OLE DB provider.
    [SSIS.Pipeline] Error: component "OLE DB Source" (1) failed the pre-execute phase and returned error code 0xC02092B4.

    shouldnt setting be Result
    Set=Full Resultset as your query returns a resultset? also i think variable to be mapped should be of object type.
    Then for data flow task also you need to put it inside a ForEachLoop based on ADO.NET recordset and map your earlier variable inside it so as to iterate for every value the sql task returns.
    Also if using SP in oledb source make sure you read this
    http://consultingblogs.emc.com/jamiethomson/archive/2006/12/20/SSIS_3A00_-Using-stored-procedures-inside-an-OLE-DB-Source-component.aspx
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • A rowset based on the SQL command was not returned by the OLE DB provider.

    Hi
    I am calling a stored procedure using ssis.
    i am creating a work table--temp in the procedure and using that to join and select columns from other tables.
    i am gettig the error
    [Positions [22612]] Error: A rowset based on the SQL command was not returned by the OLE DB provider.
    please help

    SET NOCOUNT ON 
    in the stored procedure and try again.
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to test a procedure which returns a recordset from pl/sql

    hello,
    Is it possible to test a procedure which returns a recordset from pl/sql?
    Everything I try results in errors like PLS-00382: expression is of wrong type, when I try to open the result cursor
    or PLS-00221: tc is not a procedure or is undefined.
    I created the following procedure:
    CREATE OR REPLACE PACKAGE test AS
    TYPE cursorType is REF CURSOR;
    PROCEDURE test_cursor( tc IN OUT cursorType,
    v_err OUT varchar2,
    v_msg OUT varchar2);
    END;
    CREATE OR REPLACE
    PACKAGE BODY test AS
    PROCEDURE test_cursor
    (tc IN OUT cursorType,
    v_err OUT varchar2,
    v_msg OUT varchar2)
    AS
    BEGIN
    open tc for
    SELECT '1' "number" FROM dual
    union
    select '2' "number" from dual;
    v_msg := 'no errors';
    v_err := 0;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    v_msg := 'no data found';
    v_err := SQLCODE;
    WHEN OTHERS
    THEN
    v_msg := SQLERRM;
    v_err := SQLCODE;
    END;
    END;
    I try to get the output from pl/sql with something like this:
    DECLARE
    TC PROVGRON.TEST.cursorType;
    V_ERR VARCHAR2(200);
    V_MSG VARCHAR2(200);
    BEGIN
    V_ERR := NULL;
    V_MSG := NULL;
    PROVGRON.TEST.TEST_CURSOR ( TC, V_ERR, V_MSG );
    DBMS_OUTPUT.Put_Line('V_ERR = ' || V_ERR);
    DBMS_OUTPUT.Put_Line('V_MSG = ' || V_MSG);
    -- in tc I was hoping to hava a cursor??
    FOR i IN tc
    LOOP
    DBMS_OUTPUT.PUT_LINE (i.number);
    END LOOP;
    END;
    Without the for loop (or open tc) the pl/sql will output:
    V_ERR = 0
    V_MSG = no errors
    PL/SQL procedure successfully completed.
    With anything I try with the cursor I get errors?
    What am I doing wrong?

    http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch5.htm#sthref1122

  • Avoid JDBC sender error: Execute statement did not return a result set

    Hi!
    My JDBC sender adapter towards MS SQL server works fine, with an Execute statement calling a stored procedure that returns the source data needed. The stored procedure itself updates the status of database table records, so that only the unread records are returned each time the stored procedure is called.
    However, the communication channel monitoring sets a red flag for the JDBC sender adapter, when there are no values to fetch from the database table (using the stored procedure). Message says: "Database-level error reported by JDBC driver while executing statement 'EXECUTE FetchMessage 1, 9000'. The JDBC driver returned the following error message: 'com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.'. For details, contact your database server vendor."
    This is not an error situation, as I do not expect there to be any values to fetch from the database at all times.
    I do not see how to change the stored procedure to avoid this error.
    Is there a parameter to be set on the JDBC adapter that I can use, so the red flag is avoided?
    Thanks for any input!
    Regards,
    Oeystein Emhjellen

    Hi Oeystein Emhjellen.
    The problem is Store Procedure that has to generate always a ResultSet (or cursor). If it doesn't have a output, you have to generate an Empty ResultSet.
    Like a SELECT Statement:
    If there are data, SELECT get an output result but if it get nothing the SELECT Statement get a empty ResultSet.
    Ask to your database team.
    I hope it helps you.
    Bruno.

  • Calling stored procedure and returning multiple resultsets

    Hello,
    Is it possible to create a procedure that return multiple result sets?
    e.g.
    procedure GetDataFromTables() is
    begin
    select * from table_one;
    select * from table_two;
    end GetDataFromTables;
    And I want to call this procedure that returns multiple resultsets (one for table_one and another for table_two)
    I have referred to the OCCI sample occiproc.cpp, but I am not sure how to handle multiple resultsets.
    Your help is highly appreciated.

    Thank You,
    Got the REF cursor in storedproc.cpp.
    But as it is documented, getCursor() gets the REF CURSOR value of an OUT parameter as a ResultSet.
    So, is it true that if I have to write a procedure that selects * from 50 tables (50 SQL statements) , I have to set 50 OUT parameters to get the result sets.?
    Is there any better way of doing this?
    e.g. in DB2, we can open multiple cursors in the procedure body and then get the result set one after another.
    CREATE PROCEDURE get_staging_data ()
    RESULT SETS 1 <no. of result sets>
    LANGUAGE SQL
    BEGIN ATOMIC
    DECLARE L_SQL varchar(5000);
    DECLARE c CURSOR WITH RETURN TO CLIENT FOR L_STMT;
    SET L_SQL = '';
    SET L_SQL = 'SELECT * FROM ';
    SET L_SQL = L_SQL || IN_Tab_Name ;
    SET L_SQL = L_SQL || ' WHERE VERIFY_FLAG=''S'' FOR READ ONLY OPTIMIZE FOR 2000 ROWS' ;
    PREPARE L_STMT FROM L_SQL;
    OPEN c; < can open multiple cursors in the prodedure body>
    END

Maybe you are looking for