case

Having "___ in (select distinct ___ from #temp)" in Case statement

Hi, I'm trying to achieve this select case when Org_CD = '1111' or Org_CD in (select distinct New_Org_CD from #temp) then 'International' end as 'Organisation', count(*) from #AnotherTempTable group by case when Org_CD = '1111' or Org_CD in (select distinct New_Org_CD from #temp) then 'International' end I re...

Case for first character of string

I need to make a decision about a string based on the first character, and I have a method defined in this way: (defn check-first [string] (case (get string 0) "+" 1 "-" 2 3 )) Currently it always returns 3 even when the string starts with those characters. What am I doing wrong? Also, is there a more elegant way to ...

How to catch Errno::ECONNRESET class in "case when"?

My application (Ruby 1.9.2) may raise different exceptions, including net-connection breaks. I rescue Exception => e, then do case/when to handle them in defferent ways, but several errors go through my cases straight to else. rescue Exception => e p e.class case e.class when Errno::ECONNRESET p 1 whe...

bash syntax error when using case statement

I have bash script that I use regularly in my job to automate a large job. I was making some changes today, but everything seemed fine. The script itself is about 1700 lines long. The first part of the script is all good and runs through all the user input and logic just fine. It then proceeds into the core of the script and stops wo...

Set multiple fields in a single case statement

I'm not as familiar with SQL Server 2008 and I haven't seen an answer to this question anywhere else. Does TSQL in SQL Server 2008 allow for multiple fields to be set in a single case statement. For instance: case MyField when 1 then ThisField = 'foo', ThatField = 'bar' when 2 then ThisField = 'Mickey', ThatField = 'Mouse' e...

If error then switch vs. switch with "good" case

Hello all. I'm not very familiar with machine code, but I think this is a pretty simple question. If I want to do error handling via an integer returned from a function (as opposed to the function throwing an exception), is it better practice—from a machine code standpoint—to: Check the integer in a conditional statement for a "bad"...

C# Switch-case string starting with....

Is there any way to make a case condition in a switch statement where you say if a string begins with something? ex Switch (mystring) { case("abc")://String begins with abc (abcd or abc1 or abcz or abc.. or abc will fall in this condition). //Do Something break; default: break; } UPDATE Other strings can be di...

Short Ruby Case Statement using include? Will Not Work

Hi, I have the following code with a small bug in it, the case statement returns the value "other" even though the first "when" statement evaluates true and should return "boats". I've been been looking at this for ages, must be something small. CATEGORIES = {:boats => [1, 2, 3, 4, 5, 6], :houses => [7, 8, 9, 10], ...

Case Statement Question -- vb.net

So I have case statements grouped together here, but I have a few case statements that need extra decision based on a second variable after the original case is confirmed. This is what I have now: Case "PRIVATE_PARTY" If Condition = KBB_CONDITION_EXCELLENT Then Vehicle.MarketValue = Response.PrivatePartyExcellent ElseIf...

How to convert DetailsView columns to uppercase

Hi all, I need to be able to convert all input fields in a DetailsView (Insert) to uppercase. How do I do this? My SQL query and the whole insert statement takes place in ASP.NET, and not in code behind so I'm not sure if I can dynamically do this in ASP. I've used Text-Transform in CSS to make them look uppercase for the user, but it s...

Is there a better way of this MySQL CASE SELECT ?

The last two parameters are PHP WHERE and ORDER clauses, they (probably) don't matter here. fornecedores.nome_emp AS nome_fornecedor, exchange_rates1.rate AS rateEUR_USD, exchange_rates2.rate AS rateEUR_AOA, CASE produtos.moeda WHEN 'AOA' THEN produtos.preco_custo / exchange_rates2.rate WHEN 'EUR' THEN produtos.preco_custo WHEN 'USD'...

tsql : is it possible to do nested case statements in a select?

how do i incorporate a nested if statement in a select clause of a sql query? I know to use case when condition then X else y end but how do you do a nested one in the same fashion for each record in a record set. if x.boy is not null then x.boy else if x.girl is not null then x.girl else if x.dog is not null then x.dog e...

C: Diagramming A Large Library

Is there any tools to assist in diagramming a large C library? I am working on a project to port an existing C library to C++. The C library is largely undocumented with no diagrams. I would like to use a CASE tool to help me understand how the various files interact. There is extern variables in most of the files. If possible I would p...

SQL case in select query.

I have following query Select a,b,c, case totalcount when 0 then 0 else abcd/totalcount end AS 'd', case totalcount when 0 then 0 else defg/totalcount end AS 'e' From Table1 In this query, I have same case statement in select query...C...

Sybase 15 substring error in a case statement on update

Running on Adaptive Server Enterprise/15.0.3/EBF 17157 ESD#3/P/x86_64/Enterprise Linux/ase1503/2726/64-bit/FBO/ The below code should never enter the substring case, however I am presented with a Sybase Error 536. Is this a form of optimization where it evaluates all paths regardless of the actual value?? We can work around this but w...

nest dynamic case when statements in sql 2008

Hello Experts, I have the following code in .net. foreach (string key in EntityNumbers.Keys) { if (EntityNumbers[key] != null) { e = new WebServices.Entity(); e.HierarchyLevel = key; e.Number = EntityNumbers[key]; ...

SQL Server and Oracle joins tutorials

Hello All, Question 1: I am learning SQL Server and Oracle joins (inner joins, outer joins...) and case statements syntax. Though I can google for the info, but would like to ask for some sites, links, and materials that fully explain the joins and case statments. Once again, thanks. Thanks gentlemen. Question 2: I am running a sim...

Does the method argument in AJAX need to be upper case?

Well basically what the title says, when making an AJAX request with JavaScript. Does the method, i.e. GET / POST, need to be upper case? Thanks in advance. Edit: Even a yes or no will suffice. ...