How to create an apex collection to store and loop through the values

I couldn't find any simple example to do this
Apex 4.2
I need to create an apex collection. I have a query that returns multiple roles for a user. I need to check to see if one of my item values is within the collection but am not sure how to do so. So far I have:
begin
APEX_COLLECTION.CREATE_COLLECTION (
p_collection_name => 'ALL_ROLES');
select count(granted_role) into count from dba_role_privs where upper(grantee) = upper(:APP_USER);
end;
How would I store the query results in the collection?

Trying to understand your code and a better suggestion:
declare
is_viewable boolean;
v_count number;
l_query varchar2(2000);
i_counter number(10) :=1;
begin
--l_query := 'select granted_role from dba_role_privs where upper(grantee) = upper(:APP_USER)';
--why do you need a collection, this is a simple select count(1) question
APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY (
p_collection_name => 'ALL_ROLES',
p_query => l_query,
p_generate_md5 => 'YES');
-- You create a collection, but where are you using it?
-- select count(granted_role) into count from dba_role_privs where upper(grantee) = upper(:APP_USER);
-- discard the above code
-- If you want to see  how many elements in a collection
-- determine # of elements in a collection
http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_collection.htm#CJAFFEAH
v_count := APEX_COLLECTION.COLLECTION_MEMBER_COUNT ('ALL_ROLES');
IF :P32_SUBMISSION_DATE IS NOT NULL THEN
  begin
  select count(granted_role) into v_count
     from dba_role_privs
  where upper(grantee) = upper(:APP_USER) and
    granted_role in ('SURVEY_SUID','SURVEY_JOB_SUID');
  exception
  when no_rows_found then
    v_count := 0;
  end;
  if v_count > 0 then
    is_viewable := true;
  else
    is_viewable := false;
  endif;
else
  is_viewable := false;
endif;
return is_viewable;
end;Thank you,
Tony Miller
Ruckersville, VA

Similar Messages

  • How to create a note on my computer and sync to the notes file on my iphone 4S?

    How do I create a note on my computer and then have that note show up in the notes list on my iphone?

    Basically you duplicate the current iPhoto library and delete everything except the book and its photos and archive that smaller library
    LN

  • How to create a table using blob datatype and then selecting the output???

    I have created table
    create table imgloader(img_l blob);
    now i want to insert the image i.e. '/u1/archie.jpg' to this table
    what steps to be follwed to insert the image into table..and how to see the stored image??

    Is GOOGLE & SEARCH broken for you?
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:392618837633

  • My laptop was stolen this morning how I can reporte that we apple store  and every time the use my laptop I know

    How to find my laptop 13"

    Report it to the police.
    What To Do If Your iDevice or Computer Is Lost Or Stolen
    If your Mac, iPhone, iPod, iPod Touch, or iPad is lost or stolen what do you do? There are things you should do in advance - before you lose it or it's stolen - and some things to do after the fact. Here are some suggestions:
    Reporting a lost or stolen Apple product
    Find my lost iPod Touch
    AT&T, Sprint, and Verizon can block stolen phones/tablets
    What-To-Do-When-Iphone-Is-Stolen
    Lost or Stolen iPhone? Here’s What to do
    6 Ways to Track and Recover Your Lost/Stolen iPhone
    Find My iPhone
    It pays to be proactive by following the advice on using Find My Phone before you lose your device:
    Find My iPhone
    Setup your iDevice on MobileMe
    OS X Lion- About Find My Mac
    How To Set Up Free Find Your iPhone (Even on Unsupported Devices)
    Third-party solutions for computers:
    VUWER 1.5.4
    Sneaky ******* 0.2.0
    Undercover 4.7
    LoJack for Laptops Premium Mac
    STEM 2.1
    MacPhoneHome 3.5

  • How to create an APEX 4.1 session?

    Hi,
    I've successfully used the mechanism described by [this thread|https://forums.oracle.com/forums/thread.jspa?threadID=663227] to create an APEX session in release 3.1.
    We've recently been forced to move onto Oracle 11g and APEX 4.1. The session routine no longer appears to work:
    - after setting up the session a call to the create_collection_from_query results in an error stating 'Invalid parsing schema for current workspace Id';
    - the apex_application.g_instance value is changing - post_login changes the value and show loses the value;
    Any ideas?

    Hi Scott
    Bad news. I read several time this thread, but I have not found error in my program ... .
    And I can not see what are really doing APIs of APEX.
    Time is going - so we have make a decision now.
    Probably (as I have no more answers at this forum) - we can not use APEX (as nobody using APEX sessions as I asked),
    as we can not manage its sessions programmatically (too risky).
    Thanks for your answer.
    Andres

  • How do I put a collection in a readonly report on the fly

    How do I put a collection in a readonly report on the fly??
    Thanks, examples if you can please.

    Doug,
    You can simply create a report region and use that to display the records in the collection:
    SELECT
      c001,
      c002,
      c003,
    FROM
      apex_collections
    WHERE
      collection_name = 'YOUR_COLLECTION_NAME'Thanks,
    – Scott –
    http://spendolini.blogspot.com/
    http://sumnertech.com/

  • How you create a group to send many txt msg at the same time?

    How you create a group to send many txt msg at the same time?

    The iPhone does not support groups for messaging. There are apps in the app store which purport to be able to do this.

  • How do I connect my new (purchased last week) macbook air to my samsung smart tv? I purchased the adapter at the apple store and connected to the TV via HDMI cable.  The TV says "no signal.  I do not see TV as an option in the display tab of system prefer

    how do I connect my new (purchased last week) macbook air to my samsung smart tv? I purchased the adapter at the apple store and connected to the TV via HDMI cable.  The TV says "no signal.  I do not see TV as an option in the display tab of system preferences.  what else do I need to do?

    First, make sure your TV is tuned to display the correct input signal. Most TVs have several inputs (multiple HDMIs, cable connections, RCA etc) so double-check that you're using the correct one - HDMI1, HDMI2 or whatever is written next to the port.
    I assume that you have a mini-Displayport to HDMI adaptor? If you open displays preferences, first tick the box that says "show display preferences in menu bar" then locate the menu and click Detect Displays. See if that helps.
    Matt

  • How to create an inspection lot for each line item of the Purchase order?

    Hi,
    How to create an inspection lot for each line item of the Purchase order ?
    In detail if possible.

    Hi
       please check this
    [thread|Create Inspection Lot;

  • How to create a table with datatype blob and insert a pdf file (ravi)

    how to create a table with datatype blob and insert a pdf file,
    give me the explain asap
    1.create the table?
    2.insert the pdffiles into tables?
    3.how to view the files?
    Thanks & Regards
    ravikumar.k
    Edited by: 895044 on Dec 5, 2011 2:55 AM

    895044 wrote:
    how to create a table with datatype blob and insert a pdf file,
    give me the explain asapPerhaps you should read...
    {message:id=9360002}
    especially point 2.
    We're not just sitting here waiting to answer your question as quickly as possible for you.

  • I had a problem with my 4s battery so i took it to an apple store and they replaced the phone. However they had me backup my photos in icloud because i was goingto lose them otherwise. So now my question is how do i get my photos back?

    I had a problem with my 4s battery so i took it to an apple store and they replaced the phone. However they had me backup my photos in icloud because i was goingto lose them otherwise. So now my question is how do i get my photos back?

    This should help:
    http://support.apple.com/kb/HT4486
    Regards.

  • How to create new Sheet in Excel file and write into it

    Hi to all, my requirement is this:
    I have an excel file (.xls) with multiple sheets (three sheets for precision: sheet1, sheet2 and sheet3).
    I must create in the same excel file new sheet, say sheet4, read data from sheet1, sheet2 and sheet3 and write them into sheet4.
    How to realize this in SSIS?
    Expecially, Is it possible to realize this in SSIS?
    thanks in advance.

    You need to create the sheet with the required metadata. There's no use creating blank sheet.
    Also metadata has to be fixed using a sample sheet prior to start of the package for setting the mapping. You may create a excel template for this purpose to just set the mapping at design time.
    At runtime pass actual excel sheet path for ExcelFilePath property of the source to point to correct file.
    Also the create table statement should include the same metadata info (columns)
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
    Hi, well it works fine! I have used a sample sheet prior to start of the package for setting the mapping.
    Next at run time  pass actual excel sheet path for ExcelFilePath property of the source to point to correct file.
    However I have set also ValidateExternalMetadata properties of the Excel Destination to false and DelayValidation properties of the package to true.
    Now my problem is the following:
    I stored the three sheets name (sheet1, sheet2, sheet3) in the Object type user variable through a script task and the foreach loop loops through the three sheets stored in the variable.
    Now, I want that at each iteration the CURRENT VALUE of the Object type user variable is mapped into another user variable wich in turn is given in input to the Excel Source.
    Resuming:
    -) I have to copy the content of three sheets (sheet1, sheet2, sheet3) of excel file into another new sheet,   sheet4.
    -) I stored the three sheets name (sheet1, sheet2, sheet3) in the Object type user variable.
    -) With a  foreach loop container I loops the three sheets stored in the Object type user variable.
    -) Within a foreach loop container I have a Data Flow Task that transfer data from source sheet (sheet1, sheet2, sheet3) into destination sheet, sheet4.
    -) PROBLEM: how to change dinamically at each iteration of the foreach loop the name of source sheet? In the destination excel Task the sheet is always the same at each iteration, sheet4. But in the source excel task the name of sheet musts change at each
    iteration. In particular at the first iteration the name of the source sheet must be "sheet1$", at the second iteration "sheet2$", in the last iteration "sheet3$".
    How to change sheet name dinamically at each iteration?
    thanks.

  • How to create dynamic context based on a structure defined in the program?

    Hi Experts,
             I need to create a dynamic context based on a structure wa_struc which i have define programatically.
    When I pass wa_struc to structure_name parameter of create_nodeinfo_from_struc, i get a runtime error:
    "Parameter STRUCTURE_NAME contains an invalid value wa_struc."
    How to create dynamic context based on a structure defined in the program?
    I have written the code like this:
    TYPES: BEGIN OF t_type,
                v_carrid TYPE sflight-carrid,
                v_connid TYPE sflight-connid,
             END OF t_type.
      Data:  i_struc type table of t_type,
             wa_struc type t_type.
      data: dyn_node   type ref to if_wd_context_node.
      data: rootnode_info   type ref to if_wd_context_node_info.
      rootnode_info = wd_context->get_node_info( ).
      clear i_struc. refresh i_struc.
      select carrid connid into corresponding fields of table i_struc from sflight where carrid = 'AA'.
    cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
      parent_info = rootnode_info
      node_name = 'dynflight'
      structure_name = 'wa_struc'
      is_multiple = abap_true ).
    dyn_node = wd_context->get_child_node( name = 'dynflight' ).
    dyn_node->bind_table( i_struc ).
    Thanks
    Gopal
    Message was edited by: gopalkrishna baliga

    Hi Michelle,
              First of all Special thanks for your informative answers to my other forum questions. I really appreciate your help.
    Coming back to this question I am still waiting for an answer. Please help. Note that my structure is not in a dictionary.
    I am trying to create a new node. That is
    CONTEXT
    - DYNFLIGHT
    CARRID
    CONNID
    As you see above I am trying to create 'DYNFLIGHT' along with the 2 attributes which are inside this node. The structure of the node that is, no.of attributes may vary based on some condition. Thats why I am trying to create a node dynamically.
    Also I cannot define the structure in the ABAP dictionary because it changes based on condition
    I have updated my code like the following and I am getting error:
    TYPES: BEGIN OF t_type,
    CARRID TYPE sflight-carrid,
    CONNID TYPE sflight-connid,
    END OF t_type.
    Data: i_struc type table of t_type,
    dyn_node type ref to if_wd_context_node,
    rootnode_info type ref to if_wd_context_node_info,
    i_node_att type wdr_context_attr_info_map,
    wa_node_att type line of wdr_context_attr_info_map.
    wa_node_att-name = 'CARRID'.
    wa_node_att-TYPE_NAME = 'SFLIGHT-CARRID'.
    insert wa_node_att into table i_node_att.
    wa_node_att-name = 'CONNID'.
    wa_node_att-TYPE_NAME = 'SFLIGHT-CONNID'.
    insert wa_node_att into table i_node_att.
    clear i_struc. refresh i_struc.
    select carrid connid into corresponding fields of table i_struc from sflight where carrid = 'AA'.
    rootnode_info = wd_context->get_node_info( ).
    rootnode_info->add_new_child_node( name = 'DYNFLIGHT'
    attributes = i_node_att
    is_multiple = abap_true ).
    dyn_node = wd_context->get_child_node( 'DYNFLIGHT' ).
    dyn_node->bind_table( i_struc ).
    l_ref_interfacecontroller->set_data( dyn_node ).
    But now I am getting the following error :
    The following error text was processed in the system PET : Line types of an internal table and a work area not compatible.
    The error occurred on the application server FMSAP995_PET_02 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Method: IF_WD_CONTEXT_NODE~GET_STATIC_ATTRIBUTES_TABLE of program CL_WDR_CONTEXT_NODE_VAL=======CP
    Method: GET_REF_TO_TABLE of program CL_SALV_WD_DATA_TABLE=========CP
    Method: EXECUTE of program CL_SALV_WD_SERVICE_MANAGER====CP
    Method: APPLY_SERVICES of program CL_SALV_BS_RESULT_DATA_TABLE==CP
    Method: REFRESH of program CL_SALV_BS_RESULT_DATA_TABLE==CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE_DATA of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~UPDATE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_VIEW~MODIFY of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMPONENT~VIEW_MODIFY of program CL_SALV_WD_A_COMPONENT========CP
    -Gopal
    Message was edited by: gopalkrishna baliga

  • How to create a transport request with query and only with its structure.

    HI guru,
                how to create a transport request with query and only with its structure.transport request should not  include any other query items like ( variables, conditions...etc)
    thanks in advance.
    venkata

    Hi,
    Goto RSA1 and then Transport Connection -> In SAP Transports select Object Types-> Query Elements -> Then select Query->Give Technical name of the query and then select for transfer. In the right side you can choose the components which you wanted to transport.
    Regards,
    anil

  • How to create a hierarchy in Regional Structure and how to use it

    Hi,
    Please guide me how to create a Political Region Structure hierarchy and how to use it.
    Thanks and Regards

    Hi,
    Thanks for reply please.
    I request you to please copy paste all the possible information here. It will be a great help.
    I hope you understand why we can not provide our id on this forum.
    Please guide.
    Thanks and Regards
    Edited by: MP Vashishth on May 18, 2009 7:14 AM

Maybe you are looking for

  • Payment Proposal Error in Automatic Payment Program

    While I am running the Automatic Payment Program Run after passing on the  Parameters, I have created the Payment Proposal. When I am trying the edit the payment prosal  to block payment of some of the invoice line items, system is throwling a red si

  • How to set custom master page for social/sites.aspx in sharepoint 2013

    How to set custom master page for social/sites.aspx in sharepoint 2013.? File path is C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\FEATURES\SocialDataStore\SocialDataStoreList\sites.aspx Thanks in advance

  • View employee document in portal (MSS)

    We have employee contract document scan and stored in SAP which we would view through SAP portal in MSS through Acrobat reader. Have SAP any scenario for this? Please handle this issue as urgent since our customer would implement this in production s

  • File to IDOC combining the values

    Hello Guru's, In my IDOC structure target I will be having Target Structure Header Record Item Record, Value records. Source Structure Header Record Item Record, Value records1 Value records2 Value records3 Value records4 I want to map to all this re

  • Joint Venture Accounting Posting Period

    What is the T-Code for opening Joint Venture Accounting Posting Period ? The system prompts a warning when posting an operated or non-operated cash calls I am new to SDN ,can anyone kindly refer to me the link where i can ask questions related to Joi