Trim spaces
Hi,
I am running a query on sqlplus:
select id, name, account, code from dealer;
The output I get is something like:
12,John Wilson ,475443543 ,WER345
I want to get rid of the trailing spaces in the output file. The trim function doesnt seem to do nething, please help!
Thanks.
I tried putting in but the output file still has the trailing spaces.
This is my complete code:
sqlplus -s ark/ark@inventory << EOF
set pagesize 0;
set verify off;
set lines 700;
set linesize 200;
set trimspool on;
set trimout on;
set feedback off;
set termout off;
set space 0;
set colsep ',';
spool result.txt
select id, name, account, code from dealer;
spool off;
EOF
The result which is not so clearly displayed here is:
12,John Wilson ,475443543 ,WER345
Where there r like 20 spaces after Wilson, and 5 after 475443543
Thanks
Similar Messages
-
How to trim spaces from string in BMM layer?
Hi friends,
I need to trim spaces from the string. can you please give me syntax with example.
ThanksHi
I have tried the below option , but it did not work . PS_D_PERSON
PERSON_ID is char type in the data base oracle , and it is defined as varchar on the physical layer .
So the table is loaded with space , i am not able to remove the space using trim both
Thanks
Sridhar.N -
Hello All,
I need to trim space from beginning and end of a string.
For example -
astring = ' hello123 '.
I need to get astring as 'hello123'.
Thanks in advance.
VirenHi Viren,
You can code like this
WRITE ASTRING TO ASTRING NO-GAP.
Hope this will help.
Regards,
Ferry Lianto -
Forms 10gR2 does not trim spaces
Hi,
we are planning to migrate to 10g from 6i. as far as i know forms always trims trailing spaces. so when we are inserting space to a table it inserts null.
but at 10gR2 it does not trims spaces and inserts non-null value.
Am i missing something or is it really changed?
Regards. Engin.I had fogotten about that bug. But it still exists, even in Forms 6i, patch 17 (6.0.8.26.0)
I ran this test:
Declare
v1 varchar2(4);
v2 varchar2(4);
v3 varchar2(4);
Begin
v1 := ' '; -- one space
select nvl(v1,'X'), v1 into v2, v3 from dual;
message
('V2=' || v2 || ', Length(V2) = ' || nvl(Length(v2),0) );
message
('V3=' || v3 || ', Length(V3) = ' || nvl(Length(v3),0) );
End;And I get the following messages:
V2=X, Length(V2) = 1
V3=, Length(V3) = 0Run under SQL Plus, changing Message to DBMS_Output.Put_Line:
V2= , Length(V2) = 1
V3= , Length(V3) = 1I get the correct result, the same as SQL Plus, in Forms 10.1.2.0.2. -
Error While creating a rule for trimming spaces
Hi All,
Please can you tell me the correct syntax for trimming the Spaces from the beginning of the word.
I tried like this but it is giving error as below:
BEGIN RETURN
ltrim($SPACES_TRIM, '');
END
ERROR: The return statement is expected to return a conditional value: found type<VARCHAR>. (COR-10622)
Please do help me its urgent.
Thanks & Regards,
DJHi Deepak,
when you create validation rules they always have to return TRUE or FALSE conditions. (A record can pass or fail your expression.
So your expression above returns a VARCHAR string, as you can read in the User guide, you are replacing leading nothing '' at the beginning of your string $SPACES_TRIM.
You need to understand basic concept for validation rule expressions and use of functions.
There are lots of great product tutorials here on the SCN, that describe scope, features and functionalities of Information Steward, so you got a understanding of what you can do with IS.
NIels -
Flash Builder 4 List controls trimming spaces from XML node values
I'm trying to migrate my Flex 3 application to Flash builder 4. One issue that I have is that one of my datasources returns a list of cities and regions. To get the regions to display in the correct order in Flex 3, a space was added to to their name in the database (ie. "West", "Northwest" are stored in the database as " West" and " Northwest" so that when sorted by the sql query they would appear at the top and gets translated to XML to fill in a list box or combo box in my Flex 3 application. I have functions that take that selected city or region value from the combo box and queries the database for various performance metrics. In migrating to Flash Builder 4, I noticed that the spaces in the region names no longer appear in the combo boxes. When I show the data in a datagrid, the spaces are still there but when populating a combo box or list box, the leading space gets trimmed. This is an issue since if a user selects the value "West", it doesn't find it in the database since it is listed as " West". This wasn't an issue in Flex Buider 3. Is there a work around or parameter that I can set to force the combo box or list box to show the data as-is versus having it trim off the leading spaces for my regions?
Also, a stupid question, in Flex 3, you were able to find the select value of a combo box by using comboBox.text. What is the equivalent in Flash Builder 4? Do I need to do comboBox.selectedItem.Region.toString() now or is there a shortcut to pull the text from the combo box?I think you want this:
private function onLoadPortfolioData(event:ResultEvent):void
var obj:XMLList = event.result.img as XMLList;
if (obj.length > 0)
_imgCollection = new XMLListCollection(obj);
pictureList.dataProvider = _imgCollection;
If this post answers your question or helps, please mark it as such. Thanks!
http://www.stardustsystems.com
Adobe Flex Development and Support Services -
DB adapter - Trim spaces in column
Hi,
We are facing an issue while using DB adapter when retrieving data from a column (VARCHAR2).
Our column contains data like 'XXXX<spaces>XXX<spaces>'. Whenever we retrieve this column using Db adapter (both custom sql and Select option) and we are getting data with spaces trimmed.
For eg- Data is "1234 34456 3444". Db adapter retrieves this as 1234344563444.
We need the data to be retrieved as existing in the column.
Please let us know if anyone has seen this before, any inputs will be appreciated.
Regards,
ARPLHi,
I think it's very unlikely DbAdapter would remove spaces from the middle in a string... There's probably another problem associated...
If confirmed open a SR with Oracle Support.
Cheers,
Vlad -
How to trim spaces in SQL?
Hi there,
I have installed Oracle XE on my machine and have populated it with some data. In one table,namely the Id column i noted there are spaces before the actual code. For example _ _ _12345. My question is, how do i removed these spaces? I am using Oracle SQL Developer to query the tables in XE. I have over 100,000 records.
Thanks for the help
SIhttp://download.oracle.com/docs/cd/E11882_01/server.112/e10592/functions002.htm#CJAEEJFC
Refer to the TRIM, LTRIM and RTRIM functions and issue an appropiate UPDATE statement
Sybrand Bakker
Senior Oracle DBA -
Hello Experts;
I have a table similar to this below
create table tbl_one
ID varchar(1000),
date_required date,
);Users tend to supply me with insert statement such as this below
insert into tbl_one values (' This boy ', sysdate);
insert into tbl_one values (' This child ', sysdate);
insert into tbl_one values (' This person ', sysdate);is there a way, I can add a functionality to my table that will automatically strip the leading and lagging space before it saves in the table.... All help is appreciated. Thank you'automatically' would indicate that you want a trigger.
Something along the lines of (untested)...
create trigger trg_tbl_one_i
before insert on tbl_one
for each row
begin
:new.id = trim(:new.id);
end; -
Urgent !!! How to trim spaces of an email filed ?
Hi,
I have an email field in a form ,which have a validation at the time of submission of form as shown in the below .
function isEmailValid(fld){
var result = true;
if(fld != null){
var r = new RegExp();
r.compile("^[a-z0-9_\\-\\.\\']+\\@[a-z0-9_\\-\\.]+\\.[a-z]{2,4}$","i");
result = r.test(fld.rawValue);
return result;
but if user by mistakely enters the space in that field at the time of validation it is showing an error called "Invalid Email Format"
I need to trim those spaces either modifying the above regular expression or the best way
Please suggest ..
Thanks in Advance
BharathiIn the exit event of your email field put:
this.rawValue = this.rawValue.replace(/\s/g,"");
Kyle -
Trigger or sql statments to trim spaces??
Dears,
I am receiving some data in some kind of stagging tables with some columns having extra spaces ... so is it faster and / or better to create a trigger on those tables to trim those spaces before insert or shall i trim when retrieving data from those tables?? note that this data will not be retrieved more than two times as its part of migration process.
Thanks in advance,
Swaid McKeyHow did you perform the import? imp <username>/<password>@<ORACLE_SID> fromuser=<srcusername> touser=<destusername> file=<dumpfilename> tables='<tablename>' log=<logfilename> BUFFER=2048000 RECORDLENGTH=64000
Where did the source dump file come from? if i got u right from informix dynamic server (src) to oracle 9i (intermediate) then to oracle 9i (stagging)
How did you "processing and moving data to final destination"? with pl/sql procedures selecting from stagging inserting into dist with updates in the middle.
How did you "updating the the table by trimming the> column"? update emp
set name=rtrim(name);
How many tables are we talking about? 13 table
How many columns need to be trimmed? 1 to 2 columns per table
How many rows are there? as i said before 11million
How did you take these timings?using shell script, i record the time before & after.
How did you write hte migration?cursor --> open --> loop --> fetch --> inserts --> updates --> end loop
Why are you going via a dump file to do the migration?because of the agreement with the other party
Why are you using staging tables? Are you performing other transforms on the staging tables?i only query from them but i do transform the data before inserting in the destination
Where are the spaces? leading or trailing? or both?trailing
what are the data types?VARCHAR2 (20)
Are there object types involved?no
Do the target tables already have triggers on them for other reasons?no -
Showing Text file as external table without trimming spaces
Hi all:
I am trying to display a text file from db sever with original spacing.
Well it's not entirely related to APEX.
This is how external table is created:
create table u_x
(rowline varchar2(255))
ORGANIZATION EXTERNAL
TYPE ORACLE_LOADER
DEFAULT DIRECTORY ext_tab <-- this is a dir i have created
access parameters
records delimited by newline
fields notrim
LOCATION ('aaa.txt')
REJECT LIMIT UNLIMITED;
on the first line of the aaa.text (its a report), it shows something like:
Sat Dec 29 Page 1
but when I do select * from u_x , the result shows:
Sat Dec 29 Page 1
all above is done in sql workshop /sql command in APEX 4.2.1 (db 10.2.0.5)
Is there any way to preserve the spaces between "29" and "Page"?
(the result compressed all spaces in-between to 1 space).
I think the ideal way is to invoke client's notepad to open the server's text file.
anyway to generate the link?
Thanks
JohnWell, I have tried to download the file using below procedure.
create or replace PROCEDURE download_bfile (
directory_in IN VARCHAR2,
file_in IN VARCHAR2
AS
lob_loc BFILE;
v_mime VARCHAR2 (48);
v_length NUMBER(16);
BEGIN
lob_loc := BFILENAME (UPPER (directory_in), file_in);
v_length := DBMS_LOB.getlength (lob_loc);
-- set up HTTP header
-- use an NVL around the mime type and
-- if it is a null set it to application/octect
-- application/octect may launch a download window from windows
OWA_UTIL.mime_header (nvl(v_mime, 'application/octet'), FALSE);
-- set the size so the browser knows how much to download
HTP.p ('Content-length: ' || v_length);
-- the filename will be used by the browser if the users does a save as
HTP.p ( 'Content-Disposition:attachment; filename="'
|| SUBSTR (file_in, INSTR (file_in, '/') + 1)
|| '";'
-- close the headers
OWA_UTIL.http_header_close;
-- download the BLOB
WPG_DOCLOAD.download_file (lob_loc);
apex_application.stop_apex_engine;
END download_bfile;
I run it inside sql command in apex, but it does not show a pop window to save the file,
it displays the whole text content of the file in the result window.
Any idea why the save-as window does not pop up?
thanks,
John. -
Need to trim space from time field
I've got a text box in my report where I am dropping in two times: start time and end time.
{EarlyShiftStart}-{LateShiftEnd}
My problem is if the late shift end is a time less than 10, it adds an extra space between the "-" and the start time.
So instead of:
8:00 AM-3:00PM
it is 8:00 AM- 3:00 PM.
Is there a way to have this extra or padded space removed?
Thanks,Hi,
What is the data type of your database fields for times?
If those are of type datetime, then you can use cStr(<your database field>, "hh:mm tt"), which will give you the time part as required by you and can try something like this:
cStr(<your database field for early shift time>, "hh:mm tt") & '-' & cStr(<your database field late shift time>, "hh:mm tt")
Thanks,
Raghavendra -
Trim spaces in metadata upon entry
Lightroom accepts leading or trailing spaces (or all spaces) in string metadata, which makes for some very strange behavior sometimes, since:
'San Francisco '
is not the same as
'San Francisco'
in the City (& Sublocation) fields anyway - I haven't checked all of them.
according to Lightroom, but looks the same to the user (apostrophes are not there in the metadata, they are included in this post just so you can see where the space is...
The leading spaces are easier to catch, but still.
RobLightroom accepts leading or trailing spaces (or all spaces) in string metadata, which makes for some very strange behavior sometimes, since:
'San Francisco '
is not the same as
'San Francisco'
in the City (& Sublocation) fields anyway - I haven't checked all of them.
according to Lightroom, but looks the same to the user (apostrophes are not there in the metadata, they are included in this post just so you can see where the space is...
The leading spaces are easier to catch, but still.
Rob -
Adding buildtime task for trim spaces
Hi,
how can I add buildtime task for removing whitespaces in AquaLogic 6.0? I know that I can set runtime param
<param-name>trimSpaces</param-name>
but it is not enough for me and impact on performance is unknown.
thanks in advance
bogo123Hi.
Yes you can. Build a Task Flow consuming Spaces API (WebService or REST) and setting custom properties to it.
Steps that you have to follow is:
- Use API to create your group Space:
//create the Space
GroupSpaceWSMetadata gsMetadata =
client.createGroupSpace("Databases", "Databases" "A community for people interested in databases", "databases, oracle", "CommunityofInterest");
//print the Space GUID to provide confirmation of creation
System.out.println("GUID: " + gsMetadata.getGuid());- You can add programmatically custom attributes:
//create the custom attribute
client.setCustomAttribute("Databases", "Vendors", "List of vendors", "java.lang.String", "Oracle, IBM");Code is from WebCenter Spaces API off doc: http://docs.oracle.com/cd/E25178_01/webcenter.1111/e10148/jpsdg_spaces.htm#CIHIJBIG
Regards.
Maybe you are looking for
-
Step 6 says this in the restore section "If you see an image of a wall power plug, connect your iPod to the AC adapter that came with it and plug it into a wall outlet and wait for the restore to complete." I was curious if it was okay to use the car
-
ITunes store has script problems
when i go to the itunes store after opening iTunes, the descriptions below the album icons is in code or script instead of english. Some of the other info on the iTunes store homepage is also in code or script. I reinstalled iTunes but it did not fix
-
How to call this out by clicking button from other file??
The following coding is easy and workable...!! i wonder how do i call this out by clicking button from other file... please help!! import java.awt.geom.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.print.
-
Can any body send me a working web application that has custom components using JSF 1.2, Facelets and Tomcat !
-
Machines ethernet-linked, one on wireless, can't see each other
Hi everyone, Quick question... I have my Macbook Pro connected to a wireless network, and it is connected via ethernet cable to a G5. I can see the G5 in the Finder menu, and as long as I am disconnected from the wireless network I can also do things