• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Prepared Statement that specifies field aliases  RSS feed

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there a way to write a PreparedStatement that will let you assign the data values to an alias?
If the datacolumn in the database is called Name, can you map it to the alias "CustomerName", through the prepared statement? Is there any other way to do this?
Thanks,
-Deb
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deb,
Most of the databases that I have worked with allow you to define column aliases in the SQL query, for example:

Note: I think that this may be part of standard SQL (but I'm not sure).
However, if you want to change the column name _after_ you have created your "PreparedStatement" object, I don't think this is possible.
Hope this has helped you.
Good Luck,
Avi.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the column aliases in both Statement and prepared statements.

Select name CustomerName from Customer
here CustomerName is alias name for column name.
a sql query like this can be used in both statement or prepared statement
Veena
 
Debbie Argulkar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Veena,
Thanks. I will try that out.
-Deb
 
Everybody! Do the Funky Monkey! Like this tiny ad!
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!