<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Limits to SQL Statements in sacapi.dll in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842948#M4873791</link>
    <description>&lt;P&gt;Thanks Volker, multiple simultaneous statements on an individual connection are not my greatest concern at this stage. &lt;/P&gt;
&lt;P&gt;The thing I'm worried about is that we might run into limits when trying to prepare large insert statements say when we want to use UNION ALL type statements to insert multiple rows at once as shown here &lt;A href="http://stackoverflow.com/questions/2624713/how-do-i-insert-multiple-rows-without-repeating-the-insert-into-dbo-blah-part"&gt;http://stackoverflow.com/questions/2624713/how-do-i-insert-multiple-rows-without-repeating-the-insert-into-dbo-blah-part&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I am worried about this because I have hit these limits in the past with SQL Server. It has a (default) limit of 256MB which is Batch Size (64KB) * Network Packet Size (defaults to 4KB).&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jul 2014 03:22:04 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2014-07-22T03:22:04Z</dc:date>
    <item>
      <title>Limits to SQL Statements in sacapi.dll</title>
      <link>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaq-p/13842945</link>
      <description>&lt;P&gt;Hi all, just wanting to know, are there any upper limits with respects to the size/complexity of a SQL Statement executed against SqlAnywhere 12 through the sacapi.dll? &lt;/P&gt;
&lt;P&gt;The kinds of things I'm looking to understand are &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Maximum character length (I am guessing this would be bounded by the maximum string length in SA, i.e. 2GB), but are there further restrictions placed on this by either the engine or the dll?&lt;/LI&gt;
&lt;LI&gt;Maximum number of prepared parameters?&lt;/LI&gt;
&lt;LI&gt;Any other hard limits we might run into?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jul 2014 21:21:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaq-p/13842945</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-07-21T21:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Limits to SQL Statements in sacapi.dll</title>
      <link>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842947#M4873790</link>
      <description>&lt;P&gt;Can't tell for the SA CAPI but the maximum number of concurrent prepared statements per connection can be specified via the &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbadmin/max-statement-count-option.html"&gt;max_statement_count option&lt;/A&gt;...&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2014 02:58:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842947#M4873790</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2014-07-22T02:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Limits to SQL Statements in sacapi.dll</title>
      <link>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842948#M4873791</link>
      <description>&lt;P&gt;Thanks Volker, multiple simultaneous statements on an individual connection are not my greatest concern at this stage. &lt;/P&gt;
&lt;P&gt;The thing I'm worried about is that we might run into limits when trying to prepare large insert statements say when we want to use UNION ALL type statements to insert multiple rows at once as shown here &lt;A href="http://stackoverflow.com/questions/2624713/how-do-i-insert-multiple-rows-without-repeating-the-insert-into-dbo-blah-part"&gt;http://stackoverflow.com/questions/2624713/how-do-i-insert-multiple-rows-without-repeating-the-insert-into-dbo-blah-part&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I am worried about this because I have hit these limits in the past with SQL Server. It has a (default) limit of 256MB which is Batch Size (64KB) * Network Packet Size (defaults to 4KB).&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2014 03:22:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842948#M4873791</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-07-22T03:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Limits to SQL Statements in sacapi.dll</title>
      <link>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842949#M4873792</link>
      <description>&lt;P&gt;FWIW, when using SQL Anywhere 12 and above, you can simply add several rows within one INSERT statement, cf. &lt;A href="http://dcx.sybase.com/index.html#1201/en/sachanges/newinnsbruck-sectc-37891021.html"&gt;this sample from the docs&lt;/A&gt;:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Support for more than one list of values&lt;BR /&gt;
An INSERT statement can now contain more than one list of values, allowing several rows to be inserted at once. For example:&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;PRE class="codehilite"&gt;&lt;CODE&gt;    INSERT INTO T (c1,c2,c3)
    VALUES (1,10,100), (2,20,200), (3,30,300);


&lt;P&gt;That seems to work like in MS SQL 2008 and should make those batches much shorter.&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;That being said, I can't tell whether there is a limit as in SQL Server so others will have to answer that... On the other hand, if you just attempt to generate such statements (say, by constructing a statement based on a SELECT from a larger table) you might find out yourself. - AFAIK, SQL Anywhere usually does not have "fixed" limits for queries but might run into memory constraints at runtime.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jul 2014 03:36:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842949#M4873792</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2014-07-22T03:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Limits to SQL Statements in sacapi.dll</title>
      <link>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842950#M4873793</link>
      <description>&lt;P&gt;You might want to explore the various features of &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbreference/load-table-statement.html"&gt;LOAD TABLE&lt;/A&gt;, in particular LOAD TABLE ( column names ) USING VALUE '... rows of data ...'.&lt;/P&gt;
&lt;P&gt;Even on a bad day, LOAD TABLE will run rings around INSERT, BULK or otherwise &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2014 10:47:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842950#M4873793</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2014-07-22T10:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: Limits to SQL Statements in sacapi.dll</title>
      <link>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842951#M4873794</link>
      <description>&lt;P&gt;Thanks both of you, both these answers are helpful, but the fundamental issue still remains. What I am trying to solve is a "Copy" operation where objects in our database are copied and pasted. To achieve this we are using a statement like this &lt;/P&gt;
&lt;P&gt;INSERT INTO (&amp;lt;columns that="" are="" updated="" from="" code=""&amp;gt;, &amp;lt;columns that="" are="" copied="" from="" existing="" table=""&amp;gt;)&lt;/P&gt;
&lt;P&gt;SELECT (&amp;lt;fields derived="" in="" code=""&amp;gt;, &amp;lt;fields from="" existing="" table=""&amp;gt; FROM &amp;lt;existing table=""&amp;gt; WHERE Id = &amp;lt;pk&amp;gt; &lt;/P&gt;
&lt;P&gt;UNION ALL &lt;/P&gt;
&lt;P&gt;SELECT (&amp;lt;fields derived="" in="" code=""&amp;gt;, &amp;lt;fields from="" existing="" table=""&amp;gt; FROM &amp;lt;existing table=""&amp;gt; WHERE Id = &amp;lt;pk&amp;gt; &lt;/P&gt;
&lt;P&gt;UNION ALL
...&lt;/P&gt;
&lt;P&gt;each select statement is a single row from the existing table, as we need to derive some column values in code.&lt;/P&gt;
&lt;P&gt;I am trying to determine just how far this will scale. The majority of the time users will only be copying a few objects (rows) at a time, maybe occasionally up to a few thousand, but I know from past (bitter) experience, that there is that 0.5% of users that are able to find the limits of the system (even if they are doing things we wouldn't really recommend). I guess I'd just like to know those limits before our users find them. Especially if those limits are fairly low (i.e. if we can't copy more than a few thousand rows like this, then we will actually need to put in place a work around).&lt;/P&gt;
&lt;P&gt;LOAD TABLE may actually help, but we'd still actually have to create the file first by combining data from the existing table with our data derived from code, which would still mean performing all of the SELECT queries, which in Abbot and Costello parlance is "First Base".&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2014 21:33:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842951#M4873794</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-07-22T21:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Limits to SQL Statements in sacapi.dll</title>
      <link>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842952#M4873795</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;each select statement is a single row from the existing table, as we need to derive some column values in code.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So you say it's not possible to calculate these values as part of a select list of a big INSERT SELECT ... statement? Or possibly a MERGE statement? Possibly by calculating part of these "derived" values with the help of a procedure that takes data from the existing tables as input? - IMHO, these are really mighty ETL tools..&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I am trying to determine just how far this will scale. &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I do understand that you are interested in hard limits (and they may exist, I simply do not know, the SQL Anywhere engineers certainly &lt;EM&gt;will&lt;/EM&gt; now...). However, as suggested, I'd recommend to test that yourself by constructing a giant INSERT over a UNION... Simply try to be one of the 0.1% top users:) - Even if hard limits do exist, you might run into "soft limits" beforehand. E.g. the &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbadmin/da-limits.html"&gt;number of tables&lt;/A&gt; a database can hold is limited (4293918719). While it would not violate "hard limits" to join all these tables (To cite: &lt;EM&gt;"Number of tables referenced per transaction: No limit"&lt;/EM&gt;) I guess such a query would typically fail because it would demand much more memory than available. That's a guess, I have not tried that myself:)&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2014 03:28:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842952#M4873795</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2014-07-23T03:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Limits to SQL Statements in sacapi.dll</title>
      <link>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842953#M4873796</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;create the file first&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The USING VALUE form of LOAD TABLE uses an expression, not a file. Here is an example from the Help...&lt;/P&gt;
&lt;P&gt;The following syntax specifies the value directly, inserting two rows with values of 4 and 5, respectively;&lt;/P&gt;
&lt;P&gt;... USING VALUE '4\\n5'...&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2014 13:09:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842953#M4873796</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2014-07-23T13:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Limits to SQL Statements in sacapi.dll</title>
      <link>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842946#M4873789</link>
      <description>&lt;P&gt;I do not believe there are any specific hard limits you should run into when going through sacapi.dll, apart from the normal hard limits imposed by the server. To your specific points:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Maximum character length (I am guessing this would be bounded by the
maximum string length in SA, i.e.
2GB), but are there further
restrictions placed on this by either
the engine or the dll?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;INSERTING or SELECTING very large values over sacapi.dll may be very memory intensive. In particular, dealing with values &amp;gt; 500MB as a single block could cause low memory conditions. However, sacapi.dll has APIs for INSERTing and SELECTing chunked data. As long as the chunked APIs are used for large values, you should not have a problem.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Maximum number of prepared parameters?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The server's governor has some default values (such a maximum of 50 active prepared statements per connection), but none of these are specific to sacapi.dll.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Any other hard limits we might run into?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Nope, not that I am aware of.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2014 16:18:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/limits-to-sql-statements-in-sacapi-dll/qaa-p/13842946#M4873789</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-07-24T16:18:33Z</dc:date>
    </item>
  </channel>
</rss>

