Discussion:
[freetds] Problem with nvarchar output
Ola Karlsson
2014-07-06 13:32:58 UTC
Permalink
Hi
I'm using Freetds with PHP5 to access a SQL server but I'm having trouble with the output parameters.
I have two parameters, one SQLINT4 and one SQLVARCHAR. The int is working but I don't get any returns from the varchar.

Is there anything special that needs to be done when outputting nvarchar?

PHP binds,
mssql_bind($stmt, '@ErrorMsg',$ErrorMsg,SQLVARCHAR,true,false,4000);
mssql_bind($stmt, '@OrderNr',$OrderNr,SQLINT4,true,true,8);

SQL parameters,
@ErrorMsg nvarchar(4000) output
@OrderNr Jeeves_OrderNo output


Sql server,
SQL Server 2008 R2

Freetds server,
Ubuntu 12.04 3.5.0-51-generic

Tsql -C
Version: freetds v0.91
freetds.conf directory: /etc/freetds
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no

Freetds conf,
[global]
text size = 64512
[Sqlserver]
host = xxx.xxx.xxx.xxx
port = xxxx
tds version = 8.0

PHP5
PHP 5.3.10-1ubuntu3.12


BR
Ola
James K. Lowden
2014-07-07 04:00:16 UTC
Permalink
On Sun, 6 Jul 2014 13:32:58 +0000
Post by Ola Karlsson
I'm using Freetds with PHP5 to access a SQL server but I'm having
trouble with the output parameters.
http://www.freetds.org/faq.html#ms.output.parameters

Unless PHP is using the RPC API functions, you won't see output
parameters from a modern Microsoft server.

Hoppas det hj?lper.

--jkl
Ola Karlsson
2014-07-08 10:34:55 UTC
Permalink
Post by James K. Lowden
http://www.freetds.org/faq.html#ms.output.parameters
Unless PHP is using the RPC API functions, you won't see output parameters from a modern Microsoft server.
As my integer output parameters are working im guessing this is not the problem.
Everything works, except the varchar(4000).

BR
Ola
Thomas, Christopher (LLU)
2014-07-08 22:37:34 UTC
Permalink
Look at phpinfo() and check the values for mssql.textsize and mssql.textlimit. They might be related to your problem.

Chris


-----Original Message-----
From: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] On Behalf Of Ola Karlsson
Sent: Tuesday, July 08, 2014 3:35 AM
To: FreeTDS Development Group
Subject: Re: [freetds] Problem with nvarchar output
Post by James K. Lowden
http://www.freetds.org/faq.html#ms.output.parameters
Unless PHP is using the RPC API functions, you won't see output parameters from a modern Microsoft server.
As my integer output parameters are working im guessing this is not the problem.
Everything works, except the varchar(4000).

BR
Ola
Frediano Ziglio
2014-07-12 07:06:05 UTC
Permalink
Hi,
did you check TDSDUMP ?

Frediano
Post by Ola Karlsson
Hi
I'm using Freetds with PHP5 to access a SQL server but I'm having trouble
with the output parameters.
I have two parameters, one SQLINT4 and one SQLVARCHAR. The int is working
but I don't get any returns from the varchar.
Is there anything special that needs to be done when outputting nvarchar?
PHP binds,
SQL parameters,
@ErrorMsg nvarchar(4000) output
@OrderNr Jeeves_OrderNo output
Sql server,
SQL Server 2008 R2
Freetds server,
Ubuntu 12.04 3.5.0-51-generic
Tsql -C
Version: freetds v0.91
freetds.conf directory: /etc/freetds
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
Freetds conf,
[global]
text size = 64512
[Sqlserver]
host = xxx.xxx.xxx.xxx
port = xxxx
tds version = 8.0
PHP5
PHP 5.3.10-1ubuntu3.12
BR
Ola
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Ola Karlsson
2014-07-31 08:44:58 UTC
Permalink
Hi,
Sorry for the delay. Went on hollidays for a few weeks :)

As far as I can see my error message is stated in the log exactly as it should be and it also states two returned results.
The integer value is returned correctly but not the nvarchar.

I have attached a portion of the log containing the procedure call and my error message.
I don't notice any error messages or so but then again theres a lot of information in the logs.

No errors in the php logs either.

Any ideas?


BR
Ola

-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 12 juli 2014 09:06
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output

Hi,
did you check TDSDUMP ?

Frediano
Post by Ola Karlsson
Hi
I'm using Freetds with PHP5 to access a SQL server but I'm having
trouble with the output parameters.
I have two parameters, one SQLINT4 and one SQLVARCHAR. The int is
working but I don't get any returns from the varchar.
Is there anything special that needs to be done when outputting nvarchar?
PHP binds,
SQL parameters,
@ErrorMsg nvarchar(4000) output
@OrderNr Jeeves_OrderNo output
Sql server,
SQL Server 2008 R2
Freetds server,
Ubuntu 12.04 3.5.0-51-generic
Tsql -C
Version: freetds v0.91
freetds.conf directory: /etc/freetds
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
Freetds conf,
[global]
text size = 64512
[Sqlserver]
host = xxx.xxx.xxx.xxx
port = xxxx
tds version = 8.0
PHP5
PHP 5.3.10-1ubuntu3.12
BR
Ola
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: freetds.txt
URL: <http://lists.ibiblio.org/pipermail/freetds/attachments/20140731/a5fe42cc/attachment-0001.txt>
Frediano Ziglio
2014-07-31 13:41:20 UTC
Permalink
The upper layer decided to cancel the query. The reason could be previously
in the log.
Looks like you are using an encoding which cannot support your charset
(there are some question marks in the output string possibly result of a
wrong conversion).

Frediano
Post by Ola Karlsson
Hi,
Sorry for the delay. Went on hollidays for a few weeks :)
As far as I can see my error message is stated in the log exactly as it
should be and it also states two returned results.
The integer value is returned correctly but not the nvarchar.
I have attached a portion of the log containing the procedure call and my error message.
I don't notice any error messages or so but then again theres a lot of
information in the logs.
No errors in the php logs either.
Any ideas?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 12 juli 2014 09:06
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
Hi,
did you check TDSDUMP ?
Frediano
Post by Ola Karlsson
Hi
I'm using Freetds with PHP5 to access a SQL server but I'm having
trouble with the output parameters.
I have two parameters, one SQLINT4 and one SQLVARCHAR. The int is
working but I don't get any returns from the varchar.
Is there anything special that needs to be done when outputting nvarchar?
PHP binds,
SQL parameters,
@ErrorMsg nvarchar(4000) output
@OrderNr Jeeves_OrderNo output
Sql server,
SQL Server 2008 R2
Freetds server,
Ubuntu 12.04 3.5.0-51-generic
Tsql -C
Version: freetds v0.91
freetds.conf directory: /etc/freetds
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
Freetds conf,
[global]
text size = 64512
[Sqlserver]
host = xxx.xxx.xxx.xxx
port = xxxx
tds version = 8.0
PHP5
PHP 5.3.10-1ubuntu3.12
BR
Ola
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Ola Karlsson
2014-07-31 14:01:21 UTC
Permalink
I?ve attached a bigger log but I find it difficult to see what is exactly related to this query so perhaps I?ve still missed something.
Will adding logg details for a specific instance in freetds.conf cause only logging for that instance, in my case [ap1Dev], or will it still logg for all instances?

If it?s the encoding is it a PHP problem or FreeTDS setting that needs to change?

BR
Ola

-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 31 juli 2014 15:41
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output

The upper layer decided to cancel the query. The reason could be previously in the log.
Looks like you are using an encoding which cannot support your charset (there are some question marks in the output string possibly result of a wrong conversion).

Frediano
Post by Ola Karlsson
Hi,
Sorry for the delay. Went on hollidays for a few weeks :)
As far as I can see my error message is stated in the log exactly as
it should be and it also states two returned results.
The integer value is returned correctly but not the nvarchar.
I have attached a portion of the log containing the procedure call and my error message.
I don't notice any error messages or so but then again theres a lot of
information in the logs.
No errors in the php logs either.
Any ideas?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 12 juli 2014 09:06
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
Hi,
did you check TDSDUMP ?
Frediano
Post by Ola Karlsson
Hi
I'm using Freetds with PHP5 to access a SQL server but I'm having
trouble with the output parameters.
I have two parameters, one SQLINT4 and one SQLVARCHAR. The int is
working but I don't get any returns from the varchar.
Is there anything special that needs to be done when outputting nvarchar?
PHP binds,
SQL parameters,
@ErrorMsg nvarchar(4000) output
@OrderNr Jeeves_OrderNo output
Sql server,
SQL Server 2008 R2
Freetds server,
Ubuntu 12.04 3.5.0-51-generic
Tsql -C
Version: freetds v0.91
no Sybase binary compatibility: yes Thread safety: yes iconv
library: yes TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
Freetds conf,
[global]
text size = 64512
[Sqlserver]
host = xxx.xxx.xxx.xxx
port = xxxx
tds version = 8.0
PHP5
PHP 5.3.10-1ubuntu3.12
BR
Ola
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: freetds.txt
URL: <http://lists.ibiblio.org/pipermail/freetds/attachments/20140731/13cecb3f/attachment.txt>
Frediano Ziglio
2014-08-01 16:06:29 UTC
Permalink
Looks like something upset PHP code. Are you using mssql module, right?
Which PHP version? Which PHP function are you calling, mssql_query ?


Frediano
Post by Ola Karlsson
I?ve attached a bigger log but I find it difficult to see what is exactly
related to this query so perhaps I?ve still missed something.
Will adding logg details for a specific instance in freetds.conf cause
only logging for that instance, in my case [ap1Dev], or will it still logg
for all instances?
If it?s the encoding is it a PHP problem or FreeTDS setting that needs to change?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 31 juli 2014 15:41
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
The upper layer decided to cancel the query. The reason could be previously in the log.
Looks like you are using an encoding which cannot support your charset
(there are some question marks in the output string possibly result of a
wrong conversion).
Frediano
Post by Ola Karlsson
Hi,
Sorry for the delay. Went on hollidays for a few weeks :)
As far as I can see my error message is stated in the log exactly as
it should be and it also states two returned results.
The integer value is returned correctly but not the nvarchar.
I have attached a portion of the log containing the procedure call and
my error message.
I don't notice any error messages or so but then again theres a lot of
information in the logs.
No errors in the php logs either.
Any ideas?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 12 juli 2014 09:06
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
Hi,
did you check TDSDUMP ?
Frediano
Post by Ola Karlsson
Hi
I'm using Freetds with PHP5 to access a SQL server but I'm having
trouble with the output parameters.
I have two parameters, one SQLINT4 and one SQLVARCHAR. The int is
working but I don't get any returns from the varchar.
Is there anything special that needs to be done when outputting
nvarchar?
Post by Ola Karlsson
Post by Ola Karlsson
PHP binds,
SQL parameters,
@ErrorMsg nvarchar(4000) output
@OrderNr Jeeves_OrderNo output
Sql server,
SQL Server 2008 R2
Freetds server,
Ubuntu 12.04 3.5.0-51-generic
Tsql -C
Version: freetds v0.91
no Sybase binary compatibility: yes Thread safety: yes iconv
library: yes TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
Freetds conf,
[global]
text size = 64512
[Sqlserver]
host = xxx.xxx.xxx.xxx
port = xxxx
tds version = 8.0
PHP5
PHP 5.3.10-1ubuntu3.12
BR
Ola
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Frediano Ziglio
2014-08-01 17:32:13 UTC
Permalink
I just realised you posted most of information in the first mail you sent

Frediano
Post by Frediano Ziglio
Looks like something upset PHP code. Are you using mssql module, right?
Which PHP version? Which PHP function are you calling, mssql_query ?
Frediano
I?ve attached a bigger log but I find it difficult to see what is exactly
Post by Ola Karlsson
related to this query so perhaps I?ve still missed something.
Will adding logg details for a specific instance in freetds.conf cause
only logging for that instance, in my case [ap1Dev], or will it still logg
for all instances?
If it?s the encoding is it a PHP problem or FreeTDS setting that needs to change?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 31 juli 2014 15:41
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
The upper layer decided to cancel the query. The reason could be previously in the log.
Looks like you are using an encoding which cannot support your charset
(there are some question marks in the output string possibly result of a
wrong conversion).
Frediano
Post by Ola Karlsson
Hi,
Sorry for the delay. Went on hollidays for a few weeks :)
As far as I can see my error message is stated in the log exactly as
it should be and it also states two returned results.
The integer value is returned correctly but not the nvarchar.
I have attached a portion of the log containing the procedure call and
my error message.
I don't notice any error messages or so but then again theres a lot of
information in the logs.
No errors in the php logs either.
Any ideas?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 12 juli 2014 09:06
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
Hi,
did you check TDSDUMP ?
Frediano
Post by Ola Karlsson
Hi
I'm using Freetds with PHP5 to access a SQL server but I'm having
trouble with the output parameters.
I have two parameters, one SQLINT4 and one SQLVARCHAR. The int is
working but I don't get any returns from the varchar.
Is there anything special that needs to be done when outputting
nvarchar?
Post by Ola Karlsson
Post by Ola Karlsson
PHP binds,
SQL parameters,
@ErrorMsg nvarchar(4000) output
@OrderNr Jeeves_OrderNo output
Sql server,
SQL Server 2008 R2
Freetds server,
Ubuntu 12.04 3.5.0-51-generic
Tsql -C
Version: freetds v0.91
no Sybase binary compatibility: yes Thread safety: yes iconv
library: yes TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
Freetds conf,
[global]
text size = 64512
[Sqlserver]
host = xxx.xxx.xxx.xxx
port = xxxx
tds version = 8.0
PHP5
PHP 5.3.10-1ubuntu3.12
BR
Ola
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Frediano Ziglio
2014-08-04 16:27:12 UTC
Permalink
Hi,
sorry for late reply.

I looked at PHP code to try to understand the sequence. It seems to me that
you called mssql_execute (which is ok) and the procedure got the right
result but then instead of calling mssql_next_result you just freed the
statement which cause the store procedure parameters to be discarded. Is it
right?

Frediano


Frediano
Post by Frediano Ziglio
I just realised you posted most of information in the first mail you sent
Frediano
Looks like something upset PHP code. Are you using mssql module, right?
Post by Frediano Ziglio
Which PHP version? Which PHP function are you calling, mssql_query ?
Frediano
I?ve attached a bigger log but I find it difficult to see what is exactly
Post by Ola Karlsson
related to this query so perhaps I?ve still missed something.
Will adding logg details for a specific instance in freetds.conf cause
only logging for that instance, in my case [ap1Dev], or will it still logg
for all instances?
If it?s the encoding is it a PHP problem or FreeTDS setting that needs to change?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 31 juli 2014 15:41
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
The upper layer decided to cancel the query. The reason could be previously in the log.
Looks like you are using an encoding which cannot support your charset
(there are some question marks in the output string possibly result of a
wrong conversion).
Frediano
Post by Ola Karlsson
Hi,
Sorry for the delay. Went on hollidays for a few weeks :)
As far as I can see my error message is stated in the log exactly as
it should be and it also states two returned results.
The integer value is returned correctly but not the nvarchar.
I have attached a portion of the log containing the procedure call and
my error message.
I don't notice any error messages or so but then again theres a lot of
information in the logs.
No errors in the php logs either.
Any ideas?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 12 juli 2014 09:06
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
Hi,
did you check TDSDUMP ?
Frediano
Post by Ola Karlsson
Hi
I'm using Freetds with PHP5 to access a SQL server but I'm having
trouble with the output parameters.
I have two parameters, one SQLINT4 and one SQLVARCHAR. The int is
working but I don't get any returns from the varchar.
Is there anything special that needs to be done when outputting
nvarchar?
Post by Ola Karlsson
Post by Ola Karlsson
PHP binds,
SQL parameters,
@ErrorMsg nvarchar(4000) output
@OrderNr Jeeves_OrderNo output
Sql server,
SQL Server 2008 R2
Freetds server,
Ubuntu 12.04 3.5.0-51-generic
Tsql -C
Version: freetds v0.91
no Sybase binary compatibility: yes Thread safety: yes iconv
library: yes TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
Freetds conf,
[global]
text size = 64512
[Sqlserver]
host = xxx.xxx.xxx.xxx
port = xxxx
tds version = 8.0
PHP5
PHP 5.3.10-1ubuntu3.12
BR
Ola
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Ola Karlsson
2014-08-05 07:28:19 UTC
Permalink
Hi,
No problem :)

Just to be clear I?ll post a more complete part of the PHP code below.
I?m not sure how result sets work but as there are no results from this procedure, it just inputs a line, and two returns are specified in differen variables could this really be the case?

Function PlaceOrder($xxx,$xxx....){

//CONNECT
$db_conn = db_connect();
$stmt = mssql_init('ic_PlaceOrder',$db_conn);

//BIND
if($OrderNr)
mssql_bind($stmt, '@OrderNr',$OrderNr, SQLINT4,true,false,8);
else
mssql_bind($stmt, '@OrderNr',$OrderNr, SQLINT4,true,true,8);

mssql_bind($stmt, '@ErrorMsg',$ErrorMsg, SQLVARCHAR,true,false,4000);

//EXECUTE
$rs = mssql_execute($stmt);

//RESULTS
$return['OrderNr'] = $OrderNr;
$return['ErrorMsg'] = $ErrorMsg;

//DEBUGG
print_r($return);

//CLEAN
mssql_free_statement($stmt);

return $return;
}


I also tried iterating with mssql_next_result($rs) but there is only 1 set.

BR
Ola


-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 4 augusti 2014 18:27
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output

Hi,
sorry for late reply.

I looked at PHP code to try to understand the sequence. It seems to me that you called mssql_execute (which is ok) and the procedure got the right result but then instead of calling mssql_next_result you just freed the statement which cause the store procedure parameters to be discarded. Is it right?

Frediano


Frediano
Post by Frediano Ziglio
I just realised you posted most of information in the first mail you sent
Frediano
Looks like something upset PHP code. Are you using mssql module, right?
Post by Frediano Ziglio
Which PHP version? Which PHP function are you calling, mssql_query ?
Frediano
I?ve attached a bigger log but I find it difficult to see what is exactly
Post by Ola Karlsson
related to this query so perhaps I?ve still missed something.
Will adding logg details for a specific instance in freetds.conf
cause only logging for that instance, in my case [ap1Dev], or will
it still logg for all instances?
If it?s the encoding is it a PHP problem or FreeTDS setting that needs to change?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 31 juli 2014 15:41
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
The upper layer decided to cancel the query. The reason could be previously in the log.
Looks like you are using an encoding which cannot support your
charset (there are some question marks in the output string possibly
result of a wrong conversion).
Frediano
Post by Ola Karlsson
Hi,
Sorry for the delay. Went on hollidays for a few weeks :)
As far as I can see my error message is stated in the log exactly
as it should be and it also states two returned results.
The integer value is returned correctly but not the nvarchar.
I have attached a portion of the log containing the procedure call
and my error message.
I don't notice any error messages or so but then again theres a
lot of information in the logs.
No errors in the php logs either.
Any ideas?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 12 juli 2014 09:06
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
Hi,
did you check TDSDUMP ?
Frediano
Post by Ola Karlsson
Hi
I'm using Freetds with PHP5 to access a SQL server but I'm
having trouble with the output parameters.
I have two parameters, one SQLINT4 and one SQLVARCHAR. The int
is working but I don't get any returns from the varchar.
Is there anything special that needs to be done when outputting
nvarchar?
Post by Ola Karlsson
Post by Ola Karlsson
PHP binds,
mssql_bind($stmt,
SQL parameters,
@ErrorMsg nvarchar(4000) output
@OrderNr Jeeves_OrderNo output
Sql server,
SQL Server 2008 R2
Freetds server,
Ubuntu 12.04 3.5.0-51-generic
Tsql -C
Version: freetds v0.91
no Sybase binary compatibility: yes Thread safety: yes iconv
library: yes TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
Freetds conf,
[global]
text size = 64512
[Sqlserver]
host = xxx.xxx.xxx.xxx
port = xxxx
tds version = 8.0
PHP5
PHP 5.3.10-1ubuntu3.12
BR
Ola
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Frediano Ziglio
2014-08-05 21:22:49 UTC
Permalink
Hi Ola,
log show clearly that there are two recordset before returning and from
PHP code you clearly did not handle these results. These results usually
came from any select statement but can also came from some bad designed
trigger.

Frediano

Frediano
Post by Ola Karlsson
Hi,
No problem :)
Just to be clear I?ll post a more complete part of the PHP code below.
I?m not sure how result sets work but as there are no results from this
procedure, it just inputs a line, and two returns are specified in differen
variables could this really be the case?
Function PlaceOrder($xxx,$xxx....){
//CONNECT
$db_conn = db_connect();
$stmt = mssql_init('ic_PlaceOrder',$db_conn);
//BIND
if($OrderNr)
else
//EXECUTE
$rs = mssql_execute($stmt);
//RESULTS
$return['OrderNr'] = $OrderNr;
$return['ErrorMsg'] = $ErrorMsg;
//DEBUGG
print_r($return);
//CLEAN
mssql_free_statement($stmt);
return $return;
}
I also tried iterating with mssql_next_result($rs) but there is only 1 set.
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 4 augusti 2014 18:27
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
Hi,
sorry for late reply.
I looked at PHP code to try to understand the sequence. It seems to me
that you called mssql_execute (which is ok) and the procedure got the right
result but then instead of calling mssql_next_result you just freed the
statement which cause the store procedure parameters to be discarded. Is it
right?
Frediano
Frediano
Post by Frediano Ziglio
I just realised you posted most of information in the first mail you sent
Frediano
Looks like something upset PHP code. Are you using mssql module, right?
Post by Frediano Ziglio
Which PHP version? Which PHP function are you calling, mssql_query ?
Frediano
I?ve attached a bigger log but I find it difficult to see what is exactly
Post by Ola Karlsson
related to this query so perhaps I?ve still missed something.
Will adding logg details for a specific instance in freetds.conf
cause only logging for that instance, in my case [ap1Dev], or will
it still logg for all instances?
If it?s the encoding is it a PHP problem or FreeTDS setting that needs to change?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 31 juli 2014 15:41
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
The upper layer decided to cancel the query. The reason could be
previously in the log.
Looks like you are using an encoding which cannot support your
charset (there are some question marks in the output string possibly
result of a wrong conversion).
Frediano
Post by Ola Karlsson
Hi,
Sorry for the delay. Went on hollidays for a few weeks :)
As far as I can see my error message is stated in the log exactly
as it should be and it also states two returned results.
The integer value is returned correctly but not the nvarchar.
I have attached a portion of the log containing the procedure call
and my error message.
I don't notice any error messages or so but then again theres a
lot of information in the logs.
No errors in the php logs either.
Any ideas?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 12 juli 2014 09:06
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
Hi,
did you check TDSDUMP ?
Frediano
Post by Ola Karlsson
Hi
I'm using Freetds with PHP5 to access a SQL server but I'm
having trouble with the output parameters.
I have two parameters, one SQLINT4 and one SQLVARCHAR. The int
is working but I don't get any returns from the varchar.
Is there anything special that needs to be done when outputting
nvarchar?
Post by Ola Karlsson
Post by Ola Karlsson
PHP binds,
mssql_bind($stmt,
SQL parameters,
@ErrorMsg nvarchar(4000) output
@OrderNr Jeeves_OrderNo output
Sql server,
SQL Server 2008 R2
Freetds server,
Ubuntu 12.04 3.5.0-51-generic
Tsql -C
Version: freetds v0.91
freetds.conf directory: /etc/freetds MS db-lib source
no Sybase binary compatibility: yes Thread safety: yes iconv
library: yes TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
Freetds conf,
[global]
text size = 64512
[Sqlserver]
host = xxx.xxx.xxx.xxx
port = xxxx
tds version = 8.0
PHP5
PHP 5.3.10-1ubuntu3.12
BR
Ola
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Ola Karlsson
2014-08-12 10:53:51 UTC
Permalink
Hi Frediano,

Its weird as I receive the integer result without issue. And from my tests using mssql_next_result I only receive one result set but then again I might have been using it wrong. I?ll investigate this further on the PHP side.

Thanks a lot for all your effort.

BR
Ola


-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 5 augusti 2014 23:23
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output

Hi Ola,
log show clearly that there are two recordset before returning and from PHP code you clearly did not handle these results. These results usually came from any select statement but can also came from some bad designed trigger.

Frediano

Frediano
Post by Ola Karlsson
Hi,
No problem :)
Just to be clear I?ll post a more complete part of the PHP code below.
I?m not sure how result sets work but as there are no results from
this procedure, it just inputs a line, and two returns are specified
in differen variables could this really be the case?
Function PlaceOrder($xxx,$xxx....){
//CONNECT
$db_conn = db_connect();
$stmt = mssql_init('ic_PlaceOrder',$db_conn);
//BIND
if($OrderNr)
//EXECUTE
$rs = mssql_execute($stmt);
//RESULTS
$return['OrderNr'] = $OrderNr;
$return['ErrorMsg'] = $ErrorMsg;
//DEBUGG
print_r($return);
//CLEAN
mssql_free_statement($stmt);
return $return;
}
I also tried iterating with mssql_next_result($rs) but there is only 1 set.
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 4 augusti 2014 18:27
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
Hi,
sorry for late reply.
I looked at PHP code to try to understand the sequence. It seems to me
that you called mssql_execute (which is ok) and the procedure got the
right result but then instead of calling mssql_next_result you just
freed the statement which cause the store procedure parameters to be
discarded. Is it right?
Frediano
Frediano
Post by Frediano Ziglio
I just realised you posted most of information in the first mail you sent
Frediano
Looks like something upset PHP code. Are you using mssql module, right?
Post by Frediano Ziglio
Which PHP version? Which PHP function are you calling, mssql_query ?
Frediano
I?ve attached a bigger log but I find it difficult to see what is exactly
Post by Ola Karlsson
related to this query so perhaps I?ve still missed something.
Will adding logg details for a specific instance in freetds.conf
cause only logging for that instance, in my case [ap1Dev], or will
it still logg for all instances?
If it?s the encoding is it a PHP problem or FreeTDS setting that needs to change?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 31 juli 2014 15:41
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
The upper layer decided to cancel the query. The reason could be
previously in the log.
Looks like you are using an encoding which cannot support your
charset (there are some question marks in the output string
possibly result of a wrong conversion).
Frediano
Post by Ola Karlsson
Hi,
Sorry for the delay. Went on hollidays for a few weeks :)
As far as I can see my error message is stated in the log
exactly as it should be and it also states two returned results.
The integer value is returned correctly but not the nvarchar.
I have attached a portion of the log containing the procedure
call and my error message.
I don't notice any error messages or so but then again theres a
lot of information in the logs.
No errors in the php logs either.
Any ideas?
BR
Ola
-----Ursprungligt meddelande-----
Fr?n: FreeTDS [mailto:freetds-bounces at lists.ibiblio.org] F?r Frediano Ziglio
Skickat: den 12 juli 2014 09:06
Till: FreeTDS Development Group
?mne: Re: [freetds] Problem with nvarchar output
Hi,
did you check TDSDUMP ?
Frediano
Post by Ola Karlsson
Hi
I'm using Freetds with PHP5 to access a SQL server but I'm
having trouble with the output parameters.
I have two parameters, one SQLINT4 and one SQLVARCHAR. The int
is working but I don't get any returns from the varchar.
Is there anything special that needs to be done when
outputting
nvarchar?
Post by Ola Karlsson
Post by Ola Karlsson
PHP binds,
mssql_bind($stmt,
SQL parameters,
@ErrorMsg nvarchar(4000) output @OrderNr Jeeves_OrderNo output
Sql server,
SQL Server 2008 R2
Freetds server,
Ubuntu 12.04 3.5.0-51-generic
Tsql -C
Version: freetds v0.91
freetds.conf directory: /etc/freetds MS db-lib source
no Sybase binary compatibility: yes Thread safety: yes iconv
library: yes TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
Freetds conf,
[global]
text size = 64512
[Sqlserver]
host = xxx.xxx.xxx.xxx
port = xxxx
tds version = 8.0
PHP5
PHP 5.3.10-1ubuntu3.12
BR
Ola
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Continue reading on narkive:
Search results for '[freetds] Problem with nvarchar output' (Questions and Answers)
7
replies
Help for my SQL Query Question?
started 2012-12-07 20:20:16 UTC
programming & design
Loading...