cancel
Showing results for 
Search instead for 
Did you mean: 

Undocumented "Invalid parameter type" message can be a big time-waster

Breck_Carter
Participant
1,700

The error message "Invalid parameter type" is not documented, but it can be returned from a proxy procedure call via the uninformative catch-all SQLCODE -660 exception:

SQLCODE = -660, SQLSTATE = WO005, ERRORMSG() = Server 'p002': [SAP][ODBC Driver]Invalid parameter type

With -660 your ONLY hope at finding out what went wrong is the ERRORMSG() text, and in this case "Invalid parameter type" is both undocumented AND misleading.


One cause is a local (proxy) CREATE PROCEDURE AT statement that specifies a procedure parameter where the remote procedure doesn't have any parameters (how is "missing" an "invalid type"? ...oh, never mind 🙂

Even if you CALL the procedure with no parameters (e.g., CALL p(); ) you will still get "Invalid parameter type", presumably because the CREATE PROCEDURE AT statement contains that bogus parameter definition.

Proxy procedures are wonderful things, and worth the effort.

Here is a reproducible, followed by code that works OK because the remote procedure DOES have a parameter...

---------------------------------------------------------------------
-- On ddd2 (remote)

BEGIN
   DROP PROCEDURE p;
   EXCEPTION WHEN OTHERS THEN
END;

CREATE PROCEDURE p() -- no parameter definition
   RESULT ( @r CHAR ( 50 ) )
BEGIN
   DECLARE @r CHAR ( 50 );
   SET @r = 'no parameter definition';
   SELECT @r;
END;

---------------------------------------------------------------------
-- On ddd1 (local) CREATE PROCEDURE ... AT ...

BEGIN
   DROP PROCEDURE proxy_p;
   EXCEPTION WHEN OTHERS THEN
END;

BEGIN
   DROP SERVER ddd2_server;
   EXCEPTION WHEN OTHERS THEN
END;

CREATE SERVER ddd2_server CLASS 'SAODBC' 
   USING 'ENG=ddd2; DBN=ddd2; UID=dba; PWD=sql; DRIVER=SQL Anywhere 17;';

CREATE PROCEDURE proxy_p ( 
   @v CHAR ( 50 ) DEFAULT 'Default value' ) -- parameter definition
   RESULT ( @r CHAR ( 50 ) )
   AT 'ddd2_server...p';

SELECT * FROM proxy_p ( 'Hello' );
SELECT * FROM proxy_p ( 'World' );
SELECT * FROM proxy_p();

---------------------------------------------------------------------
Server 'ddd2_server': [SAP][ODBC Driver]Invalid parameter type
SQLCODE=-660, ODBC 3 State="HY000"

@r                                                 
-------------------------------------------------- 
(0 rows)


Server 'ddd2_server': [SAP][ODBC Driver]Invalid parameter type
SQLCODE=-660, ODBC 3 State="HY000"

@r                                                 
-------------------------------------------------- 
(0 rows)


Server 'ddd2_server': [SAP][ODBC Driver]Invalid parameter type
SQLCODE=-660, ODBC 3 State="HY000"

@r                                                 
-------------------------------------------------- 
(0 rows)

Here is code that works because it has been fixed...

---------------------------------------------------------------------
-- On ddd2 (remote)

BEGIN
   DROP PROCEDURE p;
   EXCEPTION WHEN OTHERS THEN
END;

CREATE PROCEDURE p ( 
   @v CHAR ( 50 ) DEFAULT 'Default value' )
   RESULT ( @r CHAR ( 50 ) )
BEGIN
   DECLARE @r CHAR ( 50 );
   SET @r = @v;
   SELECT @r;
END;


---------------------------------------------------------------------
-- On ddd1 (local) CREATE PROCEDURE ... AT ...

BEGIN
   DROP PROCEDURE proxy_p;
   EXCEPTION WHEN OTHERS THEN
END;

BEGIN
   DROP SERVER ddd2_server;
   EXCEPTION WHEN OTHERS THEN
END;

CREATE SERVER ddd2_server CLASS 'SAODBC' 
   USING 'ENG=ddd2; DBN=ddd2; UID=dba; PWD=sql; DRIVER=SQL Anywhere 17;';

CREATE PROCEDURE proxy_p ( 
   @v CHAR ( 50 ) DEFAULT 'Default value' )
   RESULT ( @r CHAR ( 50 ) )
   AT 'ddd2_server...p';

SELECT * FROM proxy_p ( 'Hello' );
SELECT * FROM proxy_p ( 'World' );
SELECT * FROM proxy_p();

---------------------------------------------------------------------
@r                                                 
-------------------------------------------------- 
Hello                                              
(1 rows)

@r                                                 
-------------------------------------------------- 
World                                              
(1 rows)


@r                                                 
-------------------------------------------------- 
Default value                                      
(1 rows)

Accepted Solutions (0)

Answers (0)