>Dear Friends,
>
>I´m trying to do the follow statemant
>
>Insert Into Programa (Id_Programa, Data) Values ('Id_Programa.NextVal','10/10/2000)
>
>but the VFP shows me a error saying that i can insert NULL in SIC. Programas. Id_Programa.
>
>what is wrong?
>
>Thanks
You have to create an insert trigger to populate the ID_Programa field with the NextVal of your ID_Programa sequence. You can not use NextVal like a value. YOu have to Select ID_Programa from dual into v_ID variable to actually get the value. A trigger example is below. You also have to grant SELECT privilege to your users on any sequence. You should also create a public synonym for any sequence and table.
create or replace trigger PROGRAMA_BEFORE_INSUPDT
BEFORE INSERT OR UPDATE ON SCHEMA.PROGRAMA FOR EACH ROW
DECLARE
v_Id Number;
BEGIN
IF :new.ID_Programa Is Null or :new.ID_Programa < 1 THEN
select ID_Programa.nextval into v_Id from dual;
:new.ID_Programa := v_Id;
END IF;
END;
/
Then all you have to do is issue your SQL without including ID_Programa in the list:
Insert Into Programa (Data) Values ('mydata')
Mark McCasland
Midlothian, TX USA