Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Is there a way to use "COLUMN FORMAT" in a Pro*C/C++ app?

Re: Is there a way to use "COLUMN FORMAT" in a Pro*C/C++ app?

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 2 Apr 2007 07:29:26 -0700
Message-ID: <1175524166.873558.192460@d57g2000hsg.googlegroups.com>


On Apr 2, 10:09 am, "Ramon F Herrera" <r..._at_conexus.net> wrote:
> On Apr 2, 2:41 am, "sybrandb" <sybra..._at_gmail.com> wrote:
>
>
>
>
>
> > On Apr 2, 7:50 am, "Ramon F Herrera" <r..._at_conexus.net> wrote:
>
> > > My application has some SQL statements like this:
>
> > > SELECT
> > > to_char(amount1, '99,999,990.00'), \
> > > to_char(amount2, '99,999,990.00'), \
> > > to_char(amount3, '99,999,990.00'), \
> > > to_char(amount4, '99,999,990.00'),
> > > [...]
>
> > > Is that the only way to format real numbers from a precompiler
> > > application?
>
> > > The command "COLUMN FORMAT" seems to work only from SQL*Plus.
>
> > > TIA,
>
> > > -Ramon F Herrera
>
> > The COLUMN command is a sql*plus command, it isn't a SQL command. So
> > yes, it is the only way.
> > Obviously you could define the format as a string constant, but it
> > seems you prefer hardcoding and maintenance nightmares.
>
> > --
> > Sybrand Bakker
> > Senior Oracle DBA
>
> Sybrand:
>
> I have found instances in which the Oracle precompiler doesn't deal
> properly with '#define' constants in "EXEC SQL" statements, so I am
> staying away from those.
>
> However, per your suggestion, I did change all my variable sizes to
> constants, located in a central .h file. Once I determine the best
> sizes for all my VARCHARs, that file will probably remain untouched
> until the end of time.
>
> Thanks!
>
> -Ramon- Hide quoted text -
>
> - Show quoted text -

If you retrieve the numeric values from Oracle as numbers you can format them via a printf format mask like you do native C floating point numbers.

I think formatting the values via Oracle and returning them as character strings will probably work maintenance free as long as you make each string big enough for the size of the values, and you do not need to use the values as numbers in the program. This last issue if a requirement could mean you need to do the formatting in the program.

HTH -- Mark D Powell -- Received on Mon Apr 02 2007 - 09:29:26 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US