Hi All. I need to create a sql script and launch it from pgadmin. In this script some sql statements (INSERT) have to depend from the result of previous statements (SELECT). Is there a way to define a variable in SQL and set its value with the result of a SELECT query? Using the psql console I've used the command set var 'val'; and this statement works fine. Usising the same command from pgadmin an error is reported. Im using postgres 8.2 on WindowsXp environment. Thanks in advance. Luca. -- Email.it, the professional e-mail, gratis per te: http://www.email.it/f Sponsor: VOGLIA DI VACANZE ? A Riccione i Family Hotels sono gli alberghi specializzati per le vacanze dei bambini Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7983&d=20080612