Difference between revisions of "STR PAD()"

From Lianjapedia
Jump to: navigation, search
 
Line 11: Line 11:
 
The STR_PAD() function left-justifies a character string <expC1> and pads out the right of the string, to a total length of <expN> characters, with blank spaces.  The optional <expC2> may be used to pad <expC1> with a character string instead of blank spaces. If the optional <pad_type> is included, the string is processed as follows:
 
The STR_PAD() function left-justifies a character string <expC1> and pads out the right of the string, to a total length of <expN> characters, with blank spaces.  The optional <expC2> may be used to pad <expC1> with a character string instead of blank spaces. If the optional <pad_type> is included, the string is processed as follows:
  
{| class="wikitable" width=100%
+
{| class="wikitable" width="100%"
!width=30%|<pad_type>||Description
+
!width="30%"|<pad_type>||Description
 
|-
 
|-
 
|STR_PAD_RIGHT||Default behavior as above
 
|STR_PAD_RIGHT||Default behavior as above
 
|-
 
|-
|valign=top|STR_PAD_LEFT||<expC1> is right justified and padded to the left to a total of <expN> characters
+
|valign="top"|STR_PAD_LEFT||<expC1> is right justified and padded to the left to a total of <expN> characters
 
|-
 
|-
|valign=top|STR_PAD_BOTH||<expC1> is centered and padded to the left and right to a total of <expN> characters
+
|valign="top"|STR_PAD_BOTH||<expC1> is centered and padded to the left and right to a total of <expN> characters
 
|-
 
|-
 
|}
 
|}
Line 34: Line 34:
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Category:String Data]]
 
 
[[Category:String Data Functions]]
 
[[Category:String Data Functions]]

Latest revision as of 06:47, 4 February 2013

Purpose

Function to pad out a character string to a defined length

Syntax

STR_PAD(<expC1>,<expN>,[<expC2> [,<pad_type>]])

See Also

CENTER(), LPAD(), PADC(), PADL(), PADR(), RPAD(), SET STRESCAPE, STR(), STRTRAN(), STRZERO(), STUFF()

Description

The STR_PAD() function left-justifies a character string <expC1> and pads out the right of the string, to a total length of <expN> characters, with blank spaces. The optional <expC2> may be used to pad <expC1> with a character string instead of blank spaces. If the optional <pad_type> is included, the string is processed as follows:

<pad_type> Description
STR_PAD_RIGHT Default behavior as above
STR_PAD_LEFT <expC1> is right justified and padded to the left to a total of <expN> characters
STR_PAD_BOTH <expC1> is centered and padded to the left and right to a total of <expN> characters

The STR_PAD() function is useful for creating fixed length character strings by padding them out with blanks. If the string being processed is longer than the specified total length, no padding takes place.

Example

? str_pad("abc",6,"d")
abcddd

Products

Lianja Server, Lianja