<?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: Calling ESQL from .NET program in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814828#M4845671</link>
    <description>&lt;P&gt;&lt;A href="https://sqlanywhere-forum.sap.com/users/466/john/"&gt;@John&lt;/A&gt;: Thanks to confirm my experience with SQL Anywhere's ODBC drivers:)&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;&lt;A href="https://sqlanywhere-forum.sap.com/users/751/tonyv/"&gt;@Tony&lt;/A&gt;: Sorry, I don't mean to mess around with your project requirements. It's free advice, feel free to use it or not:)&lt;/P&gt;
&lt;P&gt;However, from your other question, your basic question seems to be how to do mass-inserts effectively with ADO.Net.&lt;/P&gt;
&lt;P&gt;I still have the impression it would be way easier to try an &lt;STRONG&gt;OPENSTRING()&lt;/STRONG&gt; approach with ADO.Net than to try to have a transaction on different APIs. In the end, you would just be sending one simple SQL statement to the engine, without any parameters or with just one parameter naming the file or variable which contains the mass data. With such an approach, the API used won't matter much since the base work has to be done within the database engine. In other words, the database engine would need to extract the data itself from the source, and you would not need to supply the values parameter-wise. - Well, apparently, my assumption on the data source can easily be wrong since you have not yet told how the "data [sent] over the wire from the server to the client" is stored within the client machine. Maybe you could be more verbose here?&lt;/P&gt;
&lt;P&gt;IIRC, OPENSTRING() is at the heart of the LOAD TABLE statement, and LOAD TABLE is surely the fastest way to do mass insertion. However, LOAD TABLE won't handle "upserts", and it does an automatic commit which would end your transaction...&lt;/P&gt;</description>
    <pubDate>Mon, 22 Apr 2013 03:37:16 GMT</pubDate>
    <dc:creator>VolkerBarth</dc:creator>
    <dc:date>2013-04-22T03:37:16Z</dc:date>
    <item>
      <title>Calling ESQL from .NET program</title>
      <link>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaq-p/13814821</link>
      <description>&lt;P&gt;I am going to be writing some code in a C DLL that will be called from an &lt;A href="http://ADO.net" target="_blank"&gt;ADO.net&lt;/A&gt; program.  I need the C code to use the same connection and transaction that the &lt;A href="http://ADO.net" target="_blank"&gt;ADO.net&lt;/A&gt; program uses.  That is, the work that the C code does must happen in the same transaction that the &lt;A href="http://ADO.net" target="_blank"&gt;ADO.net&lt;/A&gt; code does its work in.&lt;/P&gt;
&lt;P&gt;I'm a complete novice at ESQL. I have no idea how to do this, or even if it's possible.  Can it be done?&lt;/P&gt;
&lt;P&gt;Where does one find information on how to write ESQL code? The documentation is a bit light on detail.  It seems to rely on sample code, which isn't answering my questions.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2013 22:58:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaq-p/13814821</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-04-19T22:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calling ESQL from .NET program</title>
      <link>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814823#M4845666</link>
      <description>&lt;P&gt;Just to ask: Does it need to be ESQL - or would ODBC do as well? I guess the ODBC API would seem way more familiar to ADO.Net than ESQL...)&lt;/P&gt;
&lt;P&gt;(Yes, I'm aware that this doesn't answer any of your questios.)&lt;/P&gt;</description>
      <pubDate>Sat, 20 Apr 2013 05:45:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814823#M4845666</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2013-04-20T05:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calling ESQL from .NET program</title>
      <link>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814824#M4845667</link>
      <description>&lt;P&gt;No, it can't be ODBC.  We're trying to speed up the process in our program, not slow it down.  I do know that there is a C API as well as ESQL.  I know I can send multiple rows using the PUT statement in ESQL; if there is an equivalent in the C API, I can use that.&lt;/P&gt;
&lt;P&gt;This has to do with my other question about sending data for multiple rows to be inserted into the database in one I/O operation.  The performance of SABulkCopy is abysmal or we'd use it.&lt;BR /&gt;
&lt;/P&gt;
&lt;P&gt;Basically, I'm looking to send lots of data in single I/O operations.  I don't have time to chase down things that might work (i've got a 4 week deadline on this); I've got to do something that will work.  I believe ESQL is the fastest way to get it done.  And I know I can make it work in ESQL.  So that's what I'm going to do.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Apr 2013 08:15:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814824#M4845667</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-04-20T08:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calling ESQL from .NET program</title>
      <link>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814825#M4845668</link>
      <description>&lt;P&gt;ESQL uses DBLIB which goes directly to our native communications library. ODBC goes directly to our native communications library too -- there's no reason to expect ODBC to be slower. &lt;/P&gt;
&lt;P&gt;The "C API" (dbcapi) is a convenience layer that is used by most or all of our scripting language drivers (perl, php, etc) and is implemented in ESQL. It is more convenient to use because it manages many buffers, etc for you  and that comes at a minor cost.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2013 12:48:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814825#M4845668</guid>
      <dc:creator>johnsmirnios</dc:creator>
      <dc:date>2013-04-21T12:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calling ESQL from .NET program</title>
      <link>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814826#M4845669</link>
      <description>&lt;P&gt;John:&lt;/P&gt;
&lt;P&gt;My experience with ODBC, in general, has been that the ODBC drivers have more overhead &amp;amp; are slower.  I have no experience using ODBC with SQL Anywhere.&lt;/P&gt;
&lt;P&gt;Are there any books out there that explain how to write ESQL programs?  And is it possible for code in a DLL written using ESQL to share the connection &amp;amp; transaction in use in C# ADO.NET?&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2013 15:12:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814826#M4845669</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-04-21T15:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calling ESQL from .NET program</title>
      <link>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814827#M4845670</link>
      <description>&lt;P&gt;I don't know of any books other than the documentation: &lt;A href="http://dcx.sybase.com/index.html#sa160/en/dbprogramming/pg-esql.html*d5e25879"&gt;http://dcx.sybase.com/index.html#sa160/en/dbprogramming/pg-esql.html*d5e25879&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Sorry but I also don't know anything definitive about .NET and how/whether it allows the same connection to use ESQL. A quick glance at the code suggests that it links directly to the same native communications libraries as DBLIB and ODBC. I &lt;EM&gt;think&lt;/EM&gt; that would mean that there is no SQLCA available for native code to use since SQLCA objects are only used by DBLIB. There would also be no ODBC connection for native code to use either.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2013 21:39:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814827#M4845670</guid>
      <dc:creator>johnsmirnios</dc:creator>
      <dc:date>2013-04-21T21:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calling ESQL from .NET program</title>
      <link>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814828#M4845671</link>
      <description>&lt;P&gt;&lt;A href="https://sqlanywhere-forum.sap.com/users/466/john/"&gt;@John&lt;/A&gt;: Thanks to confirm my experience with SQL Anywhere's ODBC drivers:)&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;&lt;A href="https://sqlanywhere-forum.sap.com/users/751/tonyv/"&gt;@Tony&lt;/A&gt;: Sorry, I don't mean to mess around with your project requirements. It's free advice, feel free to use it or not:)&lt;/P&gt;
&lt;P&gt;However, from your other question, your basic question seems to be how to do mass-inserts effectively with ADO.Net.&lt;/P&gt;
&lt;P&gt;I still have the impression it would be way easier to try an &lt;STRONG&gt;OPENSTRING()&lt;/STRONG&gt; approach with ADO.Net than to try to have a transaction on different APIs. In the end, you would just be sending one simple SQL statement to the engine, without any parameters or with just one parameter naming the file or variable which contains the mass data. With such an approach, the API used won't matter much since the base work has to be done within the database engine. In other words, the database engine would need to extract the data itself from the source, and you would not need to supply the values parameter-wise. - Well, apparently, my assumption on the data source can easily be wrong since you have not yet told how the "data [sent] over the wire from the server to the client" is stored within the client machine. Maybe you could be more verbose here?&lt;/P&gt;
&lt;P&gt;IIRC, OPENSTRING() is at the heart of the LOAD TABLE statement, and LOAD TABLE is surely the fastest way to do mass insertion. However, LOAD TABLE won't handle "upserts", and it does an automatic commit which would end your transaction...&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2013 03:37:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814828#M4845671</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2013-04-22T03:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calling ESQL from .NET program</title>
      <link>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814829#M4845672</link>
      <description>&lt;P&gt;Just to add: Here is a FAQ that explains the connection between LOAD TABLE and OPENSTRING - by John himself:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://sqlanywhere-forum.sap.com/questions/12356"&gt;Where did "OpenString" come from?&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2013 03:45:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814829#M4845672</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2013-04-22T03:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calling ESQL from .NET program</title>
      <link>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814830#M4845673</link>
      <description>&lt;P&gt;Volker:&lt;/P&gt;
&lt;P&gt;Given what John has said about there being no SQLCA in the .NET drives, it seems ESQL isn't going to cut the mustard for me, anyway.  There's no way we're going to rewrite our entire program in ESQL at this late date and in the timeframe I have.&lt;/P&gt;
&lt;P&gt;And, given that LOADTABLE &amp;amp; OPENSTRING are almost one &amp;amp; the same thing, OPENSTRING is where I'm headed.  All I have to do is figure out how to structure the BLOB I'm going to pass to the statement as the one and only parameter.  Not to mention how exactly to write the statement to execute.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2013 08:27:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814830#M4845673</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-04-22T08:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calling ESQL from .NET program</title>
      <link>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814822#M4845665</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;That is, the work that the C code does must happen in the same transaction that the &lt;A href="http://ADO.net"&gt;&lt;/A&gt;&lt;A href="http://ADO.net"&gt;ADO.net&lt;/A&gt; code does its work in. ... I'm a complete novice at ESQL. I have no idea how to do this, or even if it's possible. Can it be done?&lt;/STRONG&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No. .NET (managed) to native (unmanaged) code is always done through &lt;A href="http://msdn.microsoft.com/en-us/magazine/cc164123.aspx"&gt;P/Invoke&lt;/A&gt;. You could call a native .DLL from within an &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbprogramming/programming-api-satransaction-cla.html"&gt;SATransaction&lt;/A&gt; .NET context, but the ESQL DLL would still need to create its own connection back to the database, so it wouldn't be "within the same connection context" as the .NET connection (e.g. you can't "tap in" to the underlying unmanaged connection object that is already held by &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbprogramming/programming-api-saconnection-cla.html"&gt;SAConnection&lt;/A&gt; from your ESQL code).&lt;/P&gt;
&lt;P&gt;Conversely, if you use the &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbprogramming/pg-extenv-esql-odbc.html"&gt;ESQL external environment&lt;/A&gt; called directly from the database server, you are supplied the database context to avoid creating this extra connection when invoked, so if you simply wrote everything in an ESQL DLL with this external environment architecture in mind outside of .NET, you could work within an existing connection context as you currently desire - however, as the documentation notes, there is a small performance penalty to call out to external environments, so it's not clear that this process would actually be faster even if you were to implement it.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2013 13:31:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814822#M4845665</guid>
      <dc:creator>jeff_albion</dc:creator>
      <dc:date>2013-04-22T13:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calling ESQL from .NET program</title>
      <link>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814831#M4845674</link>
      <description>&lt;P&gt;Thanks.  I've already decided not to pursue this route, and now I'm especially glad that I have.  We don't have the time or inclination to rewrite everything in a native DLL.  It's taken us 2 years to get to where we are now and we're very happy not to take a giant step back to where we were in 2010 . . .  &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2013 08:18:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/calling-esql-from-net-program/qaa-p/13814831#M4845674</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-05-17T08:18:57Z</dc:date>
    </item>
  </channel>
</rss>

