Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 14th, 2005, 10:50 AM
1andy1 1andy1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 18 1andy1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 18 sec
Reputation Power: 0
Send a message via ICQ to 1andy1
Question How do I create VIEW with CASE

I tried

CREATE VIEW v_user_structures_columns AS
SELECT
table_name,
CASE
...
END,
column_name,
app_type,
data_length,
comments,
constraints
FROM
t_user_structures_columns

and I got an error message

Dynamic SQL Error
-SQL error code = -607
-Invalid command
-must specify column name for view select expression
Statement failed, SQLCODE = -607

If I tried only the SELECT then it seams to be working OK.

any help?

Thanks,
Andrej.

Reply With Quote
  #2  
Old January 14th, 2005, 11:44 AM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,007 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 13 h 41 m 31 sec
Reputation Power: 67
The error message says it all: you need to supply a name for your case column:
Code:
CREATE VIEW v_user_structures_columns AS
SELECT
table_name,
CASE
...
END as the_case_column,
column_name,
app_type,
data_length,
comments,
constraints
FROM
t_user_structures_columns
should work. Haven't tried it though.

Reply With Quote
  #3  
Old January 17th, 2005, 03:23 AM
1andy1 1andy1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 18 1andy1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 18 sec
Reputation Power: 0
Send a message via ICQ to 1andy1
Smile

Quote:
Originally Posted by shammat
The error message says it all: you need to supply a name for your case column:
Code:
CREATE VIEW v_user_structures_columns AS
SELECT
table_name,
CASE
...
END as the_case_column,
column_name,
app_type,
data_length,
comments,
constraints
FROM
t_user_structures_columns
should work. Haven't tried it though.


Still it doesn't work.
I tried this:

CREATE VIEW v_user_structures_columns AS
SELECT
table_name,
CASE
WHEN (SUBSTR(column_name, 1, 2) = 'C_') THEN SUBSTR(column_name, 3, strlen(column_name) - 3)
WHEN (SUBSTR(column_name, 1, 2) = 'R_') THEN SUBSTR(column_name, 3, strlen(column_name) - 3)
ELSE column_name
END as app_column_name,
column_name,
app_type,
data_length,
comments,
constraints
FROM
t_user_structures_columns;

with the same error message.

but this is working fine.

CREATE VIEW v_user_structures_columns (table_name, app_column_name, column_name, app_type, data_length, comments, constraints) AS
SELECT
table_name,
CASE
WHEN (SUBSTR(column_name, 1, 2) = 'C_') THEN SUBSTR(column_name, 3, strlen(column_name) - 3)
WHEN (SUBSTR(column_name, 1, 2) = 'R_') THEN SUBSTR(column_name, 3, strlen(column_name) - 3)
ELSE column_name
END,
column_name,
app_type,
data_length,
comments,
constraints
FROM
t_user_structures_columns;

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > How do I create VIEW with CASE


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT