dbtcp-forums Forum Index dbtcp-forums
Support for dbtcp
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

what does 'open dataset' do in the demo client?

 
Post new topic   Reply to topic    dbtcp-forums Forum Index -> dbtcp internals
View previous topic :: View next topic  
Author Message
jgabriels



Joined: 07 Aug 2007
Posts: 2

PostPosted: Wed Aug 08, 2007 1:54 pm    Post subject: what does 'open dataset' do in the demo client? Reply with quote

I am trying to run the following command using the linux dbtcp:

sp_report ARAgingSummary show Current_Title, Amount_Title, Text, Label, Current, Amount parameters DateMacro = 'Today', AgingAsOf = 'Today'

It works fine using the windows test client if I click on 'open dataset' first but
using the unmodified linux source I get zero rows, so I made the following
change to protocol.c:

if ( ( strncasecmp ( &query[idx], "SELECT", 6 ) == 0 ) ||
( strncasecmp ( &query[idx], "SP_REPORT", 9 ) == 0 ) || //added by me
( strncasecmp ( &query[idx], "EXEC", 4 ) == 0 ) )

and now I get the following error message:

ERROR: dataset not opened.

So what does the 'open dataset' button actually do and how do I do that
using the linux client?

Thanks,


Jon.


p.s. This is a command specific to quickbooks if anyone is interested.


Last edited by jgabriels on Thu Sep 20, 2007 8:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
jgabriels



Joined: 07 Aug 2007
Posts: 2

PostPosted: Thu Sep 20, 2007 8:42 pm    Post subject: fixed the problem Reply with quote

The problem has been resolved with the help of dbtcp's author.

Here is the code that makes it work, if anyone else is interested:

Code:

--- protocol.c 2004-06-23 10:44:00.000000000 -0500
+++ ../dbtcp-new/protocol.c 2007-09-20 14:36:06.000000000 -0500
@@ -453,7 +453,7 @@
 int dbftp_sql ( dbftp_result *myres, char *query )
 {
   uchar cmd=CLN_CMD_SQL;
-  int is_select=0,idx;
+  int is_select=0,need_open=0,idx;

   DBUG_ENTER ( "dbftp_sql" );

@@ -466,10 +466,16 @@
       else
  {
    if ( ( strncasecmp ( &query[idx], "SELECT", 6 ) == 0 ) ||
-               ( strncasecmp ( &query[idx], "EXEC", 4 ) == 0 ) )
+               ( strncasecmp ( &query[idx], "EXEC", 4 ) == 0 ) ||
+               ( strncasecmp ( &query[idx], "SP_REPORT", 9 ) == 0 )
+        )
      {
        is_select=1;
      }
+   if ( ( strncasecmp ( &query[idx], "SP_REPORT", 9 ) == 0 ) )
+     {
+              need_open=1;
+            }
    break;
  }
     }
@@ -494,6 +500,15 @@
      {
      case SRV_CMD_SUCCESS:
               if ( is_select ) {
+   if ( need_open == 1 )
+   {
+      cmd=CLN_CMD_OPEN_DS;
+                    if ( sendreceive_tcp_pkt ( myres->sock, &cmd, myres->net_buf ) != OK )
+             {
+                       dbftp_set_error ( myres, "Network error", 0 );
+             }
+          }
+
           DBUG_RETURN ( dbftp_fetch_fields( myres ) );
           return ( dbftp_fetch_fields( myres ) );
               }

--- protocol.h 2003-05-08 07:54:54.000000000 -0500
+++ ../dbtcp-new/protocol.h 2007-08-29 09:20:41.000000000 -0500
@@ -67,8 +67,13 @@
 /* Client command code */
 #define CLN_CMD_CONNECT    1      // Connect
 #define CLN_CMD_SQL        2      // Execute SQL
+#define CLN_CMD_OPEN_DS    3      // Open Dataset ( re-execute query !!! )
+#define CLN_CMD_CLOSE_DS   4      // Close Dataset
 #define CLN_CMD_FETCH_F    5      // Fetch result set fields info
 #define CLN_CMD_FETCH      6      // Fetch next row in result set
+#define CLN_CMD_CREATE_RS  7      // Create resultset
+#define CLN_CMD_DROP_RS    8      // Drop resultset
+#define CLN_CMD_SET_RS     9      // Set resultset

 /* Server return code */
 #define SRV_CMD_ERROR     50      // Generic Error
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    dbtcp-forums Forum Index -> dbtcp internals All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group