Differences between freetds and Sybase 12.5

Joel Sanger <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
I don't know if this was sent correctly, sorry if this is a duplicate.

Hi all,
>
> I'm very new to freetds but I couldn't see this being reported or answered
> anywhere so any advice is welcome.
>
> Firstly let me say I'm writing code for a client who uses the sybase open
> client, OCS 12.5.1 and I believe your aim is to behave identically to these
> API's. If not skip the first issue! The second Issue I'm slightly confused
> over, so any help would be very appreciated.
>
> ----------------------------------------
>
> Issue 1 - Works in freetds but not in Sybase OCS 12.5.1
>
> pseudo code:
>
> initialise ct-lib
> setup simple language command - ("exec my_proc param1, param2" etc)
> send command
> retrieve results - stored proc does only updates/inserts so no ct_fetch was
> implemented
> drop command
>
> (I'm then repeating the setup command -> drop command to send updates to
> the database)
>
> This worked fine with freetds but with sybase it fails on the first
> ct_cmd_drop?
>
> I believe with sybase I received a results type of either CS_ROW_RESULT,
> PARAM_RESULT or CS_STATUS_RESULT and this must be retrieved by ct_fetch
> before you move to the next results?
>
> I can try and create a few test cases if needed?
>
> ----------------------------------------
>
> Issue 2 - Works in Sybase OCS 12.5.1 but NOT in Freetds
>
> pseudo code:
>
> initialise ct-lib
> setup RPC command - ("my_proc")
> use ct_setparam (or ct_param) to set my paramaters
> send command
> retrieve results (regardless of send result) - stored proc does only
> updates/inserts
>
> (from then on I'll update the params and use send command/retrieve results
> only)
>
> This works fine in sybase open client but in freetds I get an error on
> ct_send!
>
> Context Set-up - Return Code 1 (CS_SUCCESS)
> Connection Established - Return Code 1 (CS_SUCCESS)
> Command Build - Code Return 1 (CS_SUCCESS)
> ct_send() failed - Code Return 0 (CS_FAIL)
>
> in the freetds.log i get the following:
>
> 20:01:54.674659 3277 (ct.c:844):ct_send() command_type = 149
> 20:01:54.674683 3277 (ct.c:4239):paraminfoalloc: status = 256, maxlen 20
> 20:01:54.674700 3277 (ct.c:4240):paraminfoalloc: name = @param0, varint
> size 1 column_type 47 size 20, 20 column_cur_size 8 column_output = 0
> 20:01:54.674719 3277 (ct.c:4079):paramrowalloc, size = 8, data = 0x85a7650,
> row_size = 0
> 20:01:54.674738 3277 (ct.c:4239):paraminfoalloc: status = 256, maxlen 20
> 20:01:54.674755 3277 (ct.c:4240):paraminfoalloc: name = @pram1, varint size
> 1 column_type 47 size 20, 20 column_cur_size 8 column_output = 0
> 20:01:54.674773 3277 (ct.c:4079):paramrowalloc, size = 8, data = 0x859a820,
> row_size = 0
> 20:01:54.674791 3277 (ct.c:4239):paraminfoalloc: status = 256, maxlen 20
> 20:01:54.674807 3277 (ct.c:4240):paraminfoalloc: name = @param2, varint
> size 1 column_type 47 size 20, 20 column_cur_size 6 column_output = 0
> 20:01:54.674825 3277 (ct.c:4079):paramrowalloc, size = 6, data = 0x85a75f0,
> row_size = 0
> 20:01:54.674843 3277 (ct.c:4239):paraminfoalloc: status = 256, maxlen 20
> 20:01:54.674859 3277 (ct.c:4240):paraminfoalloc: name = @param3, varint
> size 1 column_type 47 size 20, 20 column_cur_size 6 column_output = 0
> 20:01:54.674877 3277 (ct.c:4079):paramrowalloc, size = 6, data = 0x85a7668,
> row_size = 0
> 20:01:54.674895 3277 (ct.c:4239):paraminfoalloc: status = 256, maxlen 20
> 20:01:54.674911 3277 (ct.c:4240):paraminfoalloc: name = @param4, varint
> size 1 column_type 47 size 20, 20 column_cur_size 2 column_output = 0
> 20:01:54.674928 3277 (ct.c:4079):paramrowalloc, size = 2, data = 0x85a7680,
> row_size = 0
> 20:01:54.674946 3277 (ct.c:4239):paraminfoalloc: status = 256, maxlen 20
> 20:01:54.674962 3277 (ct.c:4240):paraminfoalloc: name = @param5, varint
> size 1 column_type 47 size 20, 20 column_cur_size 4 column_output = 0
> 20:01:54.674979 3277 (ct.c:4079):paramrowalloc, size = 4, data = 0x85a9288,
> row_size = 0
> 20:01:54.674997 3277 (ct.c:4239):paraminfoalloc: status = 256, maxlen 255
> 20:01:54.675013 3277 (ct.c:4240):paraminfoalloc: name = @param6, varint
> size 1 column_type 47 size 255, 255 column_cur_size 31 column_output = 0
> 20:01:54.675030 3277 (ct.c:4079):paramrowalloc, size = 31, data =
> 0x85a9710, row_size = 0
> 20:01:54.675068 3277 (mem.c:563):tds_free_all_results()
> 20:01:54.675086 3277 (util.c:162):Changed query state from IDLE to QUERYING
> 20:01:54.675102 3277 (util.c:162):Changed query state from QUERYING to IDLE
> 20:01:54.675121 3277 (ct.c:215):setting command state from READY to SENT
> 20:01:54.675148 3277 (ct.c:1100):ct_results()
> 20:01:54.675166 3277 (token.c:495):tds_process_tokens(0x859a420,
> 0xbfc73e8c, 0xbfc73e88, 0x6914)
> 20:01:54.675183 3277 (token.c:498):tds_process_tokens() state is COMPLETED
> 20:01:54.675197 3277 (ct.c:1157):ct_results() process_result_tokens
> returned 2 (type 4052)
> 20:01:54.675218 3277 (ct.c:215):setting command state from SENT to READY
>
>
> Code snip-its: (error checking removed etc)
>
>     unused = (CS_SMALLINT) CS_UNUSED;
>     strcpy(sqlcmd, "my_proc");
>     ret = ct_cmd_alloc(this->connection, &this->cmd);
>     ret = ct_command(this->cmd, CS_RPC_CMD, sqlcmd, CS_NULLTERM,
> CS_NO_RECOMPILE);
>
>     memset(&datafmt, 0, sizeof (datafmt));
>     strcpy(datafmt.name, "@param0");
>     datafmt.namelen = CS_NULLTERM;
>     datafmt.datatype = CS_CHAR_TYPE;
>     datafmt.maxlength = 20;
>     datafmt.status = CS_INPUTVALUE;
>     datafmt.locale = NULL;
>
>     ret = ct_setparam (this->cmd, &datafmt,
>             this->message.param0,
>             &this->message.param0_len,
>             &unused);
>
>
>     strcpy(datafmt.name, "@param1");
>     ret = ct_setparam (this->cmd, &datafmt,
>             this->message.param1,
>             &this->message.param1_len,
>             &unused);
>
> ... This is line is identical for the other params except for the name and
> maxlength changes.
>
>     ret = ct_send(this->cmd);
>
> This is the line that fails!
>
> I'm not too concerned that it's not identical to sybase ocs but I can't get
> a RPC, with parameters to work with freetds. Any help would be much welcome!
>
> Best Regards,
> Joel Sanger
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.