Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

SELECTing an Oracle constant in a view

Thread Tools
 
Search this Thread
 
Old 28 September 2004, 11:55 AM
  #1  
TopBanana
Scooby Regular
Thread Starter
 
TopBanana's Avatar
 
Join Date: Jan 2001
Posts: 9,781
Likes: 0
Received 0 Likes on 0 Posts
Default SELECTing an Oracle constant in a view

I'm more of a SQL Server dude normally... anyone know how to do this? (If it's possible)

I'm getting:
ORA-06553: PLS-221: 'CONSTNAME' is not a procedure or is undefined
Old 28 September 2004, 05:22 PM
  #2  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Default

what's yer SQL?
Old 28 September 2004, 07:24 PM
  #3  
TopBanana
Scooby Regular
Thread Starter
 
TopBanana's Avatar
 
Join Date: Jan 2001
Posts: 9,781
Likes: 0
Received 0 Likes on 0 Posts
Default

Hi,

Um basically

CREATE OR REPLACE VIEW...
SELECT Table.X, Package.ConstName Y
FROM Table

That's from memory, but you get the picture!
Old 29 September 2004, 08:15 AM
  #4  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Default

so in the same query you want to select table data and a constant (value or label?) from a package?
Old 29 September 2004, 10:41 AM
  #5  
TopBanana
Scooby Regular
Thread Starter
 
TopBanana's Avatar
 
Join Date: Jan 2001
Posts: 9,781
Likes: 0
Received 0 Likes on 0 Posts
Default

You got it - table data and a constant
Old 29 September 2004, 10:43 AM
  #6  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Default

wouldn't it be better to maintain your constants in their own 'tblConstants' rather than coded in a package, especially when you know you'll be referencing them from SQL?
Old 29 September 2004, 10:44 AM
  #7  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Default

or is the SQL in the package and you want to access the constant that's defined in the package that the SQL is also in?
Old 29 September 2004, 10:48 AM
  #8  
TopBanana
Scooby Regular
Thread Starter
 
TopBanana's Avatar
 
Join Date: Jan 2001
Posts: 9,781
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by Fosters
or is the SQL in the package and you want to access the constant that's defined in the package that the SQL is also in?
Yes it is.

Selecting a constant should be quicker than adding another table join to the view?
Old 29 September 2004, 12:05 PM
  #9  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Default

like this?
procedure ProcName(ioCursor out ref_cursor)
is
ConstantVar varchar2(3);
begin
ConstantVar := 'boll0x';
open ioCursor for
select table.*,ConstantVar
from table;
end;
Old 29 September 2004, 12:06 PM
  #10  
Fosters
Scooby Regular
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Default

ignore the fact the boll0x doesn't fit into 3 bytes. d'oh!
Old 29 September 2004, 12:56 PM
  #11  
TopBanana
Scooby Regular
Thread Starter
 
TopBanana's Avatar
 
Join Date: Jan 2001
Posts: 9,781
Likes: 0
Received 0 Likes on 0 Posts
Default

LOL @ boll0x

Good try, but it has to be a view not a procedure, so I can't use an intermediary variable I don't think it's possible without placing the data in a table
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
KAS35RSTI
Subaru
27
04 November 2021 07:12 PM
Abx
Subaru
22
09 January 2016 05:42 PM
Frizzle-Dee
Essex Subaru Owners Club
13
01 December 2015 09:37 AM
south_scoob
ScoobyNet General
22
03 October 2015 01:05 PM
Phil3822
ICE
3
26 September 2015 07:12 PM



Quick Reply: SELECTing an Oracle constant in a view



All times are GMT +1. The time now is 09:33 PM.