string is sometimes null ?

From: Graeme Hinchliffe <graeme(dot)hinchliffe(at)zeninternet(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: string is sometimes null ?
Date: 2004-09-29 15:03:53
Message-ID: 1096470232.27973.49.camel@office-137.zen.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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||''_out AS 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2004-09-29 15:06:27 Re: About PostgreSQL's limit on arithmetic operations
Previous Message Thomas F.O'Connell 2004-09-29 13:34:11 Re: EXTRACT Clarification