postgresql - New to Postgres. Can you help me with a couple simple statments? -
i'm familiar mssql need work postgres stuff today. end goal return new id of table use elsewhere since i'm unfamiliar syntax of postgress, seem having trouble.
problem 1:
in mssql would:
delcare @test_number int select @test_number = 42 print @test_number
in postgres i'm trying:
test_number integer; test_number := 42 print test_number
but doesnt first line:
error: syntax error @ or near "test_number" line 1: test_number integer;
if can figure out, think i've got real problem solved like:
problem 2:
in mssql would:
declare @new_id int insert some_table (data1. data2) select @new_id = @@identity -- use @new_id w/e want
in postgres i'm trying:
new__id integer; new_id := insert some_table (data1, data2) returning id; -- use new_id w/e want
a quick search on google gives following answer.
how use variables in simple postgresql script?
it looks declare anonymous inline pgsql function in query. looks it's new postgres 9.
Comments
Post a Comment