case-statement

Mysql CASE NOT FOUND for CASE STATEMENT on a Stored Procedure

雨燕双飞 提交于 2019-12-08 15:51:38
问题 im trying to create a stored procedure that have multiples CASE STATEMENTS I have the following stored procedure: BEGIN CASE @olds WHEN 'emp' THEN CASE @news WHEN 'loc' THEN UPDATE equipos SET pe=pe-1,pg=pg+1 WHERE id=@eqloc; UPDATE equipos SET pe=pe-1,pp=pp+1 WHERE id=@eqvis; UPDATE partidos SET `eqgan`=@news WHERE id=@mst; UPDATE log_partidos SET `status`=@news WHERE `match`=@mst; WHEN 'vis' THEN UPDATE equipos SET pe=pe-1,pg=pg+1 WHERE id=@eqvis; UPDATE equipos SET pe=pe-1,pp=pp+1 WHERE id

Can the SQL Case Statement fall through?

梦想与她 提交于 2019-12-08 15:21:16
问题 Is there a way to make a CASE statement in SQL fall through like the case statement in C#? What I don't want to do is the example below but if that’s my only option I guess I'll go with it. EXAMPLE: @NewValue = CASE WHEN @MyValue = '1' THEN CAST(@MyValue AS int) WHEN @MyValue = '2' THEN CAST(@MyValue AS int) ELSE NULL END EDIT: I'm using SQL Server. 回答1: To answer your specific question: No, it cannot. See, for example, the MySQL documentation for CASE. Every WHEN must have a THEN result ,

Getting the number of cases in a switch-case in C

天大地大妈咪最大 提交于 2019-12-06 12:13:26
Is it possible to get the number of cases in a switch case in C without manually adding a counter variable which is incremented in each case? As I commented earlier, I think you want a dispatch table rather than a switch statement. Here's a little example. Say you got this: int find_the_case(); void do_something(); void do_something_different(); void do_something_completly_different(); void do_default(); int main(int argc, char *argv[]) { int c = find_the_case(); switch(c){ case 0: do_something(); break; case 1: do_something_different(); break; case 5: do_something_completly_different(); break

Haskell: Multiple Case Statements in Single Function

╄→尐↘猪︶ㄣ 提交于 2019-12-05 20:24:06
问题 I want to include more than one case statement in a Haskell function (see below for an example of a hypothetical function). However, it is not legal Haskell. What is a better way of accomplishing the same thing? Furthermore, if the case statements are not returning anything, but simply setting some value, why is it not legal to have more than one case statement in a function? (I would get a "parse error on input `case'" on line 5) tester x y = case (x < 0) of True -> "less than zero." False -

Case Statements/Decode Function in Informatica

余生颓废 提交于 2019-12-05 02:52:35
Could anyone help me with writing case statements in Informatica PowerCenter Designer? I am fairly new to Informatica, and based on my limited experience I feel case statements aren't supported. There is a decode function with similar functionality, but I am unable to find any good examples on the syntax. I would really appreciate if anyone could give me some specific examples on how to use case statements/decode function in Informatica. Thanks much for your help! You're right - there is no CASE statement, but you can use DECODE to simulate it: DECODE( TRUE , DECIMAL_PORT > 0, 'positive value'

How to write a select inside case statement

别来无恙 提交于 2019-12-04 04:57:21
问题 I have a stored procedure that contains a case statement inside a select statement. select Invoice_ID, 'Unknown' as Invoice_Status, case when Invoice_Printed is null then '' else 'Y' end as Invoice_Printed, case when Invoice_DeliveryDate is null then '' else 'Y' end as Invoice_Delivered, case when Invoice_DeliveryType <> 'USPS' then '' else 'Y' end as Invoice_eDeliver, Invoice_ContactLName+', '+Invoice_ContactFName as ContactName, from dbo.Invoice left outer join dbo.fnInvoiceCurrentStatus()

Haskell: Multiple Case Statements in Single Function

二次信任 提交于 2019-12-04 02:54:29
I want to include more than one case statement in a Haskell function (see below for an example of a hypothetical function). However, it is not legal Haskell. What is a better way of accomplishing the same thing? Furthermore, if the case statements are not returning anything, but simply setting some value, why is it not legal to have more than one case statement in a function? (I would get a "parse error on input `case'" on line 5) tester x y = case (x < 0) of True -> "less than zero." False -> "greater than or equal to zero." case (y == "foo") True -> "the name is foo." False -> "the name is

Case Statements versus coded if statements

跟風遠走 提交于 2019-12-03 16:10:54
问题 What is more efficient - handling with case statements in sql or handling the same data using if statements in code. I'm asking because my colleague has a huge query that has many case statements. I advised her to take stress off of the DB by coding the case statements. I've found that it is more efficient...but why? 回答1: There's a more fundamental question that's not being asked here: What are these CASE statements actually doing? Forget performance for a minute. If CASE is only being used

Case Statements versus coded if statements

泄露秘密 提交于 2019-12-03 05:40:13
What is more efficient - handling with case statements in sql or handling the same data using if statements in code. I'm asking because my colleague has a huge query that has many case statements. I advised her to take stress off of the DB by coding the case statements. I've found that it is more efficient...but why? There's a more fundamental question that's not being asked here: What are these CASE statements actually doing? Forget performance for a minute. If CASE is only being used to transform the final output of a query, and it's actually possible to replace the same functionality with

Anonymous partial function in early initializer requires “premature access to class”

妖精的绣舞 提交于 2019-12-02 03:57:54
问题 Why does this fail to compile: trait Item trait StringItem extends Item { def makeString: String } trait SomeOtherItem extends Item trait DummyTrait case class Marquee(items: Seq[Item]) extends { val strings: Seq[String] = items.collect { case si: StringItem => si.makeString // <-- partial function inside braces } } with DummyTrait with the error message <$anon: Item => String> requires premature access to class Marquee ? It seems to me that the partial function makes no use of Marquee . Yet