<?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: sqlany_execute() failed but sqlany_error() didnt retu... in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14448522#M4946554</link>
    <description>&lt;P&gt;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/191873"&gt;@chris_keating&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I reformatted the code for easier reading.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also - I made it based on the preparing_statements.cpp as it is a query with parameters. But it should not matter.&lt;/P&gt;&lt;P&gt;For every single parameter I do set "param.value.buffer". Just like in both samples..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jul 2026 22:58:50 GMT</pubDate>
    <dc:creator>oneeyeman1</dc:creator>
    <dc:date>2026-07-24T22:58:50Z</dc:date>
    <item>
      <title>sqlany_execute() failed but sqlany_error() didnt return an error.</title>
      <link>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaq-p/14446814</link>
      <description>&lt;P&gt;Hi, ALL,&lt;/P&gt;&lt;P&gt;For some reason the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[code]&lt;/P&gt;&lt;P&gt;if( !m_api.sqlany_execute( m_stmt ) )&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;char buffer[SACAPI_ERROR_SIZE + 20] {};&lt;BR /&gt;char sqlstate[6];&lt;BR /&gt;int rc;&lt;BR /&gt;rc = m_api.sqlany_error( m_conn, buffer, sizeof( buffer ) );&lt;BR /&gt;break;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;does not fill the "buffer" variable with the error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone please suggest what could be the issue and how to perform the successful query execution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2026 01:11:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaq-p/14446814</guid>
      <dc:creator>oneeyeman1</dc:creator>
      <dc:date>2026-07-23T01:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: sqlany_execute() failed but sqlany_error() didnt retu...</title>
      <link>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14447675#M4946476</link>
      <description>&lt;P&gt;Works fine for me.&lt;/P&gt;&lt;P&gt;[ERROR] Execute failed: [-141] Table 'foo' not found.&lt;/P&gt;&lt;P&gt;I used print_error routine in the stmt_exec example.&lt;/P&gt;&lt;P&gt;Are you sure that sqlany_execute or&amp;nbsp;sqlany_execute_immediate was the last thing executed?&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;void
print_error( a_sqlany_connection * sqlany_conn, char * str )
{
    char buffer[SACAPI_ERROR_SIZE];
    int  rc;
    rc = api.sqlany_error( sqlany_conn, buffer, sizeof(buffer));
    printf( "[ERROR] %s: [%d] %s\n", str, rc, buffer );
}
called here for example.                                                          
   ok = api.sqlany_execute( sqlany_stmt );
   if( !ok ) {
       print_error( sqlany_conn, (char *)"Execute failed" );
   }&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 23 Jul 2026 22:37:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14447675#M4946476</guid>
      <dc:creator>jack_schueler</dc:creator>
      <dc:date>2026-07-23T22:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: sqlany_execute() failed but sqlany_error() didnt retu...</title>
      <link>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14447680#M4946477</link>
      <description>&lt;P&gt;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/2817"&gt;@Jack&lt;/a&gt;_shueler,&lt;/P&gt;&lt;P&gt;Here is my scenario:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Run&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;CREATE TABLE IF NOT EXISTS abcattbl(abt_os integer NOT NULL, abt_tnam char(129) NOT NULL, abt_tid integer, abt_ownr char(129) NOT NULL, abd_fhgt smallint, abd_fwgt smallint, abd_fitl char(1), abd_funl char(1), abd_fstr smallint, abd_fchr smallint, abd_fptc smallint, abd_ffce char(18), abh_fhgt smallint, abh_fwgt smallint, abh_fitl char(1), abh_funl char(1), abh_fstr smallint, abh_fchr smallint, abh_fptc smallint, abh_ffce char(18), abl_fhgt smallint, abl_fwgt smallint, abl_fitl char(1), abl_funl char(1), abl_fstr smallint, abl_fchr smallint, abl_fptc smallint, abl_ffce char(18), abt_cmnt char(254), PRIMARY KEY( abt_tnam, abt_ownr ));&lt;/LI-CODE&gt;&lt;P&gt;inside the transaction and commit it.&lt;/P&gt;&lt;P&gt;2. Call following procedure:&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;std::wstring qry2 = L"INSERT INTO abcattbl ON EXISTING SKIP VALUES( ?, ?, (SELECT t.table_id FROM SYS.SYSTABLE t, SYS.SYSUSER u WHERE t.creator = u.user_id AND u.user_name = ? AND t.table_name = ?), ?, 8, 400, 'N', 'N', 0, 1, 0, 'MS Sans Serif', 8, 400, 'N', 'N', 0, 1, 0, 'MS Sans Serif', 8, 400, 'N', 'N', 0, 1, 0, 'MS Sans Serif', '' );";

int osid = 0;

a_sqlany_bind_param param;
if( !result )
{
    if( !m_api.sqlany_describe_bind_param( m_stmt, 0, &amp;amp;param ) )
    {
        GetErrorMessage( errorMsg );
        result = 1;
    }
}
if( !result )
{
    param.value.buffer = (char *) &amp;amp;osid;
    param.value.is_null = nullptr;
// param.value.type = A_UVAL32;
    if( !m_api.sqlany_bind_param( m_stmt, 0, &amp;amp;param ) )
    {
        GetErrorMessage( errorMsg );
        result = 1;
    }
}

if( !result )
{
    for( std::map&amp;lt;std::wstring, std::vector&amp;lt;TableDefinition&amp;gt; &amp;gt;::iterator it = pimpl.m_tableDefinitions.begin(); it != pimpl.m_tableDefinitions.end(); ++it )
    {
        for( std::vector&amp;lt;TableDefinition&amp;gt;::iterator it1 = (*it).second.begin(); it1 &amp;lt; (*it).second.end(); ++it1 )
        {
            sacapi_bool isNull;
            size_t len1, len2, len3, len4, len5, len6;
            if( !m_api.sqlany_describe_bind_param( m_stmt, 1, &amp;amp;param ) )
            {
                GetErrorMessage( errorMsg );
                result = 1;
                break;
            }
            if( !result )
            {
                len1 = (*it1).fullName.length();
                param.value.buffer = const_cast&amp;lt;char *&amp;gt;( sqlany_pimpl-&amp;gt;m_myconv.to_bytes( (*it1).fullName.c_str() ).c_str() );
                param.value.length = &amp;amp;len1;
                param.value.is_null = &amp;amp;isNull;
                if( !m_api.sqlany_bind_param( m_stmt, 1, &amp;amp;param ) )
                {
                    GetErrorMessage( errorMsg );
                    result = 1;
                    break;
                }
            }
            if( !m_api.sqlany_describe_bind_param( m_stmt, 2, &amp;amp;param ) )
            {
                GetErrorMessage( errorMsg );
                result = 1;
                break;
            }
            if( !result )
            {
                len2 = (*it1).schemaName.length();
                param.value.buffer = const_cast&amp;lt;char *&amp;gt;( sqlany_pimpl-&amp;gt;m_myconv.to_bytes( (*it1).schemaName.c_str() ).c_str() );
                param.value.length = &amp;amp;len2;
                param.value.is_null = &amp;amp;isNull;
                if( !m_api.sqlany_bind_param( m_stmt, 2, &amp;amp;param ) )
                {
                    GetErrorMessage( errorMsg );
                    result = 1;
                    break;
                }
            }
            if( !m_api.sqlany_describe_bind_param( m_stmt, 3, &amp;amp;param ) )
            {
                GetErrorMessage( errorMsg );
                result = 1;
                break;
            }
            if( !result )
            {
                len3 = (*it1).tableName.length();
                param.value.buffer = const_cast&amp;lt;char *&amp;gt;( sqlany_pimpl-&amp;gt;m_myconv.to_bytes( (*it1).tableName.c_str() ).c_str() );
                param.value.length = &amp;amp;len3;
                param.value.is_null = &amp;amp;isNull;
                if( !m_api.sqlany_bind_param( m_stmt, 3, &amp;amp;param ) )
                {
                    GetErrorMessage( errorMsg );
                    result = 1;
                    break;
                }
            }
            if( !m_api.sqlany_describe_bind_param( m_stmt, 4, &amp;amp;param ) )
            {
                GetErrorMessage( errorMsg );
                result = 1;
                break;
            }
            if( !result )
            {
                len4 = (*it1).schemaName.length();
                param.value.buffer = const_cast&amp;lt;char *&amp;gt;( sqlany_pimpl-&amp;gt;m_myconv.to_bytes( (*it1).schemaName.c_str() ).c_str() );
                param.value.length = &amp;amp;len4;
                param.value.is_null = &amp;amp;isNull;
                if( !m_api.sqlany_bind_param( m_stmt, 4, &amp;amp;param ) )
                {
                    GetErrorMessage( errorMsg );
                    result = 1;
                    break;
                }
            }
            if( !result )
            {
                auto i = m_api.sqlany_execute( m_stmt );
                if( !m_api.sqlany_execute( m_stmt ) )
                {
                    GetErrorMessage( errorMsg );
                    result = 1;
                    break;
                }
            }
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;sqlany_execute() returns 0, but calling GetErrorMessage(), which is:&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;int GetErrorMessage(std::vector&amp;lt;std::wstring&amp;gt; &amp;amp;errorMsg)
{
    char buffer[SACAPI_ERROR_SIZE + 20] {};
    char sqlstate[6];
    int rc;
    rc = m_api.sqlany_error( m_conn, buffer, SACAPI_ERROR_SIZE + 20 );
    m_api.sqlany_sqlstate( m_conn, sqlstate, sizeof( sqlstate ) );
    strcat( buffer, ": SQLSTATE: " );
    strcat( buffer, sqlstate );
    errorMsg.push_back( sqlany_pimpl-&amp;gt;m_myconv.from_bytes( buffer ) );
    return true;
}

&lt;/LI-CODE&gt;&lt;P&gt;rc equal 0 and the buffer is empty.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2026 22:50:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14447680#M4946477</guid>
      <dc:creator>oneeyeman1</dc:creator>
      <dc:date>2026-07-24T22:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: sqlany_execute() failed but sqlany_error() didnt retu...</title>
      <link>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14448349#M4946543</link>
      <description>When pasting code, use a code block. What you pasted is unreadable. I suggest you start debugging your code. - Schueler, not Shueler.</description>
      <pubDate>Fri, 24 Jul 2026 17:20:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14448349#M4946543</guid>
      <dc:creator>jack_schueler</dc:creator>
      <dc:date>2026-07-24T17:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: sqlany_execute() failed but sqlany_error() didnt retu...</title>
      <link>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14448434#M4946545</link>
      <description>I do not see anything in your implementation (snipet) that should result in a SQL error. There is an implementation error in that while you did bind the parameters, you did not provide values for them. Take a look at the stmt_exec.cpp example making note of the code starting at line 218 which supplies the parameters values and then executes the statement. If you look a request log with your app (-zr all or equivalent with sa_server_option system proceedure), your implementation does not supply any host variables to the parameters -- and there is no error reported in that log either.</description>
      <pubDate>Fri, 24 Jul 2026 18:40:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14448434#M4946545</guid>
      <dc:creator>chris_keating</dc:creator>
      <dc:date>2026-07-24T18:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: sqlany_execute() failed but sqlany_error() didnt retu...</title>
      <link>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14448522#M4946554</link>
      <description>&lt;P&gt;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/191873"&gt;@chris_keating&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I reformatted the code for easier reading.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also - I made it based on the preparing_statements.cpp as it is a query with parameters. But it should not matter.&lt;/P&gt;&lt;P&gt;For every single parameter I do set "param.value.buffer". Just like in both samples..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2026 22:58:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14448522#M4946554</guid>
      <dc:creator>oneeyeman1</dc:creator>
      <dc:date>2026-07-24T22:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: sqlany_execute() failed but sqlany_error() didnt retu...</title>
      <link>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14448523#M4946555</link>
      <description>&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/2817"&gt;@Jack&lt;/a&gt;_shueler, I edit the reply and added the code tags. Please check it.</description>
      <pubDate>Fri, 24 Jul 2026 23:00:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14448523#M4946555</guid>
      <dc:creator>oneeyeman1</dc:creator>
      <dc:date>2026-07-24T23:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: sqlany_execute() failed but sqlany_error() didnt retu...</title>
      <link>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14449062#M4946577</link>
      <description>&lt;P&gt;As I suggested in my comment, you should look at the request level log for this operation. The request log showing a working example is shown below. Make note of lines 8-12 which are identified as HOST VARIABLES ( line reports ...&lt;STRONG&gt;,H,&lt;/STRONG&gt;...) for the statement.&amp;nbsp; I also want to point out that the INSERT reported at line 13 shows no error. Please check your request log and if it does not have the host variable lines, you have an issue with the implementation.&amp;nbsp; If you look at the stmt_exec.cpp example, the parameter value.buffer is initially defined with a buffer variable and then the buffer is populated in the code block that I referred to previously.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;+1,&amp;lt;,43,PREPARE,insert into "abcattbl" on existing skip values( :?,:?,(select "t"."table_id" from "SYS"."SYSTABLE" as "t","SYS"."SYSUSER" as "u" where "t"."creator" = "u"."user_id" and "u"."user_name" = :? and "t"."table_name" = :?),:?,8,400,'N','N',0,1,0,'MS Sans Serif',8,400,'N','N',0,1,0,'MS Sans Serif',8,400,'N','N',0,1,0,'MS Sans Serif','' ) 
=,&amp;gt;,43,PREPARE,65536
=,&amp;lt;,43,DESC_IN,65536
=,&amp;gt;,43,DESC_IN
=,&amp;lt;,43,DESC_OUT,65536
=,&amp;gt;,43,DESC_OUT
=,&amp;lt;,43,EXEC,65536
=,H,43,0,unsigned int,1
=,H,43,1,long varchar,'abcattbl'
=,H,43,2,long varchar,'dba'
=,H,43,3,long varchar,'abcattbl'
=,H,43,4,long varchar,'dba'
+1,P,43,INSERT ROWS{1} : tab&amp;lt;table_name&amp;gt;{1} JNL{1} su&amp;lt;user_name&amp;gt;{1}
=,W,43,100,Row not found
=,&amp;gt;,43,EXEC&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;An example of an error in the request log would be, for an insert statement involving an undefined table, is shown below. If there is an error in the request log, the client should receive it.&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;+6,E,44,-141,Table 'NotATable' not found&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 27 Jul 2026 02:18:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sqlany-execute-failed-but-sqlany-error-didnt-return-an-error/qaa-p/14449062#M4946577</guid>
      <dc:creator>chris_keating</dc:creator>
      <dc:date>2026-07-27T02:18:21Z</dc:date>
    </item>
  </channel>
</rss>

