Re: Function error

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "'Sachin Srivastava *EXTERN*'" <ssr(dot)teleatlas(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Function error
Date: 2016-01-13 10:40:14
Message-ID: A737B7A37273E048B164557ADEF4A58B537BADFA@ntex2010a.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sachin Srivastava wrote:
> I am getting the below error for function, please see the bold line in "Function code", please suggest
> what I will do to correct this code.
>
> -----------------------
>
> ERROR: syntax error at or near "*"
> LINE 35: SELECT * from logError(msg text) is
> ^
> CONTEXT: invalid type name "* from logError(msg text) is

That error message does not look like it could come from the
function definition below, but the function definition is clearly
syntactically incorrect:

> CREATE OR REPLACE FUNCTION cp_property_room_count_trans(
> subscriberid bigint,
> incompanyid bigint,
> loginname text)
> RETURNS void AS
> $BODY$
> DECLARE

[...]

> SELECT logError(v_errorMesg text, procedureName text, subscriberID bigint, companyID bigint,
> supplierSku text, loginName text) is
>
> BEGIN
> insert into SMERROR_LOG
> (error_message, method_name, system_message, error_log_id, subscriber_id, company_id,
> creation_date, creation_user, update_date, update_user)
> values(v_errorMesg, procedureName, supplierSku, nextval('smerror_log_sequence'), subscriberID,
> companyID, LOCALTIMESTAMP, loginName, LOCALTIMESTAMP, 'V7Admin');
> end;

You cannot declare a function inside the DECLARE section of
another function. Besides, what is "SELECT logError" supposed to mean?

You will have to declare each of the helper functions with ist own
CREATE FUNCTION statement.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christian Ramseyer 2016-01-13 11:59:37 Changing varchar length by manipulating pg_attribute
Previous Message Geoff Winkless 2016-01-13 10:11:25 Re: WIP: CoC V5