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

CONSTRUCT - how to limit the field length??

Status
Not open for further replies.

SHUBA

Programmer
Nov 21, 2002
2
IN
Hi,
I just wanted to know if we could limit a field length in a construct statement. For example if i need to take an input from a form with the field name profile_code , then i type in CONSTRUCT BY NAME lc_where
ON some_profile.profile_code
....

Now, while i am entering something in the profile_code field on the form, and the actual field length of the profile_code field is 8 characters, it allows me to enter more than 8 characters on the form. As a result of this, the query fails and it says no record found.

I hope I have made this query understandable.would like a lead on this.


 
Hi,

Since CONSTRUCT accepts input from user through an active Form, you can adjust the field tag width according to your application need. Example:

database testdb
screen size 24 by 80
{

Profile : [aaa ]

}
tables
users
attributes
aaa = users.profile;
end

Alternatively, you check the data length related validations in the AFTER FIELD clause of the CONTRUCT BY NAME block. Example:

CONTRUCT BY NAME lc_where ON users.profile_code
AFTER FIELD profile_code
LET ucode = get_fldbuf(profile_code)
IF LENGTH(ucode CLIPPED) != 8 THEN
ERROR "Incomple code provided. Please re-enter."
NEXT FIELD profile_code
END IF
END CONSTRUCT

Regards
Shriyan
 
Hi Shriyan,

Thanks a lot for this useful piece of code. It helped me to solve the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top