1

You know how we could use:

dateStamp DATE DEFAULT sysdate

to assign a default value to a column in table_x. What if I want to assign a default function? Can I do that?

The function will have some values from "table_params" to run some formula including a column named : "base" in table_x.

I could possibly write a cursor to loop through and run an update statement, but I was just curious if this is possible. thanks in advance.

2 Answers 2

3

From Oracle documentation:

Restriction on Default Column Values
A DEFAULT expression cannot contain references to PL/SQL functions or to other columns, the pseudocolumns CURRVAL, NEXTVAL, LEVEL, PRIOR, and ROWNUM, or date constants that are not fully specified.

Either use a trigger (as was already mentioned) or run an UPDATE statement after your INSERT statement(s) (shouldn't be a problem if you keep your DML in PL/SQL).

Sign up to request clarification or add additional context in comments.

Comments

2

You can write an INSERT trigger for the table that calls the function you want.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.