HOWTO: Create an SQL Command with > 255 CharactersLast reviewed: February 21, 1997Article ID: Q163800 |
The information in this article applies to:
SUMMARYIt is often necessary to create an SQLEXEC command that contains more than 255 characters. But, if the command does contain more than 255 characters you will get a "syntax error" message. This article demonstrates one example of how the "insert string" might be concatenated to avoid this behavior.
MORE INFORMATIONThe following is an example of how you might use concatenation to execute a SQLEXEC command that would require more that 255 characters:
handle=SQLCONNECT("<data source>") m=SQLEXEC(handle, "CREATE TABLE t255 (one char(50)," + ; "two char(50), three char(50), four char(50)," + ; "five char(50), six char(50))") * The next command will insert the string successfully. b=SQLEXEC(handle, "INSERT INTO t255 (one) ; VALUES('xxxxxxjklmnopqrstuvwabcdefghijklmnopqrstuvw')") * The next command will also insert successfully. b=SQLEXEC(handle, "INSERT INTO t255 (one,two,three,four) ; VALUES("'abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw'," + ; "'abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw'," + ; "'abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw'," + ; "'abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw'")) *The next command will produce a syntax error because the length *of the string starting with insert is more than 255 characters. b=SQLEXEC(handle, "INSERT INTO t255 (one,two,three,four,five) ; "VALUES("'abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw'," + ; "'abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw'," + ; "'abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw'," + ; "'abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw'," + ; "'abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw'")") f1='abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw' f2='abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw' f3='abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw' f4='abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw' f5='abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw' f6='abcdefghijklmnopqrstuvwabcdefghijklmnopqrstuvw' *The next line works because there is no string *longer than 255 characters b=SQLEXEC(handle, "INSERT INTO t255" + ; "(one,two,three,four,five,six) " + ; "VALUES('"+ f1 + "','" + f2 + "','" + ; f3 + "','" + f4 + "','" + f5 + "','" + ; f6 + "')") |
KBCategory: kbusage kbhowto
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |