Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6207477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:38:13+00:00 2026-05-24T05:38:13+00:00

This question is related to my previous one: RaiseError (PERL, DBI) equivalent for unixODBC

  • 0

This question is related to my previous one: RaiseError (PERL, DBI) equivalent for unixODBC C API?

As I isolated the problem later, I’ll post new question, that is more specific, isolated and without unnecessary information.


Version: unixODBC 2.3.0
lib: unixODBC – C API

Suppose I have a stored FUNCTION:

CREATE FUNCTION "test".func() RETURNING LVARCHAR(1000);
set debug file to '/home/directory_does_not_exists/unknown.log';
trace off;
trace on;
trace off;
return 'result is set here';
END FUNCTION;

And the same body, but in stored PROCEDURE:

CREATE PROCEDURE "test".proc(pDummy SMALLINT)
set debug file to '/home/directory_does_not_exists/unknown.log';
trace off;
trace on;
LET pDummy = 2;
trace off;
END PROCEDURE;

As you can see, they are absolutely the same. The path to debug file is wrong, so error is expected. When I execute call func() from Aqua Data Studio the error is detected:

Cannot open DEBUG file for SPL routine trace

It’s the same for call proc(1).

BUT when I execute these 2 calls through unixODBC (using SQLExecute),

execute procedure proc(1);

returns SQL_ERROR (which is expected and fine), while

execute function func();

returns SQL_SUCCESS.. BUT 'result is set here' is not returned, empty string ('') is returned, instead..

Executing call func() gives the same results, as execute function func();

Calling SQLMoreResults returns SQL_NO_DATA, SQLFetch returns SQL_ERROR.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:38:15+00:00Added an answer on May 24, 2026 at 5:38 am

    First of all – thanks a lot to @Jonathan Leffler(for the hint with SQLIDEBUG=2:xyz + sqliprint and testing on his machine) and @bohica (for the hint with strace ) for the support! That really helped me to find the real problem and solve it! +1 from me for both.
    Unfortunately, the answer was not in their posts, that’s why I’ll answer it my own.


    Summary:

    SQLPrepare and SQLExecute fail sometimes on some errors, but not all. When stored procedure is used, these functions catch more errors. Unfortunately, the situation is different with stored functions.

    How I catch the errors now? If SQLExecute is successfull, I call SQLNumResultCols – that’s normal. After that, I call SQLFetch which is also expected. BUT, as SQLFetch may fail for many reasons (for example, it always fails on stored procedures), it’s error is ignored. And there’s a while like

    if ( SQLNumResultCols( stmt, &nAllCols ) != SQL_SUCCESS )
    // ...
    
    int nSucceededFetches = 0; // added now, see below why
    while ( SQL_SUCCEEDED( SQLFetch( stmt ) ) )
    {
        ++nSucceededFetches; // added now, see below why
        /* bla bla */ 
    }
    

    And here’s the key – add additional check:

    if( 0 == nSucceededFetches && nColumns > 0 )
    

    which says – if there are returned columns and fetch fails on the FIRST call, then something’s wrong. Then I have

    while ( SQL_SUCCESS == SQLError( 0, 0, stmt, szSqlState, &nNativeError, szError, 500, &nErrorMsg ) )
    { /* bla bla */ }
    

    And everything’s fine. I still don’t understand why SQLExecute returns SQL_SUCCESS (NOT even SQL_SUCCESS_WITH_INFO ..), but it doesn’t matter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is related with one of my earlier questions.. Previous Post In there
This is a CSS related question, I got one good answer from my previous
This is related to my previous question , but a different one. I have
This question is related to the previous post. How to save file and read
This question is related to a previous post . Is there something comparable to
This is a follow-up question related to my previous post . Below is a
This question is related to this previous one on how to replace accented strings
This question is related to a previous post of mine Here . Basically, I
This question is related to the previous one, when I click over an anchor
This question is related to my previous one: Running erlang shell as a daemon/service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.