Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change format in SQL statement?

Status
Not open for further replies.

CraigBest

Programmer
Aug 1, 2001
545
US
Hi Folks

Forgive me if this is the wrong forum to post this question to.

I have a numeric field in an Oracle DB I have to collect through an SQL statement along with several other fields. This field is defined in the DB as a numeric. As I read it, I need to convery it into a string field with leading zeroes for display in a grid (VB program).

How can I do this conversion in the select statement? I'm sure there must be a way. If I were not using a grid that is loded directly from the recordset returned I would use a Format statement in VB to change the value and include the leading zeroes. But I can't in this case. The grid does not allow me to include the format statement to change the data as it is read.

Hoping someone has an answer that can help. Oh yes the SQL Statement must be in PL-SQL format.

Thanks in advance

Craig
 
If you need to convert number to string you may use to_char function. You may specify format or just left-pad the result by lpad.
 
Thanks, that did it. I should have realized, I've used TO_TEXT before, but never realized it had a format function like that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top