Petri IT Knowledgebase Forums
 

Petri.co.il forums Home Forums Start Page Forums Frequently Asked Questions FAQ Member List Members List
Go Back   Petri IT Knowledgebase Forums > Databases > Database Basics
Petri.co.il is happy to award auglan the title of Most Valuable Member !!!
Register Calendar Calendar Search Petri IT Knowledgebase Forums Search Todays Posts Today's Posts Mark Forums Read

Notices

Create View with a Case Statement

Create View with a Case Statement

this thread has 1 replies and has been viewed 1685 times

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1  
Old 14th July 2012, 00:02
rever75 rever75 is offline
Casual
It's not a coincidence
 
 Join Date: Jan 2006
  6 month star 12 month star
 Posts: 71
 Reputation: rever75 is on a distinguished road (20)
Default Create View with a Case Statement

I am trying to create a view that has a case statement.

Quote:
CREATE OR REPLACE FORCE VIEW RCPTINFO" ("ORDRNO", "LINENO", "InvNO", "RCPTDT" "RCQTY) AS
SELECT rcord AS ordrNo,
rclin AS lineNo,
rcInv AS InvNo,
rcdat AS rcptDt,
CASE
If rclen > 0
then rclen AS RCQTY
Else
rcwgt AS RCQTY
FROM SalesInfo
I keep getting an error about From not being found or in right place. Any help would be greatly appreciated.
  #2  
Old 14th July 2012, 09:46
Ossian Ossian is offline
Administrator
 
 Join Date: Nov 2003
  6 month star 12 month star
 Location: Bonnie Scotland
 Posts: 15,113
  Send a message via Skype™ to Ossian
 Reputation: Ossian has much to be proud ofOssian has much to be proud ofOssian has much to be proud ofOssian has much to be proud ofOssian has much to be proud ofOssian has much to be proud ofOssian has much to be proud ofOssian has much to be proud ofOssian has much to be proud ofOssian has much to be proud of (1300)
Default Re: Create View with a Case Statement

What database software is this in please?
You appear to be missing the END keyword when the case has finished, i,e. immediately above the FROM line
Also missing a close quote after RCQTY in the first line

Here is an example of a working CASE Statement:
Code:
SELECT Top 1000 TOa, CC, "TestCase" =
CASE 
	WHEN RFC822_size > 20000 THEN BACKUP_date
	ELSE PP4_MAILBACKUP_ID
END
FROM PP4_MAILBACKUP
__________________
Tom Jones
MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
PhD, MSc, FIAP, MIITT
IT Trainer / Consultant
Ossian Ltd
Scotland

** Remember to give credit where credit is due and leave reputation points where appropriate **

Last edited by Ossian; 14th July 2012 at 10:01..
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
.bat If Then statement jmituzas DOS Command Shell 3 19th September 2010 03:01
If statement to run for more than 1 person epanzeter General Scripting 2 7th August 2008 18:33
Need help using Or in an If Statement wullieb1 General Scripting 10 31st August 2007 23:22
create a new log view in event viewer tomer_wall Misc 1 30th May 2007 15:24
Misbehaving If Then statement. JamesNesbitt General Scripting 0 10th October 2005 07:29


All times are GMT +3. The time now is 00:51.

Steel Blue 3.5.4 vBulletin Style ©2006 vBEnhanced
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
 

Valid XHTML 1.0!   Valid CSS!

Copyright 2005 Daniel Petri