database - Upper case before insert a row -


I need to put all my data in uppercase. I am using an Oracle database, and I wrote a trigger Which could work. The problem is that I do not know: new overrides can be done.

This is my code.

  Change or change the trigger my_trigger at the first or my_TABLE on each row for the removal cursor field Select from COLUMN_NAME user_tab_columns WHERE table_name = 'MY_TABLE'; Area user_tab_columns% ROWTYPE; LOOP DECLARE theField VARCHAR2 (100) for field in field field: = field.COLUMN_NAME; Newest NVARCHAR2 (1000): =: New. "MY_FIELD"; BEGIN: NEW. "MY_FIELD": = UPPER (nValor); End; End loop; End; /   

This field works with "MY_FIELD", but I need to use "variable" instead. I think that all the fields in the table are changed You can.

I hope someone can help me or recommend me another way of doing this.

Thank you. /p>

The way you want your code to work, it is completely disabled for each modified row Imagine, Oracle must loop through all the columns in the table!

Write triggers in the normal way, such as the following

 : NEW.FIRST_NAME = UPPER (: NEW.FIRST_NAME); : NEW.LAST_NAME = UPPER (: NEW.LAST_NAME);   

Now, you have to face the challenge of writing all these tables. For this, I recommend writing the PL / SQL code which prepares the code for you, you name the table, and the code generates the trigger code for you. This may be something like this:

  FOR C IN (UTI_TAB as SELECT COLUMN_NAME table_name = 'MY_TABLE' from CNAME as clock_dbMS_OUTPUT.PUT_LINE (': NEW.' || CNAME || ': = UPPER (: new.' || CNAME || ')'); End loop;   

If you have too many columns and tables, then the DBMS_OUT buffer may be complete. I would like to include the code in the temporary table.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -