Jump to content

icergb

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by icergb

  1. Well thats the first positive lead Iv'e had in days. Thanks I will give it a go when I have more time. After many hours of searching I was ready to give up. Actually I did. I have no more time to waste. I succeed to the claim that it may as well not be done. actually I think if you search google for "primary key prevent updated" my posts will come up as number 1. CREATE TABLE u_account ( p_id serial primary key, unique_id varchar(255), name varchar(255), rank varchar(255), score int4 ); CREATE TABLE g_ss ( g_id varchar(255) NOT NULL UNIQUE, b_bs int4, u_accountp_id int4 REFERENCES u_account(p_id) );
  2. Here is a comparison of the table that worked and the table that doesn't work properly; Old TABLE Table "public.u_account" Column | Type | Modifiers -----------+------------------------+------------------------------------------------------------------ jid | integer | not null default nextval('u_account_jid_seq'::regclass) unique_id | character varying(255) | name | character varying(255) | rank | character varying(255) | score | integer | Indexes: "u_account_pkey" PRIMARY KEY, btree (jid) NEW TABLE Table "public.u_account" Column | Type | Modifiers -----------+------------------------+----------- jid | integer | not null unique_id | character varying(255) | name | character varying(255) | rank | character varying(255) | score | integer | Indexes: "u_account_pkey" PRIMARY KEY, btree (jid)
  3. It has something to do with some kind of constraint CREATE TABLE u_account ( Jid integer primary key nextval('u_account_jid_seq'), score int4); CREATE SEQUENCE u_account_jid_seq; SELECT SETVAL('u_account_jid_seq', (SELECT max(jid) FROM u_account)); This is not quite right because I am not really worried about the max value. I can use a foreign key to match any other tables I want to compare it with. I need a "constraint" that will not allow the primary key to be tampered with. this way it will always update itself. I can understand using DEFAULT as an update option for the primary key. but I cannot understand using an arbitrary or random number. If my primary key is on 5 I want it to kick out an error if the number is entered for the primary key is 3990 However, if several people are looking at the database at the same time I understand that the primary key may skip a few numbers that fall into order.
  4. The same could be said for "on delete" or "on update" or cascade or even user permissions. These can all be handled from PHP. Why compare columns at all from postgres when it can be done from PHP? Thats the way it worked. It was made by one of those really expensive postgresql editors that had a limited trial How to handle it from PHP I do understand. Everyone has always told me never do it by text commands always get a gui editor. These 2 guys work for the big boys and don't even know each other. But I am trying to understand why and how it did what it did. Because it did dop that As I said
  5. I guess, but this is the way it was working before. However that still does not help me from accidently placing a random number into the "Jid" column; A primary key should not accept any arbitrary number. I am trying to tighten up the loose ends.
  6. CREATE TABLE u_account (Jid serial primary key,score int4); The primary key works fine (updates itself) ok when I update it like this; INSERT INTO u_account ('score') VALUES ('122233344');However when I insert a value like this; INSERT INTO u_account VALUES ('122233344');This updates the primary key; I don't want the primary key to accept anything other than the number that is supposed to be coming next. Someone had set it up for me before so that if I put in this code; INSERT INTO u_account VALUES ('122233344');it would ignore the primary key and just update score. Please help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.