How to use multiple selection parameters in the data model

Hi, after have looked all the previous threads about how to use multiple selection parameters , I still have a problem;
I'm using Oracle BI Publisher 10.1.3.3.2 and I'm tried to define more than one multiple selection parameters inside the data template;
Inside a simple SQL queries they work perfectly....but inside the data template I have errors.
My data template is the following (it's very simple...I am just testing how the parameters work):
<dataTemplate name="Test" defaultPackage="bip_departments_2_parameters">
<parameters>
<parameter name="p_dep_2_param" include_in_output="false" datatype="character"/>
<parameter name="p_loc_1_param" include_in_output="false" datatype="character"/>
</parameters>
<dataTrigger name="beforeReport" source="bip_departments_2_parameters.beforeReportTrigger"/>
<dataQuery>
<sqlStatement name="Q2">
<![CDATA[
select deptno, dname,loc
from dept
&p_where_clause
]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="G_DEPT" source="Q2">
<element name="deptno" value="deptno"/>
<element name="dname" value="dname"/>
<element name="loc" value="loc"/>
</group>
</dataStructure>
</dataTemplate>
The 2 parameters are based on these LOV:
1) select distinct dname from dept (p_dep_2_param)
2) select distinct loc from dept (p_loc_1_param)
and both of them have checked the "Multiple selection" and "Can select all" boxes
The package I created, in order to use the lexical refence is:
CREATE OR REPLACE package SCOTT.bip_departments_2_parameters
as
p_dep_2_param varchar2(14);
p_loc_1_param varchar2(20);
p_where_clause varchar2(100);
function beforereporttrigger
return boolean;
end bip_departments_2_parameters;
CREATE OR REPLACE package body SCOTT.bip_departments_2_parameters
as
function beforereporttrigger
return boolean
is
l_return boolean := true;
begin
if (p_dep_2_param is not null) --and (p_loc_1_param is not null)
then
p_where_clause := 'where (dname in (' || replace (p_dep_1_param, '''') || ') and loc in (' || replace (p_loc_1_param, '''') || '))';
else
p_where_clause := 'where 1=1';
end if;
return (l_return);
end beforereporttrigger;
end bip_departments_2_parameters;
As you see, I tried to have only one p_where_clause (with more than one parameter inside)....but it doesn't work...
Using only the first parameter (based on deptno (which is number), the p_where_clause is: p_where_clause := 'where (deptno in (' || replace (p_dep_2_param, '''') || '))';
it works perfectly....
Now I don't know if the problem is the datatype, but I noticed that with a single parameter (deptno is number), the lexical refence (inside the data template) works.....with a varchar parameter it doesn't work....
So my questions are these:
1) how can I define the p_where_clause (inside the package) with a single varchar parameter (for example, the department location name)
2) how can I define the p_where_clause using more than one parameter (for example, the department location name and the department name) not number.
Thanks in advance for any suggestion
Alex

Alex,
the missing thing in your example is the fact, that if only one value is selected, the parameter has exact this value like BOSTON. If you choose more than one value, the parameter includes the *'*, so that it looks like *'BOSTON','NEW YORK'*. So you need to check in the package, if there's a *,* in the parameter or not. If yes there's more than one value, if not it's only one value or it's null.
So change your package to (you need to expand your variables)
create or replace package bip_departments_2_parameters
as
p_dep_2_param varchar2(1000);
p_loc_1_param varchar2(1000);
p_where_clause varchar2(1000);
function beforereporttrigger
return boolean;
end bip_departments_2_parameters;
create or replace package body bip_departments_2_parameters
as
function beforereporttrigger
return boolean
is
l_return boolean := true;
begin
p_where_clause := ' ';
if p_dep_2_param is not null then
if instr(p_dep_2_param,',')>0 then
p_where_clause := 'WHERE DNAME in ('||p_dep_2_param||')';
else
p_where_clause := 'WHERE DNAME = '''||p_dep_2_param||'''';
end if;
if p_loc_1_param is not null then
if instr(p_loc_1_param,',')>0 then
p_where_clause := p_where_clause || ' AND LOC IN ('||p_loc_1_param||')';
else
p_where_clause := p_where_clause || ' AND LOC = '''||p_loc_1_param||'''';
end if;
end if;
else
if p_loc_1_param is not null then
if instr(p_loc_1_param,',')>0 then
p_where_clause := p_where_clause || 'WHERE LOC in ('||p_loc_1_param||')';
else
p_where_clause := p_where_clause || 'WHERE LOC = '''||p_loc_1_param||'''';
end if;
end if;
end if;
return (l_return);
end beforereporttrigger;
end bip_departments_2_parameters;
I've written a similar example at http://www.oracle.com/global/de/community/bip/tipps/Dynamische_Queries/index.html ... but it's in german.
Regards
Rainer

Similar Messages

  • Use a multiple selection parameter in the data model

    Hi
    i have created a parameter with the property multiple selection.
    This parameter i use in the Data Model where area,
    if i just mark one value the report works well if i mark more the one
    the report run into a error.
    WHERE PSNR IN :ma
    the xdo looks like
    <?xml version = '1.0' encoding = 'utf-8'?>
    <report version="1.1" xmlns="http://xmlns.oracle.com/oxp/xmlp" defaultDataSourceRef="tisoware">
    <title>BDE Nettozeit</title>
    <properties>
    <property name="showControls" value="true"/>
    <property name="online" value="true"/>
    <property name="parameterColumns" value="2"/>
    <property name="openLinkInNewWindow" value="true"/>
    </properties>
    <dataModel defaultDataSet="BDERUECK">
    <dataSet id="BDERUECK">
    <sql dataSourceRef="tisoware">
    <![CDATA[SELECT (SUBSTR(DATUM,1,6)) AS DATUM, SUM(NTTOZEIT) AS ZEIT,
    TRUNC(SUM(NTTOZEIT)/60) AS STUNDE
    FROM BDERUECK
    WHERE (DATUM  >= :datev) AND (DATUM <= :dateb) AND (KZDELETE = 'N') AND FIRMA = '1' AND ((PSNR IN :ma))
    GROUP BY (SUBSTR(DATUM,1,6))]]>
    </sql>
    <input id="datev" value="${datev}" dataType="xsd:string"/>
    <input id="dateb" value="${dateb}" dataType="xsd:string"/>
    <input id="ma" value="${ma}" dataType="xsd:string"/>
    </dataSet>
    </dataModel>
    <valueSets>
    <valueSet id="date">
    <sql dataSourceRef="tisoware">
    <![CDATA[SELECT DISTINCT DATUM
    FROM BDERUECK]]>
    </sql>
    </valueSet>
    <valueSet id="employee">
    <sql dataSourceRef="tisoware">
    <![CDATA[select      PERSTAMM.PSPERSNR as PSPERSNR,
          PERSTAMM.PSNR as PSNR
    from      TISOWARE.PERSTAMM PERSTAMM
    where    PERSTAMM.FIRMA = '1'
    order by PERSTAMM.PSPERSNR]]>
    </sql>
    </valueSet>
    </valueSets>
    <parameters>
    <parameter id="datev" defaultValue="20050103">
    <select label="Datum von : " valueSet="date" multiple="false" all="false" refreshParameters="false"/>
    </parameter>
    <parameter id="dateb" defaultValue="20060930">
    <select label="Datum bis : " valueSet="date" multiple="false" all="false"/>
    </parameter>
    <parameter id="ma" defaultValue="152">
    <select label="Mitarbeiter : " valueSet="employee" multiple="true" all="false"/>
    </parameter>
    </parameters>
    <templates default="BDE Nettozeit">
    <template label="BDE Nettozeit" type="rtf" url="BDE Nettozeit.rtf"/>
    </templates>
    </report>

    Alex,
    the missing thing in your example is the fact, that if only one value is selected, the parameter has exact this value like BOSTON. If you choose more than one value, the parameter includes the *'*, so that it looks like *'BOSTON','NEW YORK'*. So you need to check in the package, if there's a *,* in the parameter or not. If yes there's more than one value, if not it's only one value or it's null.
    So change your package to (you need to expand your variables)
    create or replace package bip_departments_2_parameters
    as
    p_dep_2_param varchar2(1000);
    p_loc_1_param varchar2(1000);
    p_where_clause varchar2(1000);
    function beforereporttrigger
    return boolean;
    end bip_departments_2_parameters;
    create or replace package body bip_departments_2_parameters
    as
    function beforereporttrigger
    return boolean
    is
    l_return boolean := true;
    begin
    p_where_clause := ' ';
    if p_dep_2_param is not null then
    if instr(p_dep_2_param,',')>0 then
    p_where_clause := 'WHERE DNAME in ('||p_dep_2_param||')';
    else
    p_where_clause := 'WHERE DNAME = '''||p_dep_2_param||'''';
    end if;
    if p_loc_1_param is not null then
    if instr(p_loc_1_param,',')>0 then
    p_where_clause := p_where_clause || ' AND LOC IN ('||p_loc_1_param||')';
    else
    p_where_clause := p_where_clause || ' AND LOC = '''||p_loc_1_param||'''';
    end if;
    end if;
    else
    if p_loc_1_param is not null then
    if instr(p_loc_1_param,',')>0 then
    p_where_clause := p_where_clause || 'WHERE LOC in ('||p_loc_1_param||')';
    else
    p_where_clause := p_where_clause || 'WHERE LOC = '''||p_loc_1_param||'''';
    end if;
    end if;
    end if;
    return (l_return);
    end beforereporttrigger;
    end bip_departments_2_parameters;
    I've written a similar example at http://www.oracle.com/global/de/community/bip/tipps/Dynamische_Queries/index.html ... but it's in german.
    Regards
    Rainer

  • Questions on select statement in the data model

    Hi,
    In the select statement, the order by statement seems only to work at the lowest level of the select statement. Is this true?
    What is the the purpose of the group by statement in the select statement?
    As far as I understand, the grouping is catered for in the data model.....
    Regards,
    Kin

    From the oracle report docs:
    The order of column values in a default group is
    determined by the ORDER BY clause of the query for
    SQL queries and by the sort column for Express queries.
    For column values in user-created groups, however, you
    must use Break Order to specify how to order the break
    column's values.So order by in your sql query is affected by groups in your data model.
    The purpose of a group by statement in your select statement is to group values for aggregation purposes, like
    select department_id,
           min(salary),
           max (salary)
      from employees
    group
        by department_id
    order
        by department_id;Grouping in the data model of a report is a little different than a group by clause, but not entirely.

  • Parameters in the Data Model not working

    I have about a bunch of Data Models that all have about 20 datasets in them. I have coded them all to take a date parameter in the SQL. So each dataset has a parameter called
    <parameter name="reportingdate" dataType="date" defaultValue="2010-10-01"/>
    I now want to use the parameters that are available in the data model to finalize all of my data models. But no matter what type of variable I use I get the following error:
    java.io.IOException: execute query failed[nQSError: 17001] Oracle Error code: 1722, message: ORA-01722: invalid number
    at OCI call OCIStmtExecute: WITH
    What type of gotchas are there with this parameter stuff. I have tried setting it as both date and string. I have tried the following formats (YYYY-MM-DD) and (MM-DD-YYYY) and I have tried 2010-07-01T00:00:00.000-04:00

    Hi,
    Use Java Date format i.e dd/MM/yyyy.
    Thanks
    Prasan

  • How to use multiple selection in parameters

    Hi all,
    I have a test report with department name as a parameter, hr.employees is the table.I checked the multiple selection for the parameter.When I choose one department name, the report runs well. But when I choose more than one department name, the report doesn't work.Seems the error is query's error. I have to edit query for the multiple selection? how to do it?Using dynamic where clause in the query?
    Any answer is very welcome,I really appreciate it. Thanks.

    Alex,
    the missing thing in your example is the fact, that if only one value is selected, the parameter has exact this value like BOSTON. If you choose more than one value, the parameter includes the *'*, so that it looks like *'BOSTON','NEW YORK'*. So you need to check in the package, if there's a *,* in the parameter or not. If yes there's more than one value, if not it's only one value or it's null.
    So change your package to (you need to expand your variables)
    create or replace package bip_departments_2_parameters
    as
    p_dep_2_param varchar2(1000);
    p_loc_1_param varchar2(1000);
    p_where_clause varchar2(1000);
    function beforereporttrigger
    return boolean;
    end bip_departments_2_parameters;
    create or replace package body bip_departments_2_parameters
    as
    function beforereporttrigger
    return boolean
    is
    l_return boolean := true;
    begin
    p_where_clause := ' ';
    if p_dep_2_param is not null then
    if instr(p_dep_2_param,',')>0 then
    p_where_clause := 'WHERE DNAME in ('||p_dep_2_param||')';
    else
    p_where_clause := 'WHERE DNAME = '''||p_dep_2_param||'''';
    end if;
    if p_loc_1_param is not null then
    if instr(p_loc_1_param,',')>0 then
    p_where_clause := p_where_clause || ' AND LOC IN ('||p_loc_1_param||')';
    else
    p_where_clause := p_where_clause || ' AND LOC = '''||p_loc_1_param||'''';
    end if;
    end if;
    else
    if p_loc_1_param is not null then
    if instr(p_loc_1_param,',')>0 then
    p_where_clause := p_where_clause || 'WHERE LOC in ('||p_loc_1_param||')';
    else
    p_where_clause := p_where_clause || 'WHERE LOC = '''||p_loc_1_param||'''';
    end if;
    end if;
    end if;
    return (l_return);
    end beforereporttrigger;
    end bip_departments_2_parameters;
    I've written a similar example at http://www.oracle.com/global/de/community/bip/tipps/Dynamische_Queries/index.html ... but it's in german.
    Regards
    Rainer

  • How to use Multiple selection in ADF faces

    i i would like to know how to use an multiple selection (ADF select many choice) to update the database.

    Hi,
    Timo is correct that there is no automated way for doing this. You can access the select many selection from a managed bean either accessing the ADF binding layer or by referencing a managed bean array property. So the use case is important. Use case would include the database attribute type to update
    Frank

  • Any one know how to use "custom" option present under the data access tab in XLS file format of Data Services

    Hi Experts,
            Any one know how to use or what is the purpose of "custom" option present under the data access tab in Excel workbook file format of Data Services
    Thanks in Advance,
    Rajesh.

    Rajesh, what is the Custom Protocol you are trying to use? It should be  something like PSFTP, etc.,
    Cheers
    Ganesh Sampath

  • How to use multiple search conditions in the where clause

    Hi,
    Below is my query
    /****** Script for SelectTopNRows command from SSMS  ******/
    SELECT distinct 
    ctacct,sum(GLMN02)
      FROM [ODS].[Staging].[tODS_INF_GLPCT]
      inner join 
      [ODS].[Staging].[tODS_INF_GLPGL] ON tODS_INF_GLPCT.CTPAGE = tODS_INF_GLPGL.GLPAGE
      where 
      CTACCT like '[0-9][0-9][0-9]-[0-9][0-9][0-9]-63020-4110%'
    This one gives me the exact result i want, now if i add one more to my where clause like this
    /****** Script for SelectTopNRows command from SSMS  ******/
    SELECT distinct 
    ctacct,sum(GLMN02)
    --,ctdesc,CTPAGE
    --SUM(GLMN02)
      FROM [ODS].[Staging].[tODS_INF_GLPCT]
      inner join 
      [ODS].[Staging].[tODS_INF_GLPGL] ON tODS_INF_GLPCT.CTPAGE = tODS_INF_GLPGL.GLPAGE
      where 
      CTACCT like'[0-9][0-9][0-9]-[0-9][0-9][0-9]-63020-4110%' or
      CTACCT like '[0-9][0-9][0-9]-[0-9][0-9][0-9]-63020-4115%'
    This query doesnt give me the exact values instead it gives me all the weird values.Can someone please help me with how to work on this where clause?
    Thanks

    Hi Patrick,
    This is what i ve tried earlier and it isnt working .If i use the first query
    /****** Script for SelectTopNRows command from SSMS  ******/
    SELECT distinct 
    ctdesc,SUM(GLMN02)
    --,ctdesc,CTPAGE
    --SUM(GLMN02)
      FROM [ODS].[Staging].[tODS_INF_GLPCT]
      inner join 
      [ODS].[Staging].[tODS_INF_GLPGL] ON tODS_INF_GLPCT.CTPAGE = tODS_INF_GLPGL.GLPAGE
      where 
     CTAcct LIKE '[0-9][0-9][0-9]-[0-9][0-9][0-9]-63020-4110%'
       --OR
       --CTAcct LIKE '[0-9][0-9][0-9]-[0-9][0-9][0-9]-63020-4115%'
      and GLYEAR = 2014
      and CTDESC = 'Sales'
      group by ctdesc
    The result set is 
    Sales                        
    -182273.96
    And if i use the second query
    SELECT distinct 
    ctdesc,SUM(GLMN02)
    --,ctdesc,CTPAGE
    --SUM(GLMN02)
      FROM [ODS].[Staging].[tODS_INF_GLPCT]
      inner join 
      [ODS].[Staging].[tODS_INF_GLPGL] ON tODS_INF_GLPCT.CTPAGE = tODS_INF_GLPGL.GLPAGE
      where 
     CTAcct LIKE '[0-9][0-9][0-9]-[0-9][0-9][0-9]-63020-4110%'
     OR
       CTAcct LIKE '[0-9][0-9][0-9]-[0-9][0-9][0-9]-63020-4115%'
      and GLYEAR = 2014
      and CTDESC = 'Sales'
      group by ctdesc
    The result set i get is 
    Sales                        
    -1455441.08
    And i verified that  CTAcct LIKE '[0-9][0-9][0-9]-[0-9][0-9][0-9]-63020-4115%'
    this second line of where clause has not desc as Sales.
    I am not sure whats causing the difference in the values.
    Can you please help me with this?
    Thanks

  • Using multiple select lists in ADF

    Hi,
    I am trying to use a multiple select list in my JSP page, and have a method in the ApplicationModule be called when the Struts action is called. I am following the example ADF tutorials, where the method is added to the ApplicationModule class, then dragged onto the Stuts Flow diagram (to associate it with an action).
    I am able to create a dyna form bean for the page that contains the multi select as a type "java.lang.String[]" (string array). I am able get that values that were selected in a normal action's "execute" method. For example:
    msf = (DynaActionForm) form;
    String[] statusSelection = (String[]) msf.get("multSelectList");
    However, I cannot seem to get the "multSelectList" values into a method in my Application Module class. The "multSelectList" is defined in my dynaFormBean as a String[] type. I am passing it in as an argument like the following....
    public void setParams(String multSelectList[]) {
    This results in the method not being called at all. I am not sure why. Does this have something to do with a String[] not being serializable??
    However, if I just attempt to pass other types form items to the method, it works. For example:
    public void setParams(String simpleCheckbox) {
    Does anyone know how to use multiple select lists in conjunction with ADF?
    P.S.
    my multSelectList looks something like this:
    <select name="multSelectList" multiple size="5">
    <option value="ALL">Select All</option>
    <option value="preferred">Preferred</option>
    <option value="standard">Standard</option>
    <option value="approved">Approved</option>
    <option value="interim">Interim</option>
    </select>

    I got this working by changing the signature of the Application Module method to use ArrayList rather than String[], then you can marshal the Struts FormBean contents into an ArrayList to pass up.
    To do this, subclass the DataAction by using "Go To Code" off of the context menu and then override the initializeMethodParameters() method:
      protected void initializeMethodParameters(DataActionContext actionContext, JUCtrlActionBinding actionBinding)
        //Get the String Array from the Form Bean
        String[] selection = (String[])((DynaActionForm)actionContext.getActionForm()).get("multiSelect");
        //convert that to an ArrayList
        ArrayList selectionArr = new ArrayList( Arrays.asList(selection));
        //Add that object to the Arg List for the AM method
        ArrayList params = new ArrayList();
        params.add(selectionArr);
        actionBinding.setParams(params);
      }

  • How to use a Formula Column in the main query?

    Hi All,
    I've tried to use a formula columns defined in some query in the condition of that query like this:
    where (:cf_ex - :cf_ex2) >= 5
    but when I run the report no data returned! Why? and how to use it the condition of the query?
    Note: I'm using Forms 6i

    where (:cf_ex - :cf_ex2) >= 5You cannot do that. Formula columns are not part of the select statement (which runs in the database), but are processed in the report.
    When you created this query, my guess is that you got the message "Note: the query Q1 has created the bind parameter(s) cf_ex, cf_ex2". Check these User Parameters in your data model. So, you are actually referencing user parameters in the query, not formula columns.
    I made a computations and things using PL/SQL that can't be done in the select statement in the data model!If it's pl/sql you can probably use that in your query. Create some database functions for cf_ex and cf_ex2 and use these in your query.

  • How to go for selective deletion if the request is rolled up???.. URGENT!!!

    hi all,
    we a have a data target which was compressed and rolled up...
    please do suggest us how to go for selective deletion  if the data target was rolled up???
    on what basis we need to do the selective deletion ??
    thanks for ur understanding...
    suggestions would be highly rewarded
    regards
    Prince

    Hi,
    in the subsequent datatargets of your ODS:
    if the requests are only rolled up, then you can delete those requests; now if your aggregates are collapsed then you'll have to dactivate them and reactivate them after. If not you can simply delete them.
    then delete all the requests from your ODS up to the request right after the missing one. This will deactivate you ODS delta init. This is not a problem since when you'll have finished with the above your ODS and subsequent targets will have a consistent status in terms of data.
    Reinit your ODS delta without datatransfer, reconstruct your missing request and the subsequent requests in your ODS.
    Reactivate them (not all together as a single activation, but separately).
    Then load the delta into your subsequent targets.
    Now if the subsequent datatargets are collapsed then you'll have to either reinit with full load or selective delete them. the missing request in your ODS still must be reloaded before!
    If you go for selective deletion you'll have to find the right selection criteria based on the data of your ODS. For instance if you can ensure that only a selected period is incorrect (all the ODS requests from the missing one to the last only contain data for JAN08) then you can selectively delete JAN08 from your subseq targets and perform a FULL load selecting JAN08 from your ODS.
    Then perform an INIT without data transfer... you can then continue your deltas as usual....
    hope this helps....
    Olivier.

  • Powerview "Add this to the Data Model" checkbox is greyed out.

    How can this checkbox "Add this to the Data Model" in the Import Data dialog box be made available and not greyed out?

    Hi Rufino,
    Data Model is a new approach for integrating data from multiple tables, effectively building a relational data source inside the Excel workbook. Within Excel, Data Models are used transparently, providing data used in PivotTables, PivotCharts, and Power
    View reports. between the data sources.
    In your scenario, it seems that you import data from Analysis Services database. However, this option is not available for Analysis Services database. So in you want to made this option, you can import data from relational database.
    Reference:Introduction to the Data Model and Relationships in Excel 2013
    Regards,
    Charlie Liao
    If you have any feedback on our support, please click
    here
    Charlie Liao
    TechNet Community Support

  • How to handle multiple selection in the Spark List control with checkbox as itemrenderer?

    Hi All,
    I am using checkbox as an ItemRenderer in spark list.
    I have a query.
    how to handle multiple selection in the Spark List control with checkbox as itemrenderer?
    how to retrieve the selected item label?
    Thank you in advance.

    Hi there, I'll tweak your code a little bit to something like this:
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    layout="vertical">
        <mx:Script>
            <![CDATA[
                 import mx.events.ListEvent;
                 import mx.controls.CheckBox;
               [Bindable]
               private var mySelectedIndexes:ArrayCollection=new ArrayCollection();
                private function onChange(e:ListEvent):void
                   if(CheckBox(e.itemRenderer).selected){
                             mySelectedIndexes.addItem(e.rowIndex);
                   }else{
                                  mySelectedIndexes.removeItemAt(mySelectedIndexes.getItemIndex(e.rowIndex));     
                   chkList.selectedIndices=mySelectedIndexes.toArray();
            ]]>
        </mx:Script>
    <mx:ArrayCollection id="collection">
            <mx:Object label="Test A"/>
            <mx:Object label="Test B"/>
            <mx:Object label="Test C"/>
            <mx:Object label="Test D"/>
            <mx:Object label="Test E"/>
            <mx:Object label="Test F"/>
            <mx:Object label="Test G"/>
        </mx:ArrayCollection>
    <mx:List id="chkList" dataProvider="{collection}" itemRenderer="mx.controls.CheckBox"  itemClick="onChange(event);" allowMultipleSelection="true"/>
    </mx:Application>

  • How to use multiple statements inside the "THEN" block of CASE statement?

    Below is the code:
    SET @strTempString = case @strKeyMode
    WHEN 'AUTO/CYCLE'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'CYCLE'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'COMMERCIAL'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'ISNAP'
    THEN  set @strFName = ltrim(rtrim((Left(dbo.CleanTheStringAdv(@strFName + '  ', 2) + '  ', 2))))
    '' + @strRefID + '|' + @strLName + '|' + @strFName + '|' + @strZIPorPolType
    WHEN 'ASNAP'
    THEN  @strRefID + '|' + @strRetID
    WHEN 'MOAT'
    THEN  @strRefID + '|' + @strRetID
    else '0'
    end 
    The first 3 conditions are understandable. How to use multiple statements in 4th case?
    Here I first want to set the value as:
    set @strFName = ltrim(rtrim((Left(dbo.CleanTheStringAdv(@strFName + '  ', 2) + '  ', 2))))
    and then return the string '' + @strRefID + '|' + @strLName + '|' + @strFName + '|' + @strZIPorPolType to @strTempString. 
    Please help me remove the syntax errors.
    Thanks in advance.

    Try below SQL
    DECLARE @strKeyMode varchar(20) = 'ISNAP'
    DECLARE @SQL VARCHAR(MAX)
    DECLARE @strRefID int=1
    DECLARE @strRetID INT=2
    --FIRST WAY
    IF @strKeyMode ='AUTO/CYCLE'
    SELECT CAST(@strRefID as varchar(10))
    ELSE IF @strKeyMode ='CYCLE'
    SELECT @sql = CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))
    ELSE IF @strKeyMode='ISNAP'
    SELECT @sql = CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))+'test'+'abc'
    ELSE
    SELECT @SQL='ABC'
    print @sql
    ----SECOND WAY
    SELECT @SQL = CASE @strKeyMode
    WHEN 'AUTO/CYCLE' THEN CAST(@strRefID as varchar(10))
    WHEN 'CYCLE' THEN CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))
    WHEN 'ISNAP' THEN CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))+'test'+'abc'
    ELSE 'No Record'
    END
    PRINT (@SQL)
    --Prashanth

  • How will i display the multiple select ids in the dashboard ?

    I have a form where there is a multiple select. When the form is submit, the ids for the multiple select is stored in the database as concatenate. For example, multiple select : 3,9,5,1.
    The ids of the multiple select is found in a table TABLE1 and the insertion is done in another table TABLE2.
    Now I have to display them in a dashboard.
    My question is how will i display the multiple select ids in the dashboard ?
    I have to do an innerjoin with TABLE1 to retrieve the names of the multiple select ids. I don't know how to do it because the column name for multiple select in TABLE2 is of type text and the column id in TABLE1 is of type int.
    Please help me solve this problem.
    Thanks in advance

    One general advice is, never store comma-delimited lists in the database. In fact, the reason is to avoid problems like the one you now face.
    The major suggestion here is to re-design your database. Make sure each selected item (for example 3, 9, 5 or 1) is stored in its own row.
    To solve the problem as it now stands, you could do something like
    <cfquery>
    select myItems
    from table2
    where id in (select id from table 1 where ...etc.)
    </cfquery>
    Then use ColdFusion's list functions to do what your dashboard requires you to do.

Maybe you are looking for

  • Problem with java and yahoo games

    hello everyone, i have a mac 10.6.8 with java SE 6 1.6.0_33-603-424 and i have problems with yahoo games.... anyone can help me please, i have a mac 10.6.8 with java SE 6 1.6.0_33-603-424 and i have problems with yahoo games.... anyone can help me pl

  • I can't open any files from Finder

    When I try  to open a file, an application, or also open Infromation window of a file or folder from Finder or from the Dock, it crashes, and the only way to open application is using Lauchpad. An information is that a few days ago the app Keychain a

  • Add XML Tag to XML File (Idoc to XML File)

    Hi there. Just a question regarding the addition of a tag header in an XML file please? Idoc - > XI -> file (XML File) We have a need to add something like this below in bold to XML Tag Header in the inbound file: <?xml version="1.0" encoding="UTF-8"

  • Updated iTunes and now will not open

    Just upgraded to iPhone 4 and in order to proceed with setup of phone, need to connect to iTunes.  I recently (within past few days), updated iTunes per software update received.  NOW, iTunes does not open at all.  I receive an error message that say

  • Explain change number in MM01

    hi can u explain the change number option in mm01 explain in steps thanks ganesh