|
Home > Archive > SQL Anywhere database > July 2005 > SQLAnywhere PHP Module interface reference
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
SQLAnywhere PHP Module interface reference
|
|
| Veselin Ivanov 2005-07-15, 9:23 am |
| Hi,
using ASA 9.0.2.3137 and PHP 4.3.10
This is a simple test of sqlanywhere_query
$result = sqlanywhere_query( $conn, $qname );
if( ! $result ) {
echo "sqlanywhere_query failed!";
} else {
sqlanywhere_result_a
ll( $result, "border=1" );
sqlanywhere_free_res
ult( $result );
}
sqlanywhere_query returns 7 when $qname is :
alter PROCEDURE "DBA"."my_test"()
begin
select * from dba.my_test;
end;
BUT!! sqlanywhere_query returns 0 when $qname is :
if exists(select 1 from sys.sysprocedure where proc_name='my_test')
then
alter PROCEDURE "DBA"."my_test"()
begin
select * from dba.my_test;
end;
end if;
Any ideas why sqlanywhere_query returns 0
TIA
Regards
Vesselin
| |
| Greg Fenton 2005-07-15, 9:23 am |
| Veselin Ivanov wrote:
>
> BUT!! sqlanywhere_query returns 0 when $qname is :
>
> if exists(select 1 from sys.sysprocedure where proc_name='my_test')
then
> alter PROCEDURE "DBA"."my_test"()
> begin
> select * from dba.my_test;
> end;
> end if;
>
What is the value of SQLCode after the above returns 0 ?
(I think you need to do a sqlanywhere_query("SELECT @@error") to get the
sqlcode).
You might try wrapping your statements above as a BEGIN...END block to
see if that works.
greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/
| |
| Veselin Ivanov 2005-07-15, 9:23 am |
| Hi Gleg,
sqlanywhere_query("SELECT @@error") returns 0
with BEGIN...END block sqlanywhere_query returns 0
sqlanywhere_query( $conn, $qname ) returns
if exists(select 1 from sys.sysprocedure where proc_name='my_test')
then
alter PROCEDURE "DBA"."my_test"()
begin
update dba.my_test set c=2;
-- select * from dba.my_test;
end;
end if;
$result >0 :)
=================
if exists(select 1 from sys.sysprocedure where proc_name='my_test')
then
alter PROCEDURE "DBA"."my_test"()
begin
--update dba.my_test set c=2;
select * from dba.my_test;
end;
end if;
$result =0 :(
=================
alter PROCEDURE "DBA"."my_test"()
begin
--update dba.my_test set c=2;
select * from dba.my_test;
end;
$result>0 :)
=================
if not exists(select 1 from sys.sysprocedure where proc_name='my_test')
then
begin
select * from dba.sys_users;
end;
end if;
$result=0 :(
=================
if exists(select 1 from sys.sysprocedure where proc_name='my_test')
then
begin
select * from dba.sys_users;
end;
end if;
$result>0 :)
the sysprocedure 'my_test' exists and the result set is OK
Regards
Vesselin
| |
| Greg Fenton 2005-07-15, 9:23 am |
| Veselin Ivanov wrote:
> Hi Gleg,
> sqlanywhere_query("SELECT @@error") returns 0
But what is the value of @@error (that is the SQLCode). You can look up
the meaning of different SQLCodes in the SQLAnywhere 9.x online docs:
ASA Error Messages
Database Error Messages
- Error messages indexed by Adaptive Server Anywhere SQLCODE
> =================
>
> if exists(select 1 from sys.sysprocedure where proc_name='my_test')
then
> alter PROCEDURE "DBA"."my_test"()
> begin
> --update dba.my_test set c=2;
> select * from dba.my_test;
> end;
> end if;
>
> $result =0 :(
Consider adding a RESULTS clause to your procedure as it is in fact
returning a result set.
> =================
>
> alter PROCEDURE "DBA"."my_test"()
> begin
> --update dba.my_test set c=2;
> select * from dba.my_test;
> end;
>
>
> $result>0 :)
>
> =================
>
> if not exists(select 1 from sys.sysprocedure where proc_name='my_test')
then
> begin
> select * from dba.sys_users;
> end;
> end if;
> $result=0 :(
>
> =================
Again, I think that looking at the SQLCode after the failed query will
help determine what is going on.
Have you run these queries using DBISQL to see if they work (i.e. get
rid of the PHP/webserver layers of the problem)?
greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/
| |
| Veselin Ivanov 2005-07-15, 11:23 am |
| the value of @@error is 0
"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
news:42d7cc79@forums
-2-dub...
> Veselin Ivanov wrote:
>
> But what is the value of @@error (that is the SQLCode). You can look up
> the meaning of different SQLCodes in the SQLAnywhere 9.x online docs:
| |
| Veselin Ivanov 2005-07-15, 11:23 am |
| Greg, I found that if I add select ... somethink all is OK
if exists(select 1 from sys.sysprocedure where proc_name='my_test')
then
alter PROCEDURE "DBA"."my_test"()
begin
select * from dba.my_test;
end;
end if;
select @@error; (or select whatelse)
so I will use this as a workaround, but I think there is somethink wrong=
Vesselin
"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
news:42d7cc79@forums
-2-dub...
> Veselin Ivanov wrote:
>
> But what is the value of @@error (that is the SQLCode). You can look up
> the meaning of different SQLCodes in the SQLAnywhere 9.x online docs:
>
> ASA Error Messages
> Database Error Messages
> - Error messages indexed by Adaptive Server Anywhere SQLCODE
>
>
>
>
> Consider adding a RESULTS clause to your procedure as it is in fact
> returning a result set.
>
>
>
>
> Again, I think that looking at the SQLCode after the failed query will
> help determine what is going on.
>
> Have you run these queries using DBISQL to see if they work (i.e. get rid
> of the PHP/webserver layers of the problem)?
>
> greg.fenton
> --
> Greg Fenton
> Consultant, Solution Services, iAnywhere Solutions
> --------
> Visit the iAnywhere Solutions Developer Community
> Whitepapers, TechDocs, Downloads
> http://www.ianywhere.com/developer/
|
|
|
|
|