|
-
well, to do it in an update statement you would need to write a function to strip out the PO's. are all the numbers 4 digits? if that's the case then your work will be pretty easy, something like
<font face="courier">
create or replace procedure remove_po (
field in varchar2,
)
return varchar2
as
begin
return substr(field, -4);
end;
</font>
then you would update the database with
<font face="courier">
update table set ponumber = remove_po(po_number);
</font>
on the other hand, if your numbers are not always 4, then you can't rely on that type of procedure, you would need some extra logic, i think this would work
if there is a space
return all of string past the space;
else if there is an 'o' (upper or lower)
return all of the string past the 'o'.
that would translate into something like
<font face="courier">
create or replace procedure remove_po (
field in varchar2
) return varchar2
as
i number;
begin
i := instr(field, ' ');
if (i is not null) then -- i think null is returned when not there, double check
return substr(field, i+1);
else
i := instr(lower(field), 'o');
if (i is not null) then
return substr(field, i+1);
else
return field;
end if;
end if;
end;
</font>
that could be cleaned up and optimized a bit but if you just want a quick fix that should work, but note that i did that off the top of my head so obviously run it on a test table first to make sure (after you get it to compile, and understand what it's doing).
if there is no space, or no 'o', then that procedure will just return the original value. if there are/can be different variations of the fields (eg, more than one space between the PO and the number, trailing whitespace, etc, you will have to modify it to fit your rules)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|