I confirmed that the data of the id column of the data inserted with the above sql was returned to the Oracle console window.
declare
tmp_id number;
begin
insert into users(nickname, platform, socialKey) values('test', 'test', 'test')
returning id into tmp_id;
DBMS_OUTPUT.PUT_LINE(tmp_id);
end;
The id value of the normally inserted data row is returned.
func TestTemp(t *testing.T) {
envSetting()
db := database.DatabaseInstance()
defer db.Close()
var userCount int
db.QueryRow(`
SET SERVEROUTPUT ON
declare
tmp_id number;
begin
insert into users(nickname, platform, socialKey) values('test', 'test', 'test')
returning id into tmp_id;
DBMS_OUTPUT.PUT_LINE(tmp_id);
end;
`).Scan(&userCount)
t.Log(userCount)
}
return data :
Running tool: /opt/homebrew/bin/go test -timeout 30s -run ^TestTemp$ github.com/temp/temp/test/auth
=== RUN TestTemp
/Users/temp/project/temp/test/auth/user_test.go:169: 0
--- PASS: TestTemp (0.22s)
PASS
ok github.com/temp/temp/test/auth 0.366s
> 2023. 1. 16. 오전 12:24:50에 테스트 실행이 종료됨 <
However, when I run the above code in golang, only 0 is returned. Could you please check what part is wrong?