从右修剪空白 [英] Trim whitespace from right

查看:71
本文介绍了从右修剪空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用firebird数据库,但我的问题是我所有的数据都在'right'上以空格存储.当我查询一些信息以在其他程序(AutoIt)中使用它时,我陷入了空白.

I am working with a firebird database and my problem is that all my data is stored with whitespace on the 'right'. When I query some information to use it in a different program (AutoIt) I am stuck with the whitespace.

UPDATE tableName SET columnName = TRIM( columnName )
UPDATE DETECTION SET DNAME =  right(TRIM  (DNAME));

我已经尝试过这种方法,但是不幸的是,它没有用.

I have tried such things but it is useless, unfortunately.

我正在尝试更新整个数据库,因为所有的修整对我来说都是无用的!

I am trying to update my whole database because all the trim right is useless for me!

----------------------------更新--------
我仍然有问题

----------------------------UPDATE--------
I am still having problems

它不起作用,也许我只是愚蠢地正确执行了

It does not work, maybe I am just stupid with also executing it proper

SELECT a.DNAME, a.DTYPE, a.WINNAME, a.AREA, a.COLOR, a.MOUSE
FROM DETECTION a -- this is my table

当我尝试时;

UPDATE DETECTION SET DNAME = trim( DNAME)

Executing...
Done.
287 fetches, 56 marks, 0 reads, 0 writes.
0 inserts, 28 updates, 0 deletes, 0 index, 28 seq.
Delta memory: 8648 bytes.
DETECTION: 28 updates. 
28 rows affected directly.
Total execution time: 0.021s
Script execution finished.
Commiting transaction...
Done.
Starting transaction...
Preparing query: UPDATE DETECTION SET DNAME = trim( DNAME)
Prepare time: 0.022s
PLAN (DETECTION NATURAL)

当我尝试

UPDATE DETECTION SET DNAME = trim(tailing from DNAME) 

我遇到以下错误

Error: *** IBPP::SQLException ***
Context: Statement::Prepare( UPDATE DETECTION SET DNAME = trim(tailing from DNAME)  )
Message: isc_dsql_prepare failed

SQL Message : -206
Column does not belong to referenced table

Engine Code    : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -206
Column unknown
TAILING
At line 1, column 43

即使第一个执行正确也不会执行任何操作,但我的查询仍然针对末尾的空格.

even when the first one executes proper it does nothing, my queries are still for with white-space trail at the end.

推荐答案

第一个数据类型应为varchar.其次,您应该检查是否还有尾随空格.通常修剪掉就可以了.领取一个您知道其内容的字段.假设玛丽,ID = 100.执行以下操作:从表中选择char_lenght(yourfield),其中id = 100比较:从表中选择char_lenght(trim(yourfield)),其中id = 100.我相信您实际上没有空格.

First datatype should be varchar. Secondly you should check if you still have trailing white spaces. Usually trim removes it ok. Pick-up a field you know the content. Lets say Mary, ID = 100. Do the following: select char_lenght(yourfield) from your table where id = 100 Compare with: select char_lenght(trim(yourfield)) from your table where id = 100. I trust you do not have white spaces in fact.

这篇关于从右修剪空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆