scripter73
Programmer
Hi,
I have a query that reads a database table and returns 2 codes to me. Code1 is a single alpha character, and the Code2 is a text number whose length could range from 1 character to 5 characters.
My problem is that I need that second code to always be 5 characters, so I need to pad it with leading zeros. For ex: if length = 4, pad with one 0; if length=3, two 0s, etc.
How can I "update" my query, or obtain another query that has my corrected Code2? Below is my code. I'm able to get the length of my Code2, and now I am stuck.
<CFQUERY name="agentdata" datasource="#session.dsn#">
select CODE1, CODE2
from TABLEA
where ID = 'G01200'
order by CODE1, CODE2
</CFQUERY>
Show Agents:<br>
<CFOUTPUT query="agentdata">
<cfset #session.agentlength# = Len(#agentdata.CODE2#)>
#agentdata.CODE1##agentdata.CODE2#, Length = #session.agentlength#<br>
</CFOUTPUT>
Thanks in advance,
scripter73
Change Your Thinking, Change Your Life.
I have a query that reads a database table and returns 2 codes to me. Code1 is a single alpha character, and the Code2 is a text number whose length could range from 1 character to 5 characters.
My problem is that I need that second code to always be 5 characters, so I need to pad it with leading zeros. For ex: if length = 4, pad with one 0; if length=3, two 0s, etc.
How can I "update" my query, or obtain another query that has my corrected Code2? Below is my code. I'm able to get the length of my Code2, and now I am stuck.
<CFQUERY name="agentdata" datasource="#session.dsn#">
select CODE1, CODE2
from TABLEA
where ID = 'G01200'
order by CODE1, CODE2
</CFQUERY>
Show Agents:<br>
<CFOUTPUT query="agentdata">
<cfset #session.agentlength# = Len(#agentdata.CODE2#)>
#agentdata.CODE1##agentdata.CODE2#, Length = #session.agentlength#<br>
</CFOUTPUT>
Thanks in advance,
scripter73
Change Your Thinking, Change Your Life.