Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » size of S_XXX struct members
size of S_XXX struct members [message #41560] Mon, 30 December 2013 15:53 Go to next message
Alboni is currently offline  Alboni
Messages: 203
Registered: January 2012
Location: Deventer, Netherlands
Experienced Member
I problem im running into a lot is users entering strings that are longer than defined in the sql tables.

for example if I have a .sch file like
TABLE_ (PAYMENT_METHOD)
	INT_	(PM_ID) PRIMARY_KEY UNIQUE AUTO_INCREMENT
	STRING_	(PM_DESCRIPTION, 30)
END_TABLE


and a user enters a description of 35 characters, then the sql insert fails with an errormessage that the value for PM_DESCRIPTION is too long.

I know I can use EditString::MaxLen(30) to limit the input, but that means entering the length of the field in 2 places.
So, can I do something like:

dialog.pm_description.MaxLen(sizeof(S_PAYMENT_METHOD::PM_DESCRIPTION));


dialog.pm_description being the EditString for editing the field
for editing PM_DESCRIPTION in the PAYMENT_METHOD table.

I know sizeof() won't work here, but what will?


[Updated on: Mon, 30 December 2013 15:56]

Report message to a moderator

Re: size of S_XXX struct members [message #41627 is a reply to message #41560] Mon, 06 January 2014 16:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13032
Registered: November 2005
Ultimate Member
Right now, it is unfortunately not possible, but it is reasonable request that could be relatively easily implemented - RM task added:

http://www.ultimatepp.org/redmine/issues/630

Mirek
Re: size of S_XXX struct members [message #41634 is a reply to message #41627] Mon, 06 January 2014 19:28 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 591
Registered: November 2008
Location: France
Contributor
Message deleted ==> I replied the wrong message

[Updated on: Mon, 06 January 2014 22:17]

Report message to a moderator

Re: size of S_XXX struct members [message #41649 is a reply to message #41560] Tue, 07 January 2014 22:53 Go to previous messageGo to next message
Alboni is currently offline  Alboni
Messages: 203
Registered: January 2012
Location: Deventer, Netherlands
Experienced Member
Being able to do something like this would be grand also:

S_PAYMENT_METHOD rec;
int n=rec.GetCount();
for (int i=0; i<n; i++)
{
	switch (rec[i].type)
	{
		case S_INT: DoSomethingWithAnInt(rec[i].Value, rec[i].MaxLength); break;
		case S_STRING: DoSomethingWithAnString(rec[i].Value, rec[i].MaxLength); break;
		................
	}
}

[Updated on: Tue, 07 January 2014 23:13]

Report message to a moderator

Re: size of S_XXX struct members [message #41665 is a reply to message #41649] Wed, 08 January 2014 12:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13032
Registered: November 2005
Ultimate Member
Alboni wrote on Tue, 07 January 2014 16:53

Being able to do something like this would be grand also:

S_PAYMENT_METHOD rec;
int n=rec.GetCount();
for (int i=0; i<n; i++)
{
	switch (rec[i].type)
	{
		case S_INT: DoSomethingWithAnInt(rec[i].Value, rec[i].MaxLength); break;
		case S_STRING: DoSomethingWithAnString(rec[i].Value, rec[i].MaxLength); break;
		................
	}
}



This is actually already possible; rec has GetRef method and Ref has GetType or even Is<> methods...

Mirek
Re: size of S_XXX struct members [message #41680 is a reply to message #41665] Fri, 10 January 2014 14:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13032
Registered: November 2005
Ultimate Member
S_type::GetWidth implemented.

Mirek
Re: size of S_XXX struct members [message #41681 is a reply to message #41560] Fri, 10 January 2014 14:48 Go to previous messageGo to next message
Alboni is currently offline  Alboni
Messages: 203
Registered: January 2012
Location: Deventer, Netherlands
Experienced Member
Cool! That was quick. Cool

Thanks! Surprised
Re: size of S_XXX struct members [message #41682 is a reply to message #41560] Fri, 10 January 2014 14:57 Go to previous messageGo to next message
Alboni is currently offline  Alboni
Messages: 203
Registered: January 2012
Location: Deventer, Netherlands
Experienced Member
Would it be an idea to automatically set the maximum length of EditString controls used in combination with SqlCtrls?

Makes sense to me....
Re: size of S_XXX struct members [message #41684 is a reply to message #41682] Fri, 10 January 2014 15:35 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13032
Registered: November 2005
Ultimate Member
Alboni wrote on Fri, 10 January 2014 08:57

Would it be an idea to automatically set the maximum length of EditString controls used in combination with SqlCtrls?

Makes sense to me....


SqlCtrls are not quite bound to specific table....

(But generally, yes).
Re: size of S_XXX struct members [message #41838 is a reply to message #41560] Tue, 28 January 2014 14:34 Go to previous messageGo to next message
Alboni is currently offline  Alboni
Messages: 203
Registered: January 2012
Location: Deventer, Netherlands
Experienced Member
I think it would be awfully handy if those new functions were static.
Re: size of S_XXX struct members [message #41841 is a reply to message #41838] Tue, 28 January 2014 20:13 Go to previous message
mirek is currently offline  mirek
Messages: 13032
Registered: November 2005
Ultimate Member
You are right, done.
Previous Topic: testing out firebird in bazaar missing ibase.h
Next Topic: firebird with sqlarray ctrl (possible?)
Goto Forum:
  


Current Time: Sat Jan 16 08:47:32 CET 2021

Total time taken to generate the page: 0.01088 seconds