Home » SQL & PL/SQL » SQL & PL/SQL » sql question
sql question [message #37872] Mon, 04 March 2002 13:21 Go to next message
Lance Pris
Messages: 40
Registered: January 2002
Member
I am using the following Statment and want to limit the lenght of the "Title" Field on the Insert.

INSERT INTO PRIMUS_TEMP_DUMP (solution_id,Title
SELECT pc_solution_id, pc_title FROM pt_solution)

Does anyone know how to do this?
Re: sql question [message #37873 is a reply to message #37872] Mon, 04 March 2002 13:30 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Altering the actual insert statement (by adding substr) would be one approach:

INSERT INTO PRIMUS_TEMP_DUMP (solution_id, title)
  SELECT pc_solution_id, substr(pc_title, 1, 30) FROM pt_solution;


Another would be a trigger (which would apply to all DML statements against the table):

create or replace trigger trg_name
before insert or update to primus_temp_dump
for each row
begin
  :new.title := substr(:new.title, 1, 30);
end;
/
Re: sql question [message #37901 is a reply to message #37872] Tue, 05 March 2002 10:25 Go to previous message
Raj
Messages: 411
Registered: November 1998
Senior Member
INSERT INTO PRIMUS_TEMP_DUMP (solution_id,Title) as
SELECT pc_solution_id, pc_title FROM pt_solution
Previous Topic: How to see other account's table structure in JDBC
Next Topic: bulk collect inside a cursor
Goto Forum:
  


Current Time: Wed Apr 24 17:46:35 CDT 2024