Trigger function using current row and current table name as variables
Assuming that, for the same trigger invocation, you take all the values from the same row in the table firing your trigger, your trigger function could look like this:

CREATE OR REPLACE FUNCTION trfn_tbl_log_any()
  RETURNS trigger AS
$func$
DECLARE
   _ct int;
BEGIN

IF NEW.timetype = 'start' THEN

   EXECUTE format($$
      SELECT floor(t.timeidx) + 1
      FROM   %s t
      WHERE  t.fnname = $1
      AND    t.timetype = 'start'
      ORDER  BY t.stmtserial DESC
      LIMIT  1$$
    , TG_RELID::regclass  -- concatenate *identifer* ..
      )
   USING NEW.fnname        -- .. but pass *value* in USING clause
   INTO  NEW.timeidx;

   GET DIAGNOSTICS _ct = ROW_COUNT;

   IF _ct &gt; 0 THEN  -- do nothing
   ELSE
      NEW.timeidx := 1;
   END IF;
END IF;

RETURN NEW;
END
$func$  LANGUAGE plpgsql;


All of this should work in Postgres 9.1. But consider upgrading to a current version anyway (currently 9.4).


NEW is not visible inside EXECUTE. Use the USING clause to pass the value from the new row (NEW.fnname).
Use TG_RELID (or TG_TABLE_SCHEMA and TG_TABLE_NAME) to concatenate the table name like we worked out under your previous question:


PostgreSQL trigger function that selects from %current% table

Use format() and dollar-quoting to simplify the syntax of string-concatenation safely.
You can assign individual columns of the NEW row directly from the dynamic query.
Use GET DIAGNOSTICS _ct = ROW_COUNT; to check if rows were found. Per documentation:


  Note in particular that EXECUTE changes the output of GET DIAGNOSTICS, but does not change FOUND.



Aside: the logic of the dynamic query is only correct for BEFORE trigger. An AFTER triggers would also see the newly inserted row.