Re: starting on functions (with a bit more succes)
От | Odysseus |
---|---|
Тема | Re: starting on functions (with a bit more succes) |
Дата | |
Msg-id | 1309989469487-4559069.post@n5.nabble.com обсуждение исходный текст |
Ответ на | Re: starting on functions (with little succes) (Odysseus <bart.pietercil@gmail.com>) |
Ответы |
Re: starting on functions (with a bit more succes)
|
Список | pgsql-novice |
ok, one error fixed: do not combine declare with language 'sql'. When using declare use 'plpgsql' now this is accepted: create FUNCTION createNewClient(clientName varchar, coreURL varchar,vs_ip varchar, vs_db varchar, vs_connstring varchar, vs_usr_pw varchar,lifespanUnitLV varchar, lifespan int2 DEFAULT null) RETURNS void AS $BODY$ declare aSerial uuid; lifeSpanUnitPK bigint; begin SELECT INTO aSerial newuuid(); select into lifeSpanUnitPK tbl_typelistvalues.pkid from tbl_typelistvalues join tbl_typelists on tbl_typelistvalues.fk_typelist = tbl_typelists.pkid where listvalue = lifespanUnitLV AND typelistname = 'token_lifespan_units'; insert into tbl_clients(vserver_userpw,vserver_ip,vserver_dbname,vserver_connectionstring,client_name,client_serial,client_core_url,token_lifespan,objptr_token_lifespan_unit) values (vs_usr_pw,vs_ip,vs_db,vs_connstring,clientName,aSerial,coreURL,lifespan,lifeSpanUnitPtr); exception when others then raise ; end; $BODY$ LANGUAGE plpgsql CALLED ON NULL INPUT SECURITY INVOKER IMMUTABLE; -------------- Problem is not solved for this: after BEGIN i would like to use this if then statement: ----------------- if lifespanUnitLV = '4' then end if ---------------- This returns an error: Error : ERROR: syntax error at or near "SELECT" LINE 14: SELECT INTO aSerial ^ It must be something with the IF itself. -- View this message in context: http://postgresql.1045698.n5.nabble.com/starting-on-functions-with-little-succes-tp4557235p4559069.html Sent from the PostgreSQL - novice mailing list archive at Nabble.com.
В списке pgsql-novice по дате отправления: