{"action":"created","issue":{"url":"https://api.github.com/repos/Ninja-Squad/DbSetup/issues/40","labels_url":"https://api.github.com/repos/Ninja-Squad/DbSetup/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/Ninja-Squad/DbSetup/issues/40/comments","events_url":"https://api.github.com/repos/Ninja-Squad/DbSetup/issues/40/events","html_url":"https://github.com/Ninja-Squad/DbSetup/issues/40","id":87632378,"number":40,"title":"Setting foreign keys from autogenerated primary keys","user":{"login":"favetelinguis","id":5941745,"avatar_url":"https://avatars.githubusercontent.com/u/5941745?v=3","gravatar_id":"","url":"https://api.github.com/users/favetelinguis","html_url":"https://github.com/favetelinguis","followers_url":"https://api.github.com/users/favetelinguis/followers","following_url":"https://api.github.com/users/favetelinguis/following{/other_user}","gists_url":"https://api.github.com/users/favetelinguis/gists{/gist_id}","starred_url":"https://api.github.com/users/favetelinguis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/favetelinguis/subscriptions","organizations_url":"https://api.github.com/users/favetelinguis/orgs","repos_url":"https://api.github.com/users/favetelinguis/repos","events_url":"https://api.github.com/users/favetelinguis/events{/privacy}","received_events_url":"https://api.github.com/users/favetelinguis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-12T06:56:21Z","updated_at":"2015-06-12T14:03:17Z","closed_at":null,"body":"Im working with an Oracle database that uses sequences for primary keys, there are triggers on these primary keys that does not allow me to enter them manually. What I would like do do in DBSetup is to retrive the autogenerated primary key and use it in a different table as a foreign key. \r\nFrom the examples given on your hompage would it be possible with DBsetup to do the following?\r\n\r\n    Operation insertVendorsAndProducts = \r\n        sequenceOf(\r\n            insertInto(\"VENDOR\")\r\n                .columns(\"ID\", \"CODE\", \"NAME\")\r\n                .values(This is autogenerated, \"AMA\", \"AMAZON\")\r\n                .build(),\r\n            insertInto(\"PRODUCT\")\r\n                .columns(\"ID\", \"NAME\", \"VENDOR_ID\")\r\n                .values(1L, \"Kindle\", \"1L\")\r\n                .build(),\r\n            sql(\"update PRODUCT set FEATURED_PRODUCT_ID = with autogenerated value from VENDOR where Vendor ID = 1\"));\r\n\r\nCurrently we are running SQL like this to populate the database.\r\n\r\ndeclare\r\n  id number;\r\nbegin\r\n  insert into f (b) VALUES ('J') returning account__id  into id;\r\n  insert into b (fid) VALUES (id);\r\nend;"},"comment":{"url":"https://api.github.com/repos/Ninja-Squad/DbSetup/issues/comments/111503214","html_url":"https://github.com/Ninja-Squad/DbSetup/issues/40#issuecomment-111503214","issue_url":"https://api.github.com/repos/Ninja-Squad/DbSetup/issues/40","id":111503214,"user":{"login":"favetelinguis","id":5941745,"avatar_url":"https://avatars.githubusercontent.com/u/5941745?v=3","gravatar_id":"","url":"https://api.github.com/users/favetelinguis","html_url":"https://github.com/favetelinguis","followers_url":"https://api.github.com/users/favetelinguis/followers","following_url":"https://api.github.com/users/favetelinguis/following{/other_user}","gists_url":"https://api.github.com/users/favetelinguis/gists{/gist_id}","starred_url":"https://api.github.com/users/favetelinguis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/favetelinguis/subscriptions","organizations_url":"https://api.github.com/users/favetelinguis/orgs","repos_url":"https://api.github.com/users/favetelinguis/repos","events_url":"https://api.github.com/users/favetelinguis/events{/privacy}","received_events_url":"https://api.github.com/users/favetelinguis/received_events","type":"User","site_admin":false},"created_at":"2015-06-12T14:03:17Z","updated_at":"2015-06-12T14:03:17Z","body":"Ok thanks for the answeres. Using DbSetup has given me alot of knowledge about good DB design. I dont think you should add suport for \"badly designed databases\" it is better that teams realize the better ways of doing things when they start to trying to test stuff."}}