Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I have over 900 records in a database table which one of the fields for example called TM_LOC which contains location path and the item that is on the location.

So normally the location would look like this

D:\CHANNEL_FIVE\BROADCAST\COMPLETED

Then when at items has been put into the location the system that we using normally would store the location against that item for example:

D:\CHANNEL_FIVE\BROADCAST\COMPLETED\EHD0152368

So the EHD0152368 is the name of the file that is on the location.

However, its not coming out as D:\CHANNEL_FIVE\BROADCAST\COMPLETEDEHD0152368 removing the \ between the path location and the item itself.

In PLSQL i want to write an SQL to be able to update all the data that has got this location and that has no \ between the location and the path.

I hope someone could help me out with the sql i m very new to this, so any help would be much appreciated.

Let me know if you need more information
Thanks
Posted
Comments
phil.o 30-Apr-14 5:12am    
Could you share the piece of code responsible for the construct of the location?
Geofferz 30-Apr-14 5:22am    
Hi, the only code I have is the code creating the table in the database. I think rest is done through the application which has been written by someone else. So the information is entered from a thick client system UI and then it just gets stored into the database table.

I have no access to the code creating the records unfortunately.

So basically I just wanted pointers for example, select * from devices where TM_LOC is...and then an update TM_LOC to ....

if that makes sense?
phil.o 30-Apr-14 5:24am    
Ok, I see :)

1 solution

Try:
SQL
UPDATE MyTable SET TM_LOC=SUBSTRING(TM_LOC, 0, 36) + '\' + SUBSTRING(TM_LOC, 36, 10000)
WHERE TM_LOC NOT LIKE 'D:\CHANNEL_FIVE\BROADCAST\COMPLETED\%'
 
Share this answer
 
Comments
Geofferz 30-Apr-14 7:01am    
I have the following sql that i want to try and run to return all the items on the following location but doesnt seem to bring back anything. Is the sql correct:

select t.*, t.rowid from tm_mis t where M_CTNR_LOC = '|J:\WIP\ITV\ITV_COMP\COMPLETED\%|'
OriginalGriff 30-Apr-14 8:50am    
No: '%' is only a wildcard character in LIKE clauses - it's just another character in EQUALS expressions.
Geofferz 30-Apr-14 12:37pm    
Still removing the % does not bring back anything when i run the sql
OriginalGriff 30-Apr-14 13:58pm    
:sigh:
No, it won't. Because without a wildcard it amounts to
WHERE 'D:\CHANNEL_FIVE\BROADCAST\COMPLETED\'='D:\CHANNEL_FIVE\BROADCAST\COMPLETED\EHD0152368'
Which is always false.
Use the LIKE clause...with the percent.
Geofferz 2-May-14 7:47am    
Awesome thanks OriginalGriff that worked using the like clause

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900