problems using the replace() function

Hey everybody. :)

I wrote a query that finds the address of a company (5 columns and concatenates into one). These columns are street, city, County, telno and faxno.
Some of the companies have a null value for the County, that is when I write the query that it returns a similar result to... 3 main Street, Manchester, 0384758948, 04857846927, but if there was a County it would be 3 Main Street, Manchester, Greater Manchester, 0384758948, 04857846927.

I tried to write the query then if it is not a County, it removes just the comma and the address becomes 3 Main Street, Manchester, 0384758948, 04857846927... but I can't seem to understand so I thought I'd come and ask the professionals. :)

set linesize 100
column suppname heading "name of the provider.
Select suppname, street | ', ' || City | ', ' || County of | ', ' || Zip code | ', ' || telno | ', ' || faxno "address of supplier.
from suppliers
where the County is null
Replace (County, County, ");

It gives me an error "command not completed successfully", but I can't for the life of understand me why.

Thank you in advance. :)

If the County is optional, you can concatenate the like this:

select suppname, street || ', ' || town || ', ' ||
    nvl2(county, county||', ', null)
           || postcode || ', ' || telno || ', ' || faxno "Supplier Address"

(you can do the same for the other columns if necessary)

Tags: Database

Similar Questions

  • Using the Replace function

    Hi all

    I have a column called supplements and it has values such as

    1. the payment is > 90 days
    2. the payment is < = 10 days

    Now, I want to use the Replace function to replace > and < to "greaterthan".
    and 'lessthan' RESP, but the problem is that, in the function replace, I can give that one argument. So what I do is in the region of fx for the column

    Replace (supplements,' > ',' greaterthan')

    This replaces the > sign very well with string greaterthan and show me values such as

    1. the payment is greaterthan 90 days
    2. the payment is < = 10 days

    but I want to replace < "lessthen" also, how can I do? Can I undergo two replace statements? How can replace several string or special characters for a single column?

    Help, please.

    Thank you
    Ronny

    Try this
    CASE
    WHEN supplements LIKE ' % > %' THEN Replace(latepayment,'>','greaterthan')
    WHEN supplements LIKE ' %<=%' then=""><>
    END

  • Columns of Union two problem using the TO_CLOB function

    Hello

    Let me start by you (a simplified version of) showing the query I'm running:

    SELECT
    l.Person,
    TO_CLOB(l.letter_code ||) "letter has been sent.") Note
    letters l

    UNION

    Select
    n.Person
    n.Note
    n notes

    And here's the table structure

    LETTERS)
    l.Person varchar2 (10);
    l.letter_code varchar2 (2);
    *)*

    NOTES)
    n.Person varchar2 (10);
    CLOB n.note;
    *)*

    Each request runs on its own without any problem but when I union together I get a ' * ORA-00932: inconsistent data types: expected - got CLOB * "error. I can't understand what is the cause. The TO_CLOB in the first query is to convert the varchar2 column in a CLOB then why would he be oppose to be clauses with the second query?

    Any advice would be much appreciated! Thanks :)

    You may not use the set operations, UNIONS, MINUS, INTERSECT with CLOB columns etc. simple as that.

  • Problem using the AVERAGE function

    So, I have the following query:

    Oracle 10g
                    select distinct
                                  avg(sum(plyr.avg_speed)) as tm_speed,
                                  sch.game_code,
                                  sch.home_team_name as team_name,
                                  tm.team_id
                                  
                           from
                                  soccer.soccer_optical_player_gm_stats plyr,
                                  soccer.soccer_optical_team_gm_stats tm,
                                  customer_data.cd_soccer_schedule sch
                           where  sch.season_id = 200921
                           and    tm.team_id = sch.home_team_id
                           and    sch.game_code = plyr.game_code
                           group by
                                  sch.game_code,
                                  sch.home_team_name, 
                                  tm.team_id
    When I try to execute the query I get the following error: not a function single-group grou.

    Some examples of data (and I've adjusted the query slightly to make it work with sample data):
    create table optical_player_gm_stats as (
               select 454654 game_code,32.546 avg_speed from dual union all
               select 887878,31.465 from dual union all
               select 454654,24.488 from dual union all
               select 454654,24.447 from dual union all
               select 887878,18.998 from dual union all
               select 255555,10.001 from dual union all
               select 200081,10.021 from dual
              );
              
    create table optical_team_gm_stats as (
               select 454654 game_code,5555 team_id from dual union all
               select 887878,1122 from dual union all
               select 454654,5555 from dual union all
               select 454654,5555 from dual union all
               select 887878,1122 from dual union all
               select 255555,5555 from dual union all
               select 200081,3144 from dual
              );
              
    create table soc_schedule as (
               select 454654 game_code, 'Cats' home_team, 200921 season_id, 5555 home_team_id from dual union all
               select 887878,'Sharks',200921,1122 from dual union all
               select 200081,'Grizzlies',200921,3144 from dual
              );
         
    --Adjusted query so it works with sample tables above     
      select distinct
                                  avg(sum(plyr.avg_speed)) as team_speed,
                                  sch.game_code,
                                  sch.home_team as team_name,
                                  tm.team_id,
                                  null
                           from
                                  optical_player_gm_stats plyr,
                                  optical_team_gm_stats tm,
                                  soc_schedule sch
                           where  sch.season_id = 200921
                           and    tm.team_id = sch.home_team_id
                           and    sch.game_code = plyr.game_code
                           group by -- plyr.avg_speed,
                                  sch.game_code,
                                  sch.home_team, 
                                  tm.team_id  
              
    Published by: user652714 on May 12, 2009 11:42

    Hello, you should not use SEPARATE functions of aggregation (aggregation will produce the DISTINCT records in which you are going to GROUP BY for aggregation). In addition, AVG (SUM (()) makes no sense: AVG() on its own is what you need - it is never necessary to nest functions of aggregation like that.)

    Therefore, try:

    select  avg(plyr.avg_speed) as tm_speed,
                                  sch.game_code,
                                  sch.home_team_name as team_name,
                                  tm.team_id
                           from
                                  soccer.soccer_optical_player_gm_stats plyr,
                                  soccer.soccer_optical_team_gm_stats tm,
                                  customer_data.cd_soccer_schedule sch
                           where  sch.season_id = 200921
                           and    tm.team_id = sch.home_team_id
                           and    sch.game_code = plyr.game_code
                           group by
                                  sch.game_code,
                                  sch.home_team_name,
                                  tm.team_id;
    
  • Problem using the DECODE function

    I'm trying to decode what follows, but I seem to have a problem of syntax:
    decode
    (
           p.balls,p.strikes,
           1,0 '1-0 Count',
           2,0 '2-0 Count',
           3,0 '3-0 Count',
           0,1 '0-1 Count',
           0,2 '0-2 Count',
           1,1 '1-1 Count',
           2,1 '2-1 Count',
           3,1 '3-1 Count',
           0,2 '0-2 Count',
           1,2 '1-2 Count',
           2,2 '2-2 Count',
    ) as Count,
    what I'm trying to take place is whenever the column of balls a '1' and the column to strike a '0' to decode the number of 1 - 0"etc...

    Hello

    Why use DECODE at all?

    TO_CHAR (p.balls) || ' -' || TO_CHAR (p.strikes) || ' Count'
    

    Assuming that you really need to use DECODE: it only works on a single value.

    You can combine your two values into one:

    DECODE ( (10 * p.balls) + p.strikes
           ,  0, '0-0 Count'
           ,  1, '0-1 Count'
           ,  2, '0-2 Count'
           ,  3, '0-3 Count'
           , 10, '1-0 Count'
    ...
           , 32, '3-2 Count'
           )
    

    or DECODE the two columns separately.

    DECODE ( p.balls
           , 0 '0-'
           , 1 '1-'
           , 2 '2-'
           , 3 '3-'
           )
    ||
    DECODE ( p.strikes
           , 0 '0 Count'
           , 1 '1 Count'
           , 2 '2 Count'
           )
    
  • Do I need to use the NVL function for this request?

    I seem to have some problems using the NVL function on a date. I'm trying to create a query pulls back just a date a file was sent between the sysdate and the date_sent more a minute. Here is the code I use...

    Oracle: 10.2 G
    SELECT date_sent as date_sent
    INTO    iDateSent
    FROM    tableX
    WHERE  file_id= 9999
    AND    date_sent BETWEEN sysdate AND date_sent + 1/1440; 
    Currently Output (null):
    DATE_SENT
    Desired output when date_sent is null:
    DATE_SENT
    0:0:000 0:00:00
    Note:
    date_sent column is in a normal date - same format as sysdate format.

    The problem I encounter is when date_sent is null, the stored procedure, I built crashes because date_sent returns a null and a null value cannot be stored in the variable 'iDateSent '. I was thinking about using the NVL function here to resolve, however, I'm not entirely sure who will work with the above query. Any thoughts?

    Published by: user652714 on July 9, 2010 12:58

    Published by: user652714 on July 9, 2010 13:11

    Hello

    you said: "desired output when date_sent is null: date_sent: 0".
    It is not possible to have a date of 'zero '.

    "and a null value cannot be stored in the variable 'iDateSent'. '.

    I do not think: If this variable is declared normally (without any not null not constrained to this topic) so that it can contain a null value. (it's 99% of the time in PL/SQL).

    I think it's that your SQL retrieves no rows, to manage what you should put an exception handler:

    begin
    SELECT date_sent as date_sent
    INTO    iDateSent
    FROM    tableX
    WHERE  file_id= 9999
    AND    date_sent BETWEEN sysdate AND date_sent + 1/1440;
    exception when NO_DATA_FOUND then
     iDateSent:=null;
    end;
    

    So what you can do if you don't want the date empty a nvl:

    return(nvl(iDateSent,sysdate));  -- or another date ...
    

    Published by: user11268895 on July 9, 2010 22:09

  • Problem in the export using the QUERY functionality

    Problem in the export using the QUERY functionality


    I'm trying to export some rows in a table using the query functionality
    and I have some errors... I'm using the syntax is

    system@orcl QUERY = scott.emp expdp: '"WHERE emp_no = 123455" '
    DIRECTORY = data_pump_dir DUMPFILE = data_pump.dmp
    LOGFILE = data_pump_12345.log INDEX = n

    Can someone tell me please the problem with that statement

    I also tried to use the simple export

    exp file system@orcl = orcl_export.dmp log = orcl_export.log
    tables = Scott.EMP index = QUERY = n------"WHERE emp_no\ = 123455\"

    and this error

    EXP-00008: ORACLE error 904
    ORA-00904: identify invalid

    My os is Solaris
    Please let me know what the problem

    Hello

    Try to create parfile and use that, otherwise, you will need to escape each clause correctly to run exp or expdp successfully.

    test.par

    tables=emp
    query="WHERE emp_no=123455"
    
    or
    tables=myobjects
    query="WHERE owner='SYS'"
    
    $> exp username/password parfile=test.par
    
    Export: Release 10.2.0.1.0 - Production on Thu Mar 19 10:17:48 2009
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining Scoring Engine options
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    
    About to export specified tables via Conventional Path ...
    . . exporting table                      MYOBJECTS      22650 rows exported
    Export terminated successfully without warnings.
    

    Concerning

    Published by: OrionNet on March 19, 2009 10:21

  • alternatives without using the regexp_replace function

    SELECT

    REGEXP_REPLACE (phone_number,

    "([[: digit:]] {3})------." ([[: digit:]] {3}). ([[: digit:]] {4})',

    "\2-\3 (\1)") "REGEXP_REPLACE.

    Employees;

    is there another without using the regexp_replace function...

    Another way

    (eliminating instr... function as your problem focuses on one length fixed)

    WITH t AS (SELECT '112.345.6789' FROM DUAL str).

    TT AS (SELECT REPLACE (str, '.') t str)

    SELECT ' (')

    || SUBSTR (str, 1, 3)

    || ') '

    || SUBSTR (str, 4, 3)

    || '-'

    || SUBSTR (str, 7)

    TT;

    See you soon,.

    Manik.

  • Does anyone have an example VI for using the SendInput function in User32.dll?

    Hi all

    I am creating a VI that creates a click of the mouse.  I looked at the MSDN Web site and found that I need to use the SendInput function in User32.dll.  The problem is that some of the parameters for this function are nested structures.  How to use this function in a call library function node?  Is there already a LabVIEW wrapper for this function?

    Thank you

    MechEman

    I would use rather MouseEvent.  I looked at my VI and it can be cleaned up a bit, but it works for what you want to do.

  • After mac os update and software reinstall now unable to use the scan function

    Hello

    I never thought I had to post on one of them, but it really made me. I have a Macbook and stupidly thought that I would update to the mavericks os 10.9 the other day.

    I continued to be able to print once the update, but it was impossible to use the scan function. So, I removed the printer and the drivers and downloaded the new drivers which would have been compatible with os x 10.9. When I went to reinstall the printer, he couldn't locate it on the list of "available printers" - I connect using wi - fi connection at home.

    The only way I could connect the printer was installed manually by entering the ip address. It was found and I print now, so I don't think there is nothing wrong with the connectivity, but a warning when you do this that says scan function does not work, and of course the scan option is simply not there.

    Thought I have would bypass this using analysis of e-mail on the printer. It seemed to work fine, but when I received the email there was no attachment.

    My husband is now scanning these documents to his computer (a pc) and emailing for me - is not ideal.

    Any ideas on how I can fix this?

    Thank you

    Annie

    Hi Annie,.

    Here is a picture of a printer, USB cable,

    Now that I know what printer we work with, I have another idea. On the front screen of the printer please press the wireless icon. There are 4 icons in the upper part, the wireless is the second from the left. In the Menu arrow until settings wireless advanced. I would like to disable IPV6, arrow down to IPV6, and then select OFF.

    I saw the IPV6 interferes with the Hello Protocol several times, often time turning off this feature will solve the problem and allow the Mac to see the printer on the network. Once IPV6 is disabled try to add the printer again.

    Please let me know if this solves the problem, I am eager to see this solved and you get printing and scanning of your own computer.

  • How to use the add_months() function in a mapping?

    Hello

    I have a variable in ODI with a date and I need to add another variable to add 'x' months...

    How can do that?

    Thank you

    If you say you have variable1 organise a date for example 01/01/2015 and variable 2 holding a certain number of months for example 7?

    If so in your mapping expression simply use the date functions available to your database technology (step/target) and replace the variable in the function

    that is for Oracle your mapping would be ADD_MONTHS (#Variable1,Variable2of #)

  • PS elements 11 cannot use the text function. Error message could not initialize the text.

    When I try to use the text function the letters do not appear. Text feature appears frozen. Get the error message - unable to initialize the text.

    Recently PSE11 uninstalled and reinstalled. Downloaded 2 Google font. Was able to use the text function with Google fonts with no problems. Two days later, attempted to work with the text function and the typed letters appear on the screen/layer. Tried to add the text with fonts pre-installed PS - still once, no text appeared. Impossible to set up a text box. How can I fix it? Thank you

    Suggest that you reset the text tool, that only he can fix.

    I believe in PSEv.11, there is a small arrow, top of the page to the left on the tool options bar. Click on this.

    If the arrow is not there, look in the options bar to the text tool, on the right, for a box with lines inside. Adobe changed the location and icon in later versions of the program.

  • I installed lightroom on a new computer (windows 10) cc. I copied all of my original photos on a hard drive and them imported by adding them on the new computer using the import function. I have a catalog update saved on thehard d

    I installed lightroom on a new computer (windows 10) cc. I copied all of my original photos on a hard drive and them imported by adding them on the new computer using the import function. I have a catalog to date backed on thehard drive and have tried to insert into the new folder to lightroom. Unfortunately none of my changes, collections etc. seem to be present on the new computer. I still work lightroom with any changes on the old computer where all the photos. Help

    He seemed to have solved this problem - the catalogue of the old computer has been saved as a zip file. Once extracted, it could be used as the primary catalog for lightroom on the new computer

  • Problems with the Row_Number function

    I have problems with the Row_Number function. I use to assign line numbers to records where a student has a note of passage on a module and the exclusion of the modules failed (I want to show her a 0 as the line number for the modules failed). The problem is that when I try to use a condition, the report still assigns a line number to a defective module if it does not display it (it shows a 0 I wanted to show him). The results are displayed as follows:

    Line number Module Grade
    1ModuleAPass
    2ModuleBPass
    0ModuleCIn case of failure
    4 (instead of 3)ModuleDPass

    How can I make him jump to assign a line number to all the modules failed? Please help.

    Thank you.

    Thank you very much, Melanie. I made changes to query as per your suggestion, which is a union of the modules failed and passed (using row_number on success modules). Thanks for the solution.

  • to use the NOW() function with operator (such as NOW () - 120) 11.1.1.6.11 or 11.1.1.7.1

    Hi all

    I want to use the function NOW with a different operator in obiee11.1.1.6.11 or 11.1.1.7.1

    but every time I have a creating a filter as

    TRAN_DATE is equal to NOW()-120, we become "an arithmetic operation is being performed on a non-digital type.»

    11.1.16.11 and 11.1.1.7.1

    Hare TRAN_DATE is in RPD datetime data type

    Can someone tell me how to replace the error and make the report run and return the results

    Do now () - 120 is a very simplistic way to look at it because it is highly ambiguous. IE: NOW less 120 "what?" Minutes? Seconds? Years? Petroleum products?

    Accuracy is the key. Now() gives a timestamp (a real timestamp DATA TYPE object!), so I guess you mean days.

    Timestamp data types are changed (projected through time) using the TIMESTAMPADD function, which in your case would by this formula:

    TIMESTAMPADD (SQL_TSI_DAY,-120, NOW()))

Maybe you are looking for

  • Seagate HDD portable (USB 3) not recognized.

    Hi guys. I have a 1 TB & 2 to Seagate drives hard portable running off USB 3.  Until today, I was able to play the discs on all my Apple devices. However, although readers turn upward, they no longer appear in the finder or disk on my Mac Pro utility

  • WIndows Server 2008 R2 the number of activations?

    I was wondering how many times he can be reinstalled and that active?I got it on the DreamSpark site. I hear her 5 times for Win 7 and 10 for the servers, but I don't know if it of true or not. 2nd question: If I miss how should I do? I see that you

  • error generating a source distribution

    I get the following error when generating a source distribution in LabView 8.6: Error 1 has occurred to AB_Destination.lvclass:Copy_File.vi-> AB_Source.lvclass:Copy_SourceItem.vi-> AB_Build.lvclass:Copy_Files.vi-> AB_Build.lvclass:Build.vi-> AB_Build

  • Problem with Voddler: the video only in green tones.

    Hello I have problems with Voddler (Beta), a movie streaming program: movies play in green and white tones only.  I have a Sony VAIO VGN-250E with an Intel 945GM video card Express Chipset Family running Vista Home Premium 32-bit.First of all, Voddle

  • Freshly installed windows 7 + No. drivers HP Pavilion dv6

    Hi, I have fresh installed windows due to my computer laptop beinng slower then nothing and now I know that there no drivers and I can't find them anywhere is possible can someone link me to a pack of driver install files that will give me all my dri