Version: 13.0-beta-1
Build #: 30782
Build Date: 2013-Jan-02 11:58:13 AM
Procedure --> Execute Bind is displaying Undefined data type for variable RETURN_VALUE.
Occurs with PostgreSQL as well
For the sample procedure which is created in fung_schema in Greenplum, select tmp_procedure_1()
Right click and select Script to Window--> Execute Bind
Once it is scripted, execute the stored procedure and it always displays a message - Undefined data type: (void) for variable: (RETURN_VALUE)
|
65 KB
Below are two PostgreSQL scripts generated by ADS based on a procedure and a function that take no arguments:
(1) 'EXECUTE BIND' script generated by ADS based on a procedure that takes no arguments:
.variable RETURN_VALUE, void
.println ' Execute:'
.println ' [RESULT] = public.tmp_proc_0()'
.println ''
.executeCallableQuery 'RETURN_VALUE<void,out>',
{ ? = CALL public.tmp_proc_0() }
.println ' Results:'
.println ' [', RETURN_VALUE, '] = public.tmp_proc_0()'
.println ''
GO
Here is the definition of the procedure:
CREATE FUNCTION "public"."tmp_proc_0" () RETURNS void AS
$BODY$ $BODY$
LANGUAGE 'sql'
(2) 'EXECUTE BIND' script generated by ADS based on a function that takes no arguments:
.variable RETURN_VALUE, record
.println ' Execute:'
.println ' [RESULT] = public.tmp_function_1()'
.println ''
.executeCallableQuery 'RETURN_VALUE<record,out>',
{ ? = CALL public.tmp_function_1() }
.println ' Results:'
.println ' [', RETURN_VALUE, '] = public.tmp_function_1()'
.println ''
GO
Here is the definition of the function:
CREATE OR REPLACE FUNCTION "public"."tmp_function_1" () RETURNS record AS
$BODY$ SELECT * FROM test_tbl_for_functions $BODY$
LANGUAGE 'sql'
------
It seems that the script generated by 'EXECUTE BIND' is ADS specific; .variable, .println, .executeCallableQuery, etc. are ADS specific commands. See link below for more info:
https://www.aquaclusters.com/app/home/project/public/aquadatastudio/wikibook/Documentation12/page/196/Aqua-Commands
If we execute the first script, the following error is generated:
>[Error] Script lines: 1-11 -----------------------
Undefined data type: (void) for variable: (RETURN_VALUE)
and, execution of the second script generates this error:
>[Error] Script lines: 1-12 -----------------------
Undefined data type: (record) for variable: (RETURN_VALUE)
These errors are thrown by .variable command which expects the data type followed the 'RETRUN_VALUE' to be one of a data type that can be used to define a table column; and of course, 'void' and 'record' is not one of those data types that can be used to define a table column; see CmdVariable.execute(Session session, StmtResult stmtResults, Object[] args) method for more info.
Not sure what is the right way to fix this problem, need to discuss with Niels before moving forward.
Per PostgreSQL 8.2 document, the return type of a function is defined as:
The return type may be a base, composite, or domain type, or may reference the type of a table column. Depending on the implementation language it may also be allowed to specify "pseudotypes" such as cstring. If the function is not supposed to return a value, specify void as the return type.
When there are OUT or INOUT parameters, the RETURNS clause may be omitted. If present, it must agree with the result type implied by the output parameters: RECORD if there are multiple output parameters, or the same type as the single output parameter.
The type of a column is referenced by writing tablename.columnname%TYPE.
See link below for details:
http://www.postgresql.org/docs/8.2/static/sql-createfunction.html
Also tried a similar test case against a function returning an integer, failed in CmdExecuteCallableQuery.execute(...).
Per PostgreSQL 8.2 document, the return type of a function is defined as:
The return type may be a base, composite, or domain type, or may reference the type of a table column. Depending on the implementation language it may also be allowed to specify "pseudotypes" such as cstring. If the function is not supposed to return a value, specify void as the return type.
When there are OUT or INOUT parameters, the RETURNS clause may be omitted. If present, it must agree with the result type implied by the output parameters: RECORD if there are multiple output parameters, or the same type as the single output parameter.
The type of a column is referenced by writing tablename.columnname%TYPE.
See link below for details:
http://www.postgresql.org/docs/8.2/static/sql-createfunction.html
Also tried a similar test case against a function returning an integer, failed in CmdExecuteCallableQuery.execute(...).
Issue #8142 |
Closed |
Completion |
No due date |
No fixed build |
No time estimate |
Below are two PostgreSQL scripts generated by ADS based on a procedure and a function that take no arguments:
(1) 'EXECUTE BIND' script generated by ADS based on a procedure that takes no arguments:
.variable RETURN_VALUE, void
.println ' Execute:'
.println ' [RESULT] = public.tmp_proc_0()'
.println ''
.executeCallableQuery 'RETURN_VALUE<void,out>',
{ ? = CALL public.tmp_proc_0() }
.println ' Results:'
.println ' [', RETURN_VALUE, '] = public.tmp_proc_0()'
.println ''
GO
Here is the definition of the procedure:
CREATE FUNCTION "public"."tmp_proc_0" () RETURNS void AS
$BODY$ $BODY$
LANGUAGE 'sql'
(2) 'EXECUTE BIND' script generated by ADS based on a function that takes no arguments:
.variable RETURN_VALUE, record
.println ' Execute:'
.println ' [RESULT] = public.tmp_function_1()'
.println ''
.executeCallableQuery 'RETURN_VALUE<record,out>',
{ ? = CALL public.tmp_function_1() }
.println ' Results:'
.println ' [', RETURN_VALUE, '] = public.tmp_function_1()'
.println ''
GO
Here is the definition of the function:
CREATE OR REPLACE FUNCTION "public"."tmp_function_1" () RETURNS record AS
$BODY$ SELECT * FROM test_tbl_for_functions $BODY$
LANGUAGE 'sql'
------
It seems that the script generated by 'EXECUTE BIND' is ADS specific; .variable, .println, .executeCallableQuery, etc. are ADS specific commands. See link below for more info:
https://www.aquaclusters.com/app/home/project/public/aquadatastudio/wikibook/Documentation12/page/196/Aqua-Commands
If we execute the first script, the following error is generated:
>[Error] Script lines: 1-11 -----------------------
Undefined data type: (void) for variable: (RETURN_VALUE)
and, execution of the second script generates this error:
>[Error] Script lines: 1-12 -----------------------
Undefined data type: (record) for variable: (RETURN_VALUE)
These errors are thrown by .variable command which expects the data type followed the 'RETRUN_VALUE' to be one of a data type that can be used to define a table column; and of course, 'void' and 'record' is not one of those data types that can be used to define a table column; see CmdVariable.execute(Session session, StmtResult stmtResults, Object[] args) method for more info.
Not sure what is the right way to fix this problem, need to discuss with Niels before moving forward.