string is sometimes null ? - Mailing list pgsql-general

From Graeme Hinchliffe
Subject string is sometimes null ?
Date
Msg-id 1096470232.27973.49.camel@office-137.zen.co.uk
Whole thread Raw
Responses Re: string is sometimes null ?  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-general
Hiya
    I have written a PL/PGSQL function which tots up users accounting
information from their RADACCT data on the fly.  So each insert or
update modifies their totals.

    This has worked without error when I have tested it by hand with hand
crafted inserts and updates, however when I put it on the actual live
accounting server (both systems are running 7.4.3) it seems to work
partially.

    The RADIUS server is reporting problems when trying to write START of
accounting entries, and the error given is:

ERROR:  cannot EXECUTE a null querystring CONTEXT:  PL/pgSQL function
"radacct_trig" line 43 at open

The lines its refering to are:

--- START ---

str:=''SELECT
username,year_of_jan,current_in,current_out,current_start,last_update,m''||monthcurr||''_in AS
monthin,m''||monthcurr||''_outAS monthout 
  FROM customer_stats WHERE username=''''''||username||'''''''';

  OPEN curs FOR EXECUTE str;

--- END ---

str is defined as a varchar(255).  What could be causing str to be NULL
when the execute is caused?  I would have thought if some of the
variables were null that it would have complained about a malformed SQL
query but this is saying the string is NULL!

any ideas help much appreciated, thanks.

--
-----
Graeme Hinchliffe (BSc)
Core Internet Systems Designer
Zen Internet (http://www.zen.co.uk/)

Direct: 0845 058 9074
Main  : 0845 058 9000
Fax   : 0845 058 9005



pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Setting search paths inside a function (plpgsql)
Next
From: "Jonathan Villa"
Date:
Subject: Converting to Java date example