Creating a scoring column based on threatened species lists

I'm doing scoring for sites based on the number of threatened species at each particular site and the threat status of each of the threatened species.
A threatened species could either have a threat status of nationally_critical, nationally_endangered, or nationally_vulnerable.
I am trying to write a query will display a column called TOTAL_SCORE where:
TOTAL_SCORE = (number of Nationally Critical species * 1) + (number of Nationally Endangered species * 0.5) + (number of Nationally Vulnerable species * 0.25)
I'm able to do this using excel formulas but I have no idea how to go about writing it in SQL. I would have attached the excel spreadsheet but attachments are not allowed in this forum I think?
See below for descriptions and DDL for the tables I have:
I have three tables: SITES, SPECIES_LIST, THREAT_STATUS_SCORES
The SITES table contains the site number and the species present at each particular site:
SITE_NUMBER    SPECIES_PRESENT
1            Olearia_pachyphylla, Oligosoma_whitakeri, Spio_aequalis
2            Ophioglossum_petiolatum, Ourisia_modesta, Pachycladon_exile
3            Dichelachne_micrantha, Galaxias_pullus
4            Spio_aequalis
5            Pachycladon_exile, Geranium_retrorsum
6            Olearia_pachyphylla, Ourisia_modesta, Oligosoma_judgei
7            Drosera_pygmaeaThe SPECIES_LIST table has a list of nationally critical, nationally endangered, and nationally vulnerable species:
NATIONALLY_CRITICAL               NATIONALLY_ENDANGERED      NATIONALLY_VULNERABLE
Olearia_pachyphylla               Oligosoma_judgei          Dichelachne_micrantha
Ophioglossum_petiolatum               Oligosoma_whitakeri          Drosera_pygmaea
Ourisia_modesta                       Spio_aequalis                  Geranium_retrorsum
Pachycladon_exile               Galaxias_pullus          Gratiola_concinnaThe THREAT_STATUS_SCORES table shows the score given to each threat status i.e. each nationally vulnerable species gets a score of 1,
each nationally endangered species gets a score of 0.5, and each nationally vulnerable gets a score of 0.25:
THREAT_STATUS           SCORE
NATIONALLY_CRITICAL     1
NATIONALLY_ENDANGERED     0.5
NATIONALLY_VULNERABLE     0.25DDL:
CREATE TABLE sites
(site_number varchar2(3) not null,
species_present varchar2(255),
CONSTRAINT site_number_pk PRIMARY KEY (site_number))
CREATE TABLE species_list
(nationally_critical varchar2(50),
nationally_endangered varchar2(50),
nationally_vulnerable varchar2(50))
CREATE TABLE threat_status_scores
(threat_status varchar2(50),
score number(4,2))
INSERT INTO sites VALUES (1, Olearia_pachyphylla, Oligosoma_whitakeri, Spio_aequalis);
INSERT INTO sites VALUES (2, Ophioglossum_petiolatum, Ourisia_modesta, Pachycladon_exile);
INSERT INTO sites VALUES (3, Dichelachne_micrantha, Galaxias_pullus);
INSERT INTO sites VALUES (4, Spio_aequalis);
INSERT INTO sites VALUES (5, Pachycladon_exile, Geranium_retrorsum);
INSERT INTO sites VALUES (6, Olearia_pachyphylla, Ourisia_modesta, Oligosoma_judgei);
INSERT INTO sites VALUES (7, Drosera_pygmaea);
INSERT INTO species_list VALUES (Olearia_pachyphylla, Oligosoma_judgei, Dichelachne_micrantha);
INSERT INTO species_list VALUES (Ophioglossum_petiolatum, Oligosoma_whitakeri, Drosera_pygmaea);
INSERT INTO species_list VALUES (Ourisia_modesta, Spio_aequalis, Geranium_retrorsum);
INSERT INTO species_list VALUES (Pachycladon_exile, Galaxias_pullus, Gratiola_concinna);
INSERT INTO threat_status_scores VALUES (NATIONALLY_CRITICAL, 1);
INSERT INTO threat_status_scores VALUES (NATIONALLY_ENDANGERED, 0.5);
INSERT INTO threat_status_scores VALUES (NATIONALLY_VULNERABLE, 0.25);Any help on how I could add a TOTAL_SCORE column to the SITES table would be much appreciated.
I'm using oracle 11g
Edited by: 993451 on Apr 1, 2013 4:01 PM
Edited by: 993451 on Apr 1, 2013 4:02 PM

If you're using Oracle 11.2, then the query for total_scores might be:
SELECT    pr.site_number
,       LISTAGG (s.species_name, ', ') WITHIN GROUP (ORDER BY s.species_name)
                           AS species_present
,       SUM (t.score)          AS total_score
FROM       species_present     sp
JOIN       species          s   ON   s.species_id    = sp.secies_id
JOIN       threat_status_scores     t   ON   t.threat_level  = s.threat_level
GROUP BY  pr.site_number
ORDER BY  pr.site_numberThanks for this. This works great, all I needed to do was change a minor spelling error and not include the pr prefix at the start of site_number. What is the pr prefix? Sorry, I'm a beginner at sql.
Here is the new full DDL based on your post:
CREATE TABLE  species
(   species_id          NUMBER (10)     PRIMARY KEY
,   species_name     VARCHAR2 (50)     UNIQUE
,   threat_level     VARCHAR2 (1)     CONSTRAINT  species_danger_chk
                          CHECK  (threat_level IN ( 'C'
                                  , 'E'
                                  , 'V'
INSERT INTO species (species_id, species_name,          threat_level)
             VALUES (1,          'Olearia pachyphylla', 'C');
INSERT INTO species (species_id, species_name,          threat_level)
             VALUES (2,          'Oligosoma judgei',     'E');
INSERT INTO species (species_id, species_name,          threat_level)
             VALUES (3,          'Aster alpinus',     NULL);
CREATE TABLE species_present
(   site_number          NUMBER (10)
,   species_id          NUMBER (10)
,   CONSTRAINT species_present_pk PRIMARY KEY ( site_number
                                            , species_id
INSERT INTO species_present (site_number, species_id) VALUES (1, 1);
INSERT INTO species_present (site_number, species_id) VALUES (1, 4);
INSERT INTO species_present (site_number, species_id) VALUES (1, 9);
INSERT INTO species_present (site_number, species_id) VALUES (4, 9);
CREATE TABLE threat_status_scores
(threat_level varchar2(50),
score number(4,2));
INSERT INTO threat_status_scores VALUES ('C', 1);
INSERT INTO threat_status_scores VALUES ('E', 0.5);
INSERT INTO threat_status_scores VALUES ('V', 0.25);
SELECT    site_number
,       LISTAGG (s.species_name, ', ') WITHIN GROUP (ORDER BY s.species_name)
                           AS species_present
,       SUM (t.score)          AS total_score
FROM       species_present     sp
JOIN       species          s   ON   s.species_id    = sp.species_id
JOIN       threat_status_scores     t   ON   t.threat_level  = s.threat_level
GROUP BY  site_number
ORDER BY  site_number;>
Why not have one table, but a separate row for each species, with the level of endangerment (if any) being an attribiute of the species? The distinction between >citically endagered species and vulnerable species is important, of course, but aren't the two kinds iof species fundamentally the same kind of entity? Don't they >have the same kinds of attributes? Aren't they used in the same way?
Here's one possible table design:
You're right. It is much better to have a single table for threatened species with three columns: species_id, species_name, and threat_level.
Since species_name is unique, and (I imagine) it is unlikely to change, then there might be an argument for not having a species_id, and making species_name the >primary key.Species_names are unique, however believe it or not they do sometimes change - at least in New Zealand! The botanists and ecologists put out updated species lists every few years and occassionally they will change species names for various reasons.
You're right; that would be a problem. The number of columns in a table is fixed, and while that number can be adjusted, it's not something that people do all the >time. Tables can have as many rows as necessary, and adding or removing rows is easy. Put each sighting on a separate row, something like this:
CREATE TABLE species_present
(   site_number          NUMBER (10)
,   species_id          NUMBER (10)
,   CONSTRAINT species_present_pk PRIMARY KEY ( site_number
                                            , species_id
INSERT INTO species_present (site_number, species_id) VALUES (1, 1);
INSERT INTO species_present (site_number, species_id) VALUES (1, 4);
INSERT INTO species_present (site_number, species_id) VALUES (1, 9);
INSERT INTO species_present (site_number, species_id) VALUES (4, 9);I think that this is a good idea. However, I'm not allowed to change sites table (I should have mentioned this earlier).
What happens is that contractors collect the threatened species information and they have already put the table in this format:
CREATE TABLE sites
(site_number varchar2(3) not null,
species_present varchar2(255),
CONSTRAINT site_number_pk PRIMARY KEY (site_number))
INSERT INTO sites VALUES (1, 'Olearia_pachyphylla, Oligosoma_whitakeri, Spio_aequalis');
INSERT INTO sites VALUES (2, 'Ophioglossum_petiolatum, Ourisia_modesta, Pachycladon_exile');
INSERT INTO sites VALUES (3, 'Dichelachne_micrantha, Galaxias_pullus');
INSERT INTO sites VALUES (4, 'Spio_aequalis');
INSERT INTO sites VALUES (5, 'Pachycladon_exile, Geranium_retrorsum');
INSERT INTO sites VALUES (6, 'Olearia_pachyphylla, Ourisia_modesta, Oligosoma_judgei');
INSERT INTO sites VALUES (7, 'Drosera_pygmaea');

Similar Messages

  • Create a derived column based on a value within the file name

    I am importing a CSV file which is easy enough, but I have an issue where I need to manufacture a couple of column values based on the filename of the input.  So this same process will import different types of records to the same table in sql server.
     I need to pull out the record code from the file name.  
    For instance, say I can use the same package to input two different CSV files.  One is named Input_M02_Data.csv and one named Input_B15_Data.csv.  I need to create a derrived column and store the record code there (i.e.:  M02 or B15) based
    on which file it came out of.  
    fyi-
    I also need to create a second column for Dept based off of the file name as well.  M02 is dept 45 and B15 is dept 99  which I also need to insert into this table when I import the data from the .csv file.  
    Any help is greatly appreciated!

    Hi Jason,
    According to your description, you want to add two derived columns based on the file name to also insert into table. One stores the value between two “_” within file name, another stores the department based on that column.
    If in this scenario, we can add a variable FileName that stores the filename, then add the two variables as derived columns like below in the Derived Column Transformation:
    Name:
    SUBSTRING(@[User::FileName],FINDSTRING(@[User::FileName],"_",1)+1,FINDSTRING(@[User::FileName],"_",2)-(FINDSTRING(@[User::FileName],"_",1)+1))
    Dept:
    @[User::Name] =="M02"?"dept 45":@[User::Name] =="B15"?"dept 99":"dept 00"
    The following screenshot is for your reference:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

  • How to create new calculated column based on filtered columns?

    Dear All,
    I'm using Oracle Analysis.
    I have two column, each one have different formula.
    My Formula based on filter.
    Column1
    FILTER("DW"."SUM_PLAN_MONTH_AMOUNT" USING ("DW"."PLAN_YEAR" BETWEEN YEAR(DATE'@{P_BEGIN_DATE}') and YEAR(DATE'@{P_END_DATE}')))Column2
    FILTER("PAYMENTS"."SUM_PAY_AMOUNT" / 1000 USING ("PAYMENTS"."PAY_DATE_PAID" BETWEEN DATE'@{P_BEGIN_DATE}' AND DATE'@{P_END_DATE}'))How to add new calculated column based on those two column?
    For example:
    Column1 | Column2 | NewColumn
    5 | 10 | 10 / 5 * 100
    7 | 12 | 12 / 7 * 100
    Regards,
    Eba
    Edited by: Erdenebayar on Apr 19, 2012 1:42 PM
    Edited by: Erdenebayar on Apr 19, 2012 3:37 PM

    Hello MK,
    I have a tried following formula. It is working, but result is not filtered.
    I filtered "PAYMENTS"."SUM_PAY_AMOUNT" and "DW"."SUM_PLAN_MONTH_AMOUNT" columns.
    "PAYMENTS"."SUM_PAY_AMOUNT" / "DW"."SUM_PLAN_MONTH_AMOUNT" * 100Can you share me some tutorial?
    BR,
    Eba
    Edited by: Erdenebayar on Apr 19, 2012 3:43 PM
    Edited by: Erdenebayar on Apr 19, 2012 3:43 PM
    Edited by: Erdenebayar on Apr 19, 2012 3:43 PM

  • Creating hyperlink in column based on data, in ALV Web Dynpro ABAP

    Hi,
    I have a scenario in which i need to create hyperlink on a column. However all rows in that column need not be hyperlink. Based on the data i need to create it as hyperlink.
    eg: Column1 Column2
          ABC        1234
          DEF     5678
          GHI          9123
          DEF     5678
    So in above case where data is DEF i keep it as hyperlink, other rows are not.
    I am using ALV component to display data in a view container element.
    Please help me with this.
    Regards,
    Saud

    hi,
    DATA: lr_column TYPE REF TO cl_salv_wd_column.
    lr_column = l_value->if_salv_wd_column_settings~get_column( 'CONNID' ).
    DATA: lr_link_to_action TYPE REF TO cl_salv_wd_uie_link_to_action.
    CREATE OBJECT lr_link_to_action.
    lr_link_to_action->set_text_fieldname( 'CONNID' ).
    *lr_link_to_action->SET_ENABLED_FIELDNAME( 'BOOL' ).*
    lr_column->set_cell_editor( lr_link_to_action ).
    Here BOOL is my context attribute of type wdy_boolean inside the context node.
    Now based on the value of BOOL , your link to action will vary.
    DATA lo_nd_cn_flight TYPE REF TO if_wd_context_node.
      DATA ls_cn_flight TYPE wd_this->element_cn_flight.
      DATA lt_cn_flight TYPE wd_this->elements_cn_flight.
    *   navigate from <CONTEXT> to <CN_FLIGHT> via lead selection
      lo_nd_cn_flight = wd_context->get_child_node( name = wd_this->wdctx_cn_flight ).
      SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE lt_cn_flight.
        *LOOP AT LT_CN_FLIGHT INTO LS_CN_FLIGHT WHERE CARRID = 'AA'.*
          *LS_CN_FLIGHT-BOOL = ABAP_TRUE.*
          *MODIFY LT_CN_FLIGHT FROM LS_CN_FLIGHT TRANSPORTING BOOL.*
          *ENDLOOP.*
      lo_nd_cn_flight->bind_table( lt_cn_flight ).
    CN_FLIGHT is my context node binded to ALV. Now in above code you can set the  value of BOOL attribute and link to Action will depend on this value.

  • Getting Error while creating a new column in a list or library in a site collection - Sharepoint 2013

    Hi,
    I am getting below error when i create a new column in a library or list,
    "Save Conflict
    Your changes conflict with those made concurrently by  another user. IF you want your changes to be applied, click back in your browser, refresh the page, and resubmit your changes"
    Any help please.
    Smile Always

    Hi,
    I have done a test in my SharePoint 2013. And I can re-appear your issue.
    Per my test, I found that If  there are more than one user create a new column in
    a library or list at the same time, when we
    click ok after the other users, we will get the error.
    Or if we open a library or list in two windows with the same user, when we
    create a new column in a library or list in two windows
    at the same time, we will get the error.
    To resolve your issue, refresh your page and
    create a new column again.
    Best Regards,
    Lisa Chen
    Lisa Chen
    TechNet Community Support

  • Creating a dynamic lov based on a column

    Hi,
    I want to create a dynamic lov based on a column in a database-table.
    Eg. the query
    'select code, description from code_table'
    is the contents of the column 'lov_query' in the table 'parameters'.
    For every parameter there can be a different lov-query, but the result is always
    two columns (code and description, number and name, etc.), exactly what you need to use in a lov.
    I've written a (dbms_sql) function that takes the parameter-id and returns the lov_query.
    create or replace function "GET_PMR_LOV"
    (pmr_id in NUMBER)
    return VARCHAR2
    is
    cur INTEGER := DBMS_SQL.OPEN_CURSOR;
    fdbk INTEGER;
    l_pmr_id NUMBER(9) := pmr_id;
    l_stmnt VARCHAR2(2000);
    begin
    DBMS_SQL.PARSE
    (cur, 'select pmr.lov_query from parameters pmr where pmr.ID ' || ' = 'L_PMR_ID', DBMS_SQL.NATIVE);
    DBMS_SQL.BIND_VARIABLE (cur, 'L_PMR_ID', l_pmr_id);
    DBMS_SQL.DEFINE_COLUMN (cur, 1, l_stmnt, 2000);
    fdbk := DBMS_SQL.EXECUTE (cur);
    fdbk := DBMS_SQL.FETCH_ROWS (cur);
    IF fdbk > 0
    THEN
    DBMS_SQL.COLUMN_VALUE (cur, 1, l_stmnt);
    return (l_stmnt);
    ELSE     
    return null;
    END IF;
    DBMS_SQL.CLOSE_CURSOR (cur);
    END;
    But now I'm stuck on how to pass on this statement in HTMLDB
    as an dynamic lov, I don't seem to be able to execute this statement
    into the two display and return columns. Any ideas?

    Hello again,
    This lov is on an updatable report-column where the user has to make a choice from an non-named, popup and query-based lov. In the lov-query box I have just put:
    "return get_pmr_lov(:p41_param_id)" (without the quotes ;-)
    Here's my latest version plus an alternative, which both seem to work fine:
    create or replace function "GET_PMR_LOV"
    (pmr_id in NUMBER)
    return VARCHAR2
    is
    cur INTEGER := DBMS_SQL.OPEN_CURSOR;
    fdbk INTEGER;
    l_pmr_id NUMBER(9) := pmr_id;
    l_stmnt VARCHAR2(1000);
    begin
    DBMS_SQL.PARSE (cur, 'select pmr.lov_query from paramaters pmr where pmr.ID ' || '= :L_PMR_ID', DBMS_SQL.NATIVE);
    DBMS_SQL.BIND_VARIABLE (cur, 'L_PMR_ID', l_pmr_id);
    DBMS_SQL.DEFINE_COLUMN (cur, 1, l_stmnt, 1000);
    fdbk := DBMS_SQL.EXECUTE (cur);
    fdbk := DBMS_SQL.FETCH_ROWS (cur);
    IF fdbk > 0 THEN
    DBMS_SQL.COLUMN_VALUE (cur, 1, l_stmnt);
    return (l_stmnt);
    ELSE
    return null;
    END IF;
    DBMS_SQL.CLOSE_CURSOR (cur);
    END;
    create or replace function "GET_PMR_LOV2"
    (pmr_id in NUMBER)
    return VARCHAR2
    is
    l_pmr_id NUMBER(9) := pmr_id;
    l_stmnt VARCHAR2(1000);
    BEGIN
    EXECUTE IMMEDIATE 'select pmr.lov_query from parameters pmr where pmr.ID = :1'
    INTO l_stmnt USING l_pmr_id;
    return l_stmnt;
    END;
    The error-message remains the same, unable to bind :p41_param_id !

  • How to Create a new column from two different result sets

    How to Create a new column from two different result sets, both the result set uses the different date dimensions.

    i got solutions for this is apply filters in column formula it self, based on the requirement.

  • Creating a target group based on the BP email address only in CRM

    Hi there,
    I am currently trying to create a target group based on the business partner email address only.
    I have a list of over 1000 email addresses - these email addresses equate to a BP in our CRM system, however I do not have a list of the equivalent business partner numbers, all I have to work on are the email addresses.  With these 1000 BP email addresses I need to update the marketing attributes of each of these 1000 BP records in CRM.
    What I need is a method to find the 1000 BP numbers based on the email addresses and then use the marketing expert tool (tx. CRMD_MKT_TOOLS) to change the marketing attributes on all of the 1000 BPs.
    The issue I am having is how can I find the list of BP numbers just based on the BP email address, I tried creating an infoset based on table BUT000, BUT020 and ADR6 but I after creating attribute list & data source for this I am stuck on what to do next. In the attribute list the selection criteria does not allow me to import a file for the selection range.  I can only enter a value but I have 1000 email addresses and cannot possibly email them manually in the filter for the attribute list.   I also looked at imported a file into the target group but I do not have any BP numbers so this will not work.
    Does anyone know a method where I can create a target group based on the email addresses only without having to do any code?
    Any help would be most appreciated.
    Kind regard
    JoJo

    Hi JoJo ,
    The below report will return you BP GUID from emails that is stored in a single column .xls file and assign the BP to a target group.
    REPORT  zexcel.
    * G L O B A L D A T A D E C L A R A T I O N
    TYPE-POOLS : ole2.
    TYPES : BEGIN OF typ_xl_line,
    email TYPE ad_smtpadr,
    END OF typ_xl_line.
    TYPES : typ_xl_tab TYPE TABLE OF typ_xl_line.
    DATA : t_data TYPE typ_xl_tab,
           lt_bu_guid TYPE TABLE OF bu_partner_guid,
           ls_bu_guid TYPE  bu_partner_guid,
           lt_guids TYPE TABLE OF bapi1185_bp,
           ls_guids TYPE  bapi1185_bp,
           lt_return TYPE bapiret2_t.
    * S E L E C T I O N S C R E E N L A Y O U T
    PARAMETERS : p_xfile TYPE localfile,
                  p_tgguid TYPE bapi1185_key .
    * E V E N T - A T S E L E C T I O N S C R E E N
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_xfile.
       CALL FUNCTION 'WS_FILENAME_GET'
         IMPORTING
           filename         = p_xfile
         EXCEPTIONS
           inv_winsys       = 1
           no_batch         = 2
           selection_cancel = 3
           selection_error  = 4
           OTHERS           = 5.
       IF sy-subrc <> 0.
         CLEAR p_xfile.
       ENDIF.
    * E V E N T - S T A R T O F S E L E C T I O N
    START-OF-SELECTION.
    * Get data from Excel File
       PERFORM sub_import_from_excel USING p_xfile
       CHANGING t_data.
       SELECT but000~partner_guid FROM but000 INNER JOIN but020 ON
    but000~partner =
       but020~partner
         INNER JOIN adr6 ON but020~addrnumber = adr6~addrnumber INTO TABLE
    lt_bu_guid FOR ALL ENTRIES IN t_data WHERE adr6~smtp_addr =
    t_data-email.
       CLEAR: lt_guids,ls_guids.
       LOOP AT lt_bu_guid INTO ls_bu_guid.
         ls_guids-bupartnerguid = ls_bu_guid.
         APPEND ls_guids TO lt_guids.
       ENDLOOP.
       CALL FUNCTION 'BAPI_TARGETGROUP_ADD_BP'
         EXPORTING
           targetgroupguid = p_tgguid
         TABLES
           return          = lt_return
           businesspartner = lt_guids.
    *&      Form  SUB_IMPORT_FROM_EXCEL
    *       text
    *      -->U_FILE     text
    *      -->C_DATA     text
    FORM sub_import_from_excel USING u_file TYPE localfile
    CHANGING c_data TYPE typ_xl_tab.
       CONSTANTS : const_max_row TYPE sy-index VALUE '65536'.
       DATA : l_dummy TYPE typ_xl_line,
              cnt_cols TYPE i.
       DATA : h_excel TYPE ole2_object,
              h_wrkbk TYPE ole2_object,
              h_cell TYPE ole2_object.
       DATA : l_row TYPE sy-index,
              l_col TYPE sy-index,
              l_value TYPE string.
       FIELD-SYMBOLS : <fs_dummy> TYPE ANY.
    * Count the number of columns in the internal table.
       DO.
         ASSIGN COMPONENT sy-index OF STRUCTURE l_dummy TO <fs_dummy>.
         IF sy-subrc EQ 0.
           cnt_cols = sy-index.
         ELSE.
           EXIT.
         ENDIF.
       ENDDO.
    * Create Excel Application.
       CREATE OBJECT h_excel 'Excel.Application'.
       CHECK sy-subrc EQ 0.
    * Get the Workbook object.
       CALL METHOD OF h_excel 'Workbooks' = h_wrkbk.
       CHECK sy-subrc EQ 0.
    * Open the Workbook specified in the filepath.
       CALL METHOD OF h_wrkbk 'Open' EXPORTING #1 = u_file.
       CHECK sy-subrc EQ 0.
    * For all the rows - Max upto 65536.
       DO const_max_row TIMES.
         CLEAR l_dummy.
         l_row = l_row + 1.
    * For all columns in the Internal table.
         CLEAR l_col.
         DO cnt_cols TIMES.
           l_col = l_col + 1.
    * Get the corresponding Cell Object.
           CALL METHOD OF h_excel 'Cells' = h_cell
             EXPORTING #1 = l_row
             #2 = l_col.
           CHECK sy-subrc EQ 0.
    * Get the value of the Cell.
           CLEAR l_value.
           GET PROPERTY OF h_cell 'Value' = l_value.
           CHECK sy-subrc EQ 0.
    * Value Assigned ? pass to internal table.
           CHECK NOT l_value IS INITIAL.
           ASSIGN COMPONENT l_col OF STRUCTURE l_dummy TO <fs_dummy>.
           <fs_dummy> = l_value.
         ENDDO.
    * Check if we have the Work Area populated.
         IF NOT l_dummy IS INITIAL.
           APPEND l_dummy TO c_data.
         ELSE.
           EXIT.
         ENDIF.
       ENDDO.
    * Now Free all handles.
       FREE OBJECT h_cell.
       FREE OBJECT h_wrkbk.
       FREE OBJECT h_excel.
    ENDFORM. " SUB_IMPORT_FROM_EXCEL
    Just copy paste the code and run the report select any local xls file with emails and pass the target group guid.
    snap shot of excel file:
    Let me know if it was useful.

  • When creating a "lookup" column be able to display not only one column from the other list, but additional columns

    With the lookup technique, it is possible to select an item from another list and display one column of this item
    It is obviously possible to create several lookup columns on the same list and therefore display several columns
    There’s a high risk of not selecting the same item and therefore have inconsistent columns
    The Requirement therefore consist of being able of displaying several columns of the same item from the other list, based on one unique selection
    Example:
    In list(x), define lookup column on list (y), column Title (possible today)
    Then define a “secondary” lookup column on same list, column Code
    The effect would be that when selecting an item from list (X), both Title and Code would show up consistently in 2 different columns of list (Y)
    All possible solutions are welcomed

    If you are using SharePoint 2010, you can retrieve additional columns when adding a Lookup. If you are using 2007, there is no direct OOTB way, but the following two posts provide potential work-arounds:
    https://www.definitivelogic.com/blog/microsoft-sharepoint-2007-pulling-column-data-one-list-another-based-common-list-field
    http://stefan-stanev-sharepoint-blog.blogspot.com/2010/11/sharepoint-2007-associated-lookup.html
    Dimitri Ayrapetov (MCSE: SharePoint)

  • How to create a calculated column in sharepoint

    I created the custom list in share point. In that list i renamed the title as
    Name.
    I created the WindowsID as person or group column in share point list.
    In the same list, I want to create a new calculated column as EmpName as hyperlink with the below formula  
    ="<a href='"&WindowsID &"'>"&Name&"</a>"
    But I am unable to create a new column by using above formula.
    Could you please let me know what i missed in the above formula.
    Please note that i am unable to see the WindowsID in the insert column.
    Thanks for ur support.

    Hello
    Sorry for the delay replay.
    Based on your guidance,i followed the below steps
    1.created the loginname  column of type person or group
    2.Added the contentquery webpart
    3.crated the custom xslt template
    4.Please find the below template
    <xsl:template name="ListingItem" match="Row[@Style='ListingItem']" mode="itemstyle">
        <xsl:variable name="DisplayTitle">
          <xsl:call-template name="OuterTemplate.GetTitle">
            <xsl:with-param name="Title" select="@Title"/>
            <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="LoginID">
       <xsl:value-of select="ddwrt:UserLookup(string(@DomainID) ,'User')" />
    </xsl:variable>
        <div id="membersdiv" class="members">
         <!-- <xsl:value-of select="$LoginID" disable-output-escaping="yes"/>-->
         <xsl:if test="$LoginID != ''">
              <a href="{$LoginID}">
              <xsl:value-of select="@Title" disable-output-escaping="yes"/>
              </a>
          </script>
         </xsl:if>
    </div>
      </xsl:template>
    if user is having the login id then i need display the title.on click of that title i need to redirect to user settings page like http://url/_layouts/15/userdisp.aspx?ID=1  .How can i redirect to
    the sharepoint personal settings page based on person click

  • View with columns based on function - problem with query

    Hi,
    I'm using Oracle 9i;
    I've created a view which has columns based on a table columns (multiple columns from 1 table) and funtion (multiple columns based on 1 function).
    The function takes ID as the first argument and name of the column to determine which value to return as the second one.
    Here is a sample of such function (simplified):
    FUNCTION my_function
    (in_id IN NUMBER, in_col_name IN VARCHAR2)
    RETURN VARCHAR2
    IS
    c_name VARCHAR2(100);
    c_last_name VARCHAR2(100);
    BEGIN
    SELECT T.NAME, T.LAST_NAME
    INTO c_name, c_last_name
    FROM TABLE_1 T, TABLE_2 Z
    WHERE T.PK = Z.FK
    AND Z.ID = in_id;
    IF in_col_name = 'NAME' THEN
    RETURN c_name;
    ELSIF in_col_name = 'LAST_NAME' THEN
    RETURN c_last_name;
    END IF;
    END;
    For simplicty I've restricted the number of columns.
    CREATE OR REPLACE VIEW my_view
    (ID, NAME, LAST_NAME)
    AS
    SELECT
    T.ID ID
    ,CAST(my_function(T.ID,'NAME') AS VARCHAR2(100)) NAME
    ,CAST(my_function(T.ID,'LAST_NAME') AS VARCHAR2(100)) LAST_NAME
    FROM TABLE T;
    There is no problem with query:
    SELECT * FROM my_view;
    The problem arises when I query the view (regardles of '=' or 'LIKE'):
    SELECT * FROM my_view
    WHERE name LIKE '%some_part_of_name%'
    The query returns rows for same names, for same it doesn't. If I put '=' and the whole name the query returns nothing, but when I put 'LIKE' and the first letter it returns rows in some cases.
    I've tried to debug this situation and I've discovered that the function recives ID not in the proper order and not the same amount of times - in explicit:
    for each ID in (1, 2, 3, 4, 5, 6, ... , 100) the function should be called twice for each ID and in the same order, but it does not.
    I get 1, 1, 2, 3, 3, 6, 20, 20 and so on.
    Help needed.
    Greetings.

    The problem is more complicated than the solutions provided here.
    The reason why I'm using the function is this:
    the original view was constructed using multiple union all selects and the speed was terrible. I've created the index on the base table to obtain a proper sort. For retriving all records at once the view works perfectly, but if one wants to query by columns based on function the results are suprisng - sometimes there are, some times there are none, or if you serch with "like" and only a part of string there are results, but with "=" there are no results.
    Here are real DDLs:
    View:
    CREATE OR REPLACE VIEW V_DOK_ARCH
    (ID_ZDAR, TYP, STAN, DATE_CREATED, CREATED_BY,
    DATE_MODIFIED, MODIFIED_BY, SPRA_ID_SPRA, PODM_ID_PODM, PODM_UMOW_ID_UMOW,
    NR_WFS, WFS_NR_INTER, UWAGI_OPER, FUNDUSZ, NUMER,
    DATA_PODPISANIA, RODZAJ, TYP_PRZY, TYP_UBEZ, NAZWISKO,
    IMIE, IMIE_OJCA, NAZWA_FIRMY, NAZWA_FIRMY_SKR, DANE_KLIE)
    AS
    SELECT /*+ INDEX(Z ZDAR_DATE_CREATED_DESC_I) */
    Z.ID_ZDAR ID_ZDAR
    , Z.TYP TYP
    , Z.STAN STAN
    , Z.DATE_CREATED DATE_CREATED
    , Z.CREATED_BY CREATED_BY
    , Z.DATE_MODIFIED DATE_MODIFIED
    , Z.MODIFIED_BY MODIFIED_BY
    , Z.SPRA_ID_SPRA SPRA_ID_SPRA
    , Z.PODM_ID_PODM PODM_ID_PODM
    , Z.PODM_UMOW_ID_UMOW PODM_UMOW_ID_UMOW
    , Z.NR_WFS NR_WFS
    , Z.WFS_NR_INTER WFS_NR_INTER
    , Z.UWAGI_OPER UWAGI_OPER
    , Z.FUNDUSZ FUNDUSZ
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NUMER') AS VARCHAR2(30)) NUMER
    , F_Rej_Zdar_Date(Z.ID_ZDAR, 'DATA_PODPISANIA') DATA_PODPISANIA
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'RODZAJ') AS VARCHAR2(4)) RODZAJ
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_PRZY') AS VARCHAR2(4)) TYP_PRZY
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_UBEZ') AS VARCHAR2(3)) TYP_UBEZ
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO') AS VARCHAR2(30)) NAZWISKO
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE') AS VARCHAR2(30)) IMIE
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA') AS VARCHAR2(30)) IMIE_OJCA
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY') AS VARCHAR2(300)) NAZWA_FIRMY
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR') AS VARCHAR2(100)) NAZWA_FIRMY_SKR
    , CAST(LTRIM(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA')||F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY')||DECODE(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY'),NULL,F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR'),NULL)) AS VARCHAR2(492)) DANE_KLIE
    FROM T_ZDARZENIA Z
    WHERE F_Rej_Zdar_Char(Z.ID_ZDAR, 'JEST') = 'T';
    and functions:
    CREATE OR REPLACE FUNCTION F_Rej_Zdar_Char
    (WE_ID_ZDAR IN NUMBER
    ,WE_KOLUMNA IN VARCHAR2
    RETURN VARCHAR2
    IS
    c_numer           T_PRZYSTAPIENIA.NUMER%TYPE;--VARCHAR2(30);
    c_rodzaj           T_KLIENCI.RODZAJ%TYPE;--VARCHAR2(1);
    c_typ_przy           T_PRZYSTAPIENIA.TYP_PRZY%TYPE;--VARCHAR2(1);
    c_typ_ubez           T_PRZYSTAPIENIA.TYP_UBEZ%TYPE;--VARCHAR2(3);
    c_nazwisko           T_KLIENCI.NAZWISKO%TYPE;--VARCHAR2(30);
    c_imie                T_KLIENCI.IMIE%TYPE;--VARCHAR2(30);
    c_imie_ojca      T_KLIENCI.IMIE_OJCA%TYPE;--VARCHAR2(30);
    c_nazwa_firmy      T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(300);
    c_nazwa_firmy_skr T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(100);
    c_jest                VARCHAR2(1) := 'T';
    c EXCEPTION;
    BEGIN
    --dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR);
    BEGIN
    SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
    INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
    FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
    WHERE p.KLIE_ID_KLIE = k.ID_KLIE
    AND z.PODM_ID_PODM = D1.ID_PODM
    AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
    AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
    AND D2.PRZY_ID_PRZY = P.ID_PRZY
    AND z.ID_ZDAR = WE_ID_ZDAR;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
         BEGIN
         SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
         INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
         FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
         WHERE z.PODM_UMOW_ID_UMOW IS NULL
         AND z.PODM_ID_PODM = D.ID_PODM
         AND D.KLIE_ID_KLIE = k.ID_KLIE
         AND p.KLIE_ID_KLIE = k.ID_KLIE
         AND z.ID_ZDAR = WE_ID_ZDAR;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              BEGIN
              SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, I.nazwisko, I.imie, I.imie_ojca, I.NAZWA NAZWA_FIRMY, I.NAZWA_SKR nazwa_firmy_skr
              INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
              FROM T_ZDARZENIA z, T_INSTYTUCJE I
              WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
              AND z.PODM_UMOW_ID_UMOW IS NULL
              AND Z.PODM_ID_PODM = I.ID_INST
              AND z.ID_ZDAR = WE_ID_ZDAR;
              EXCEPTION
                   WHEN NO_DATA_FOUND THEN
                   BEGIN
                   SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
                   INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                   FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                   WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                   AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
                   AND z.ID_ZDAR = WE_ID_ZDAR;
                   EXCEPTION
                        WHEN NO_DATA_FOUND THEN
                        BEGIN
                        SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
                        INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                        FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                        WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                        AND z.PODM_ID_PODM = a.ID_AGAG
                        AND z.PODM_UMOW_ID_UMOW IS NULL
                        AND z.ID_ZDAR = WE_ID_ZDAR;
                        EXCEPTION
                             WHEN NO_DATA_FOUND THEN
                             BEGIN
                             SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
                             INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                             FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                             WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                             AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
                             AND z.ID_ZDAR = WE_ID_ZDAR;
                             EXCEPTION
                                  WHEN NO_DATA_FOUND THEN
                                  BEGIN
                                  SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
                                  INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                  FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                                  WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                                  AND z.PODM_ID_PODM = a.ID_AGKAN
                                  AND z.PODM_UMOW_ID_UMOW IS NULL
                                  AND z.ID_ZDAR = WE_ID_ZDAR;
                                  EXCEPTION
                                       WHEN NO_DATA_FOUND THEN
                                       BEGIN
                                       SELECT k.NUMER_UMOWY NUMER, DECODE(k.TYP_PRZYSTAPIENIA,'P','F','P') RODZAJ,k.TYP_PRZYSTAPIENIA TYP_PRZY,'NPO' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, k.nazwa_firmy nazwa_firmy, k.nazwa_firmy_skr nazwa_firmy_skr
                                       INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                       FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
                                       WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                       AND k.TYP_PRZYSTAPIENIA IN ('P','W')
                                       AND z.PODM_ID_PODM IS NULL
                                       AND z.PODM_UMOW_ID_UMOW IS NULL
                                       AND z.ID_ZDAR = WE_ID_ZDAR;
                                       EXCEPTION
                                            WHEN NO_DATA_FOUND THEN
                                            BEGIN
                                            SELECT k.NUMER_UMOWY NUMER, 'F' RODZAJ,'-' TYP_PRZY,'OPS' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
                                            INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                            FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
                                            WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                            AND z.PODM_ID_PODM IS NULL
                                            AND z.PODM_UMOW_ID_UMOW IS NULL
                                            AND z.ID_ZDAR = WE_ID_ZDAR;
                                            EXCEPTION
                                                 WHEN NO_DATA_FOUND THEN
                                                 BEGIN
                                                 SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, NULL nazwisko, NULL imie_pierwsze, NULL imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
                                                 INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                                 FROM T_ZDARZENIA z
                                                 WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
                                                 AND z.PODM_ID_PODM IS NULL
                                                 AND z.PODM_UMOW_ID_UMOW IS NULL
                                                 AND z.ID_ZDAR = WE_ID_ZDAR;
                                                 EXCEPTION
                                                      WHEN NO_DATA_FOUND THEN
                                                           --dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR||' ostatni wyjatek');
                                                           NULL;
                                                 END;
                                            END;
                                       END;
                                  END;
                             END;
                        END;
                   END;
              END;
         END;
    END;
    --raise c;
    IF WE_KOLUMNA = 'NUMER' THEN
    RETURN c_numer;
    ELSIF WE_KOLUMNA = 'RODZAJ' THEN
    RETURN c_rodzaj;
    ELSIF WE_KOLUMNA = 'TYP_PRZY' THEN
    RETURN c_typ_przy;
    ELSIF WE_KOLUMNA = 'TYP_UBEZ' THEN
    RETURN c_typ_ubez;
    ELSIF WE_KOLUMNA = 'NAZWISKO' THEN
    RETURN c_nazwisko;
    ELSIF WE_KOLUMNA = 'IMIE' THEN
    RETURN c_imie;
    ELSIF WE_KOLUMNA = 'IMIE_OJCA' THEN
    RETURN c_imie_ojca;
    ELSIF WE_KOLUMNA = 'NAZWA_FIRMY' THEN
    RETURN c_nazwa_firmy;
    ELSIF WE_KOLUMNA = 'NAZWA_FIRMY_SKR' THEN
    RETURN c_nazwa_firmy_skr;
    ELSIF WE_KOLUMNA = 'JEST' THEN
    RETURN c_jest;
    END IF;
    END;
    CREATE OR REPLACE FUNCTION F_Rej_Zdar_Date
    (WE_ID_ZDAR IN NUMBER
    ,WE_KOLUMNA IN VARCHAR2
    RETURN DATE
    IS
    d_data DATE;
    BEGIN
    BEGIN
    SELECT p.DATA_PODPISANIA
    INTO d_data
    FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
    WHERE p.KLIE_ID_KLIE = k.ID_KLIE
    AND z.PODM_ID_PODM = D1.ID_PODM
    AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
    AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
    AND D2.PRZY_ID_PRZY = P.ID_PRZY
    AND z.ID_ZDAR = WE_ID_ZDAR;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
         BEGIN
         SELECT p.DATA_PODPISANIA
         INTO d_data
         FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
         WHERE z.PODM_UMOW_ID_UMOW IS NULL
         AND z.PODM_ID_PODM = D.ID_PODM
         AND D.KLIE_ID_KLIE = k.ID_KLIE
         AND p.KLIE_ID_KLIE = k.ID_KLIE
         AND z.ID_ZDAR = WE_ID_ZDAR;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              BEGIN
              SELECT NULL DATA_PODPISANIA
              INTO d_data
              FROM T_ZDARZENIA z, T_INSTYTUCJE I
              WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
              AND z.PODM_UMOW_ID_UMOW IS NULL
              AND Z.PODM_ID_PODM = I.ID_INST
              AND z.ID_ZDAR = WE_ID_ZDAR;
              EXCEPTION
                   WHEN NO_DATA_FOUND THEN
                   BEGIN
                   SELECT p.DATA_PODPISANIA DATA_PODPISANIA
                   INTO d_data
                   FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                   WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                   AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
                   AND z.ID_ZDAR = WE_ID_ZDAR;
                   EXCEPTION
                        WHEN NO_DATA_FOUND THEN
                        BEGIN
                        SELECT p.DATA_PODPISANIA DATA_PODPISANIA
                        INTO d_data
                        FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                        WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                        AND z.PODM_ID_PODM = a.ID_AGAG
                        AND z.PODM_UMOW_ID_UMOW IS NULL
                        AND z.ID_ZDAR = WE_ID_ZDAR;
                        EXCEPTION
                             WHEN NO_DATA_FOUND THEN
                             BEGIN
                             SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
                             INTO d_data
                             FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                             WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                             AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
                             AND z.ID_ZDAR = WE_ID_ZDAR;
                             EXCEPTION
                                  WHEN NO_DATA_FOUND THEN
                                  BEGIN
                                  SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
                                  INTO d_data
                                  FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                                  WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                                  AND z.PODM_ID_PODM = a.ID_AGKAN
                                  AND z.PODM_UMOW_ID_UMOW IS NULL
                                  AND z.ID_ZDAR = WE_ID_ZDAR;
                                  EXCEPTION
                                       WHEN NO_DATA_FOUND THEN
                                       BEGIN
                                       SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
                                       INTO d_data
                                       FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
                                       WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                       AND k.TYP_PRZYSTAPIENIA IN ('P','W')
                                       AND z.PODM_ID_PODM IS NULL
                                       AND z.PODM_UMOW_ID_UMOW IS NULL
                                       AND z.ID_ZDAR = WE_ID_ZDAR;
                                       EXCEPTION
                                            WHEN NO_DATA_FOUND THEN
                                            BEGIN
                                            SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
                                            INTO d_data
                                            FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
                                            WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                            AND z.PODM_ID_PODM IS NULL
                                            AND z.PODM_UMOW_ID_UMOW IS NULL
                                            AND z.ID_ZDAR = WE_ID_ZDAR;
                                            EXCEPTION
                                                 WHEN NO_DATA_FOUND THEN
                                                 BEGIN
                                                 SELECT NULL DATA_PODPISANIA
                                                 INTO d_data
                                                 FROM T_ZDARZENIA z
                                                 WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
                                                 AND z.PODM_ID_PODM IS NULL
                                                 AND z.PODM_UMOW_ID_UMOW IS NULL
                                                 AND z.ID_ZDAR = WE_ID_ZDAR;
                                                 EXCEPTION
                                                      WHEN NO_DATA_FOUND THEN
                                                           d_data := NULL;
                                                 END;
                                            END;
                                       END;
                                  END;
                             END;
                        END;
                   END;
              END;
         END;
    END;
    IF WE_KOLUMNA = 'DATA_PODPISANIA' THEN
    RETURN d_data;
    END IF;
    END;

  • How to create internal table dynamically based on a table entry

    hi Experts,
      I have table yprod_cat. It has product categories.
      In my ABAP program I need to create internal table dynamically based on the number of entries in the table.
      For example:
      If the table has 3 entries for product category
      1. Board
      2. Micro
      3. Syst
    Then create three (3) internal tables.
    i_board
    i_micro
    i_syst
    How can we do this? Any sample code will be very usefull
    Thanks & Regards
    Gopal
    Moderator Message: No sample codes can be given. Please search for them or work it!
    Edited by: kishan P on Jan 19, 2011 4:22 PM

    Our APEX version is 4.2We are using below SQL query to display radio groups dynamically..
    SELECT APEX_ITEM.RADIOGROUP (1,deptno,'20',dname) dt
    FROM dept
    ORDER BY 1;
    Created a form using SQL type and given abouve SQL query as source.. But when we run the page, there were no radio groups displayed in the page..
    Below is the output of the query..
    <input type="radio" name="f01" value="10" />ACCOUNTING
    <input type="radio" name="f01" value="20" checked="checked" />RESEARCH
    <input type="radio" name="f01" value="30" />SALES
    <input type="radio" name="f01" value="40" />OPERATIONS
    >
    If Tabular Form:
    Edit Region > Report Attributes > Edit Column > Change the Column type to "Standard Report Column"
    If normal Page Item:
    Edit Page Item > Security > Escape special characters=No.
    Pl read the help on that page item to understand the security risk associated with =NO.
    Cheers,
    Edited by: Prabodh on Dec 3, 2012 5:59 PM

  • Logical (Business) Column based on physical column value

    Hello everyone,
    I'm new to here. I've been more of a reader than poster so far, but hopefully, I could offer some advice too.
    My question today is the following - let's say I have brought 2 columns to the physical layer (in the same table or in different, but joined - it doesn't really matter). 1 column is defining EXPENSE_TYPE (such as "Air Travel", "Car rental", "Hotel"...Another column is simply EXPENSE_AMT.
    I'd like to create 3 logical columns name AIR_TRAVEL_AMT, CAR_RENTAL_AMT, HOTEL_AMT in the busines layer based on the EXPENSE_AMT and EXPENSE_TYPE (AIR_TRAVEL_AMT= EXPENSE_AMT Where EXPENSE_TYPE="Air Travel")
    I know that best practices would make me create those columns in the fact table during in ETL process, however, I have no choice here now.
    My question is - how do I do it (I think it could be either variable/initialization block item - or possible I could write a CASE statement?).
    Is this method going to affect performance negatively?
    Thank you in advance.
    UPD: I think it's possible to do this using something like
    CASE WHEN Expense_Type = "AirType" THEN 1 else 0
    am I on correct path on figuring this one out?
    Message was edited by:
    wildmight

    Hi Wildmight,
    you´re right, you can do it with a CASE statement:
    For AIR_TRAVEL_AMT:
    CASE WHEN EXPENSE_TYPE="Air Travel" THEN EXPENSE_AMT ELSE 0 END
    Regards.

  • How to create an new column from ordered pairs

    Hi,
    Wondering if anyone can help this problem. I am analyzing network traffic between a PC and a Server. I can easily get a count of packets in each direction, PC1 to Server1 and the return path, Server 1 to PC1. But want I really want is a count
    of PC1 to OR from Server1, basically a count of packets by IP conversation.
    Each row is a packet with fields like: Time, Source, Destination.
    For example
    2:01:01, PC1, Server1
    2:01:01, Server1,  PC1 
    I would like to create a new column that represents a conversation. So new have columns: Time, Source, Destination, Conv. To get something like this:
    2:01:01, PC1, Server1, Conv1
    2:01:01, Server1,  PC1, Conv1
    2:01:01, PC2, Server1, Conv2
    2:01:01, Server1,  PC2, Conv2
    Thanks,
    Wes

    Wes, I just got around to revisiting your problem. The solution I came up with is twofold. The first part is the creation of a custom function that generates a conversation ID in the form PC1_Server1, PC2_Server1 etc. The second part uses a lookup table
    for each unique combination of PC and server to return a conversation number (Conv1, Conv2...).
    First of all, the "NetTraffic" table (your original table) generates the following script
    let
        Source = Excel.CurrentWorkbook(){[Name="Table8"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", type time}}),
    in
        #"Changed Type"
    In the above, the type of the timestamp column is changed to time, but you can alternatively fix it as text.
    I've called the custom function "ConversationIdentifier." It takes four parameters, as described by the parameter names.
    (sourceList as list, sourceValue as text, destinationList as list, destinationValue as text) as text=>
    let
        SourceConversationList = List.Sort(List.Select(sourceList,each (_ = sourceValue or _ = destinationValue))),
        DestinationConversationList = List.Sort(List.Select(destinationList,each (_ = sourceValue or _ = destinationValue)),Order.Descending),
        ConversationID = SourceConversationList{0}&"_"&DestinationConversationList{0}
    in
        ConversationID
    Usage:
    As an added custom column in Power Query, the formula, based on the "NetTraffic" table would be:
    =ConversationIdentifier(#"Changed Type"[Source],[Source],#"Changed Type"[Destination],[Destination])
    As previously mentioned, the custom function generates combinations of PC and server, such that each combination represents a conversation.
    Next, I created a two-column "ConversationLookup" table in a worksheet, with entries like PC1_Server1|Conv1, PC2_Server1|Conv2, and so on.
    In the NetTraffic table, I did a merge with the ConversationLookup table, ensuring that the "Only Include Matching Rows" option is left unchecked (left join).
    Finally, I removed unwanted columns. Note: You don't need to use the lookup step if PC1_Server1, PC2_Server1 etc. serves your need for identifying a conversation.

  • Level Based Measure and a column based on that

    Hello All,
    I need suggestions to implement the following requirement.
    1. No of orders stored in a fact table at day level
    2. No. of orders at month level should be calculated
    3. Depending on the count, each month would be assigned to a bucket.
    0-10 orders -> B1
    11-100 orders -> B2
    > 100 orders -> B3
    What I did in RPD
    1. fact joined to time dimension
    2. created a logical column: ORDER_COUNT: count(distinct order_number) iand set the level = month
    3. created a logical column: BUCKET: using the output of above logical column and CASE statement to implement the bucket rule.
    Now, when I run a report like this:
    Year; ORDER_COUNT; BUCKET
    Returns me 12 rows. Understood because ORDER_COUNT is a month level measure
    E.g.
    2011 5 B1
    2011 5 B1
    2011 15 B2
    2011 15 B2
    2011 5 B1
    2011 5 B1
    2011 15 B2
    2011 15 B2
    2011 5 B1
    2011 5 B1
    2011 15 B2
    2011 15 B2
    But as soon as I pull the BUCKET column as column heading in pivot table, it returns me only the 1st month row and changes the "BUCKET" value to B3.
    Looks like, it recalculates the bucket and sums up all 12 months orders and then applies the bucket rule.
    Like this -
    B3
    2011 5
    My expectation was something like this
    B1 B2 B3
    2011 30 90 0
    where 30 is the sum of the order_counts of all B1 months, <m>
    Ques:
    1. Is there a way I can avoid the recalculation of bucket information when the granularity/dimensionality changes in the report
    2. I read in the below link that if the grain of the report > grain of the level-based-measure then the output of the report is "not-deterministic"
    Am I hitting that scenario?
    [http://gerardnico.com/wiki/dat/obiee/measure_level_based]
    Any suggestion would be highly appreciated.
    I am using 11.1.1.6.2 version.
    Thanks & Regards
    Monika

    Hi ,
    If I understand your requirement  correctly , then you need currency Conversion.
    you can refer this links.
    http://consultingblogs.emc.com/christianwade/archive/2006/08/24/Currency-Conversion-in-Analysis-Services-2005.aspx
    http://www.ssas-info.com/analysis-services-faq/27-mdx/244-how-change-currency-symbol-based-on-selected-currency-dimension-member
    http://social.technet.microsoft.com/wiki/contents/articles/18672.currency-conversion-in-ssas-2012-multidimensional-tabular.aspx
    May I know , You Require all this using MDX and SSRS Parameter ?
    Thanks

Maybe you are looking for