Error creating service with record type as a return type

Hi, I tried the following code to get the nth highest sal using the service and the record type.
CREATE OR REPLACE PACKAGE pack_rec_cur AS
TYPE rec_type IS RECORD (
 name EMP.ename%TYPE,
 sal EMP.sal%TYPE);
  END;
The lot above is created
CREATE OR REPLACE 
  FUNCTION fun_rec_cur(n INT) RETURN pack_rec_cur.rec_type AS
   rec pack_rec_cur.rec_type;
    CURSOR cur_rec IS
      SELECT ename,sal
        FROM emp
         WHERE sal is not null 
          ORDER BY DESC;
BEGIN
 OPEN cur_rec;
  FOR i IN 1..n LOOP
   FETCH cur_rec into rec;
   EXIT WHEN cur_rec%NOTFOUND;
  END LOOP;
 CLOSE cur_rec;
 RETURN rec;
END;   
The above function is errors
LINE/COL ERROR
-------- ---------------------------------------
4/7      PL/SQL: SQL Statement ignored
7/16     PL/SQL: ORA-00936: missing expression
SQL> 
Could you please correct me where I am wrong

Thank you.

By clauase missing column name in the order. Is it ename desc?

CREATE OR REPLACE
  FUNCTION fun_rec_cur(n INT) RETURN pack_rec_cur.rec_type AS
   rec pack_rec_cur.rec_type;
    CURSOR cur_rec IS
      SELECT ename,sal
        FROM emp
         WHERE sal is not null
          ORDER BY ENAME DESC; ---added ename
BEGIN
 OPEN cur_rec;
  FOR i IN 1..n LOOP
   FETCH cur_rec into rec;
   EXIT WHEN cur_rec%NOTFOUND;
  END LOOP;
 CLOSE cur_rec;
 RETURN rec;
END;   

------------
-OUTPUT
-----------

SQL> SET SERVEROUT ON
SQL>
SQL> DECLARE
  2     rec            pack_rec_cur.rec_type;
  3  BEGIN
  4     rec         := fun_rec_cur (6); --you get the 6th record in order of ename desc
  5     DBMS_OUTPUT.put_line ('ename::' || rec.NAME || '  sal ::' || rec.sal);
  6  END;
  7  /
ename::MARTIN  sal ::1250

PL/SQL procedure successfully completed.

SQL> 

Tags: Database

Similar Questions

  • XMLTYPE with record type

    Hi friends,

    Is it possible to use XMLTYPE with record types?

    For example, in the following code I expect output voltage

    < TY_EMP > < > 1001 EMPNO < / EMPNO > < ADAMS ENAME > < / ENAME > < SAL > 5000 < / SAL > < TASK MANAGER > < / JOB > < / TY_EMP >

    The code is...

    DECLARE

    Ty_emp RECORD TYPE IS

    (

    EmpNo INTEGER

    , ename VARCHAR2 (100)

    NUMBER of sal

    , VARCHAR2 (100) employment

    );

    r_emp ty_emp;

    BEGIN

    r_emp.EmpNo: = 1001;

    r_emp. Ename: = "Adams";

    r_emp. SAL: = 5000;

    r_emp.job: = "MANAGER";

    -This line gives the error.

    dbms_output.put_line (XmlType (r_emp). GETSTRINGVAL()); -Here, I don't want to talk about all the fields in the record. I just need to specify the name of the record.

    END;

    p.s. to use object types to generate XML data...

    SQL > ed
    A written file afiedt.buf

    1 TYPE to CREATE or REPLACE ty_emp () AS OBJECT
    2 empno INTEGER
    3, ename VARCHAR2 (100)
    4, NUMBER of sal
    5, job VARCHAR2 (100)
    6*   );
    SQL > /.

    Type of creation.

    SQL > ed
    A written file afiedt.buf

    1 DECLARE
    2 r_emp ty_emp: = new ty_emp (null, null, null, null);
    3 BEGIN
    4 r_emp.empno: = 1001;
    r_emp.ename 5: = "Adams";
    6 r_emp.sal: = 5000;
    7 r_emp.job: = "MANAGER";
    8 dbms_output.put_line (XMLTYPE (r_emp) .getstringval ());
    9 * END;
    SQL > /.
    1001 Adams 5000 MANAGER

    PL/SQL procedure successfully completed.

    SQL >

  • Error using BULK collect with RECORD TYPE

    Hello

    I wrote a simple procedure to declare a record type & then by a variable of type NESTED table.

    I then selects the data using COLLECT in BULK & trying to access it via a LOOP... We get an ERROR.

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

    CREATE OR REPLACE PROCEDURE sp_test_bulkcollect
    IS

    TYPE rec_type () IS RENDERING
    emp_id VARCHAR2 (20).
    level_id NUMBER
    );

    TYPE v_rec_type IS TABLE OF THE rec_type;

    BEGIN

    SELECT employe_id, level_id
    LOOSE COLLECTION v_rec_type
    OF portfolio_exec_level_mapping
    WHERE portfolio_execp_id = 2851852;

    FOR indx IN v_rec_type. FIRST... v_rec_type. LAST
    LOOP

    dbms_output.put_line ('Emp-' | v_rec_type.emp_id (indx) |) » '|| v_rec_type.level_id (indx));

    END LOOP;

    END;
    -----------------------------------------------------------------------------------------------------------------------------------

    Here is the ERROR I get...


    -Errors of compilation for the PROCEDURE DOMRATBDTESTUSER. SP_TEST_BULKCOLLECT

    Error: PLS-00321: expression "V_REC_TYPE" is not appropriate for the left side of an assignment statement
    Online: 15
    Text: IN portfolio_exec_level_mapping

    Error: PL/SQL: ORA-00904: invalid identifier
    Online: 16
    Text: WHERE portfolio_execp_id = 2851852;

    Error: PL/SQL: statement ignored
    Line: 14
    Text: COLLECT LOOSE v_rec_type

    Error: PLS-00302: component 'FIRST' must be declared
    Online: 19
    Text: LOOP

    Error: PL/SQL: statement ignored
    Online: 19
    Text: LOOP
    ------------------------------------------------------------------------------------------------

    Help PLZ.

    and with a complete code example:

    SQL> CREATE OR REPLACE PROCEDURE sp_test_bulkcollect
      2  IS
      3  TYPE rec_type IS RECORD (
      4  emp_id VARCHAR2(20),
      5  level_id NUMBER
      6  );
      7  TYPE v_rec_type IS TABLE OF rec_type;
      8  v v_rec_type;
      9  BEGIN
     10     SELECT empno, sal
     11     BULK COLLECT INTO v
     12     FROM emp
     13     WHERE empno = 7876;
     14     FOR indx IN v.FIRST..v.LAST
     15     LOOP
     16        dbms_output.put_line('Emp -- '||v(indx).emp_id||' '||v(indx).level_id);
     17     END LOOP;
     18  END;
     19  /
    
    Procedure created.
    
    SQL>
    SQL> show error
    No errors.
    SQL>
    SQL> begin
      2     sp_test_bulkcollect;
      3  end;
      4  /
    Emp -- 7876 1100
    
    PL/SQL procedure successfully completed.
    
  • Windows Error Reporting service stopped recording of events in the event log, and now when it spawns werfault.exe, the process consumes the CPU until he is killed.

    Windows error reporting service ceased to record events in the event viewer. The last successful entry was 26/03/2010. Since then whenever the service generates Werfault.exe to handle the error, the process seems stuck in a loop of consumer processor, but do nothing. It uses 99% of CPU (80% preferred), is not e/s and number of handles, thread, & working set do not develop.

    Three Windows updates were installed in shortly after the last successful log entry (automatic update is enabled):

    KB915597 def 1.79.702.0 & def 1.79.495.0 both for Windows Defender

    KB980182 for IE 7

    I think that my system is clean, at least Spyware Doctor think it is. I also did some tests Ad-Aware. Windows Defender analyzes every day without error.

    Has anyone else encountered this problem?

    Hi Wannknow,

    It's good information - and thanks for the thanks! You really only need to run an adware or virus (malware) program at the same time. What I would recommend is that you choose an adware program - either "Windows Defender" or "spyware doctor" and disable the other. This can be your root problem, so at this point I turn back on 'report of problems and solutions' and see if you experience the same problem:

    Again, here are the instructions:

    1. open Control Panel. (Press Ctrl-ESC and type 'control' is faster access method).

    2. click on "System and Maintenance" and then click "problem reports and solution."

    3. click on change settings in the left panel of the problem reports and Solutions window.

    4. Select Advanced settings.  In the "for my programs, problem report is: ' select 'off '. Click on CLOSE the

    Hope this helps,

    Steve <> Microsoft partner

  • Fail to create the web service with the type of data defined by the user using the jwsc Ant task!

    Hello everyone!

    I used JAXWS to create WSDL from a file of Jehovah's witnesses.

    It's my TJ:
    -----------------------------------------------------------------------------------
    package ws;

    Import javax.jws.WebService;
    Import javax.jws.WebMethod;
    ws import. MyDataType;

    *@WebService*
    * public class MyWebService {*}
    public MyWebService()
    *{*
    *}*
    *@WebMethod*
    public MyDataType MyWebMethod (MyDataType mdt)
    *{*
    * / / mdt.setS ("I got it!"); *
    return mdt;
    *}*
    *}*
    -----------------------------------------------------------------------------------


    and this is my type of data:
    -----------------------------------------------------------------------------------
    package ws;

    * public class MyDataType {*}


    String ^ s;
    public MyDataType()
    *{*

    *}*
    * public String getS() {*}
    return s;
    *}*

    * Sets public Sub (String s) {*}
    This.s = s;
    *}*
    *}*
    -----------------------------------------------------------------------------------



    and that's my Ant build.xml
    -----------------------------------------------------------------------------------
    * < by default of the project = "all" > *.
    * < property name = "weblogic.jar.classpath" value="D:/Projects/bea103/wlserver_10.3/server/lib"/ > * "
    * < taskdef name = "jwsc" classname = "weblogic.wsee.tools.anttasks.JwscTask" > *.
    * < classpath > *.
    * < path id = "weblogic.classpath" > * "
    * < pathelement path = "WEBLOGIC_HOME" / >. *
    * < fileset dir = "${weblogic.jar.classpath}" > *.
    * < include name = "weblogic.jar" / > *.
    * < / fileset > *.
    * < / path > *.
    * < / classpath > *.
    * < / taskdef > *.
    * < target name = "all" depends = "clean, build-service" / > *.
    * < name target 'clean' = > *.
    * < delete dir = "output" / > *.
    * < / target > *.
    * < name target = 'build-service' > *.
    * <!-add jwsc and related tasks here - > *.
    * < jwsc srcdir = "" destdir = "wsoutput" > * "
    * < jws file = "MyWebService.java" type = "JAXWS" / > * "
    * < / jwsc > *.
    * < / target > *.
    * <!-< target name = "deploy" > - > <! - add wldeploy task here - > <!-< / target >-> *.
    * < / project > *.
    -----------------------------------------------------------------------------------

    I have run the Ant task, but I get this error:
    -----------------------------------------------------------------------------------
    BuildFile: build.xml

    clean:

    build service:
    [jwsc] TJ: processing module /MyWebService
    [jwsc] The analysis of source files
    [jwsc] The analysis of source files
    [jwsc] 1 TJS files processing for the module /MyWebService
    * [jwsc] [JAM] WARNING: could not resolve class MyDataType *.
    [jwsc] TJ: C:\Documents and Settings\samimi\IdeaProjects\SampleWebService\src\ws\MyWebService.java valid.
    [jwsc] Treatment of the web services JAX - WS 1...
    * [jwsc] error: couldn't get TypeDeclaration for: MyDataType apt tour: 1 *...
    ...................
    BUILD FAILED
    C:\Documents and Settings\samimi\IdeaProjects\SampleWebService\src\ws\build.xml:
    19: weblogic.wsee.tools.WsBuildException: JAX - WS web services processing error
    -----------------------------------------------------------------------------------

    Please help me solve this problem.
    Thank you
    Mojir

    I tried to compile your source code and received the same exception.
    However after compiling the MyDataType.java before running the jwsc task, I was successfully able to build the service.

    Please try the ant script below and let me know the result:

    **
    *     *
    *
    *



    <>
    srcdir = "${source.dir}" "

    DESTDIR = "${Build.dir} '"
    keepGenerated = 'true '.
    classpath = "${Class.Path} '"
    Debug = 'true '.
    verbose = "false" >

         


              

    Thank you
    Sandeep

  • Qosmio G20-139: error creating DVD with MCE

    Hello

    I'm having a problem DVD creation with MCE. I followed all the links, trying to save my recorded TV progs.

    I get on well, until it starts to create a DVD. It only happens to 1%, then he rushes up to 100% and after about 30 seconds it says "dvd creation error".

    I use a G20-139 and the dvd drive is a carpet * a dvd - ram uj846s.
    Help.

    See you soon

    Ogilvie

    Hello

    It is not easy to say what the problem is here, but in my opinion, you should try to use a third party burning application, try to create DVDs.

    I can recommend Nero Express. I tested it on Qosmio G20 and it works perfectly. I also have very good results with Ulead DVD MovieFactory 5. It works perfectly.

  • Error creating service Bi presentation in obiee (11.1.1.3)

    Hello
    I'm using Jdeveloper (11.1.1.5) and OBIEE (11.1.1.3)

    I created an ADF application in Jdev and when I try to create a presentation of BI services I receive the following error message.

    *"*
    * Connection attempt failed.*
    * java.lang.RuntimeException: failed to retrieve the connection token. This version requires a version of BI that implements the SOAP version 7. Please make sure you use the right time of BI
    *"*

    the creation of the presentation to jdev (11.1.15) service only works with OBIEE (11.1.1.5) and not OBIEE (11.1.1.3).

    Help, please!

    Thank you
    Vinciane

    Published by: Vinciane July 26, 2011 14:02

    Published by: Vinciane July 27, 2011 06:18

    Vinciane,

    The SOAP out with OBIEE 11.1.1.3 interface is the version 6 (v6) as you can see from its WSDL URL.

    That would leave only one of the SOAP out with OBIEE 11.1.1.5 interface as version 7.

  • Error creating table with clusters

    Hello
    I tried the following
    CREATE CLUSTER emp_dept (deptno NUMBER(3))
    Cluster is created

    Then I tried to create the table with the cluster above but giving error:
    create table emp10 (ename char(5),deptno number(2) )cluster emp_dept(deptno);
    The error is:
    ORA-01753 column definition incompatible with clustered column definition
    Could you please help me in this

    Your cluster is based on a NUMBER data type (3), while the emp10 table has a deptno column with a data type of NUMBER (2).

  • Flex services with several types of return

    Hello

    We create a webapplication with flex and php.

    Everything works fine, until we got to the part of the library of the application.

    Each service has so far had only 1 return type (for example: user, group,...)

    Now for the library, we want to return a collection of ArrayCollection of different types of objects. To be more precise the LibraryService must return a collection ArrayCollection containing objects of folder and file.

    But how to configure this in Flex (Flash Builder 4 (standard))?

    So far it converts all objects of type Object, I really wish it was the folder or the file

    The only solution we can think of right now is to create a new library object which will contain 2 ArrayCollections, file type and file type. This might work of course, but I wonder if there is a better solution for this OR that I can configure several types of return for a service.

    Ideas/advice is greatly appreciated.

    Look at Zend or AMFPHP.

  • Problem of forms 6 with record type.

    Hello!.
    Forms [32 Bits] Versão 6.0.8.11.3 (Produção)
    Oracle Database 10g Release 10.2.0.3.0 - 64bit Production
    I have this code in a pl sql package named consulta_dbi on the server:
    type tsintegra is record (
                situacao         varchar(255) := null,
                cnpj             number       := null,
                ie               varchar(255) := null,
                razaosocial      varchar(255) := null
        );
    
        type treceita is record (
                cnpj                 number         := null,
                dataabertura         date          := null,
                razaosocial          varchar(255) := null
        );
    In forms, I have these procedures:
    PROCEDURE buscar_dados_sintegra IS
              sintegra      consulta_dbi.tsintegra;
    BEGIN
            null;
    END;
    AND
    PROCEDURE buscar_dados_receita IS
              receita      consulta_dbi.treceita;
    BEGIN
            null;
    END;
    buscar_dados_receita works. But whe I try to compile buscar_dados_sintegra shapes (narrow) breaks.

    Does anyone know how to fix this?

    Thank you

    I bring both the database + forms on the last group of patches and try again.

    see you soon

  • Error creating VM with client PXE:M0F workstation: Intel PXE ROM operating system not found

    I'm new to VMWare workstation.  I have a problem on a new installation of the workstation 7.  When I create my first VM, I point to a XP ISO image that I know works because we use it for the image of the PC and I get the following messages:

    PXE:M0F: Existing Intel PXE ROM.

    Operating system not found

    This could be the cause?

    Thank you

    Hello and welcome

    There is no error in itself - it simply means that a this may be the case

    -l'iso is not bootable

    -the check box stating 'Connected' is not marked

    -the box indicating "Connected to the ignition" is not marked

    ___________________________________

    VMX-settings- Workstation FAQ -[MOA-liveCD | http://sanbarrow.com/moa241.html]- VM-infirmary

  • javax.management.InstanceNotFoundException: com.oracle.jps:type = JpsCredentialStore when creating credentials with credential store framework

    Hello

    I have an installation of WebLogic 11 g 1 material (on Windows Server 2012 with Oracle backend) and try to create credentials with credential store framework following steps inhttp://www.redheap.com/2013/06/secure-credentials-in-adf-application.html

    I tried to do with WLST (under Oracle\Middleware\oracle_common\common\bin) and get the following error:

    WLS: / WcsDomain/serverConfig > createCred (map = "ClayTablet.Sample", key is "TestKey", user = "TestUser", password = "blah", desc = "Test"key);

    Now to the tree of domainRuntime. It is a tree read-only with DomainMBean as the root.

    For further assistance, use the help (domainRuntime)

    COMMAND FAILED for an unknown reason, check the stack for more details trace

    Traceback (innermost last):

    Folder "system <>", line 1, in?

    File "C:\Oracle\MIDDLE~1\ORACLE~1\common\wlst\jpsWlstCmd.py", line 522 to createCred

    File "C:\Oracle\MIDDLE~1\ORACLE~1\common\wlst\jpsWlstCmd.py", line 504, createCredImpl

    at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:237)

    at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:223)

    at javax.management.remote.rmi.RMIConnectionImpl_1036_WLStub.invoke (unknown Source)

    to weblogic.management.remote.common.RMIConnectionWrapper$ 16.run(ClientProviderBase.java:918)

    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)

    at weblogic.security.service.SecurityManager.runAs (SecurityManager.java: 146)

    at weblogic.security.Security.runAs(Security.java:61)

    at weblogic.management.remote.common.RMIConnectionWrapper.invoke(ClientProviderBase.java:916)

    to javax.management.remote.rmi.RMIConnector$ RemoteMBeanServerConnection.invoke (RMIConnector.java:993)

    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    javax.management.InstanceNotFoundException: javax.management.InstanceNotFoundException: com.oracle.jps:type = JpsCredentialStore

    Thank you

    Yu

    P.S. I was using the command WLST under Oracle\Middleware\wlserver_10.3\common\bin to do the same thing and got a different error NameError: createCred and posted a question about that in virtue of How to create credentials under Bank of credentials?

    After searching the same error message in the community, I tried to move to WLST under Oracle\Middleware\oracle_common\common\bin and got the error posted here.

    Having extended my domain name with JRF and JRF WebService services asynchronous, I was able to run "createCred" and "listCred" and so on.

    Yu

  • CF 11 Enterprise multiple instances are not created correctly with a separate service account.

    The company that multiple instances are not created correctly with a separate service account.

    The questions that I have are very similar to the issues identified in the link below.

    https://forums.Adobe.com/message/6584848#6584848

    My company of 11 CF will not create additional services for my sites of cold fusion beyond the initial service created during the installation process. My problems are compounded because when I try and uninstall the CF11 Uninstalling application crashes and generates the error below. I now have to try to manually uninstall to reinstall CF11. Any help or suggestion to get the problem solved is welcome.

    Description:

    A problem caused this program blocking interact with Windows.

    Signature of the problem:

    Problem event name: AppHangB1

    Application name: javaw.exe

    Application version: 7.0.510.13

    Application timestamp: 52b25e38

    Hang Signature: 0967

    Hanging Type: 6144

    OS version: 6.1.7601.2.1.0.274.10

    Locale ID: 1033

    Signing of additional blocking 1: 09675b5d8f587c9fd57b85cb72e629da

    Signing of additional blocking 2: 2cff

    Signing of additional blocking 3: 2cff32d5db809ac6ce8170a1d7ac1eb0

    Signature of blocking additional 4:0967

    Signing of additional blocking 5: 09675b5d8f587c9fd57b85cb72e629da

    Signing of additional blocking 6: 2cff

    Signing of additional blocking 7: 2cff32d5db809ac6ce8170a1d7ac1eb0

    I solved the problem with the implementation of Cold Fusion 11. I had to disable Windows server 2008 R2 UAC for all users in order to complete the installation with IIS as a web server. This also solves the problem with the inability to uninstall Cold Fusion.

  • Dynamic SQL with in bulk in the record type

    Oracle 10.2 g

    I received this Tom

    [http://asktom.oracle.com/pls/apex/f?p=100:11:0:NO:]

    I'm able to do this without dynamic SQL, but my requirement is to do it in dynamic SQL
     create table t1 ( x int, y int );
    
     insert into t1 select rownum, rownum+1 from all_users where rownum <= 5;
    
     create table t2 ( x int, y int, z int );
    
     declare
                type array is table of t1%rowtype;
                l_data array;
        begin
                select * bulk collect into l_data from t1;
      
                forall i in 1 .. l_data.count
                
                       execute immediate 'insert into (select x, y from t2) values :x' using l_data(i);
        end;
     
    Error at line 1
    ORA-06550: line 9, column 90:
    PLS-00457: expressions have to be of SQL types
    ORA-06550: line 9, column 20:
    PL/SQL: Statement ignored
    There is a work around in 11g, but can we do something in 10g?



    Thank you
    HESH.

    HESH wrote:

    but following does not.

    declare
    type array is table of t1%rowtype;
    l_data array;
    begin
    select * bulk collect into l_data from t1;
    
    forall i in 1 .. l_data.count
    
    execute immediate 'insert into (select x, y from t2) values :x' using l_data(i);
    end;
    

    I want just a dynamic SQL code for the insert with FORALL statement would adopt as well as collections.

    Doesn't make much sense.

    Extract you the data from the SQL engine in the table of the record type. If the output data that cursor SQL must be read in the SQL engine and copied into the memory of PL/SQL engine.

    Then, you send that VERY SAME DATA back to the SQL engine to be used by a SQL insert cursor.

    Where is the logic behind the extraction of data from SQL in a PL/SQL table structure and then push this same structure table on the SQL engine database? What is the purpose to send data on a detour of underperforming and non-scalale through the PL/SQL engine?

    You have any justification (technical or functional wise) to back up this absurd approach?

    Why this can be achieved using a single SQL cursor that does both the choice (extraction) and (in bulk) insertion - using the plain old INSERT... SELECT structure?

    And if the insert is variable, then what? Create a dynamic INSERT... SELECT cursor and execute it (using bind values). This simple... Right?

  • Need to create a new record with the rules of the takeover bid

    Hi all

    I want to create a new record with OPA according to the result value (Service request is valid)

    For example
    When the demand for services is valid if
    There are (the activity is valid)
    the activity is valid if
    activity type = 'other '.

    Can someone help me how to

    Can you provide a little more information on what you want to do?

    If you want to create an object in, for example, a database based on the results of the OPA assessment or investigation, then that lies outside of the OPA and is usually performed by the client that calls the rules.

    If you want to create an instance of entity within the am Session OPA, then this will be involved custom code. There is an example of this in the OPA 10.2.0 documentation, see: example: enter into instances of entity with an inference listener in policy of Automation Developer Help. It is available online at http://download.oracle.com/docs/html/E20344_01/toc.htm

Maybe you are looking for