‎2007 Nov 02 12:10 PM
Hi
what is the maximum length a string variable can hold? say i want a variable zname to hold a string of 10,000 characters is it posible? kindly advice. if not what is the other way of doing it?
‎2007 Nov 02 12:15 PM
‎2007 Nov 02 12:15 PM
‎2007 Nov 02 12:18 PM
Hi,
I do not think that there is a limit. But I am sure it will keep 10k chars b'coz I used it to keep 12k char of length.
Regards,
Subbu
‎2007 Nov 02 12:23 PM
Hiii Prabhu,
though a string can generally store 256 char(Normally we use this .) still the following documents will clear ur doubt and show u the corect path,
Open SQL supports three different types to store varying length character strings: VARCHAR, LONGVARCHAR and CLOB. Only columns of the VARCHAR type, whose maximum size is limited to 1000 characters, are allowed to occur in comparison expressions, ORDER BY clauses, and so on.
From a functional point of view, LONGVARCHAR and CLOB columns behave the same, but the size restriction imposed on the LONGVARCHAR type allows this type to be mapped to an appropriate VARCHAR data type on each supported database platform. On most database platforms, this type is more efficient than the respective CLOB type.
To store character strings with more than 1,333 characters, the CLOB type must be used.
For portability reasons, Open SQL does not permit the storage of empty (zero-length) strings in any of these column types, because on some database platforms the empty string is always treated as a NULL value, which would lead to different query behavior on different database platforms. Furthermore, Open SQL forbids the storage of string values with trailing blanks in VARCHAR and LONGVARCHAR columns. This is because comparison semantics differs between blank-padded and non-padded semantics on the various database platforms. Blank-padded semantics compares two strings as equal if they differ in the number of trailing blanks only that is, "ABC equals ABC , whereas non-padded semantics compares two strings as equal only if they have equal length and no differing characters that is, ABC is not equal to ABC .
If an application needs to represent something like an "initial" value in a VARCHAR or LONGVARCHAR column, it is recommended that you use the string " " (a String object consisting of one single space). Although this is, strictly speaking, also a blank-padded string, it is accepted by Open SQL and can be treated in a portable way across all supported database platforms. In the case of CLOB columns, an initial value can and should be represented as a NULL value explicitly.
Binary Strings
Open SQL for Java supports the following data types to store binary strings:
· BINARY
· LONGVARBINARY
· BLOB
Only columns of the fixed BINARY type are comparable, whereas LONGVARBINARY and BLOB columns are not.
From a functional point of view, LONGVARBINARY and BLOB columns behave the same, but the size restriction imposed on the LONGVARBINARY type allows this type to be mapped to an appropriate VARBINARY type on each supported database platform. On most database platforms, this type is more efficient than the respective BLOB type.
To store binary strings with more than 2,000 bytes, the BLOB type has to be used.
With Open SQL for Java you cannot store empty (zero-length) binary strings in any of these column types, because on some database platforms the empty string is always treated as a NULL value. If you need to represent a custom initial value, you should either use some outstanding value in accordance with your application or consider storing a NULL value explicitly. In the latter case, you should be aware of the NULL value handling in SQL comparisons.
char(size) Holds a fixed length string (can contain letters, numbers, and special characters). The fixed size is specified in parenthesis
varchar(size) Holds a variable length string (can contain letters, numbers, and special characters). The maximum size is specified in parenthesis
tinytext Holds a variable string with a maximum length of 255 characters
text
blob Holds a variable string with a maximum length of 65535 characters
mediumtext
mediumblob Holds a variable string with a maximum length of 16777215 characters
longtext
longblob Holds a variable string with a maximum length of 4294967295 characters