Error while creating function with record type as return type

Hi i tried the following code to get the nth highest sal using record type and function.
CREATE OR REPLACE PACKAGE pack_rec_cur AS
TYPE rec_type IS RECORD (
name EMP.ename%TYPE,
sal EMP.sal%TYPE);
  END;The above package 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 giving 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'm doing mistake
Thanks.

You are missing the column name in order by clauase. 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>

Similar Messages

  • Error while creating delivery with reference to STO

    Hi,
    I am getting the following error while creating the delivery with reference to STO
    Document is incomplete: You cannot save the delivery
    Diagnosis:
    When the system checked whether saving delivery was
    permitted, it determined that the requirements stored in
    Define Incompletion Procedures for this document do not
    allow this subsequent function.
    I have checked the following already:
    1. Maintained shipping data for both the supplying and receiving plants.
    2. Shipping tab exists in the PO
    3. Shipping point determination is checked.
    4. Customer masters created for both supplying plants and receiving plant for the sales area created for STO
    5. Material master is available in both receiving and supplying plants.
    It is working fine in one client. and giving a problem only in the other.not able to figure out where the error is. appreciate your suggestions
    regards
    joe

    Hi Joseph,
                     First go to transaction "VUA4" and see what is the incompletion procedure asigned to your delivery type. Then go to
    "OVA2" and see what are the fileds maintained in incompletion procedure of the delivery type and the status groups assigned to them. Now you go to "OVA0(ZERO) and see whether the status group allows to save the delivery. If it doesn't you can untick that check box. But if this is a live system , i doubt if you would be bale to do that. Any way one of the possible causes is storgae location missing. Kindly pelase let me know If you need any more infromation on this.
    Regards,
    Ram Pedarla

  • ESS: Error while creating Family/Dependents record from portal

    Hi All,
    I'm getting a critical error while creating family members and dependents record from portal.
    CRITICAL ERROR
    "Type conflict in the ASSIGN statement in the program CL_HRPA_CONVERT_0021_US=======CP        ., error key: RFC_ERROR_SYSTEM_FAILURE"
    I checked the short dump in R/3 Side and searched for OSS note and didnt find any. I raised an OSS message.
    If any had've already comeacross this, pls let me know.
    System Details
    EP 6.0 SP15
    ESS Business Package BPERP4ESS0_0
    ESS Support Package  ESS10P_2-10002965, PCUIGP010P_1-20000568
    Thanks
    Karthik

    Hello Karthik:
    I'm getting the same error:
    "critical error while creating family members and dependents record from portal.
    Type conflict in the ASSIGN statement in the program CL_HRPA_CONVERT_0021_US=======CP ., error key: RFC_ERROR_SYSTEM_FAILURE"
    Maybe you can help me solving this problem.
    I appreciate your help.
    Thanks in advance.

  • Error while creating document with attachment.

    Hi,
    I am getting an error "An error occured while creating the original attribute for PDF"
    I tried with out file attachment, it works as you know it is simple....
    I tried with various types of attachments like .TXT and .WRD (changed both wsapplication and docfile parameters), however i get the same error. I tried both from presentation and application server (by providing   pf_ftp_dest                = 'SAPFTPA'    pf_http_dest               = 'SAPHTTPA' )
    Any idea on how to solve this?
    All i need is create a DMS document with a PDF attachment from application server. Are there any other ways to solve this issue?
    ws_docdata-documenttype = 'ARE'.
    ws_docdata-description = 'BAPI DMS'.
    ws_docdata-statusextern = 'CR'.
    ws_file-storagecategory = 'DMS_C1_ST'.
    ws_file-wsapplication   = 'PDF'.
    ws_file-description = 'Job output'.
    ws_file-docfile = 'C:\CAD Integ BAPIS_46.pdf'.
    append ws_file to it_files.
    CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
      EXPORTING
         documentdata               = ws_docdata
    IMPORTING
         return                     = v_ret
    TABLES
         documentfiles              = it_files   .
    BREAK-POINT.
    IF v_ret-type CA 'EA'.
      ROLLBACK WORK.
      WRITE : v_Ret-message.
    ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = '5'.
    ENDIF.
    Thanks
    Pavan

    Hi,
    I found that it is due to document type = 'ARE'. I changed hte document type to one of hte standard type 'TST'. It works for presentation server, but does not work for application server. Any ideas? Any help is appreciated with points.
    ws_docdata-documenttype = 'TST'.
    ws_docdata-description = 'BAPI DMS'.
    ws_docdata-statusextern = 'CT'.
    ws_docdata-documentnumber = 'ZNG-10000000017'.
    ws_file-storagecategory = 'DMS_C1_ST'.
    ws_file-wsapplication   = 'PDF'.
    ws_file-description = 'Job output'.
    ws_file-docfile = p_file.
    append ws_file to it_files.
    CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
      EXPORTING
        documentdata               = ws_docdata
       pf_ftp_dest                = 'SAPFTPA'
       pf_http_dest               = 'SAPHTTPA'
    IMPORTING
       documentnumber             = v_docnum
       documentpart               = v_docpart
       documentversion            = v_docver
       return                     = v_ret
    TABLES
       documentfiles              = it_files   .
    IF v_ret-type CA 'EA'.
      ROLLBACK WORK.
      WRITE : v_Ret-message.
    ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = '5'.
    ENDIF.
    Thanks
    Pavan

  • Error while creating BOM with FM CSAP_MAT_BOM_MAINTAIN

    Hi All,
    While creating the bom with the FM "CSAP_MAT_BOM_MAINTAIN" using change number i am getting the below error message.
    " Processing of this object is not supported with change number."
    Please help me out.
    Regards
    Suresh

    call function 'CSAP_MAT_BOM_MAINTAIN'
      exporting
        material                 = material
        plant                    = plant
        bom_usage                = usage
        alternative              = alternat
        valid_from               = y_date
    *   CHANGE_NO                =                   "<----Have u used this field for creating ?
    *   REVISION_LEVEL           =
        i_stko                   = l_stko
    *   FL_NO_CHANGE_DOC         = ' '
        fl_commit_and_wait       = 'X'
        fl_bom_create            = 'X'
        fl_new_item              = ' '
        fl_complete              = ' '
    * IMPORTING
    *   FL_WARNING               =
    *   O_STKO                   =
    CSAP_MAT_BOM_CREATE would be an ideal one for creation and CSAP_MAT_BOM_MAINTAIN for change
    Regards,
    Mithun Shetty.

  • Error while creating Function module extracter

    Hello Guru's
    I am getting error while FM extracter creating.
    Have created FM and Extract structure and while creating datasource using these where i am getting error as given below
    1> ZV_ZFRT_INVOICES(Datasource): TABLES-paramter E_T_DATA for extractor Z_ZFRGT_INVOICES(FM) is missing
    2>(DS)ZV_ZFRT_INVOICES: Field ZEILE of the provider structure is missing in extract str. ZVZFRT_INVOICES(Extract structre)
    3>(DS )ZV_ZFRT_INVOICES: Field EBELP of the provider structure is missing in extract str. ZVZFRT_INVOICESExtract structre)
    Please some one can help me to get out of the issue.

    HI Aryan,
    No need to create FM on your own. You can copy the FM from Function Group RSAX.
    The procedure to create FM extractor is as follows:
    1) Create an extract structure.
    2) Go to SE80. Select Function Group RSAX , right click and then copy.
    3) Give your own name to the function group to copy.
    4) Select one appropriate FM from the list of FMs provided. eg FM RSAX_BIW_GET_DATA_SIMPLE.
    5)Specify the name of new FM you want to create.
    6) Go to SE37 and open the FM you have created by copying from Function Group RSAX.
    7) no need to change the import tab.
    8) On tables tab, for paramerter name E_T_DATA under asociate name specify the name of extract structure you hav created.
    9) Under source code tab make the changes in the source code only to customise it to your requirement. eg: declare the database table you are using, make changes where datasource is in picture, etc.
    I have created a generic DataSource with the help of above procedure.. I hope you will find it helpful...
    Regards,
    Geetanjali

  • ESS Leave Request - Error while creating a leave record

    Hi Friends,
      Some of the ESS leave request(not workflow) has gone into error when the system tryies to create a leave record in background. I can view these error request using the report RPTARQDBVIEW. This happens when the background program(PTARQPOST) tries to create a leave record. In some cases  the status of the leave request is set to error(the status attribute of the container element(Req) has the value Error),but we are not able to find what is actual error.Is there any log where we can check what is the problem? Please advice.

    May be
    Internally the pernr might not be locked or some one may be maintaing the pernr for whom you are trying to post.

  • Error while creating snapshot with OEL6.5 guest in VMware.

    While creating snapshots we are getting the following kernel messages:
    ------------[ cut here ]------------
    WARNING: at fs/ext4/super.c:341 ext4_journal_start_sb+0x129/0x140 [ext4]()
    Hardware name: VMware Virtual Platform
    Modules linked in: autofs4 ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 xt_state nf_conntrack ip6table_filter ip6_tables ipv6 ppdev vmw_balloon parport_pc parport coretemp hwmon crc32c_intel ghash_clmulni_intel microcode pcspkr sg i2c_piix4 vmw_vmci shpchp ext4 jbd2 mbcache sd_mod crc_t10dif sr_mod cdrom aesni_intel ablk_helper cryptd lrw aes_x86_64 xts gf128mul mptspi mptscsih mptbase scsi_transport_spi vmxnet3 floppy pata_acpi ata_generic ata_piix vmwgfx ttm drm i2c_core dm_mirror dm_region_hash dm_log dm_mod [last unloaded: speedstep_lib]
    Pid: 4123, comm: master Not tainted 3.8.13-44.1.1.el6uek.x86_64 #2
    Call Trace:
    [<ffffffff8105d67f>] warn_slowpath_common+0x7f/0xc0
    [<ffffffffa019abd7>] ? ext4_dirty_inode+0x27/0x60 [ext4]
    [<ffffffff8105d6da>] warn_slowpath_null+0x1a/0x20
    [<ffffffffa01b7f89>] ext4_journal_start_sb+0x129/0x140 [ext4]
    [<ffffffffa019abd7>] ext4_dirty_inode+0x27/0x60 [ext4]
    [<ffffffff811bae4f>] __mark_inode_dirty+0x3f/0x1f0
    [<ffffffff811ab026>] update_time+0xa6/0xe0
    [<ffffffff811ab0f8>] file_update_time+0x98/0xe0
    [<ffffffff8119a90d>] pipe_write+0x34d/0x6b0
    [<ffffffff81191b87>] do_aio_write+0xc7/0xd0
    [<ffffffff8101a719>] ? emulate_vsyscall+0x329/0x3d0
    [<ffffffff81191c37>] do_sync_write+0xa7/0xe0
    [<ffffffff81191fc4>] vfs_write+0xb4/0x130
    [<ffffffff811a47d5>] ? poll_select_set_timeout+0x95/0xb0
    [<ffffffff8119276f>] sys_write+0x5f/0xa0
    [<ffffffff815a0a59>] system_call_fastpath+0x16/0x1b
    ---[ end trace 4525293ca5c40077 ]---
    According to Jan Kara:
    It seems like you are hitting the warning:
    WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE);
    which means that writing to a named pipe is modifying timestamp of a file while filesystem is frozen. This is not harming the fs such but the fs snapshot you are presumably taking may be slightly inconsistent.
    I see the process which is writing to the named pipe is "postfix". Had anyone else seen this behavure before and meaby have a solution for it?

    kernel/git/torvalds/linux.git - Linux kernel source treehttp://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7e775f46a125f894a1d71e96797c776dbec161f0has it fixed.
    http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7e775f46a125f894a1d71e96797c776dbec161f0

  • Error while creating PR with account assignment K

    Hello All,
    We have a issue  for one user , he is trying to created PR in ME51N in production system  but cannot and he gets the error message " Field selection PT8B not defined'. Infact the the field selection PT8B itself  is not there in the configuration. But in quality system the user  is able to create PR without any issue.
    Also  his colleague can able to create the PR in production in ME51N without any issues.  Even i am able to create the PR in ME51N in quality system without any problem , i came across the exact issue in the below thread , since the issue is only for that specific user , i am not able to find the cause.
    EROR while saving PR
    Pls provide your inputs/suggestions
    Thanks
    Benny

    Hi Benny,
    There's possibility to assign different screen layouts to different users 8and of course the screen layout for the same users in different systems can be different). It is included in "functional auth. for byers" and can be found in IMG under Purchasing -> Auth. mgmt. Each code here has among other fields a field called "field selection", which presumably contains PT8B for one of the func. auth. codes. This func. auth. code is in turn linked to the user master record by means of the parameter EFB ("own data" or trs SU3 or trs SU01).
    Therefore it is very much possible that the different users are allocated to the different func. auth. codes and the same user in the quality system is allocated to the different func. auth. code than in prod.
    BR
    Raf

  • Error while creating table with clusters

    Hi
    I tried the following
    CREATE CLUSTER emp_dept (deptno NUMBER(3))Cluster is created
    Then i tried to create the table having the above cluster but giving the errors:
    create table emp10 (ename char(5),deptno number(2) )cluster emp_dept(deptno);The error is:
    ORA-01753 column definition incompatible with clustered column definitionCould you please help me in this

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

  • Error while creating MBO with web service data source

    Hi All,
         I am trying to create MBO by selecting web service as a data source type in SMP 2.3. I am providing sharepoint webservice url of type wsdl with HTTP basic authentication. However, I am getting following error can anyone help me in that. Looking for detail explaination as this is new for me...
    (For "define XSLT manually" I am using sample .xsl file)
    Regards,
    Harshada

    Harshada Karane
    Are you using any proxy in your browser? If yes, please set the proxy in workspace and then trHow to bypass proxy settings in SMP workspace for connecting any public Web Service within corporate Network
    Rgrds
    JK

  • Showing error while creating IT0000 ee record

    Hi,
    I am new to HR functional. Please do need full.
    When i am creating record in infotype 0000, it is showing error like No entry in table T503 for     779.
    I am giving value 7 fro employee group and 79 for employee subgroup.
    Is there any where that i can enter value 779.
    Thanks,
    Thrilleswar

    Hi ram,
    Thanks so much..
    this error is resolved but the other error is showing like Number range 01 is internal, do not enter a personnel number.
    Is there any place that i can be able to make my number work here.
    Thanks,
    Thrilleswar

  • Error while creating Communication Channel- No SLD elements of type  SAP_XI

    Hi Experts,
    I am getting an error when i am tring to create an Communication channel for File Adapter .
    Error message:
    No SLD elements of type  SAP_XI Adapter Framework Found.
    Could you let me know how to proceed and fix the issue.
    Regards
    Kiran Kumar.P

    Hi Kiran,
      Your Adapter Framework is probably not registered in the SLD.... perform the action as follows:
    1. In the J2EE administrator tool in cluster - server - services - deploy
    stop the J2EE applications:
    a. sap.com/com.sap.aii.af.service.cpa.monitor
    b. sap.com/com.sap.aii.af.
    2. Restart the sap.com/com.sap.aii.af application.
    Refer sapnote in chapter 8.2 for more in the link provided below on Trouble shooting.
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/bd5950ff-0701-0010-a5bc-86d45fd52283
    Also try stop and start of the Java EE application "com.sap.xi.directory".
    for more info refer this thread..
    SLDAccess set to true, but not available with PI 7.10 SPS 7
    Regds,
    Pinangshuk.

  • Error while creating Function.

    Hii All,
    I'm currently working on 10gR2 .I'm trying to dynamically pass a column and parse it but I've encountered following error.Please help me.
    Create or replace Function r_return_col
                         p_table_name          in          varchar2,
                         p_column_name          in          varchar2
                        )return varchar2
    is
              l_count                    number;
              l_clob                    clob;
              l_count_str               varchar2(32000);
              l_column_value          varchar2(32000);
              l_str                    clob;
              l_ret_str               clob;
    begin
              l_count_str := ' select count('||p_column_name||') ' ;
              l_count_str := l_count_str||' from      '||p_table_name ;
              execute immediate l_count_str into l_count;
              for i in 1..l_count
              loop
                        l_str := 'select '||p_column_name||' from ' ;
                        l_str := l_str||' ( ';
                        l_str := l_str||' select row_number() over(order by '||p_column_name||') rw,'||p_column_name||'  from '||p_table_name;
                        l_str := l_str||' ) where rw = '||i ;
                        execute immediate l_str into l_column_value;
                        l_ret_str := l_column_value||','||l_column_value;
              end loop;
                   return 'select l_ret_str from dual';
    end;
    show err;
    SQL> @D:\raghu\oracle_docs\rows_to_columns.sql
    Warning: Function created with compilation errors.
    Errors for FUNCTION R_RETURN_COL:
    LINE/COL ERROR
    34/5     PL/SQL: Statement ignored
    34/23    PLS-00382: expression is of wrong typeRegards
    Raghu.

    I've modified my code as below
    Create or replace Function r_return_col
                         p_table_name          in          varchar2,
                         p_column_name          in          varchar2
                        )return varchar2
    is
              l_count                    number;
              l_clob                    clob;
              l_count_str               varchar2(32000);
              l_column_value          varchar2(32000);
              l_str                    varchar2(32000);--clob;
              l_ret_str               clob;
    begin
              l_count_str := ' select count('||p_column_name||') ' ;
              l_count_str := l_count_str||' from      '||p_table_name ;
              execute immediate l_count_str into l_count;
              dbms_output.put_line('Count is : '||l_count);
              for i in 1..l_count
              loop
                        l_str := 'select '||p_column_name||' from ' ;
                        l_str := l_str||' ( ';
                        l_str := l_str||' select row_number() over(order by '||p_column_name||') rw,'||p_column_name||'  from '||p_table_name;
                        l_str := l_str||' ) where rw = '||i ;
                        execute immediate l_str into l_column_value;
                        l_column_value := q'[']'||l_column_value||q'[']' ;
                        l_ret_str := l_ret_str||','||l_column_value;
              end loop;
                   return 'select '||ltrim(l_ret_str,',')||' from dual';
    end;
    show err;But now instead of returning the query I'd like to return the rows retrived after executing the query.How could I accomplish this??Can this be done using refcursor?Please help me.
    Regards
    Raghu

  • Error while creating function filter for SAP R3 destination

    Hi All,
    I am using SAP Portal Add-in 1.0 Patch 3 for Visual Studio 2003 with SAP Portal Runtime 1.0 Patch 3 for Microsoft .NET and SAPDotNetConnector2.0.
    Portal server is successfully added to my server explorer.SAP R3 system  destination is also added succesfully ,but when i create a function filter  
    for my destination function to add my RFC enabled function module it  gives me an error message "Missing R3NAME=... or ASHOST=... in connect_param in RfcOpenEx",but when i log into the R3 system from portal system ,I am able to log successfully.
    please see the attached jpg file for your reference.
    what should I do,plz help me.

    3 things:
    1. When you say "but when i log into the R3 system from portal system ,I am able to log successfully"... what do you mean exactly? Do you mean you tried to do a "test connection"?
    2. Make sure the portal user mapping is set to "user & password" and not SSO. In order to work with the destination in design time you need to have it set to User and Password. Later, for run-time connection you can change it to SSO.
    3. If number 2 failed, can you please click on the destination in the server explorer and look at the property grid for the connection string property? make sure it's correct (you can post it here if you don't know).
    Regards,
    Ofer

Maybe you are looking for