If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Postgres 8.3 to 9.1 function problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Dec 2012
Posts: 1
Postgres 8.3 to 9.1 function problem

Migrating the following function from 8.3.9 to 9.1.7 throws the error:

SELECT easy_pay(606,1);
ERROR: syntax error at or near "."
LINE 1: SELECT user.esbalance < amount
^
QUERY: SELECT user.esbalance < amount
CONTEXT: PL/pgSQL function "easy_pay" line 19 at IF

Code:
CREATE OR REPLACE FUNCTION public.easy_pay(integer, integer)
 RETURNS integer
 LANGUAGE plpgsql
AS $function$DECLARE
  user_id ALIAS FOR $1;
  amount ALIAS FOR $2;
  user record;
  mg record;
  newbalance float;
BEGIN
  SELECT INTO user es.balance as esbalance
              from
                  easy_users es
              where
                  es.usid = user_id;

  IF NOT FOUND THEN
    RAISE EXCEPTION 'Cannot find user';
    return -2;
  END IF;

  IF user.esbalance < amount THEN
        return -1;
  END IF;
  newbalance     := user.esbalance - amount;
  UPDATE easy_users SET balance = newbalance
                  WHERE usid = user_id;  
  return 1;
END;$function$
Language 'plpgsql' is already installed in the database..
Any help will be appreciated!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On