cancel
Showing results for 
Search instead for 
Did you mean: 

sybase asa 17 run webserver error webservice CALL PROCEDURE

ximen
Participant
0 Kudos
107

 

run demo.db:

"C:\Program Files\SQL Anywhere 17\bin64\dbsrv17.exe" -c 8m -n demo17 "C:\Users\Public\Documents\SQL Anywhere 17\Samples\\demo.db" -xs http(port=8098;maxrequestsize=70m;LOPT=ALL,HEADERS;LOG=D:\WEB.LOG) -zoc clientinfo.txt -qn


create procedure:

CREATE PROCEDURE "DBA"."Z_calltable"( IN
@table_name char(128)

)
RESULT( "column_name" char(128) )
BEGIN
--select * from `[@table_name]`;
select * from table ref(@table_name) as t;
END;

create webservice:

CREATE SERVICE "z_get_col" TYPE 'RAW' AUTHORIZATION OFF USER "DBA" URL ON AS call "z_calltable"(:tname);


brower http web address:

http://127.0.0.1:8098/z_get_col?tanme=Counters


error:

SQL error: The variable '@table_name' cannot be NULL in this context.

 

 

View Entire Topic
chris_keating
Product and Topic Expert
Product and Topic Expert

Did you test calling the procedure on its own rather than from an web service call? The TABLE REF requires a variable type TABLE REF and it cannot be a character string - it has to be a database object

i.e., TABLE REF( groupo.departments ) not TABLE_REF( 'groupo.departments').  This will need to be constructed with an indirect identifier not a TABLE REF as that is going to need to be declared as such before being passed to the procedure.

I assume that the HTTP request is just a typo for the variable name.  

create or replace procedure foo( in @table_name char(128) )
result( colval smallint ) )
begin
select 1 from `[@table_name]`;
end;

call foo('departments');

create or replace service foobar 
     type 'raw' authorization off 
     user dba 
     url on 
as 
     call foo(:table_name);

And the HTTP request

http://localhost:12345/foobar?table_name=departments