Thread: loop Through Query Results : Record
Hello, I'm trying to loop Through Query Results For example : - I have a table with few user to create . create table userToCreate(name varchar ) - I create a function : create function createuser() return int2 AS' declare username RECORD; begin for username in select name from userToCreate loop CREATE USER username.name; end loop ; return 1; end ' LANGUAGE 'sql'; I don't understand why i get this error : An error has occured in pdAdmin II:frmSQLInput.cmdExecute_Click: Number : -2147467259 Description ERROR: parser error at or near "record" Does someone can help me ? thank's
hi, try tablename.RECORD ?? On Thu, Mar 25, 2004 at 03:51:59PM +0100, DAVANNE Eric - NTR wrote: > Hello, > I'm trying to loop Through Query Results > For example : > - I have a table with few user to create . > create table userToCreate(name varchar ) > > - I create a function : > create function createuser() return int2 AS' > declare > username RECORD; > begin > for username in select name from userToCreate loop > CREATE USER username.name; > end loop ; > return 1; > end > ' LANGUAGE 'sql'; > > I don't understand why i get this error : > An error has occured in pdAdmin II:frmSQLInput.cmdExecute_Click: > Number : -2147467259 > Description ERROR: parser error at or near "record" > > Does someone can help me ? > > thank's > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend -- joe speigle www.sirfsup.com
DAVANNE Eric - NTR <EDavanne@nanterre.sema.slb.com> writes: > create function createuser() return int2 AS' > declare > username RECORD; > begin > for username in select name from userToCreate loop > CREATE USER username.name; > end loop ; > return 1; > end > ' LANGUAGE 'sql'; That function is written in plpgsql language, not sql language. regards, tom lane