pgsql function parameter order
Posted: Fri 16 May 2014 14:12
Dear,
I'm given a task to change the database in an existing web application from mssql to pgsql.
Everything is used with strongly typed datatable (using stored procedures/functions).
The first problem is, that the generated function parameter's are in alphabetical order (not the same as the parameter order in databas):

If everything is left that way it does not work. I can arrange the order of the parameters by hand and everything works fine, but I have to do it every time I reconfigure the query.
Are there any way to skip this manual step?
The second problem is, I didn't find a way that pgsql would allow me to use something like the '@' in mssql for declaring a variable, so I can't differ the incoming parameter from a table column name.
Because of this I introduced 'p_' prefix for incoming parameters as seen in the code prior.
But these datatables are used in detail views and are bound to different objects (existing code that I don't really want to touch).
Because of this 'p_' prefix the insert statement variables does not match the returned table column names.
I found a way in Parameters Collection Editor to overwrite
Column name: p_columnName
ParameterName: columnName
With this the existing code works perfectly, but this is also a manual step that has to be redone every time something changes.
Normally the visual editor generates the following values:
ColumnName: (empty)
ParameterName: p_columnName
Thanks for any help.
Best regards.
I'm given a task to change the database in an existing web application from mssql to pgsql.
Everything is used with strongly typed datatable (using stored procedures/functions).
The first problem is, that the generated function parameter's are in alphabetical order (not the same as the parameter order in databas):
Code: Select all
CREATE OR REPLACE FUNCTION telep_telephely_paged_select(p_username character varying, p_varosnev character varying, p_nev character varying, p_nyilvszam integer, p_cim character varying, p_tev_id integer, p_stat_id integer, p_tipus_id integer, p_sortexpression character varying DEFAULT 'nyilvszam desc'::character varying, p_pagingstartrow integer DEFAULT 0, p_pagingrowcount integer DEFAULT 10)
RETURNS SETOF telep_telephely_paged_select_resulttype AS
$BODY$
DECLARE

If everything is left that way it does not work. I can arrange the order of the parameters by hand and everything works fine, but I have to do it every time I reconfigure the query.
Are there any way to skip this manual step?
The second problem is, I didn't find a way that pgsql would allow me to use something like the '@' in mssql for declaring a variable, so I can't differ the incoming parameter from a table column name.
Because of this I introduced 'p_' prefix for incoming parameters as seen in the code prior.
But these datatables are used in detail views and are bound to different objects (existing code that I don't really want to touch).
Because of this 'p_' prefix the insert statement variables does not match the returned table column names.
I found a way in Parameters Collection Editor to overwrite
Column name: p_columnName
ParameterName: columnName
With this the existing code works perfectly, but this is also a manual step that has to be redone every time something changes.
Normally the visual editor generates the following values:
ColumnName: (empty)
ParameterName: p_columnName
Thanks for any help.
Best regards.