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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatting a field on insert trigger

Status
Not open for further replies.

louie728

Programmer
Feb 4, 2004
27
US
Hello, I am trying to create a stored procedure that gets called in the insert trigger of a table, that when adding a record a certain field (width of 7 and a character type) gets formated like PADL('field',7). I have tried doing in a stored procedure to no avail and I have also tried just adding directly in the insert trigger. I get a datatype mismatch error if I try adding directly in the trigger and get nothing via stored procedure.
 
It sounds like it is a numeric value and needs to be converted to a character.

lnMyVal = 23
lcVal = ALLTRIM(STR(lnMyval))
PADL(lcVal,7,"0"))


You can use the type function to verify its data type.
? TYPE(lcVal)



Jim Osieczonek
Delta Business Group, LLC
 
Jim,
Thanks for replying. It is a character value. I basically want a certain field to be right justified in lieu of left justified when I enter a record to it. Perhaps the insert trigger is not the route I should take. Maybee there is some sort of format or field validation.

Thanks
 
louie728,

You need to use a field level RULE. Triggers are not able to update the row the record pointer is on.

boyd.gif

craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Craig,

I tried using PADL('FIELD',7) on the field validation rule and I get a datatype mismatch (really strange).

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top