Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set default value of spaces

Status
Not open for further replies.

fryguy5049

Technical User
Apr 20, 2004
24
US
MySql 4.1/ Windows Server 2000

How can I set a field to a defualt value of spaces? For example I need field "def_spc" to equal 8 spaces. This is just a filler field and it would never change for any record. Also, what's the best data type for this type of field? Thanks
 
What exactly is it that you want to acomplish? What purpose would the filler filed have if its always empty?

Maybe if you can explain a little more we can help you better?

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
I am creating an extract for a mainframe application that requires fillers between certain fields. I wanted to just specify the field "def_spc" when I needed a 8 space filler.
 
Still don't quite understand why you would want empty columns, but you could use a Char type with a length of 8 characters.
Code:
def_spc char(8) DEFAULT "        ";

When you run a query you are just going to ignore the columns.
alltogether.
If you need fillers you should create them at the front end, with whatever language you are programming and dynamically create the space between the specified columns. Hardcoding them into an empty DB column is pointless as it does nothing to the data or the way its going to be displayed.





----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
What about

set @def_spc:=' ';

select
somefield1,
somefield2,
@def_spc,
somefield3
into outfile 'output_for_mainframe'
fields terminated by ''
lines terminated by '\r\n'
from mytable;



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top