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 Sep 28, 2004 | 11:55 AM
  #1  
TopBanana's Avatar
TopBanana
Thread Starter
Scooby Regular
 
Joined: Jan 2001
Posts: 9,781
Likes: 0
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
Reply
Old Sep 28, 2004 | 05:22 PM
  #2  
Fosters's Avatar
Fosters
Scooby Regular
 
Joined: Jul 2000
Posts: 2,145
Likes: 0
From: Islington
Default

what's yer SQL?
Reply
Old Sep 28, 2004 | 07:24 PM
  #3  
TopBanana's Avatar
TopBanana
Thread Starter
Scooby Regular
 
Joined: Jan 2001
Posts: 9,781
Likes: 0
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!
Reply
Old Sep 29, 2004 | 08:15 AM
  #4  
Fosters's Avatar
Fosters
Scooby Regular
 
Joined: Jul 2000
Posts: 2,145
Likes: 0
From: Islington
Default

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

You got it - table data and a constant
Reply
Old Sep 29, 2004 | 10:43 AM
  #6  
Fosters's Avatar
Fosters
Scooby Regular
 
Joined: Jul 2000
Posts: 2,145
Likes: 0
From: Islington
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?
Reply
Old Sep 29, 2004 | 10:44 AM
  #7  
Fosters's Avatar
Fosters
Scooby Regular
 
Joined: Jul 2000
Posts: 2,145
Likes: 0
From: Islington
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?
Reply
Old Sep 29, 2004 | 10:48 AM
  #8  
TopBanana's Avatar
TopBanana
Thread Starter
Scooby Regular
 
Joined: Jan 2001
Posts: 9,781
Likes: 0
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?
Reply
Old Sep 29, 2004 | 12:05 PM
  #9  
Fosters's Avatar
Fosters
Scooby Regular
 
Joined: Jul 2000
Posts: 2,145
Likes: 0
From: Islington
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;
Reply
Old Sep 29, 2004 | 12:06 PM
  #10  
Fosters's Avatar
Fosters
Scooby Regular
 
Joined: Jul 2000
Posts: 2,145
Likes: 0
From: Islington
Default

ignore the fact the boll0x doesn't fit into 3 bytes. d'oh!
Reply
Old Sep 29, 2004 | 12:56 PM
  #11  
TopBanana's Avatar
TopBanana
Thread Starter
Scooby Regular
 
Joined: Jan 2001
Posts: 9,781
Likes: 0
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
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
KAS35RSTI
Subaru
27
Nov 4, 2021 07:12 PM
Abx
Subaru
22
Jan 9, 2016 05:42 PM
Frizzle-Dee
Essex Subaru Owners Club
13
Dec 1, 2015 09:37 AM
south_scoob
ScoobyNet General
22
Oct 3, 2015 01:05 PM
Phil3822
ICE
3
Sep 26, 2015 07:12 PM




All times are GMT +1. The time now is 02:02 AM.