• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Need help with Oracle View

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 598
26
Oracle Notepad Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 598
26
Oracle Notepad Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic