473,327 Members | 2,094 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,327 software developers and data experts.

PL/SQL - changing one column's value depending another column's value

I have a table which I'm extracting data from with a SELECT statement(and outputing as a text file), there's some changes I want to make to the extracted data before it is output (not the actual data on the table).

There's column1 and column2.
column1 has some null values. I want these values to be a certain value 'NB' if they are null AND if column2 is null as well! If there is a value in column2, then these can stay null. And if column1 already has a value (is not null) then I want to display that value..

How can I go about this in PL SQL? Thanks
Jul 5 '07 #1
2 2973
debasisdas
8,127 Expert 4TB
try using the NVL function and do post back with your code that u have tried .
Jul 5 '07 #2
try using the NVL function and do post back with your code that u have tried .
Thanks, sure. I've tried
Expand|Select|Wrap|Line Numbers
  1. nvl (column1||column2, 'NB') column1
Just returns '0' each time, and obviously displays both columns together.. was thinking along those lines

Also tried combining the two values using a DECODE so if both columns are null, show 'NB' for column1 -- but the following code
Expand|Select|Wrap|Line Numbers
  1. DECODE (column1||column2, 0, 'NB', column1) column1
doesn not work.. has the error 'invalid number'


EDIT: Scratch that, the decode with the 0 in quotes seems to work..... now i feel stupid.. thanks
Jul 5 '07 #3

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

Similar topics

3
by: jeffgeorge | last post by:
Working on a report oriented application. One of the columns on a form needs to be red, black or blue depending of the value in that column. Can I write an expression to handle this or does...
3
by: MS | last post by:
What's the best way to "store" and display a value in a text box that changes from day to day. An example of this would be where the name of the user is manually typed in after using the datbase,...
6
by: spmm_pls | last post by:
Hi, Could some1 please tell me what the best way is to adjust the value of a column in my databound datagrid (in ASP.NET) For example my database returns the values 1,2 and 3 in the column...
0
by: Dan Hartshorn | last post by:
VS.NET 2003, C#, Windows Server 2003. I have a datagrid and I want the last column to be either an EditCommandColumn or a template column, depending on a value I have. The value changes for each...
2
by: Renato Cramer | last post by:
Hello All, There is data of several enterprises (ours clients) in a single database. All tables have a column on primary key what identify the enterprise called id_enterprise. My objective is...
2
by: John | last post by:
Hi Everyone, I have a question about dynamically changing the length of a varchar(n) field, in case the value I'm trying to insert is too big and will give a "truncated" error, but before the...
10
by: Enrique Cruiz | last post by:
Hello all, I am currently implementing a fairly simple algorithm. It scans a grayscale image, and computes a pixel's new value as a function of its original value. Two passes are made, first...
4
by: andreas.hei | last post by:
How can I get the value of the last Item in a coums? SELECT COLUMN FROM DATABASE ORDER BY COLUMN DESC? something with Fields(0).value? Thank you in advance
7
oll3i
by: oll3i | last post by:
i want to change the values in two columns one colum is a combobox and the secons column is editable too i want to get the value of that second column and the value of combobox and sent that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.