Passing field name into Cursor

I would like to pass the name of a field for the WHERE clause, into a cursor. In my application I need to change the field name for the where clause. I get an "Invalid Number" error when I try the following:
cursor l_sel2Cur (c_group varchar2)
is
select email from test_grp_tbl6 where c_group = 1;
select column_name
into l_colName
from listserv_grp_lk
where lg_id = v_listserv_grp;
open l_sel2Cur(l_colName);
I hope this is enough explanation. I have seen examples where the value for the where clause is passed in, but not where the field name itself is passed in. Is this possible?
Thanks in advance,
John

See the following example:
SQL> create or replace procedure print_enames(in_col in varchar, in_val in varchar2) is
  2  c sys_refcursor;
  3  v_name emp.ename%type;
  4  begin
  5    open c for 'select ename from emp where '||in_col||'='''||in_val||'''';
  6    loop
  7     fetch c into v_name;
  8     exit when c%notfound;
  9     dbms_output.put_line('ename='||v_name);
10    end loop;
11  end;
12  /
Procedure created.
SQL> select * from emp;
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
14 rows selected.
SQL> set serverout on
SQL> exec print_enames('mgr','7839')
ename=JONES
ename=BLAKE
ename=CLARK
PL/SQL procedure successfully completed.
SQL> exec print_enames('sal','1250')
ename=WARD
ename=MARTIN
PL/SQL procedure successfully completed.
SQL> exec print_enames('deptno','30')
ename=ALLEN
ename=WARD
ename=MARTIN
ename=BLAKE
ename=TURNER
ename=JAMES
PL/SQL procedure successfully completed.

Similar Messages

  • Passing field name in function as parameter

    Hi
    I want to pass the fields name as in parameter in function and then return the value of that field.
    thanks
    pramod patel

    CREATE OR REPLACE FUNCTION demo
    (i_in IN number)
    RETURN NUMBER
    IS
    BEGIN
    RETURN i_in*2;
    END demo;
    Hope that helps ... also, remember you can't use precision and scale (in the case of NUMBER), or length (in the case of VARCHAR2) for the parameters but you can ANCHOR (%TYPE or %ROWTYPE)
    Good luck!

  • Passing function name into another function?

    Hi
    I have a movieclip prototype thats scales and moves any
    movieclips depending
    on the parameters passed in. I want to be able to pass in a
    function name
    that is executed when the main function has finished. The
    problem is the
    line of code that calls the main function executes the
    function name that I
    m trying to pass in as a parameter. Is there something I m
    missing?
    see my code below:
    "mcMainAnimation.moveFadeTransform(0, mcMainAnimation._y,
    -100,
    mcMainAnimation._xscale, -30, 50,moveToX());"
    MovieClip.prototype.moveFadeTransform = function(t, oldY,
    diffY, oldScale,
    newScale, tTime, funcToCall) {
    this.onEnterFrame = function() {
    t++;
    if (t<=tTime) {
    this._y = easeIn(t, oldY, diffY, tTime);
    this._xscale = easeIn(t, oldScale, newScale, tTime);
    this._yscale = easeIn(t, oldScale, newScale, tTime);
    } else {
    t = 0;
    funcToCall;
    this.onEnterFrame = null;
    moveToX = function () {
    trace("called");
    Thank in advance
    Shaun

    Hi!
    Try to modify code to:
    mcMainAnimation.moveFadeTransform(0, mcMainAnimation._y,
    -100,
    mcMainAnimation._xscale, -30, 50,moveToX);"
    ... so don't use () at end of function. That should do the
    trick.
    Also, you need to add the () to funcToCall, so that instead
    of:
    t = 0;
    funcToCall;
    this.onEnterFrame = null;
    you should have
    t = 0;
    funcToCall();
    this.onEnterFrame = null;
    /Jensen/
    "forums.macromedia.com" <[email protected]>
    wrote in message
    news:e6m428$qa0$[email protected]..
    > Hi
    >
    > I have a movieclip prototype thats scales and moves any
    movieclips
    > depending on the parameters passed in. I want to be able
    to pass in a
    > function name that is executed when the main function
    has finished. The
    > problem is the line of code that calls the main function
    executes the
    > function name that I m trying to pass in as a parameter.
    Is there
    > something I m missing?
    >
    > see my code below:
    >
    > "mcMainAnimation.moveFadeTransform(0,
    mcMainAnimation._y, -100,
    > mcMainAnimation._xscale, -30, 50,moveToX());"
    >
    > MovieClip.prototype.moveFadeTransform = function(t,
    oldY, diffY, oldScale,
    > newScale, tTime, funcToCall) {
    > this.onEnterFrame = function() {
    > t++;
    > if (t<=tTime) {
    > this._y = easeIn(t, oldY, diffY, tTime);
    > this._xscale = easeIn(t, oldScale, newScale, tTime);
    > this._yscale = easeIn(t, oldScale, newScale, tTime);
    > } else {
    > t = 0;
    > funcToCall;
    > this.onEnterFrame = null;
    > }
    > };
    > };
    >
    > moveToX = function () {
    > trace("called");
    > }
    >
    >
    > Thank in advance
    >
    > Shaun
    >

  • Field names Missing in the (Excel) Mail attachment

    Hi ,
    I am trying to send my ALV Grid Output as Excel Email attachment using the below code
    The problem is that the field names are missing in the receivers Mail.
    i.e
    *Name*   *Emp Code*   * Branch*         "this is missing
    abc         123                 ukp
    I searched many threads but unable to find the solution for this.
    Kindly suggest me regarding this issue.
    loop at p_eadd.
        if p_eadd-low <> space.
          clear reclist.
          reclist-rec_type = 'U'.  "Internet-adress
          reclist-receiver = p_eadd-low.
          reclist-express = 'X'.
          append reclist.
        endif.
      endloop.
    * endif.
    * Send the document
      call function 'SO_NEW_DOCUMENT_SEND_API1'
         exporting
              document_type              = 'RAW'
              document_data              = doc_chng
    *         PUT_IN_OUTBOX              = 'X'
         tables
              object_content             = objcont
              receivers                  = reclist
         exceptions
              too_many_receivers         = 1
              document_not_sent          = 2
              operation_no_authorization = 4
              others                     = 99.
      ld_aplstat = '4'.
      case sy-subrc.
        when 0.
          loop at reclist.
            if reclist-receiver = space.
              name = reclist-rec_id.
            else.
              name = reclist-receiver.
            endif.
            if reclist-retrn_code = 0.
              write: / name, ': succesfully sent'.
            else.
              write: / name, ': error occured'.
            endif.
          endloop.
          ld_aplstat = '0'.
        when 1.
          write: / 'Too many receivers specified !'.
        when 2.
          write: / 'No receiver got the document !'.
        when 4.
          write: / 'Missing send authority !'.
        when others.
          write: / 'Unexpected error occured !'.
      endcase.
    *.Tell workflow to go on
      clear ls_scma_event.
      ls_scma_event-wf_event = cs_wf_events-finished.
      ls_scma_event-wf_witem = wf_witem.
      ls_scma_event-wf_okey  = wf_okey.
      call function 'KPEP_MONI_CLOSE_RECORD'
        exporting
          ls_key        = gs_key
          ls_scma_event = ls_scma_event
        changing
          ld_aplstat    = ld_aplstat
        exceptions
          no_id_given   = 1
          others        = 2.
    call function 'SAP_CONVERT_TO_XLS_FORMAT'
          exporting
           i_field_seperator          = ' '
           i_line_header              = 'X'
            i_filename                 = p_file
    *   I_APPL_KEEP                = ' '
          tables
            i_tab_sap_data             = it_final
    * CHANGING
    *   I_TAB_CONVERTED_DATA       =
         exceptions
           conversion_failed          = 1
    *   OTHERS                     = 2
        if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
    Thanks in Advance,
    Mr. Ben

    Hi Ben,
    Follow the code below....
    Your internal table it_final will have the attachment data. After you got the attachment data do the following
    gc_ret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
    lt_attachment        TYPE TABLE OF  solisti1 ,
    gt_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0 WITH HEADER LINE,
      CLEAR:gs_attach.                      <this will have your attachment, declare a structure which contains fields of your  excel sheet>
    <before this you have to copy all the fields from your final internal table which should be attached to email to gs_attach>
    For attaching field names
        CONCATENATE gc_ret gs_attach INTO gs_attach.
        gs_attach = gs_attach+1.
        APPEND gs_attach TO gt_attach.
    CLEAR:lt_attachment.
          lt_attachment[] = gt_attach[].
    SORT  lt_attachment .
          DELETE ADJACENT DUPLICATES FROM lt_attachment COMPARING ALL FIELDS.
          CLEAR gs_attach.
          CONCATENATE <field names >
          INTO gs_attach SEPARATED BY gc_tab.
          INSERT gs_attach INTO lt_attachment INDEX 1.
    <field addition ends>
    call function 'SO_NEW_DOCUMENT_SEND_API1'
         exporting
              document_type              = 'RAW'
              document_data              = doc_chng
            PUT_IN_OUTBOX              = 'X'
         tables
              object_content             = objcont
              receivers                  = reclist
            contents_bin               = lt_attachment
         exceptions
              too_many_receivers         = 1
              document_not_sent          = 2
              operation_no_authorization = 4
        if sy-subrc  0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
    Regards,
    Aravind.

  • Not able to download the field names in GUI_DOWNLOAD(very urgent)

    Hi All,
    I am downloading the file contents to the presentation server.i am able to get the file contents proeprly but not able to download the field names into text file.
    Can anybody please help me in this issue..? its very urgent. Valuable answers will be rewarded.
    CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = w_filename
          filetype                = 'DAT'
         write_field_seperator   = c_x
          col_select              = c_x
          COL_SELECT_MASK         = t_mask
        TABLES
          data_tab                = t_tab
          fieldnames              = t_colnames
        EXCEPTIONS
    Thanks & Regards,
    Satish.

    Hi,
    I have tried in both ways its not working.
    while a ran the program it is going to the dump.
    I am working in mySAP ECC6.0
    Can pl you suggest other way..
    Thanks & Regards,
    Satish.

  • How to display header fields names in the next page in report6i

    how to display repeat header field names into the next page in report6i urgent plz......
    When i am runing report in 1st page only the header information is displaying in 2 page the header info is not displaying only records are displaying.So i want to display the header info in 2nd page also.
    Plz help out.

    Hello,
    Go to the report layout model and select those items/objects which are not getting display on next page and open the property pallet by pressing F4 key and set the property Print Object On to All Pages then it will display on all pages.
    -Ammad

  • Navigate through block and keep all field names available to a report

    Dear OTN Members,
    when i press a button, it has to go to a BLOCK what i mentioned and it has to collect all field names those having Visual attribute name what i mentioned and this list i want to populate into a new block where i press button? is it possible in any way.
    thanks in advance

    Thank you Mr Natesh,
    but for me it is not possible to send the form, the form consists of lot of blocks and again i have to send you SQL scripts to generate respective blocks etc. if you can think of it with example block A with 20 fields, and block B with a field multi record block, here i want to populate all A.20 field names into B. again the fields in A are differentiated with Visual ttributes 2 types. here i want to restrict the list to a perticular VA.
    hope you will help me in this.

  • How to pass file name as parameter into url: or fo:external-graphic src

    Hello gurus,
    In my rtf I want to dynamically get the name of the image file and display the image in the report. If use hard coded image file name it works but if I try to get the name into a variable and pass that variable it is not working.
    Basically my client is having different logos for each operating unit. in the OA_MEDIA directory there are separate logos for each OU. during run time based on OU name we need to display the corresponding image. If I can get this entire path($OA_MEDIA/logo.jpg') in XML field<?CF_OU_LOGO?> then I'm able to print the logo using url:{CF_OU_LOGO}
    But I'm using seeded data source and I cant modify the data source, I need to handle this in RTF only. I could able to get the file name into a variable but not sure how to pass to url.
    could some one help me on this. I tried the following options
    <fo:external-graphic src="url($ln)" />
    url:{$ln} in web etc...
    here 'ln' is the variable which holds '$OA_MEDIA/logo.jpg'. ln is defined as <xsl:variable name="ln" select=".//CF_OPERATING_UNIT" />
    later I set the values as <?xdoxslt:set_variable($_XDOCTX, 'ln',translate( concat('${OA_MEDIA}/','Logo',.//CF_OPERATING_UNIT,'.jpg'),' ',''))?><?xdoxslt:get_variable($_XDOCTX, 'ln')?>
    thanks,
    Vijay

    Vijay
    What version of EBS is the customer running? I read somewhere that in R12 all of the concurrent parameters are passed to the XMLP template. I have not tried this but if true. You could create a conc program parameter that would hold the location of the image. You could either have the user pick the image or maybe derive it from the other parameter choices.
    Lets assume the token name is DLOGO you can reference that in your template.
    <?param:DLOGO?>
    this needs to be at the top of the template. Then where you need to embed the image just reference the value using
    $DLOGO
    You can embed this in the external graphic field
    As I mentioned I have not tested it yet, hopefully its there, if not there are ways around it. Try it first.
    Tim

  • Passing field value from appoinment into task

    Hi,
    I need to pass the field values from appointment into the task. I was able to pass values from one record type to another but in this case as both appointment and task belong to the same record type namely activity and they are having the same foreign key namely ActivityId.
    So any one please tell me , is it possible to pass values from appointment in to the task or not ?
    If so how?
    Thanks,
    Kirubahar.
    Edited by: Kiruba on Mar 4, 2011 6:45 AM

    Write a workflow and select the field you want to copy the value into in the Field Name and the value you want to copy in value field, you don't need to use joinfieldValue at all.
    cheers
    Alex

  • Passing form field name to the subject line of the task assign email

    Hello Everyone,
    I am trying to create a process that need to pass one of the field data from a form to the task email assign but could not make it work right as expected. I think I miss something but could not figure it out myself. If any one has done this before, please share your knowledge.
    Thanks in advance,
    Han Dao

    Hi Jasmin,
    I thought it simple thing to do by passing the xPath to the subject line but for some reasons, it does not work instead it show the whole xpath on the subject line. Here is my xpath:
    {$/process_data/FormData/object/data/xdp/datasets/data/FSFIELDS_/Form1936/EmpInfoSub/UserM gr$}
    where Form1936 is the pageName, EmpInfoSub is sub-form, and UserMgr is field name on the form.
    Thanks,
    Han Dao

  • Script to insert file name into keywords field of same file

    Hello,
    search a solution, a Script or another, which writes the file name into keywords field of same file (Metadata: Description/Keywords) in "photoshop", "bridge" or better in "Lightroom" .
    I found this topic from Mike Hale http://www.ps-scripts.com/bb/viewtopic.php?t=1330
    It's possible this script to change this in such a way that it does this:
    "script to insert file name into keywords field of same file"
    Thanks and best greetings
    Wolfgang

    This works in CS2:-
    #target bridge
       if( BridgeTalk.appName == "bridge" ) {
    nameDescription = MenuElement.create("command", "AddName to Description", "at the beginning of Thumbnail");
    nameDescription .onSelect = function () {
         nameToDescription();
    function nameToDescription(){
    var items = app.document.selections;
          for (var i = 0; i < items.length; ++i) {
             var item = items[i];   
    var m = item.synchronousMetadata;
    filenameToDesc(m, item.name.slice(0,-4));
    function filenameToDesc(metadata, Description) {
    var strTmpl = "name2Desc";
    var strUser = Folder.userData.absoluteURI;
    var filTmpl = new File(strUser + "/Adobe/XMP/Metadata Templates/" + strTmpl + ".xmp");
    var fResult = false;
    try
    { if (filTmpl.exists)
    filTmpl.remove();
    fResult = filTmpl.open("w");
    if (fResult) {
    filTmpl.writeln("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"3.1.2-113\">");
    filTmpl.writeln(" <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">");
    filTmpl.writeln(" <rdf:Description rdf:about=\"\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">");
    filTmpl.writeln("<dc:description>");
    filTmpl.writeln("<rdf:Alt>");
    filTmpl.writeln("<rdf:li xml:lang=\"x-default\">"+Description+"</rdf:li>");
    filTmpl.writeln("</rdf:Alt>");
    filTmpl.writeln("</dc:description>");
    filTmpl.writeln(" </rdf:Description>");
    filTmpl.writeln(" </rdf:RDF>");
    filTmpl.writeln("</x:xmpmeta>");
    fResult = filTmpl.close();
    metadata.applyMetadataTemplate(strTmpl, "replace");
    filTmpl.remove();
    catch(e)
    { fResult = false; }
    return fResult;

  • File name into text field

    Is there a way to display the forms file name, into a text field?
    Example: The form's file name is "MyForm.1.01.pdf"
    I would like to display "MyForm.1.01" in a text field on the form.
    If my form is saved and goes up a revision to say "MyForm.1.02"
    "MyForm.1.02" is then displayed in the text field.
    I was thinking, this could be on the pre open event, so that when the form is saved, it would display the new revision when the form is next opened?
    Thanks in advance.

    Hi,
    The following will get the file name:
    this.rawValue = event.target.documentFileName;
    I would put this in the docReady event, as this event fires only once, when the form opens.
    There is a sample here: https://acrobat.com/#d=ZnxO-dlXXFDS0GvYcQk2NQ
    Hope that helps,
    Niall
    Assure Dynamics

  • Passing table name to a procedure and then need to open a cursor ..

    Hi All,
    I have been out of touch in plsql for sometime and need to do something like :
    passing table name to a procedure while calling(fp_table_old captures this value) and then need to open a cursor for this table in 'for i in (select * from fp_table_old )', one of the ways I tried is : for i in (execute immediate Lv_sql_query ) but its not working for me, please find the code below for reference, I know I am sounding stupid but I have been very out of touch, please help.
    code :
    create procedure p_table_compare(fp_table_old in varchar2, fp_table_new in varchar2)
    as
    Lv_sql_query varchar2(2000);
    begin
         Lv_sql_query := 'select * from '||fp_table_old;
         for i in (Lv_sql_query)
         loop
              dbms_output.put_line(i.employee_id);
         end loop;
    end;
    Regards
    Rahul

    if I am doing something like this : for i in (execute immediate Lv_sql_query)
    I am getting an error which is :
    PLS-00103: Encountered the symbol "IMMEDIATE" when expecting one of the following:
    . ( ) , * @ % & | = - + < / > at in is mod remainder not
    range rem => .. <an exponent (**)> <> or != or ~= >=
    My code:
    create or replace procedure p_table_compare(fp_table_old in varchar2, fp_table_new in varchar2)
    as
    Lv_sql_query varchar2(2000);
    begin
         --dbms_output.put_line('Hello World');
         Lv_sql_query := 'select * from '||fp_table_old;
         for i in (execute immediate Lv_sql_query)
         loop
              dbms_output.put_line(i.employee_id);
         end loop;
    end;
    Please help.
    Regards
    Rahul

  • Pass the name of a button into existing instance of a class from actionlist

    I want to pass a name of a button from actionlistener that is associated with that button into existing instance of a class. I need to do so because I have array of buttons and I have set the name of the buttons as coordinates. Is there a way to do that?

    My buttons are declared as JButton arrayOfButtons[][] = new JButton[numberOfRows][numberOfColumns];and I labeled them inside 2 for loops as:
    arrayOfButtons[row][column].setName(Integer.toString(row) + " " + Integer.toString(column));
    arrayOfButtons[row][column].setText("Some displayed text");I also added ActionListener
    arrayOfButtons[row][column].addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println(((JButton)e.getSource()).getName());
    });Now when I press a button it only displays the array coordinates on a command line. I want the class instance where I declared the buttons to get notified which button was clicked.

  • How to pass parameter into cursor for loop ?

    Hi Experts,
    I want to pass parameter l_bom_header_tbl(i).assembly_item_name into the for statement below How to achieve this?
    for j in 1 .. l_bom_components_tbl.COUNT LOOP
    Thanks

    Maybe i failed to describe in detail,so here i go:
    I have two for loops:
    for i in 1 .. l_bom_header_tbl.COUNT LOOP --1st For Loop
    V_bom_header_tbl.organization_code :='DSC';
    V_bom_header_tbl.assembly_item_name:= l_bom_header_tbl(i).assembly_item_name ;
    k:=1;
    I want to pass parameter l_bom_header_tbl(i).assembly_item_name into the for statement below: How to achieve this?
    for j in 1 .. l_bom_components_tbl.COUNT LOOP *2nd For Loop*
    v_bom_components_tbl(k).Assembly_Item_name := l_bom_header_tbl(i).assembly_item_name ;
    k := k + 1;
    end LOOP;
    end loop;
    end;
    I want to pass a paramter into second for loop in such a way that it accepts from the first for loop
    for j in 1 .. l_bom_components_tbl.COUNT LOOP -2nd loop
    Edited by: ILovePlSql on Mar 22, 2010 12:25 PM

Maybe you are looking for