473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help needed with String Operation

Hi,

I am using the below query to get Agent SHort NAme in the format
LastName Suffix-FirstName MiddleInitial

select RPAD(UPPER(DECODE(NVL(LENGTH(name_aka_lst_name),0) , 0, NULL, name_aka_lst_name) ||
DECODE(NVL(LENGTH(frst_name),0), 0, name_sffx,
DECODE(NVL(LENGTH(name_sffx),0), 0, ' ' || frst_name,' ' || name_sffx || '-'||frst_name)) ||
DECODE(NVL(LENGTH(mddl_name),0), 0, NULL, ' ' || mddl_name)),35) agnt_shrt_nm
from d where
tx_id = '123'


Now my problem is if the length of the field Agnt_Shrt_NM is greater than 35, I should trim the frst_name such that the length is restricted to 35.

Pls help me to find out how I can do this.
Jun 6 '07 #1
2 1981
debasisdas
8,127 Expert 4TB
Hi
shalinirk
Welcome to TSDN.

You have reached the right place for knowledge shairing.

Here you will find a vast resource of related topics and code.

Feel free to post more doubts/questions in the forum.

But before that give a try from your side and if possible try to post what/how you have approached to solve the problem.
It will help Experts in the forum in solving/underestanding your problem in a better way.

CAN YOU POST YOUT TABLE STRUCTURE PLEASE .
Jun 6 '07 #2
Hi Debasis,

I tried a lot. But it didn't materialize.

Please find the structure of the table

Name Null? Type
------------------------------- -------- ----
DRCTRY_ID NOT NULL NUMBER
NAME_PRFX VARCHAR2(4)
FRST_NAME VARCHAR2(30)
MDDL_NAME VARCHAR2(30)
MI VARCHAR2(1)
NAME_AKA_LST_NAME NOT NULL VARCHAR2(60)
NAME_SFFX VARCHAR2(10)
TX_ID VARCHAR2(9)

I want output in the format LastName Suffix-FirstName MiddleInitial.
And whenever the combination goes beyond 35 characters I want to trim the First Name instead of trimming from the end.

Using the below query I am able to get data in the format LastName Suffix-FirstName MiddleInitial. But am not able to include the trim function.
SQL> select drctry_id, RPAD(UPPER(DECODE(NVL(LENGTH(name_aka_lst_name),0) , 0, NULL, name_aka_lst_name) ||
2 DECODE(NVL(LENGTH(frst_name),0), 0, DECODE(NVL(LENGTH(name_sffx),0),0,NULL,' '||NAME_SFFX),
3 DECODE(NVL(LENGTH(name_sffx),0), 0,DECODE(NVL(LENGTH(frst_name),0),0,NULL,' '||FRST_NAME),
4 ' '||name_sffx || '-'||frst_name)) ||
5 DECODE(NVL(LENGTH(mddl_name),0), 0, NULL, ' '||substr(mddl_name,1,1))),35) agnt_shrt_nm
6 from d where
7 tx_id = '1232' ;

Thanks n Regards,
Shalini R K
Jun 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Durairaj Avasi | last post by:
#!/usr/bin/perl -w use Net::LDAP; use Net::LDAP::Util qw(ldap_error_name ldap_error_text); my $ldap = Net::LDAP->new('xy.webdurai.net', port=> 389) or die "$@"; $ldap->debug(15); my @args = (...
19
by: What-a-Tool | last post by:
I have a school project (ASP) in which I have to call three different ASP pages from three different and identical (except for the form "action", obviously) HTM pages. This I have no problem with....
7
by: William Gill | last post by:
I have been trying to pass parameters as indicated in the api. when I use: sql= 'select * from %s where cusid = %s ' % name,recID) Cursor.execute(sql) it works fine, but when I try : sql=...
12
by: LongBow | last post by:
Hello all, From doing a google serach in the newsgroups I found out that a string can't be returned from a function, but using a char* I should be able to do it. I have spent most of the day...
4
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working,...
3
by: DM | last post by:
newbie trying to set up a Database and keep getting the same result. ERROR An error occured while retrieving the information from the database: Unable to cast COM object of type...
15
by: DavidS | last post by:
Have Visual Studio.NET installed on MS 2000 Professional OS laptop. No issue ever with web development and SQL connections. Purchased new laptop with XP Professional SP2!!!!!!!! & Visual...
0
by: jennifer.perkins | last post by:
I've seen a couple posts by people having similar problems, but the suggested solutions I've tried so far haven't worked. I'm using a SOAP client in VB.Net (constructed by wsdl.exe) and the...
2
by: ali.sobh | last post by:
Hi, i am new in c++ and i need some help with a program i need to do a universal unit converter. this calculator can only do : +, *, /, and -. it should read a string (the equation) and ask you...
3
by: Rymfax | last post by:
I was hoping someone could help me get SetupInstallFromInfSection working properly. I'm trying to start in install section in a driver INF (hal.inf specifically). I'm doing this in C#, but I also...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.