ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
While accessing database #<POSTGRESQL-DATABASE localhost/examp/postgres OPEN {10045D0443}>
with expression "SELECT currval ('NIL')":
Error 42P01 / relation "nil" does not exist
LINE 1: SELECT currval ('NIL')
But the object is inserted. And it seems it's possible to insert the same object twice and it will have different id in the database, which is also a problem.
When I insert the object with the foreign key, it doesn't get inserted into the database. I have no idea how I can do that.
I thought perhaps I can insert it manually, just set the slave#master slot in the :before method of the accessor:
I'm not quite sure how to do this with Postgres, but the first thing that I would seek to do is to ask the databaseserver what SQL it actually sees. Since you're dealing with an ORM [i](and an ORM in Lisp!), it can be a bit difficult to see exactly what the ORM is producing. (In general, ORMs can act strangely if you don't yet know what you're doing, since building error-tests into an ORM greatly increases its complexity.)
It sounds like you have set up either the ORM, or the database schema itself, to auto-generate values for primary keys. You can do this, of course. If you want to prevent the insertion of duplicates of a particular set of columns ("tuple" ...), you'll need to define a UNIQUE INDEX on that set of columns.
When inserting into a table having a foreign-key constraint, remember that you cannot insert a record into a child table unless corresponding keys exist in all masters. This is the case no matter what language you're using to produce the queries.
Last edited by sundialsvcs; 04-21-2016 at 08:49 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.