Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help with Oracle View

 
Hemanth Kumar Simhadri
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an Oracle table with 10 columns. I want to create a view for this table. My problem is that, I want to set a specific value for two of the columns in my view. Can I do like this.


Table Name: MASTERTABLE
Column1   Column2    Column3    Column4........... Column10
1              abc            ade           sas                    ssadas
2              awsda        asda         qdas                     aswdw

Table View: MASTERTABLE_VIEW
select COLUMN1, COLUMN2, COLUMN4, COLUMN7, COLUMN10 from MASTERTABLE;update MASTERTABLE_VIEW set COLUMN2='TEXT123', COLUMN4='TEXT456';

Is this way of creating the view correct?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hemanth Kumar Simhadri wrote:Is this way of creating the view correct?

I would assume this can be easily done using the appropriate values in the SELECT list to create your view. Example:Although I wonder why you want to include these values into your view, if you want a fixed value. And clearly this fixed value is different from the actual value for each record in the master table
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused. Do you want to UPDATE the TABLE, or just have your VIEW specify a literal value?

To specify a literal value, just use single quotes.:

--

When posting code, please use the code tags. The language selector and Code button on top of the editor makes it very easy, and your code will be easier to read and be much prettier too.
 
Hemanth Kumar Simhadri
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Tkatch wrote:select COLUMN1, 'TEXT123' COLUMN2, 'TEXT456' COLUMN4, COLUMN7, COLUMN10 from MASTERTABLE;


This is the one exactly that I am looking for. Thank you very much for the help.
 
Hemanth Kumar Simhadri
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:select COLUMN1, 'TEXT123' AS COLUMN2, 'TEXT456' AS COLUMN4, COLUMN7, COLUMN10
from MASTERTABLE


This query is working as I expected. Thanks for your help
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hemanth Kumar Simhadri wrote:This query is working as I expected. Thanks for your help

Great to hear the query is working as expected, but you still didn't have answered/addressed my question/doubt: I wonder why you want to include these values into your view, if you want a fixed value. And clearly this fixed value is different from the actual value for each record in the master table
 
Hemanth Kumar Simhadri
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:you still didn't have answered/addressed my question/doubt: I wonder why you want to include these values into your view, if you want a fixed value. And clearly this fixed value is different from the actual value for each record in the master table


I have a specific requirement like that for my web application. We dont want to hardcode that in the web layer. We still have several master tables for which we have to create multiple views with a fixed value for specific columns.

I hope I answered your question
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hemanth Kumar Simhadri wrote:I have a specific requirement like that for my web application. We dont want to hardcode that in the web layer. We still have several master tables for which we have to create multiple views with a fixed value for specific columns.

Fair enough!
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:
Hemanth Kumar Simhadri wrote:I have a specific requirement like that for my web application. We dont want to hardcode that in the web layer. We still have several master tables for which we have to create multiple views with a fixed value for specific columns.

Fair enough!


In one sense, VIEWs represent objects, or codify a set of rules. So, hardcoded values make sense when used in that respect. I have hardcoded alues in VIEWs now and then to good effect.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic