SQL Case Statement Problem with Maxdb

Hello,
I'm running a J2E application on Netweaver AS. I have on problem that I just cannot figure out.
The statement works in SQL Studio but when I try to code it it does not work at all.
select COLA, SUM(CASE WHEN COLB=10 THEN 1 ELSE 0 END) from TABLE group by COLA
When executed as statement in Java I get:
Error [javax.servlet.ServletException: java.lang.IllegalStateException: illegal stack size: 4
contents:
com.sap.sql.tree.SelectStatement
com.sap.sql.tree.IntegerLiteral
com.sap.sql.tree.IntegerLiteral
com.sap.sql.tree.ComparisonPredicate], with root cause [java.lang.Exception: java.lang.IllegalStateException: illegal stack size: 4
contents:
com.sap.sql.tree.SelectStatement
com.sap.sql.tree.IntegerLiteral
com.sap.sql.tree.IntegerLiteral
com.sap.sql.tree.ComparisonPredicate].
Any thoughts on that? Thanks!
Edited by: MD on Feb 18, 2009 7:37 PM

Hi MD,
with SQL Studio you mean you work with MaxDB?
Are you sure you're working directly on MaxDB and not with OpenSQL? (That's different!)
If you want the first, try setting SQL type "vendor" or "native sql". In such case you have to define a new custom datasource through configuration. How that works depends on the version you are using.
Try to find out what the actual error message is. The stack trace is not enough. There should be more.
Regards,
Benny

Similar Messages

  • SQL CASE statement in XML template- End tag does not match start tag 'group

    Hi All,
    I am developing a report that has the SQL CASE statement in the query. I am trying to load this into RTF with report wizard and it gives me below error
    oracle.xml.parser.v2.XMLParseException: End tag does not match start tag 'group'
    Does XML publisher support CASE statement?
    My query is something like this
    SELECT customercode,
    SUM(CASE WHEN invoicedate >= current date - 30 days
    THEN balanceforward ELSE 0 END) AS "0-30",
    SUM(CASE WHEN invoicedate BETWEEN current date - 60 days
    AND current date - 31 days
    THEN balanceforward ELSE 0 END) AS "31-60",
    SUM(CASE WHEN invoicedate < current date - 60 days
    THEN balanceforward ELSE 0 END) AS "61>",
    SUM(balanceforward) AS total_outstanding
    FROM MyTable
    GROUP BY customercode
    ORDER BY total_outstanding DESC
    Please advice if the CASE statement or the double quotes are causing this error
    Thanks,
    PP

    I got this to work in the XML but the data is returning zeros for all the case statements. When I run this in toad I get results for all the case conditions but when ran in XML the data displayed is all zeros. I am not sure what I am missing. Can someone shed some light on this please
    Thanks!
    PP

  • Update with case statement problem.

    Hi,
    I have this statement
    update tab_tr set col_rate =
      case
      when col_ern_type in ('031','035','036') then (1.5 * col_rate)
      when col_ern_type in ('041','045','046') then (2 * col_rate)
    end;this statement updated some 2 million rows in the table tab_tr. But the total count of rows for col_ern_type in ('031','035','036', '041','045','046') yeild only around 222642 rows.
    select count(*) from tab_tr where col_ern_type in ('031','035','036', '041','045','046');  --> 222642 rowswhat is the problem with the above update statement.
    Thank you,

    Hi,
    DBA_1976 wrote:
    ... I thought the case statement conditions are counted as the where condition. But ......A CASE expression just takes the place of some other expression, such as a literal, a function, or a column.
    For example, which rows do you think this should update?
    UPDATE  tab_tr
    SET     col_rate  = 100;It would update all rows, of course.
    How about this statement?
    UPDATE  tab_tr
    SET     col_rate  = column_x;Will it only change the rows where column_x are a certain value, or not NULL, or in any way depend on column_x? No, of course not. It will update all rows.
    How about this statement?
    UPDATE  tab_tr
    SET     col_rate  = function_y (col_ern_type);Will it only change the rows where the fucntion returns a certain value? Will it depend on the value in col_ern_type? No, of course not. It calls the function for each row, and whatever the function returns (even if the function returns NULL), that's what goes into col_rate on each row.
    A CASE expression is just something that you can substitute in place of any other expression, such as the literal 100, or the column column_x, or the function function_y in the statements above. Naturally, the value that gets put into col_rate will depend on what the CASE expression returns, but the behavior of the UPDATE statement as a whole will not.

  • Can CR 2008 with XML ODBC driver using SQL CASE statement?

    Hi:
    when i use SQL Command to provide data to the report from XML file connection. I can not use CASE statement , CR always has error message about "CASE" word.
    I test the same Statement in SQL client connected to Oracle, it runs fine.
    So.. Is it driver's limitation that XML datasource can not use CASE statement inside SQL command window?
    Thanks anyone's reply in advance.
    Johnnychi

    Hi Johnny,
    CR supports what every the ODBC driver supports. The error you are getting is from the XML driver, CR is just passing it through.
    Try using an ODBC to XML driver and then a stand-alone ODBC test tool to see if your SQL works.
    If not you'll have to find another way to use the CASE statement.
    Thank you
    Don

  • Sql case statement with link not opening new window

    Apex 4.2
    I am writing a query that has a case statement. I need the case statement to open up a new window, not a new tab. I have the following:
    SELECT
    case when SCHED_ID = 1 then
    '<a href="javascript:popupURL(''http://www.google.com'')">LINK</a>'
    end as MyLink
    FROM Table_Name
    When I plug this into a a column link in the URL field under a page item or report item, then a popup window appears. However, inside the query I am getting a new tab.
    ANy help on this matter would be great. Thanks in advance.

    Hi,
    Try adding a target attribute to you link:
    '<a href="javascript:popupURL(''http://www.google.com'')" target="_blank">LINK</a>' 
    Regards,
    Vincent

  • PL/SQL - Case Statement

    Hello, just starting to learn PL/SQL. I have a query which runs just fine and it has a case statement. When I take that query and place it into a procedure and compile, it gives me a compile error stating "ENCOUNTERED symbol CASE when expecting... providing a list of symbols.
    This procedure is part of a package, so I am only showing the procedure portion...
    PROCEDURE QRY_USERS (oRows                     OUT t_cursor)
    IS
    BEGIN
         OPEN o_Rows FOR
         select ou.User_id,
                   ou.AD_Login_ID,
                   ou.First_name,
                   ou.Last_Name,
         oct.CODE_DESC,
                   case when ou.deleted is null then 'N'
                   else 'Y' end Deleted
         from tst_ops_users ou, tst_ops_code_tbl oct
         where oct.CODE_TYPE ='USER_TYPE'
              and oct.code_name = ou.USER_ROLE_TYPE;
    END QRY_USERS;
    So is there some different syntax with case statements or is there some other erro causing this?
    Thanks a bunch for your assistance!!!

    Which version of the database are you working on? In 8i the PL/SQL engine did not support the use of CASE in SQL statements (along with a whole bunch of other fresh additions to SQL syntax).
    If that is your problem you could try this, which ought to use the SQL engine instead...
    PROCEDURE QRY_USERS (oRows OUT t_cursor)
    IS
    BEGIN
    OPEN oRows FOR
    'select ou.User_id,
    ou.AD_Login_ID,
    ou.First_name,
    ou.Last_Name,
    oct.CODE_DESC,
    case when ou.deleted is null then ''N''
    else ''Y'' end Deleted
    from tst_ops_users ou, tst_ops_code_tbl oct
    where oct.CODE_TYPE =''USER_TYPE''
    and oct.code_name = ou.USER_ROLE_TYPE';
    END QRY_USERS;although you can obviate the need for CASE by using either DECODE or NVL2...
    nvl2(ou.deleted , 'Y', 'N') AS deletedCheers, APC

  • SQL Case Statement

    Hi,
    could you please advise how to add below New case to below Main case
    New case:
    when (convert(varchar,date,101) >= '01/01/2014' OR qtr >= '14Q1') then
    case when PP='ABC' and pl='EFG' then Revenue*.552
    else 0 end
    Main case:
    SUM(
    case
    when ((convert(varchar,date,101)>= '09/19/2013' and qtr = '13Q3') OR qtr >= '13Q4') then
    case when PP='ABC' and pl='EFG' then Revenue*.542
    else 0 end
    when (convert(varchar,date,101) < '09/19/2013' OR qtr < '13Q3') then
    case when PP='ABC' and pl='EFG' then Revenue*.501
    else 0 end
    else 0 end) revenue,

    There is no CASE statement in SQL; we have CASE expression. AND you got the syntax wrong. SQL uses the ISO-8601 date format; it is one of the most basic ISO Standards on Earth AND you should know it. But worse than that, you are still using the 1970's
    Sybase CONVERT string function! NO! Did you know that DATE is a reserved word in SQL AND cannot be a column name? 
    When we design a code for temporal units like Quarters, we follow the ISO-8601 as closely as possible. That means a full four-digit year. 
    Since you were rude AND did post DDL, I will guess that your improper “date” is a TIMESTAMP (aka DATETIME or DATETIME2(n) in Microsoft dialect). 
    >> could you please advise how to add below New CASE to below Main CASE <<
    I never heard the term “main CASE”, even when I voted on this feature. Can you explain it to me and show where I missed it? 
    The quarters are temporal computations; we would not put them in a base table, but a good SQL programmer would use a VIEW with a join to a report period table.   
    CASE WHEN CAST (foobar_timestamp AS DATE) >= '2014-01-01'
           OR foobar_qtr > = '2014Q1'
         THEN CASE WHEN pp = 'ABC' 
                   AND pl = 'EFG'
              THEN something_revenue * 0.552
              ELSE 0.000 END;
    I will assume that pl and pp well-understood terms in your industry and not improper data element names. Why did you nest CASE expressions? Let me answer that: you think that CASE is IF-THEN-ELSE statements! 
    Did you notice that an event during '2014Q1' is always BETWEEN '2014-01-01' AND '2014-03-31'? So this is redundant! 
    A minor point, it is good idea to use a leading zeroes and decimal zeroes to show the guy maintaining code what he is working with. It also helps the compiler avoid casting. Your expression also has no name. 
    CASE WHEN CAST (foobar_timestamp AS DATE) > = '2014-01-01'
     AND pp = 'ABC' 
     AND pl = 'EFG'
     THEN something_revenue * 0.552
     ELSE 0.00 END AS nameless_floob;
    I am afraid that you might have re-discovered the Algol-60 dangling ELSE problem. As with Algol-60, the ELSE in SQL associates with the nearest CASE. Not with the outermost CASE. 
    Your expression ought to have this skeleton: 
    SUM(CASE WHEN ??? 
             THEN something_revenue * 0.542
             WHEN ??? 
             THEN something_revenue * 0.501
             WHEN ???
             THEN something_revenue * 0.552
             ELSE 0.000 END)
     AS something_revenue_tot
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • T-sql case statement in a select

    When I execute the following t-sql 2012 statement, the "NO Prod' value is not
    being displayed from the sql listed below:
    SELECT DISTINCT
    IsNull(cs.TYPE,'') as type,
    CASE IsNull(Course.TYPE,'')
    WHEN 'AP' then 'AP Prod'
    WHEN 'IB' then 'IB Prod'
    WHEN 'HR' then 'HR Prod'
    WHEN '' then 'NO Prod'
    END AS label
    FROM CustSection cs
    INNER JOIN dbo.Person p on P.personID = cs.personID
    Left join customCustomer cs564 on cs564.personID = p.personID and
    cs564.attributeID ='564'
       where ( cs.type is null and cs564.attributeID = null)    
         or
        (cs.type IN ('HR','AP') OR
          (cs.type='IB' AND SUBSTRING(cs.code,1,1)='3'))  
    ORDER BY label
    What I want is for 'NO Prod' to be displayed when
    cs.type is null and cs564.attributeId  is null.
    Thus can you tell me how to fix query above so the 'NO Prod'  value is displayed in the
    select statement listed above?

    There is no CASE statement in SQL; we have a CASE expression. We do not use the old 1970's Sybase*- ISNULL(); we have  COALESCE().
    There is no such thing as a magic generic “type” in RDBMS. There is no such thing as a generic “code” in RDBMS. They have to to be “<something in particular>_type” and “<something in particular>_code” in a valid data model. How about blood_type
    and postal_code?? 
    There is no such thing as a generic “person” table in RDBMS. First of all, do you really have only one person, as you said?? But the important point is that these persons play a role in the data model – customers, students, etc. You are doing the wrong thing
    and doing it badly.  This table should not exist any more than a  table of “Things” such exist. 
    And the reason you are beyond any real help is “attribute_id” which tell us that your schema is a total disaster of data and meta data mixed together in a non-RDBMS written in awful SQL. Based on cleaning up bad SQL for 30 years, it looks like you are an OO
    programmer who never unlearned his prior mindset. 
    Why did you allow an encoding schema with blanks? Why do you have so many NULL-able columns? 
    SELECT DISTINCT is very rare in a properly designed schema. The DRI references assure that rows cam be matched. To get you started, look at this skeleton:
    CREATE TABLE Products
    (product_gtin CHAR(15) NOT NULL PRIMARY KEY, 
     product_type CHAR(2) DEFAULT 'XX' NOT NULL
      CHECK (product_type IN ('AP', 'IB', 'HR', 'XX'))
    The table name is a plural noun because it models a set (NOT an OO class).
    The GTIN is an industry standard identifiers, and not have to invent our own.
    The product_type (not blood_type, not automobile_body_type!) has a constraint that assures it is never NULL and never blank; I invented 'XX' as a default. 
    You need more help than you can get in a forum, but if you will follow Netiquette and post the DDL, we can get you started.
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Case Statement problem

    Hi All,
    I am trying to come up with a case statement for the below provided sql but i am not able to do that can you guys help me out
    (SELECT NO_OF_DAYS.id_person
    FROM NO_OF_DAYS
    WHERE NO_OF_DAYS.STATUS = 'Y'
    AND NO_OF_DAYS.ID_PERSON = PERSON.ID_PERSON
    HAVING (SUM( NO_OF_DAYS.DT_STAT_END
    - NO_OF_DAYS.DT_STAT_START)) > 180)
    the case statement i am trying to come up with is if the person status start - end date is greater than 180 days then 'y' else 'n' end

    Hi.
    If you have two tables: NO_OF_DAYS and PERSON and PERSON is a parent table of NO_OF_DAYS this could work:
    WITH NO_OF_DAYS AS
         SELECT 1 id_person,TO_DATE('2012-01-01','YYYY-MM-DD') DT_STAT_START, TO_DATE('2012-01-31','YYYY-MM-DD') DT_STAT_END,'Y' status FROM dual UNION
         SELECT 1 id_person,TO_DATE('2012-02-01','YYYY-MM-DD') DT_STAT_START, TO_DATE('2012-02-20','YYYY-MM-DD') DT_STAT_END,'Y' status FROM dual UNION
         SELECT 2 id_person,TO_DATE('2012-01-01','YYYY-MM-DD') DT_STAT_START, TO_DATE('2012-03-31','YYYY-MM-DD') DT_STAT_END,'Y' status FROM dual UNION
         SELECT 2 id_person,TO_DATE('2012-04-01','YYYY-MM-DD') DT_STAT_START, TO_DATE('2012-10-01','YYYY-MM-DD') DT_STAT_END,'Y' status FROM dual
    PERSON AS
         SELECT 1 id_person FROM DUAL UNION
         SELECT 2 id_person FROM DUAL
    SELECT
         NO_OF_DAYS.id_person,
         CASE WHEN (SUM(NO_OF_DAYS.DT_STAT_END- NO_OF_DAYS.DT_STAT_START)) > 180 THEN 'Y'
              ELSE 'N'
         END y_n
    FROM
         NO_OF_DAYS,
         PERSON
    WHERE
         NO_OF_DAYS.ID_PERSON = PERSON.ID_PERSON AND
         NO_OF_DAYS.STATUS = 'Y'
    GROUP BY NO_OF_DAYS.id_person;
    --results
    ID_PERSON     Y_N
    1          N
    2          YHope this helps.
    Regards.

  • Case statement problems in oracle forms 6i

    Hello,
    Any one can help me that how to use case statment in Oracle forms 6i.
    i have read one thread and there was no proper solution so could any one please let me know to use case statement.
    Please also let me know which category i should search for FORMS 6i.
    when i'm using below code with cursor then i'm getting error 103
    database:=11g
    application := forms 6i
    operating system:= win Xp
    code is given below :-
    cursor c1 is
    select nc.nomenclature_id,
    nvl(nc.category_value, 0) master,
    nvl(nc2.category_value, 0) case,
    nvl(nc3.category_value, 0) bundle,
    case
    when nvl(nc.category_value, 0) > 0 and
    nvl(nc2.category_value, 0) > 0 and
    nvl(nc3.category_value, 0) > 0 then
    'A' --All packouts Master, Case, Bundle
    when nvl(nc.category_value, 0) > 0 and
    nvl(nc2.category_value, 0) > 0 and
    nvl(nc3.category_value, 0) = 0 then
    'B' --Both Master and Case
    when nvl(nc2.category_value, 0) = 0 and
    nvl(nc3.category_value, 0) = 0 then
    'C' --Master Case Only
    else
    'N'
    end code
    from nomn_category nc, --master case
    (select nc2.nomenclature_id,
    nc2.category_value
    from nomn_category nc2
    where nc2.category_id = '230732') nc2,
    (select nc3.nomenclature_id,
    nc3.category_value
    from nomn_category nc3
    where nc3.category_id = '236566') nc3
    Edited by: Rahul on Feb 3, 2012 7:18 PM
    Edited by: Rahul on Feb 3, 2012 7:20 PM

    hello Andreas,
    It is ok but i dont have to use view there.
    i need to use without view, because this code has to be use in FORMS6i.
    But Forms6i doesn't support to case function. i'm newbie in Forms.
    If you can convert to below bold one portion(case) into decode then please help me or
    if you have any idea about Forms6i then please send me any link where is given explanation about excel report that how to make excel report through Forms6i step by step and that excel report should be generate on any dynamic path which is given by user:-
    cursor c1 is
    select nc.nomenclature_id,
    nvl(nc.category_value, 0) master,
    nvl(nc2.category_value, 0) case,
    nvl(nc3.category_value, 0) bundle,
    case
    when nvl(nc.category_value, 0) > 0 and
    nvl(nc2.category_value, 0) > 0 and
    nvl(nc3.category_value, 0) > 0 then
    *'A'*
    when nvl(nc.category_value, 0) > 0 and
    nvl(nc2.category_value, 0) > 0 and
    nvl(nc3.category_value, 0) = 0 then
    *'B' --Both Master and Case*
    when nvl(nc2.category_value, 0) = 0 and
    nvl(nc3.category_value, 0) = 0 then
    *'C'*
    else
    *'N'*
    end "code"
    from nomn_category nc,
    (select nc2.nomenclature_id,
    nc2.category_value
    from nomn_category nc2
    where nc2.category_id = '230732') nc2,
    (select nc3.nomenclature_id,
    nc3.category_value
    from nomn_category nc3
    where nc3.category_id = '236566') nc3
    thanks

  • Sql - execute statement problems

    I have a "try" with a "catch" that contains an sql execute statement, and some statements after that, but it doesn't execute any of the following statements. It successfully compiles and has no errors when I run it. It just doesn't insert the information and it stops every command that follows. When I remove the execute state (the one with the asterist next to it), the following statements execute fine. Any information on what I might be missing would be greatly appreciated. Thanks.
    try{
    new JdbcOdbcDriver();
    String url = "jdbc:odbc:javadb";
    String user = "";
    String password = "";
    Connection con =
    DriverManager.getConnection(url, user, password);
    Statement stmt = con.createStatement();
    System.out.println("Made the Connection");
    *stmt.executeUpdate("INSERT INTO tbl VALUES ('bradley')");
    System.out.println("Made the Connection");
    JOptionPane.showMessageDialog(this, "Data Inserted");
    }catch(Exception e)
    e.printStackTrace();
    }

    Look in your log file. When you perform "e.printStackTrace()" the stack is sent to the System.out, which JSP has already redirected to the log.
    If you're having trouble finding the log (it depends on what webserver you're using), try changing that to:
    out.println("<h3>We have an error: " + e + "</h3>");
    (Notice the absense of "System." here. We're using the pre-defined JSP "out" object that's going to the client browser.)
    That will print the error message, plus the reason for the error, on your client as 2nd level header.
    Personally, I always print out my error messages in this manner. I find that having a full, complete, extensive stack trace is next to useless. It's like asking for the definition of the word "Java", and having the Oxford Unabridged Dictionary dropped in your lap.

  • Naming the evaluated case statement field with concatenating input variable value

    Hi,
    I am trying to add the input variable value to case statement evaluated field like below query:
    declare @Year varchar(4)
    select ProductCode,datepart(mm,Date) MonthValue,
      case when datepart(mm,Date) = 1 then sum(Price) else 0 END AS Jan+@Year,
      case when datepart(mm,Date) = 2 then sum(Price) else 0 END AS Feb+@Year,
      case when datepart(mm,Date) = 3 then sum(Price) else 0 END AS Mar+@Year,
      case when datepart(mm,Date) = 4 then sum(Price) else 0 END AS Apr+@Year,
      case when datepart(mm,Date) = 5 then sum(Price) else 0 END AS May+@Year,
      case when datepart(mm,Date) = 6 then sum(Price) else 0 END AS Jun+@Year,
      case when datepart(mm,Date) = 7 then sum(Price) else 0 END AS Jul+@Year,
      case when datepart(mm,Date) = 8 then sum(Price) else 0 END AS Aug+@Year,
      case when datepart(mm,Date) = 9 then sum(Price) else 0 END AS Sep+@Year,
      case when datepart(mm,Date) = 10 then sum(Price) else 0 END AS Oct+@Year,
      case when datepart(mm,Date) = 11 then sum(Price) else 0 END AS Nov+@Year,
      case when datepart(mm,Date) = 12 then sum(Price) else 0 END AS Dec+@Year
    from Sales_Imports where datepart(yyyy,Date) = @Year
    group by  ProductCode, datepart(mm,Date)
    Please help me any other way as this is not working...
    Thanks,
    Srini

    create table Sales_Imports (ProductCode int, Price int, [date] date)
    insert into Sales_Imports values
    (1,10,'1/1/2014'),(1,109,'2/1/2014'),(1,10,'1/1/2014'),(1,109,'12/1/2014'),
    (2,10,'1/1/2014'),(2,109,'2/1/2014'),(2,10,'10/1/2014'),(2,109,'12/1/2014')
    declare @Year varchar(4)='2014'
    DECLARE @MaxCount INT, @SQL NVARCHAR(max) ,@i INT;
    Set @MaxCount = 12 
    SET @i = 0;
    SET @SQL = '';
    WHILE @i < @MaxCount
    BEGIN
        SET @i = @i + 1;
        SELECT @SQL = @Sql + ', SUM(CASE WHEN datepart(mm,[Date]) = ' + cast(@i AS NVARCHAR(10)) + ' THEN  Price Else 0 END) AS ' +Left(DateName(month,Dateadd(month,@i-1,0)) ,3)+@Year
    END
    SET @SQL = N' SELECT  ProductCode, datepart(mm,Date) MonthValue ' + @SQL 
    + N' FROM  Sales_Imports
     where datepart(yyyy,Date) ='+ @Year + N'group by  ProductCode, datepart(mm,Date)
     Order by ProductCode, datepart(mm,Date)';
    --PRINT @SQL;
    execute (@SQL);
    --Or your original one
    declare @Year varchar(4)
    Set @Year ='2014'
    declare @SQL  Nvarchar(4000)
    SET @SQL=
    N' select ProductCode,datepart(mm,Date) MonthValue,
      case when datepart(mm,Date) = 1 then sum(Price) else 0 END AS [jan' +@year+'],
      case when datepart(mm,Date) = 2 then sum(Price) else 0 END AS [feb' +@year+'],
      case when datepart(mm,Date) = 3 then sum(Price) else 0 END AS [Mar'+@year+'],
      case when datepart(mm,Date) = 4 then sum(Price) else 0 END AS [Apr'+@year+'],
      case when datepart(mm,Date) = 5 then sum(Price) else 0 END AS [May'+@year+'],
      case when datepart(mm,Date) = 6 then sum(Price) else 0 END AS [june'+@year+'],
      case when datepart(mm,Date) = 7 then sum(Price) else 0 END AS [july'+@year+'],
      case when datepart(mm,Date) = 8 then sum(Price) else 0 END AS [Aug'+@year+'],
      case when datepart(mm,Date) = 9 then sum(Price) else 0 END AS [Sep'+@year+'],
      case when datepart(mm,Date) = 10 then sum(Price) else 0 END AS [Oct'+@year+'],
      case when datepart(mm,Date) = 11 then sum(Price) else 0 END AS [Nov'+@year+'],
      case when datepart(mm,Date) = 12 then sum(Price) else 0 END AS [Dec'+@year+']
    from Sales_Imports where datepart(yyyy,Date) = ' + @Year +N' group by  ProductCode, datepart(mm,Date)'
    --print @Query
    Execute (@SQL)
    drop table Sales_Imports

  • SQL Server 2000 problem with MII Version 12.1.8 Build(24) Reconnecting

    Hi,
    I have a problem using XMII Version 12.1.8 Build(24) with com.microsoft.sqlserver.jdbc.SQLServerDriver JDBC driver with SQL 2000.
    The problem we have is the machine where the SQL server is installed on reboot as per schedule once a week. When the server comes back online, XMII  seems to get problem to reconnect correctly. Sometimes it reconnects perfectly, sometimes not.
    When it fails, the only way to fix the problem is to uncheck the 'Enabled' checkbox, then save the data server, then check the 'Enabled' checkbox, then save again.
    When the reconnect issue happens, uploading messages to SAP fail 100% of time, but downloading Control Recipes  from SAP works 50% of time. For example, some PO's can be processed correctly, some others not, causing data losses due to poor data buffering(buffering doesn't cover connection time out). The failed PO's are marked as 'Sent' into CO53 SAP transaction but in fact, are lost in a hole causing data losses.
    See the error we get atfer the server reboot:
    Unable to get a connection from the pool
    [EXCEPTION]
    com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host VANASR70, port 1433 has failed. Error: "connect timed out. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting... [see details]
    Cannot create a connection to the database
    [EXCEPTION]
    com.sap.xmii.Illuminator.system.CommunicationException: Cannot create a connection to the database... [see details]
    Error processing transaction com.sap.xmii.bls.engine.TransactionInstance@cee764f
    [EXCEPTION]
    com.sap.xmii.scheduler.CronException: PMU ERR VAN - Cannot Qry MSIDs.... [see details]
    Unable to get a connection from the pool
    [EXCEPTION]
    com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host VANASR70, port 1433 has failed. Error: "Connection refused. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting... [see details]
    Unable to get a connection from the pool
    [EXCEPTION]
    com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host VANASR70, port 1433 has failed. Error: "connect timed out. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting... [see details]
    The only way we have thought to workaround this problem is to develop our own buffering method into XMII workbench puting all data received from SAP or SQL insert query into an Oracle temp database. We should probably be able to fix this by this way, but it reprensents many costs and efforts, so we try to avoid this for sure.
    Please, if you can provide us a patches or hints about how to fix this, it could be very appreciated because loosing data is very anoying.
    Thanks a lot!
    Edited by: mrmans on May 19, 2011 5:48 PM
    Edited by: Michael Appleby on May 19, 2011 6:10 PM

    The validation query is in place and the system works very well 99% of the time.
    When the SQL server machine reboot each sunday morning, during the time the machine is rebooting, the data server lose the connection which is normal, but when the machine comes back alive(less then 10 minutes), the data server seems to stay in an 'in-between' state showing the connection status 'Running' but showing also error messages posted in the orginial post in Netweaver logs. So at first look the data server is up and running and reconnected to SQL server after the reboot, but in fact, following these errors after the SQL server machine has rebooted, some data are processed correctly from SAP (Control Recipes) and some not.
    The problems looks like very similar to threadID 1596329.
    Here is the data server configuration for all our 5 data servers:
    Connector IDBC
    ConnectorID  
    ConnectorType SQL
    DatePrefix '
    DateSuffix '
    DaysRetention 7
    Description VANASR70 INTERFACE with MS-SQL JDBC 3.0
    Enabled T
    InitCommand  
    InternalDateFormat yyyy-MM-dd HH:mm:ss
    JDBCDriver com.microsoft.sqlserver.jdbc.SQLServerDriver
    MaxRetryCount 50
    Name PROF_INT_VAN
    PoolMax 150
    PoolSize 100
    RetryInterval 60000
    ServerPackage com.sap.xmii.Illuminator.connectors.IDBC
    ServerURL jdbc:sqlserver://VANASR70:1433;databaseName=INTERFACE
    Timeout 30
    UseCount 256
    UserName mii_user
    ValidationQuery SELECT GETDATE()
    WaitTime 60

  • SQL server 2005 problem with service starting

    I am having a problem starting my sqlserver service. It will not start and therefore i have no access to my sql 2005 server database. This is what in the event log. This database was working fine until i had two drives kill over in a RAID configuration.
    The striping went out with a hitch and no i want to see if anyone have any ideas before i perform a restore. Do i need to run SQL server repair with the installation disk?

    Well from viewing the log it looks like i am in a pickle. Since the SQL service won't start, is there a command or script to run for a database check using powershell? Since it looks like i will be doing a restore, just curious now.
    2014-01-16 15:27:58.30 spid5s      Starting up database 'master'.
    2014-01-16 15:27:59.81 spid5s      Error: 824, Severity: 24, State: 2.
    2014-01-16 15:27:59.81 spid5s      SQL Server detected a logical consistency-based I/O error: incorrect pageid (expected 1:363; actual 0:0). It occurred during a read of page (1:363) in database ID 1 at offset 0x000000002d6000 in file
    'W:\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf'.  Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately.
    Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.
    2014-01-16 15:27:59.81 spid6s      Error: 922, Severity: 14, State: 1.
    2014-01-16 15:27:59.81 spid6s      Database 'master' is being recovered. Waiting until recovery is finished.
    2014-01-16 15:27:59.81 spid6s      System Task System Task produced an error that was not handled.  Major: 9, Minor: 22, Severity:14, State:1
    2014-01-16 15:27:59.81 spid5s      Error: 3313, Severity: 21, State: 2.
    2014-01-16 15:27:59.81 spid5s      During redoing of a logged operation in database 'master', an error occurred at log record ID (2369:160:2). Typically, the specific failure is previously logged as an error in the Windows Event Log
    service. Restore the database from a full backup, or repair the database.
    2014-01-16 15:27:59.81 spid5s      Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. For more information about how to rebuild the master database, see SQL
    Server Books Online.

  • Cascading Select Statements - problem with blank drop-downs

    Hello,
    I have posted a number of questions about Cascading Select Statements in APEX and though I've received some good information, I still get a blank drop-down when I select the first LOV.
    I also found "How to test an On-Demand Process used for AJAX" on the web. Here is the link to the web page:
    http://www.inside-oracle-apex.com/2006/12/how-to-test-on-demand-process.html
    When I try to test the ON-DEMAND Application Process in the Address Bar of my browser by typing the following, I get an error:
    http://beta.biztech.net:2020/pls/apex/f?p=4000:0:211233229176642:APPLICATION_PROCESS=CASCADING_SELECT_LIST:::P6_PROJECT_ID:CASCADING_SELECTLIST_ITEM_1
    The error I get is:
    Unexpected error, unable to find item name at application or page level.
    ERR-1002 Unable to find item ID for item "P6_PROJECT_ID" in application "4000".
    As perhaps a last ditch effort, I will post all the steps, all the code and a link to my application.
    Here is a link you can visit to view my application:
    http://beta.biztech.net:2020/pls/apex/f?p=112:1
    You can log in with the following ID and Password
    ID: tsimkiss
    PW: TS92
    Here are the steps that I have followed and the code that I have used.
    ++++++++++++++++++++++++++++++++++++++++++++++++++
    1. Create an application process in Shared Components
    - On Demand CASCADING_SELECT_LIST - like this:
    Process Point: On Demand
    Name: CASCADING_SELECT_LIST
    TYPE: PL/SQL Anonymous Block
    BEGIN
    OWA_UTIL.mime_header ('text/xml', FALSE);
    HTP.p ('Cache-Control: no-cache');
    HTP.p ('Pragma: no-cache');
    OWA_UTIL.http_header_close;
    HTP.prn ('<select>');
    HTP.prn ('<option value="' || 1 || '">' || '- select tasks -' || '</option>');
    FOR c IN (SELECT newops.task_name AS task_name,
    newops.task_id AS task_id
    FROM NEW_OPPORTUNITIES newops
    UNION
    SELECT DISTINCT pt.task_name AS task_name,
    pt.task_id AS task_id
    FROM pa_tasks@bizdev pt,
    pa.pa_projects_all@bizdev prj
    WHERE prj.project_id = pt.project_id
    AND prj.project_id =
    CASE
    WHEN TO_NUMBER(:cascading_selectlist_item_1)=1
    THEN prj.project_id
    ELSE TO_NUMBER(:cascading_selectlist_item_1)
    END)
    LOOP
    HTP.prn ('<option value="' || c.task_id || '">' || c.task_name || '</option>');
    END LOOP;
    HTP.prn ('</select>');
    END;
    2. Create an application item in Shared Components:
    Name: CASCADING_SELECTLIST_ITEM_1
    3. Create an LOV in Shared Components
    - This is the Primary LOV (name it similar to it's select list page item):
    List of Values Name: PROJECT_ID
    Source: Lists of Values Query
    SELECT newops.CLIENT AS project_name, newops.PROJECT_ID AS project_id FROM NEW_OPPORTUNITIES newops
    UNION
    SELECT ppa.NAME AS project_name, ppa.PROJECT_ID AS project_id FROM pa.pa_projects_all@bizdev ppa
    WHERE ppa.project_status_code='APPROVED'
    AND (ppa.COMPLETION_DATE IS NULL or ppa.completion_date > sysdate)
    AND (ppa.CLOSED_DATE IS NULL or ppa.closed_date > sysdate)
    ORDER BY project_name asc
    4. Create a javascript and put it in the header of the page where cascading drop-downs are:
    <script>
    function get_select_list_xml(pThis,pSelect){
    var l_Return = null;
    var l_Select = html_GetElement(pSelect);
    var get = new htmldb_Get(null,html_GetElement('pFlowId').value,
    'APPLICATION_PROCESS=CASCADING_SELECT_LIST',0);
    get.add('CASCADING_SELECTLIST_ITEM_1',pThis.value);
    gReturn = get.get('XML');
    if(gReturn && l_Select){
    var l_Count = gReturn.getElementsByTagName("option").length;
    l_Select.length = 0;
    for(var i=0;i<l_Count;i++){
    var l_Opt_Xml = gReturn.getElementsByTagName("option");
    appendToSelect(l_Select, l_Opt_Xml.getAttribute('value'),
    l_Opt_Xml.firstChild.nodeValue)
    get = null;
    function appendToSelect(pSelect, pValue, pContent) {
    var l_Opt = document.createElement("option");
    l_Opt.value = pValue;
    if(document.all){
    pSelect.options.add(l_Opt);
    l_Opt.innerText = pContent;
    }else{
    l_Opt.appendChild(document.createTextNode(pContent));
    pSelect.appendChild(l_Opt);
    </script>
    5. Create two Select List page items:
    P6_PROJECT_ID <-- This is the primary drop-down
    P6_TASK_ID <-- This is the secondary drop-down
    6. In your primary select list, put the following into HTML Form Element Attributes:
    HTML Form Element Attributes: onchange="get_select_list_xml(this,'P6_TASK_ID')"
    Other settings on the page:
    Name: P6_PROJECT_ID
    Display As: Select List
    Source Used: Always, replacing any existing values in session state
    Source Type: Database Column
    Source value or expression: PROJECT_ID
    Named LOV: PROJECT_ID <--- Choose from drop-down (this is the Application LOV created earlier)
    Null display values: - select project -
    Display Null: Yes
    7. The second select list is based on an LOV and depends on the value of the first select list:
    Name: P6_TASK_ID
    Display As: Select List
    Source Used: Always, replacing any existing values in session state
    Source Type: Database Column
    Source value or expression: TASK_ID
    Null display values: - select project -
    Display Null: Yes
    List of values definition:
    SELECT newops.task_name AS task_name,
    newops.task_id AS task_id
    FROM NEW_OPPORTUNITIES newops
    UNION
    SELECT DISTINCT pt.task_name AS task_name,
    pt.task_id AS task_id
    FROM pa_tasks@bizdev pt,
    pa.pa_projects_all@bizdev prj
    WHERE prj.project_id=pt.project_id
    AND prj.project_id=:P6_PROJECT_ID
    ORDER BY task_name asc
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    If you need an actual running copy of my application, I'm not sure I can upload to the Oracle APEX website since uses datalinks to some tables. If necessary, I will give you my login into if you email me directly, however.
    If someone could just straighten my code out especially on the ON-DEMAND Application Process, I think that would really help me out.
    Hope someone out there can help me.
    Thanks
    LEH

    Sorry, looking at your code that testing URL is still incorrect. You should be passing name / value pairs in the last arguments, and your passing P6_PROJECT_ID as the name part and CASCADING_SELECTLIST_1 as the value part. In your application process you are using CASCADING_SELECTLIST_1 as the parent ID for the P6_TASK_ID dropdown, so it is this name / value pair that you'll need to test. So your URL should look something like this...
    http://beta.biztech.net:2020/pls/apex/f?p=112:0:211233229176642:APPLICATION_PROCESS=CASCADING_SELECT_LIST:::CASCADING_SELECTLIST_ITEM_1:[some project id]
    (Note: Where [some project id] should be an ID for a project in your database, that has tasks.)
    And I'm with Dan here, I still can't access that link you provided. apex.oracle.com should be your next move if you can't resolve it, as you've got at least two people willing to go and have a look at your code.
    Hope it helps,
    Anthony.

Maybe you are looking for

  • Printing (flattening) a PDF'd powerpoint file

    Hello. I work in a Uni print room and get bombarded with lots of printing problems so i thought i would share this one and see if it is common or if there's any advice that could help. I was sent a powerpoint file that has been converted to a PDF (i

  • Error using the Keithley 2400

    Hi, I am pretty new to LabVIEW and right now I am just trying to set up a simple test (source current, measure voltage) using the Keithley 2400 and Labview 8.2 I got the driver for this instrument off of NI's website at http://sine.ni.com/apps/utf8/n

  • How to get feedback to Apple?

    I tried using the feedback form but I don't think it works, how else do you get feedback to them? Cheers. What I submitted is below It seems this feedback form is outdated, there is no iPod (video) model in the selection list, iTunes 5 and 6 aren't l

  • [SOLVED] can't build firefox - full perl install required

    Hi Archers, Here's the error message i get when i try to build Firefox : checking for perl... /usr/bin/perl checking for minimum required perl version >= 5.004... 5.008008 checking for full perl installation... no configure: error: Cannot find Config

  • Statisitcal Delivery Date

    Hi Experts, We have an unique sitution... We are creating a STO from  US to Europe. Here, Statistical Del Date is defaulting as a Date in the year 2201 or something like that...How this is defaulting? User has not entered any Dates..and change log do