SQL Query CASE statement using two fields

Hi,
I have two fields. One is called rescategory1, the other is called rescategory2.
I'm not sure if its a CASE statement I need or some sort of WHERE clause but I want to create a query that does the following or something similar:
CASE rescategory2
WHEN rescategory1 = '44' AND rescategory2 = '1' THEN 'Backup'
WHEN rescategory1 = '44' AND rescategory2 = '2' THEN 'Hardware'
END AS [Resolution Sub Category]
Basically, I'm looking to give rescategory2 a value based on that of rescategory1 and rescategory2 combined.
How do I write this?
Cheers
Paul

do you mean this?
rescategory2 = CASE
WHEN rescategory1 = '44' AND rescategory2 = '1' THEN 'Backup'
WHEN rescategory1 = '44' AND rescategory2 = '2' THEN 'Hardware'
END
ie assigning value for rescategory2
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • SQL Query - case statement

    HI Friends ,
    My Scenario in table data :
    EmpId       fromdate           todate                Billtype
    2              01-09-2014        09-09-2014         B
    3              01-09-2014         NULL                   B
    2              10-09-2014        NULL                    P
    4             01-09-2014        NULL                     U
    5             01-09-2014        15-09-2014           B
    5             16-09-2014        30-09-2014            U
    OutPut :
    EmpId    Status
    2     P
    3     B
    4    U
    5    P
    requirement : Need to develop this Sql Query ..Using the Case statement .
    Please Help
    thanks
    Rakesh

    Wonderfull Patrick......
    I executed the logic and returning the expected result .  Thanks a lot.
    But still need some more modification ......
    suppose an employee E7 has the following entry :
    E7    01-04-2014      20-06-2014       B
    E7    21-06-2014      Null                   P
    This means that the Employee E7 has Joined Project P1 in April First  on a Billed Project and worked till July 20th and then again Moved to a Partial Billing Project P3 and from that July Till working in that Project
    So as per logic , we are suppose to get the Status of the Employees in the previous Month.....logically means October......  so for the same E7  the Status would  be "P"...because from July he is working on a Partial Billed Project
    .....   If suppose E7 worked on an Unbilled Project from July .... then for the month of October ......the Status for the same  E7 would be "U"
    Soooo ......if Employee E8 made 2 transitions within a month take example of last month October .
    E7    01-04-2014      20-06-2014        B
    E7    21-06-2014      Null                    P
    E8    01-10-2014      20-10-2014       B
    E8    21-10-2014      23-10-2014       P
    E8    24-10-2014      Null/Empty         U
    so for this employee the Result for the November month will be  "P" but if i check in month of december ...... for the same the satus should be "U" because from the last October 24th he is working on a "UnBilled Project"
    Please Help ......!!!
    I think what you need is just a filter like below
    declare @FromDate datetime
    SET @FromDate ='20141001'
    SELECT EmpId,
    CASE WHEN MAX(Billtype) = 'B' THEN 'B'
    WHEN MIN(Billtype) = 'U' THEN 'U'
    ELSE 'P'
    END AS Status
    FROM table
    WHERE fromdate >= @FromDate
    OR (fromdate < @Fromdate
    AND (todate > @FromDate
    OR todate IS NULL))
    GROUP BY EmpId
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Error in CASE statement used in Reports query

    My query has lots of selection criteria. I'm trying to use CASE for that.
    This is a part of my query with parameters:
    AND ad.location IN (CASE &p_location
    WHEN 1 THEN
    (SELECT TRIM(code_nbr) FROM code_detail
    WHERE code_nbr like 'LC%')
    WHEN 2 THEN -- then the user can type in more than 1 locations
    &p_location1|| p_location2
    END)
    AND --- there are more conditions after this
    The query fails that invalid relational operator in this CASE statement.
    Any suggestions...is there any other way to do it...Thanks in advance

    I would recommend the use of lexical parameters in the before report trigger
    Set up a parameter SQL_WHERE - text, 4000 chars.
    In your datamodel get rid of the case statement and just put &SQL_WHERE
    In the before report trigger modify your case statement to be something like:
    &SQL_WHERE:=' and ad.location in ';
    case when :p_location = 1 then
    &SQL_WHERE:=&SQL_WHERE||' select trim(code_nbr) from code_detail etc';
    end
    This way you can debug and test your case statement in the pl/sql environment. Plus the query should run faster as you are moving the complex where statement into a separate part of the report

  • Grouping using report query / Case statement in toplink

    I have following tables
    1. Student with columns id, gender
    2. Subject_Score with columns id, student_id, subject_id, score
    To get scores grouped by subject, I am doing
    ExpressionBuilder subjScoreBuilder = new ExpressionBuilder();
    ReportQuery query = new ReportQuery(SubjectScore.class);
    query.addAverage("average-score",subjScoreBuilder.get("score"));
    query.addGrouping(subjScoreBuilder.get("subjectId"));
    Vector responses = (Vector) serverSession.executeQuery(query);
    Float score = (Float) queryResult.get("average-score");
    This works fine. It gives avg score per each subject
    Now i want both in one query
    A) avg score per subject
    B) avg score per subject per gender
    I want to achive this in one query
    I am doing like:
    ExpressionBuilder subjScoreBuilder =new ExpressionBuilder(SubjectScore.class);
    ExpressionBuilder studentExpBuilder = new ExpressionBuilder(Student.class);
    Expression expression = subjScoreBuilder.get("studentid").equal(studentExpBuilder.get("id")));
    ReportQuery query = new ReportQuery(SubjectScore.class, expression);
    query.addAverage("average-score", subjScoreBuilder.get("score"));
    query.addGrouping( subjScoreBuilder.get("subjectId"));
    query.addGrouping( studentExpBuilder.get("gender"));
    This gives me avg scor per each subject per gender. i.e.
    it applies grouping on both subjectId & gender.
    This is fine.
    But I also want avg score per each subject (group on subject only) in same query.
    1. How can we achive it?
    2. is there something like Case statement in toplink?      
    Thanks a lot for any help.

    I believe in SQL you would need two queries to do this directly, so you will need to issue two queries.
    You could select the Count and Avg, this would give you all the data need to compute the Avg yourself.
    i.e.
    (count(male) * avg(male) + count(female) * avg(female)) / (count(male) + count(female))

  • ReportViewer using SQL Query error states: Incorrect syntax near ','.

    Hello Community
        Using Visual Studio 2008 and SQL Server 2008 I created a Windows Application
    that uses SQL Server Reporting Services.  The application uses ReportViewer and
    calls a method written using SQL query.
                1-First I created the form.
                2-Next I dragged the ReportViewer (Toolbox) and Table (from DataSource) onto the form.
    The problem is that when it reaches the last line of the SQL query (ie, da.Fill(ds, "TableOne");)
    the code fails stating the error message:
                "Incorrect syntax near ','."
         The following is the code behind the form containing the query:
            private void ReportPgm1_Load(object sender, EventArgs e)
                // TODO: This line of code loads data into the 'ReportDBDataSet.TableOne' table. You can move, or remove it, as needed.
                this.TableOneTableAdapter.Fill(this.ReportDBDataSet.TableOne);  
                reportViewer1.ProcessingMode = ProcessingMode.Local;
                LocalReport ReportOneLocalReport = reportViewer1.LocalReport;
                DataSet ds = new DataSet("ReportDBDataSet.TableOne");
                pgmReportOne(FromDate, ToDate,   ds);
                ReportDataSource ds = new ReportDataSource("ReportDBDataSet.TableOne");
                ds.Value = dataset.Tables["TableOne"];
                ReportOneLocalReport.DataSources.Clear();
                ReportOneLocalReport.DataSources.Add(ds);
                this.reportViewer1.RefreshReport();
            private void pgmReportOne(DateTime FromDate, DateTime ToDate, DataSet ds)
                SqlConnection connection = new SqlConnection("Data Source=ReportDBServer;Initial Catalog=ReportDB;Uid=sa;pwd=Password");
                string sqlReportOne = "Select ([InDate], [FirstName], [LastName], [AGe]" +
                                   "from TableOne";
                SqlCommand command = new SqlCommand(sqlReportONe, connection);
                command.Parameters.Add(new SqlParameter("paramFDate", FromDate));
                command.Parameters.Add(new SqlParameter("paramTDate", ToDate));
                SqlDataAdapter da = new SqlDataAdapter(command);
                da.Fill(ds, "TableOne");
        Why does the last line throw an error?
        Thank you
        Shabeaut

    --NOTE: The statement below cannot be run on SQL Server 2012
    --If you have an earlier version and can set the compatibility
    --level to 80, it can be run.
    SELECT sso.SpecialOfferID, Description, DiscountPct, ProductID
    FROM Sales.SpecialOffer sso,
    Sales.SpecialOfferProduct ssop
    WHERE sso.SpecialOfferID *= ssop.SpecialOfferID
    AND sso.SpecialOfferID != 1
    Hi Scott
    The *= is old syntax and not compatible with SQL Server 2012 (as stated in the comments). 
    You could do something like this instead
    SELECT sso.SpecialOfferID
    ,Description
    ,DiscountPct
    ,ProductID
    FROM Sales.SpecialOffer sso
    left outer join Sales.SpecialOfferProduct ssop on sso.SpecialOfferID = ssop.SpecialOfferID
    WHERE sso.SpecialOfferID != 1

  • SQL QUERY updateable report with APEX_ITEM fields to update hidden columns

    Here is my SQL query:
    select
    "EMPLOYEE_ID",
    "PUBLICATION_ID",
    "TITLE",
    '<NOBR>1. ' || APEX_ITEM.TEXT(101,CODE1,2,3) || '  ' ||
    APEX_ITEM.TEXT(102,CODE1_PCT,2,3) || ' %</NOBR><BR>' ||
    '<NOBR>2. ' || APEX_ITEM.TEXT(103,CODE2,2,3) || '  ' ||
    APEX_ITEM.TEXT(104,CODE2_PCT,2,3) || ' %</NOBR><BR>' ||
    '<NOBR>3. ' || APEX_ITEM.TEXT(105,CODE3,2,3) || '  ' ||
    APEX_ITEM.TEXT(106,CODE3_PCT,2,3) || ' %</NOBR>' rfcd_codes,
    APEX_ITEM.DISPLAY_AND_SAVE(100,CODE1) hidden_rfcd1,
    mycomments
    from "#OWNER#".mytable
    I have 3 code fields with their percentages (_pct). I have concatinated them so I can format them nicely on the page.
    I have create a process 'on-submit and before computations and validations' where I was hoping to assign my table columns (eg the code and pct columns) from the APEXITEMs in my select statement.
    I can get the values from these (APEX_ITEM) fields by referencing APEX_APPLICATION.G_F10(i) etc.... so thats cool.
    But my problem is how do I reference the table columns so I can assign them.
    I am using a 'Multi Row Update' process to perform the update to the database.
    P.S. mycomments column is working fine. It gets updated nicely but its just those other APEX_ITEM fields.

    I don't have the apex_application.g_f01(i) referenced in the page source...In the page source you wouldn't find anything by that name
    Identify the tabular form's checkbox column in the page(firebug/chrome developer panel makes this easy)
    It should be like
    &lt;input id=&quot;...&quot; value=&quot;&quot; type=&quot;checkbox&quot; name=&quot;fXX&quot; &gt;we are interested in the name attribute , get that number (between 01 and 50)
    Replace that number in the code, for instance if it was f05 , the code would use
    apex_application.g_f05
    --i'th checked record' primary keyWhen you loop through a checkbox array, it only contains the rows which are checked and it is common practice to returns the record's primary key as the value of the checkbox(available as the the i'th array index as apex_application.g_f05(i) , where i is sequence position of the checked row) so that you can identify the record.

  • Kodo 3.4.1: how to limit # of sql query params when using collection param

    Hi,
    We have a problem when using Kodo 3.4.1 against SQL Server 2005, when we execute query:
              Query query = pm.newQuery( extent, "IdList.contains( this )" );
              query.declareParameters( "Collection IdList" );
              query.declareImports( "import java.util.Collection;" );
              return (List) query.execute( list );
    We got:
    com.microsoft.sqlserver.jdbc.SQLServerException: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Too many parameters were provided in this RPC request. The maximum is 2100.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(Unknown Source)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)
    at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:354)
    at com.solarmetric.jdbc.PoolConnection$PoolPreparedStatement.executeQuery(PoolConnection.java:341)
    at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:352)
    at com.solarmetric.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:1106)
    at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:352)
    at kodo.jdbc.runtime.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1730)
    at com.solarmetric.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:339)
    at kodo.jdbc.sql.Select.execute(Select.java:1581)
    at kodo.jdbc.sql.Select.execute(Select.java:1533)
    at kodo.jdbc.runtime.SelectResultObjectProvider.open(SelectResultObjectProvider.java:102)
    at com.solarmetric.rop.EagerResultList.<init>(EagerResultList.java:22)
    at kodo.query.AbstractQuery.execute(AbstractQuery.java:1081)
    at kodo.query.AbstractQuery.executeWithArray(AbstractQuery.java:836)
    at kodo.query.AbstractQuery.execute(AbstractQuery.java:799)
    It seems that there're too many ids in the list, and Kodo didn't limit the # of sql parameters when craft the sql query. Is there a way to ask Kodo to use multiple queries with smaller # of sql parameters instead of using one big sql query?
    Thanks

    Hi,
    Sadly, there is no way to do that in Kodo currently. The closest is the inClauseLimit DBDictionary setting, but that setting just breaks things up into multiple IN statements put together with an OR clause. In your case, it looks like the network transport, not the SQL parser, is complaining about size limits.
    You could force the query to run in-memory, but that would probably be prohibitively slow, unless the data set that you're querying against is relatively small.
    -Patrick

  • SQL query requested to pull one field out of multiple records

    Post Author: ralph.devlin
    CA Forum: Data Connectivity and SQL
    We use Track IT to manage our ticket base. We have parent work orders and child assignments that I am trying to report on. What I want to do is create a view, or even if this can be done in a formula, is pull data from the main work order, which in our scnerio and accorindg to the database diagrapm is WORKORDERTYPEID = 0, It will pull the TASKS.RESPONS field from that WO. Then it will compare the TASKS.PARETNWOID to WOID and if WORKORDERTYPEID = 1 then it needs to return the TASKS/RESPONS field of that record, and there may be three records or so. Then What I may need it to do is organize it maybe into seperate columns so I can add each one to Crystal keeping in mind that it will need to link those records to main WOID of the parent so it will display on one line. Any ideas
    Ralph

    Post Author: ralph.devlin
    CA Forum: Data Connectivity and SQL
    Ok I tried that and it seemed to work fine, here is an aexample of the data returned
    168458
    Lane, Carrie
    Ralph Devlin
    Ralph Devlin
    168458
    PHX - Training Room
    SM - 8th Fl Conf Room
    NULL
    NULL
    168458
    6/20/2008 3:30:00 PM
    Video Conference
    0
    168458
    Lane, Carrie
    Ralph Devlin
    Luis Estrada
    168458
    PHX - Training Room
    SM - 8th Fl Conf Room
    NULL
    NULL
    168458
    6/20/2008 3:30:00 PM
    Video Conference
    1
    Using the last column which is the workordertypeid, I was able to elimate the first row of data, which is the parent work order, but see how it is returning the technician name twice, where the second row returns me as the primary and then the technician on the assignment WO as well, which I want. In Crystal I have it only selecting the rows with the 1 is the last column, since those rows have the data arranged how I want them to be.
    Once issue that just arose, is what if we only had one work order that we wanted to report on in the subreport. since the WO will get a 0 in the last column, it will never be selected in the report. Is there a way to either us a statement that selects it if it is the only WO listed compared by the WOID field, or if there is a way in SQL, to get what is showing in row 2 to be the only row returned back so I can then show all work orders regardless if they are an assignment
    Here is my current SQL query
    SELECT     T1.WOID, T1.REQUEST, T1.RESPONS, T2.RESPONS AS Addtech, T2.PARENTWOID, T1.LOOKUP2, T1.TaskLookup3, T1.TaskLookup4, T1.TaskLookup5,                       T1.WO_NUM, T1.DUEDATE, T1.WOTYPE3, T2.WorkOrderTypeIdFROM         dbo.TASKS AS T1 LEFT OUTER JOIN                      dbo.TASKS AS T2 ON T2.PARENTWOID = T1.WOID

  • Returning 25th to 40th result of SQL query, do I use a cursor?

    I have a complex SQL query that returns ALL the results I am looking for. I would to be able to only return the Nth to Nth result, like just the 50th to 70th record counts (assuming there is a sort by in the statement so it always returns in the same order.)
    I thought of using a cursor and checking %ROWCOUNT and only returning the proper rows, but that seemed like it would be inefficient. I could do the same on my front end (PHP 4.0.6) relatively easily, but that would be a really inefficient way to retrieve 20 records from a query with 1000+ records returned.

    Thanks, the links were helpful.
    Since rowcount ignores my order by clause, I have attempted to find ways to overcome this. I have tried using the rowcount method by recreating my tables as index-orginized with an index on the column that I need to be ordered by. As a result of this, I have come accross two problems.
    1. then index does not seem to update the order when I update the column. The column being indexed is a date type. The values added are usually sysdate, so although new elements are added properly, updating old ones does not change their index position.
    2. I really need to access the items from most recent to oldest, thus desc. Since I am returning by rowcount, this makes it difficult. The following SQL is the best I can come up with and requires the output to be looped in reverse for display in the correct order:
    select postid, subject, to_char(lastmod, 'Month FMDD, YYYY HH')||':'||to_char(lastmod, 'MIam'), name from (select t.postid, t.subject, t.lastmod, r.name, rownum ro from forumtopic t, forumrooms r where t.roomid = '1000668' and t.roomid = r.roomid and r.useraccess = '1') where ro between ((select count(*) from forumtopic subt where subt.roomid = '1000668')-40) and ((select count(*) from forumtopic subt where subt.roomid = '1000668')-25);

  • Passing a string into an SQL query IN statement

    Hello,
    I need to connect to a database to pull some data to dynamically create a form based on the data I pull back. My SQL query works fine when I manually run it through a SQL client tool, but when I try to pass it through my workflow I'm having trouble with passing my string into the IN part of the statement. So if for example my SQL query is:
    SELECT Field1, Field2, Field3 FROM Table1 WHERE Field4 IN (?)
    I have a process variable that has the string I'm trying to pass into the ?, but I don't seem to be able to get the query to run. I have tried setting up my query to run as a Parameterized Query (passing my string process variable into the ?), and by setting the query up through xPath (where I am calling my process variable with an xPath declaration), but am not having any luck.
    The process variable I am trying to pass is formatted such that I'm passing 'Value1','Value2','Value3' but I can reformat this string if need be. Even with using test data I can't get the query to return anything. For test data I have tried: 'Value1','Value2','Value3' ; Value1','Value2','Value3 ; Value1,Value2,Value3 but the query never returns any data. I can't seem to see how to format the string to pass into the query. The Query will work with a single Value in the test data, but as soon as I try to pass multiple values within the string it fails. Any suggestions?

    The problem looks to be a limit on what I can pass into the SQL query component. My string is coming from data returned from another database. I take the xml output from that database call, pass it through a set variable component to remove my xml tags from the string, and then format the string in a script component (I have to do it this way because of the way the data coming out of my first database call). I've put in loggers, and can see that the string I'm passing into my query that is giving me problems, is formatted the same way as if I were to use the concat function Scott listed above. It looks like there is a limitation on what can be passed in my variable. I have tried creating my entire SQL query statement in a set variable component, and then just calling the process variable that holds that statement, but there is a character limit of 128 character for what can be passed in a variable through xpath in the SQL query component.
    The next thing I tried was changing my SQL where clause. Instead of passing my variable directly into the IN statement I set up a PATINDEX('%:'+countyname+ ':%', ?) > 0 call to check for the values in my database call. As you can see I took out the "," that I was passing as part of my string, thinking that the SQL component was getting confused by them, and placed ":" characters around my values being passed in my string variable. No matter what I try to do though I'm not able to get the query to run. The component looks like it is taking my string, and is seeing the whole thing as a string instead of passing it as individual values within a string.
    I think I'm getting close, but I keep getting a Content not allowed in prolog exception in the server logs.

  • Sql query not executed using recordset

    Hi All,
    I am trying to first format and then execute SQL query statement using recordset object with DI API. the issue is with vb.net's string formatting. I want to use 'USE [DB_Name]' statement in SQL and then 'Alter Procedure ..' statement. as this has to be the first statement in sql , I am using 'GO' in between and seperating each sentence with following syntax.
      Dim AltProc  as string
      AltProc = " USE [DB_name]" & Environment.NewLine
      AltProc = AltProc & " GO " &  Environment.NewLine
      AltProc = AltProc & " ALTER proc [proc_name] " &  Environment.NewLine
    '---------------------and so on
    Orec.DoQuery(AltProc)
    this formatting does not recognize new line and gives 'incorrect syntax near 'Go'' error.  strange thing is, if I take this query in SQL, it runs perfectly and I can see it getting formatted with each new line created. I tried even VbcrLf but it didnt work.
    any one has any idea?
    thanks in advance,
    Binita

    HI Binita
    The reason:
    GO is the "command" delimiter of MS Query Editor.
    It is not working with RecordSet Object.
    In MS SQL 2008 version you can define the schema before the procedure name but in SQL server 2000/2005 it is not possible.
    IN SQL 2008 use the Fully Qualified name instead of GO:
    Dim AltProc  as string
      AltProc = " ALTER proc [DB_name].[dbo].[proc_name] "  + vbcrlf
    '---------------------and so on
    Orec.DoQuery(AltProc)
    it is not working on MS SQL 2008 i have tried.
    'CREATE/ALTER PROCEDURE' does not allow specifying the database name as a prefix to the object name.'
    Regards,
    J.
    Edited by: Janos  Nagy on Jun 22, 2009 2:55 PM

  • Sql query - been trying for two days

    Hi guys im trying to carry out an sql query
    Im using a left join to do a query, which gives me a set of results:
    select COURSESTUDENT.StudentNo, COURSESTUDENT.CourseCode, COURSESTUDENT.Year, MARKS.ExamMark, MARKS.EntryNo FROM COURSESTUDENT LEFT JOIN MARKS ON COURSESTUDENT.StudentNo=MARKS.StudentNo AND COURSESTUDENT.CourseCode=MARKS.CourseCode AND COURSESTUDENT.Year=MARKS.Year
    but I would like to do a select on this result but do not want to use a create view as if more than one person access this page at a time then if the servlet tries to create the view an error will occur.
    I would like to do the following select statement on the results of the query above..
    select * from (above) where CourseCode='ELE304' AND Year=1999;
    Is this possible, im using postgres..
    Please help......
    thanks
    tzaf

    just add "where ..." to the end of the first query.

  • Dynamically change sql query (from statement)

    Hi all,
    Is it possible to change the 'from statement' dynamically in
    report 6i? I have 3 identical tables with different names (each
    to collect data in different area) and I want to be able to
    dynamically change the sql query at run time so I can use only
    one (1) report to print data in 3 different tables.
    Is it possible? Thanks for the tip!

    Yes you can. Create a user parameter lets say "frm". give the
    initial value for the parameter as the table a. Ex : FROM EMP .
    Go to the datamodel of the report . Change the query like this,
    Original query => Select * from emp
    Modified query => Select * &frm
    Coz frm has the default value FROM EMP, so it will replace the
    default value. When you call the report from differrent product
    you can pass the parameter value as table a, table b , table x.
    Hope you got your answer.
    Thanx
    Feroz

  • How to use two "field separator" in the same Comunication Channel

    Hi experts,
    I  upload flat files with XI, and my Comunication Channel is configured to use the field separator "~".
    FILA.fieldSeparator     ~
    Is posible to configure that Comunication Channel to accept two field separator. I want that upload flat files that has as separator "~" and flat files that has "|" .
    thanks
    regards

    IT IS not possible to have 2 fieldseparator to identify the fields of a record.

  • SQL Query to fetch a specific field in xml

    Hi,
    Below is my sample Xml file.
    <?xml version = "1.0" encoding = "UTF-8"?>
    <methodCall xmlns = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd Schema_new.xsd">
    <methodName>rBatchFile </methodName>
    <params>
    <param>
    <value>
    <struct>
    <member>
    <name>filename</name>
         <value>
         D:\test.txt
         </value>
    </member>
    <member>
    <name>batchId</name>
    <value>
         L1
    </value>
    </member>
    </struct>
    </value>
    </param>
    </methodName>
    </methodCall>
    I want to query a "value" field based on the "name" field. I tried with the following query which didnt work.
    SELECT a.extract('//value/text()' , 'xmlns:="http://www.tibco.com/schemas/CS4_new1/Schema.xsd" ')
    FROM ( SELECT t.customerinfo.extract('//member[name="filename"]','xmlns:="http://www.tibco.com/schemas/CS4_new1/Schema.xsd" ')
    FROM cust_order t ) a;
    Please do provide the SQL query ASAP.

    with tab as (
    select xmltype('<?xml version = "1.0" encoding = "UTF-8"?>
    <methodCall xmlns = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd Schema_new.xsd">
    <methodName>rBatchFile </methodName><params>
    <param>
    <value>
    <struct>
    <member>
    <name>filename</name>
    <value>
    D:\test.txt
    </value>
    </member>
    <member>
    <name>batchId</name>
    <value>
    L1
    </value>
    </member>
    </struct>
    </value>
    </param>
    </params>
    </methodCall>
    ') a from dual
    --end of sample data
    SELECT
      extractvalue(column_value,'/member/name') name,
      extractvalue(column_value,'/member/value') value
    from tab t,xmltable('xmlns = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd Schema_new.xsd"','for $i in //member return $i' passing t.a)An example...but i tweaked the xml...check the xml namespace once before executing...
    without adding the namespaces...code will be like...
    with tab as (
    select xmltype('<?xml version = "1.0" encoding = "UTF-8"?>
    <methodCall >
    <methodName>rBatchFile </methodName><params>
    <param>
    <value>
    <struct>
    <member>
    <name>filename</name>
    <value>
    D:\test.txt
    </value>
    </member>
    <member>
    <name>batchId</name>
    <value>
    L1
    </value>
    </member>
    </struct>
    </value>
    </param>
    </params>
    </methodCall>
    ') a from dual
    --end of sample data
    SELECT
      extractvalue(column_value,'/member/name') name,
      extractvalue(column_value,'/member/value') value
    from tab t,xmltable('for $i in //member return $i' passing t.a)Ravi Kumar

Maybe you are looking for

  • Is there any way to keep the old mail, phone, calendar format and yet switch to IOS7?

    Is there anyway to keep our old mail, calendar, and phone format and yet use IOS7?  I find the new system so plain that it is difficult to see.  I keep missing new emails because the little numbers are so small they barely show up and the plain white

  • Detecting the current tab page

    Hello All, I am working on a task for our current project which requires that I correctly identify the current tab page selected on the user's page. Toward that, I was passed some information about the function: wwpob_api_page function get_selected_t

  • How to migrate from existing Database Usermanagement to Active Directory?

    Hello experts, we are running a portal with more than 2000 users. So far our user management is done by the portal´s own identity management with the database as data source. However for many reasons instead of the database we would like to use an ex

  • LSMW: Profit center using BO BUS0015

    Hi All, I am using the BO BUS0015 to create profit center. Idocs are posted successfully, when in partner profile i m chosing <b>Trigger by Background program</b> However when i using Trigger Immediately its giving an erro message : <b>Event for star

  • Why doesnt my volume work but my ringer does?

    Today from a minute to another my volume just stopped working,but meanwhile my ringer still works,what should i do?