[GENERAL] [PL/pgSQL] How should I use FOUND special variable. Documentation is little unclear for me

2006-11-09 Thread Jeremiasz Miedzinski
Hello.I'm porting some procedures from PL/SQL  and I encountered following problem:In PL/SQL I'm using this statement related to cursor:OPEN crs_cnt(start_millis, end_millis);LOOP FETCH crs_cnt into row_cnt;
    EXIT WHEN crs_cnt%NOTFOUND;    insert into spm_audit_stats values(SEQ_SPM_ID_AUTO_INC.nextval, start_millis, base_stat_period, row_cnt.adt_count, row_cnt.adt_avg, row_cnt.adt_max, row_cnt.adt_min, row_cnt.adt_stdev, row_cnt.adt_service_name, row_cnt.adt_root_user);
 global_counter := global_counter + 1;END LOOP;CLOSE crs_cnt;Now, I need to do the same action in PL/pgSQL. It's rather simple, but I don't know how to use FOUND variable described in documentation:
FETCH retrieves the next row from the cursor
into a target, which may be a row variable, a record variable, or a
comma-separated list of simple variables, just like SELECT INTO.  As with SELECTINTO, the special variable FOUND may   be checked to see whether a row was obtained or not.
When I'm trying to use it in Oracle way, my DB reports error. Also I tried to use it like that:IF NOT crs_cnt%FOUND THEN ...But it also doesn't worked for me.Thanks for any help.Kind Regards.
-- -- audi vide sile --


[GENERAL] [PL/pgSQL] Commit every N rows. Is it possible ?

2006-11-09 Thread Jeremiasz Miedzinski
Hello,I'm still trying to convert my PL/SQL stored procedures into PL/pgSQL. Now, I have problem with commiting transaction every N rows:
loopfetch csr_ac into row_id;   if not FOUND then  exit;   end if;   counter := counter + 1;   delete from spm_audit where adt_id=row_id;   delete from spm_audit_pipeline_data where apd_adt_id=row_id;
   global_counter := global_counter + 1;   if counter = rows_between_commit then   counter := 0;   commit;   end if;end loop;I'm digging into postgresql documentation but maybe I'm just not smart enough to understand the way which transactions are being processed into pgSQL. Is it possible to port above code to PL/pgSQL ?
Kind Regards.-- -- audi vide sile --


Re: [GENERAL] cannot connect anymore from a remote host

2006-11-09 Thread Jeremiasz Miedzinski
2006/11/9, Luca Ferrari <[EMAIL PROTECTED]>:
Hi all,after a crash of my machine I restarted the pgsql as usual, and I can connectfrom the machine itself, but no more from a remote host. I checked thepg_hba.conf file and it's ok, but either from psql or pgadmin I cannot
connect to the host. Nmapping my host I cannot see the daemon listening onHi Luca,

Have You checked network interfaces on your machine ? Maybe some of them doesn't start-up properly...

Rgds. -- -- audi vide sile --


Re: [GENERAL] [PL/pgSQL] Commit every N rows. Is it possible ?

2006-11-10 Thread Jeremiasz Miedzinski
2006/11/9, Richard Huxton :
It's not clear to me why your function does what it does anyway. I can'tsee why you wouldn't just do this as standard queries.As it was mentioned on 
http://orafaq.com/faqplsql.htm
Contrary to popular believe, one should COMMIT less frequently within a 
PL/SQL loop to prevent ORA-1555 (Snapshot too old) errors. The higher the 
frequency of commit, the sooner the extents in the rollback segments will 
be cleared for new transactions, causing ORA-1555 errors.So, I understand that if function/procedure in postgreSQL is treated as one transaction I can for example execute 15000 delete queries and nothing similar to ORA-1555 shouldn't happen.
Kind Regards.-- -- audi vide sile --