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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle stop truncating my ACCEPT variable value darnit!

Re: Oracle stop truncating my ACCEPT variable value darnit!

From: Galen Boyer <galenboyer_at_hotpop.com>
Date: 8 Apr 2003 21:17:12 -0500
Message-ID: <uptnw9r3a.fsf@hotpop.com>


On Tue, 8 Apr 2003, Joe at NoSP4M eat-me dot net wrote:
> I am trying to get a user entered value into one of my scripts, and
> the value keeps getting truncated.
>
> The user enters 09
> The number is truncated to just 9, and I need 09

First off, you are confused with the term. Truncating means the right side is being lopped off.

> Is there anyway to stop this madness?

I would guess you have the wrong datatype called out in your accept.

Let's say you script called, tmp.sql looks like the following:

    accept SomeValue number PROMPT 'SomeValue: '

    select '&SomeValue' from dual;

Then, your sqlplus interaction would look like:

    SQL> @tmp
    SomeValue: 09
    old 1: select '&SomeValue' from dual     new 1: select ' 9' from dual

    '9'


             9

Instead, try tmp.sql having:

    accept SomeValue char PROMPT 'SomeValue: 'n

    select '&SomeValue' from dual;

Then, your sqlplus interaction would look like:

    SQL> @tmp
    TableName: 09
    old 1: select '&TableName' from dual     new 1: select '09' from dual

    '0
    --
    09

The number converts the accepted string to a number. The char keeps it around.

-- 
Galen deForest Boyer
Sweet dreams and flying machines in pieces on the ground.
Received on Tue Apr 08 2003 - 21:17:12 CDT

Original text of this message

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