aspose file tools*
The moose likes JDBC and the fly likes Prepared Statement that specifies field aliases Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Prepared Statement that specifies field aliases" Watch "Prepared Statement that specifies field aliases" New topic
Author

Prepared Statement that specifies field aliases

Debbie Argulkar
Ranch Hand

Joined: Jul 26, 2002
Posts: 43
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
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1124

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.
Veena Rani
Ranch Hand

Joined: Mar 09, 2000
Posts: 34
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

Joined: Jul 26, 2002
Posts: 43
Hi Veena,
Thanks. I will try that out.
-Deb
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Prepared Statement that specifies field aliases