• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

SQL Question...

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.
Originally posted by: Descartes
He's better off keeping the data stored accurately in the database. If he has a number of 50 being stored, for some reason, as 0000.50 in the database, the last thing he should do is massage the data into being correct for output. If he wants a numeric field to display with some funky formatting, he should convert it to a string and pad the data with zero's. I'm not suggesting he change the datatype of the column.

I said for *display*, not to actually alter the data. {SNIP}
Uh, so did I. Did you even read my first comment? And I quote: *ahem*
keep it in standard float format (0.0), and convert it to a character (0000.00) for display purposes.
 
Originally posted by: Descartes
Descartes... i have no idea what you're jabberwockin about

That was more for Beau, so you can safely ignore me.... as can everyone else for that matter 🙂

I'm more of a TSQL monkey, so I honestly don't know what your issue is. It seems KnightBreed is an Oracle pundit though... I'm sure he can come up w/ a solution 🙂
When I find out what pundit means, you're gonna be in sooo much trouble. 😀
 
Spooner, can you post the DDL to both tables (source and destination tables)?

Descartes, I'm hardly a pundit of any language. The app my company makes works in Oracle, SQL Server, and Sybase Server Anywhere, and any database specific SQL needs to be converted into all formats, so I have spent some time in TSQL - though I do my development work in Oracle.

You seem to have a good grasp of the low level workings of TSQL databases. Much more so than I (in Oracle)... 😱
 
I'll tell you how I've done something like this in TSQL. Don't laugh for TSQL lacks the more lucid facilities of PL/SQL. When .NET is native w/ SQL Server.NET, that won't be the case 😉

Sometimes, when integrating w/ other platforms, I need to pad date fields. So, I *could* do something like...

case len(cast(month(somedatefield) as char(2))
when 1 then '0' + cast(month(somedatefield) as char(2))
else cast(month(somedatefield) as char(2))
end

That's just to give you an idea of a possibility. Obviously that many casts isn't good, so you'd want to declare a single variable for it, etc.

I know there has to be a more efficient way to do that in PL/SQL? In TSQL, we also have an extended sproc called xp_sprintf, that wraps C/C++'s sprintf that would do this beautifully. I'm sure there's a PL/SQL equivalent?
 
I'll tell you how I've done something like this in TSQL. Don't laugh for TSQL lacks the more lucid facilities of PL/SQL. When .NET is native w/ SQL Server.NET, that won't be the case 😉

Sometimes, when integrating w/ other platforms, I need to pad date fields. So, I *could* do something like...

case len(cast(month(somedatefield) as char(2))
when 1 then '0' + cast(month(somedatefield) as char(2))
else cast(month(somedatefield) as char(2))
end

That's just to give you an idea of a possibility. Obviously that many casts isn't good, so you'd want to declare a single variable for it, etc.

I know there has to be a more efficient way to do that in PL/SQL? In TSQL, we also have an extended sproc called xp_sprintf, that wraps C/C++'s sprintf that would do this beautifully. I'm sure there's a PL/SQL equivalent?
 
Just out of curiosity, does 3300 translate to 0000.33 or 0033.00?

/me back to reading my oracle/sql book.
 
Originally posted by: Beau6183
Just out of curiosity, does 3300 translate to 0000.33 or 0033.00?

/me back to reading my oracle/sql book.
the field displays "33.00" in Oracle
when extracted, it translates into "00000.33" i WANT it to translate to "00033.00"
 
Originally posted by: Spooner
Originally posted by: Beau6183
Just out of curiosity, does 3300 translate to 0000.33 or 0033.00?

/me back to reading my oracle/sql book.
the field displays "33.00" in Oracle
when extracted, it translates into "00000.33" i WANT it to translate to "00033.00"
DDL my friend! Post the DDL to the tables in question! I wanna get a better idea of how these tables are defined.
 
Originally posted by: Spooner
Originally posted by: Beau6183
Just out of curiosity, does 3300 translate to 0000.33 or 0033.00?

/me back to reading my oracle/sql book.
the field displays "33.00" in Oracle
when extracted, it translates into "00000.33" i WANT it to translate to "00033.00"

I said 3300 as in 3300.00, not 33.00.
 
Originally posted by: KnightBreed
Originally posted by: Spooner
Originally posted by: Beau6183
Just out of curiosity, does 3300 translate to 0000.33 or 0033.00?

/me back to reading my oracle/sql book.
the field displays "33.00" in Oracle
when extracted, it translates into "00000.33" i WANT it to translate to "00033.00"
DDL my friend! Post the DDL to the tables in question! I wanna get a better idea of how these tables are defined.
I'm looking in the backend to see what table this subform is pulling values from 😱
 
Originally posted by: Descartes
I'll tell you how I've done something like this in TSQL. Don't laugh for TSQL lacks the more lucid facilities of PL/SQL. When .NET is native w/ SQL Server.NET, that won't be the case 😉
Lucid facilities? PL/SQL for any pre-Oracle9 platform doesn't even support CASE statements. The only comparable equivalent would be DECODE(variable, if constant1, then return X, if constant2, then return Y, else return Z). :frown:

edit: fixed formatting.
 
So it's basically stripping all trailing "0" after the decimal right? Why not just round all numbers to the 2 degree, then multiply by 100 then apply the filter? As knightbreed already said?
 
Originally posted by: Beau6183
So it's basically stripping all trailing "0" after the decimal right? Why not just round all numbers to the 2 degree, then multiply by 100 then apply the filter? As knightbreed already said?

Come again?
 
If it is just stripping the zeros after the decimal, multiply everyting by 100, then they all have zeros after the decimal. It should pad everything the same:

33.00 -> 3300 -> 0033.00

19.37 -> 1937 -> 0019.37
 
Originally posted by: Spooner
I'm looking in the backend to see what table this subform is pulling values from
Wait, subforms? Are you looking at the data through some form? Is it possible the form is formatting the output incorrectly? It's possible the actual data in the table is fine.
Originally posted by: Spooner
yes i did
Please find out how these tables/columns are defined. Post the DDL. Post the DDL. Post the DDL.
 
here's the table I'm pulling "screen_entry_value" from

Name Null? Type
------------------------------- -------- ----
ELEMENT_ENTRY_VALUE_ID NOT NULL NUMBER(15)
EFFECTIVE_START_DATE NOT NULL DATE
EFFECTIVE_END_DATE NOT NULL DATE
INPUT_VALUE_ID NOT NULL NUMBER(9)
ELEMENT_ENTRY_ID NOT NULL NUMBER(15)
SCREEN_ENTRY_VALUE VARCHAR2(60)

sorry about the formatting 😱
 
and i have it being passed into this:

nvl( UPPER(LPAD(vDepAmt,8,'00000.00')) , LPAD('00000.00',8) )


where "vDepAmt" is the "screen_entry_value"
 
FUNCTION Procedure fPadNumber(
     RETURN NUMBER;
IS

     CURSOR cur_lngNum IS
          SELECT screen_entry_value
          FROM MyTable
          WHERE my-where-statements-here;
     IntPOS integer;
     lngNum Long;
     strNum VARCHAR;

BEGIN

     OPEN cur_lngNum;
     strNum = to_char(cur_lngNum,'0999.99');
     lngNum = to_Number(strNum);
     RETURN lngNum;

END fPadNumber;
 
Back
Top