Problem with Union

Hello

I have a request below which I need the merger of two of them to get the result in a single query result, here's the query
but the error me do is ORA-12704: incompatibility of character set, please let me know wat is the error in the query below

Select rpad ('Roster_num', 20, "") 'Roster_num '.
of the double

UNION ALL

SELECT
SEPARATE
RPAD (AP. EMPLOYEE_CODE, 20, "") 'Roster_num '.

AR_EMPLOYEE_PERSONAL AP,
AR_ADDRESS AA,
AR_V_ROSTER_EMPLOYEE_DEF AD,
AR_STATE_PROV_REGION ASP,
AR_DEFINITION_TERRITORY ADT

WHERE
BDM PROJECT = 81 AND
BPM EMPLOYEE_ID = AA. EMPLOYE_ID AND
BPM EMPLOYEE_ID = AD. EMPLOYEE_ID (+) AND
BAM STATE_PROV_REG_ID = ASP STATE_PROV_REG_ID AND
BDM DEFINITION_TERRITORY_ID = ADT. DEFINITION_TERRITORY_ID (+)



Thank you
Sudhir

Explanation with some examples:

SQL>desc t_test;
Name                           Null     Type
------------------------------ -------- -----------------
COL1                                    NUMBER
COL2                                    NUMBER
COL3                                    NUMBER
COL4                                    NCHAR(30)   

We see that COL4 in the table is of type NCHAR.

SQL>select * from t_test;
COL1                   COL2                   COL3                   COL4
---------------------- ---------------------- ---------------------- ------------------------------
1                      123                    3                      Roster
2                      3                      4                      RKött
3                      4                      2
9                      10                     12
11                     23                     43                                                    

SQL>select rpad('Roster_num',20,' ') "Roster_num"
from dual
union all
select RPAD(col4,20,' ')  "Roster_num" from t_test;

Error starting at line 7 in command:
select rpad('Roster_num',20,' ') "Roster_num"
from dual
union all
select RPAD(col4,20,' ')  "Roster_num" from t_test
Error at Command Line:7 Column:7
Error report:
SQL Error: ORA-12704: character set mismatch
12704. 00000 -  "character set mismatch"
*Cause:    One of the following
           - The string operands(other than an nlsparams argument) to an
           operator or built-in function do not have the same character
           set.
           - An nlsparams operand is not in the database character set.
           - String data with character set other than the database character
           set is passed to a built-in function not expecting it.
           - The second argument to CHR() or CSCONVERT() is not CHAR_CS or
           NCHAR_CS.
           - A string expression in the VALUES clause of an INSERT statement,
           or the SET clause of an UPDATE statement, does not have the
           same character set as the column into which the value would
           be inserted.
           - A value provided in a DEFAULT clause when creating a table does
           not have the same character set as declared for the column.
           - An argument to a PL/SQL function does not conform to the
           character set requirements of the corresponding parameter.
*Action:

Error returned for incompatibility of character as data types are not compatible.

SQL>select rpad('Roster_num',20,' ') "Roster_num"
from dual
union all
select TO_CHAR(RPAD(col4,20,' '))  "Roster_num" from t_test;

Roster_num
------------------------------------------
Roster_num
Roster
RKött                                                                                                                                                                                                    

6 rows selected
SQL>

After the converted to the TO_CHAR problem solved

Tags: Database

Similar Questions

  • Problem with Union All

    Hello Experts,

    I'm still on the learning curve in PL/SQL and I have 2 different. I need to create a view that will merge these 2 tables.
    create view eft_view as
    select 
      BILL_TO_RETAILER      ,
      RETAILER_NAME         ,
      NAME_ON_BANK_ACCOUNT  ,
      BANK_ABA              ,
      BANK_ACCT             ,
      ON_LINE_AMOUNT        ,
      INSTANT_AMOUNT        ,
      TOTAL_AMOUNT          ,
      SOURCE                ,
      INSERTED_DATE         ,
      CDC                   from weekly_eft_temp union all
    select 
      BILL_TO_RETAILER  ,
      RETAILER_NAME     ,
      STATUS            ,
      ON_LINE_AMOUNT    ,
      INSTANT_AMOUNT    ,
      NON_SWEPT_AMT     ,
      TTYPE             ,
      EXCEPTION_REASON   from weekly_bill_expt_temp;
    I used the union of all, but it doesn't seem to work. I don't know where it's track. I searched on the net but his send me examples for 2 tables tat are similar.

    Any suggestions please

    You must replicate the columns that do not exist fill them with NULL values.

    Perhaps;

    create view eft_view as
      select bill_to_retailer,
             retailer_name,
             name_on_bank_account,
             bank_aba,
             bank_acct,
             null status,
             on_line_amount,
             instant_amount,
             total_amount,
             source,
             inserted_date,
             cdc,
             cast (null as number) non_swept_amt,
             null ttype,
             null exception_reason
        from weekly_eft_temp
      union all
      select bill_to_retailer,
             retailer_name,
             null name_on_bank_account,
             null bank_aba,
             null bank_acct,
             status,
             on_line_amount,
             instant_amount,
             null total_amount,
             null source,
             null inserted_date,
             nul cdc,
             non_swept_amt,
             ttype,
             exception_reason
        from weekly_bill_expt_temp;
    
  • I can't see a message from my Union because of problems with the address changed for pop-upwindows and some other issues

    Hello
    I am from Sweden and I have problems with a Web site that has my Union. I could see messages from them before, but they changed their address and on the site, they say people that they must put the new address on the approved list of the pop-up windows. I did but it still does not. Maybe I did wrong, I don't know, but it's annoying as hell that I can't see the messages they send.

    I really need help with that.

    Best regards
    Lena

    You can control and manage permissions for all areas on the Subject: authorizations page.

    You can delete all data stored in Firefox with a specific area through "Forget this Site" from the context menu of the history entry (see the history or the history sidebar) or via the subject: permissions page.

    Using "Forget this Site" will delete all data stored in Firefox in this area as bookmarks, cookies, words of past, cache, history, and exceptions, so be careful and if you have a password or other data from this area you don't want to lose so take note of these passwords and bookmarks.
    You can't recover from which "forget" unless you have a backup of the affected files.

    It has no lasting effect, so if come back you on such a 'forgotten' site, then the data of this Web site will be saved once more.

  • Problem with Alias and Union of common table expressions

    I have a query that runs in SQL Server, but I have problems with it in PL/SQL.  I keep running into the error message saying "invalid identifier" when I try to refer to PlantNumber or Plant_No or any other part of the CTE or subquery.  Is this not possible with Oracle?

    Here's a shortened version of my request:

    WITH RemoveData AS
       (
       SELECT a . PLANT_NO , a . ALLOC_WHDV_VOL , a . KW_CTR_REDELIVERED_HV , a . MTR_NO , a . MTR_SFX , a . TRNX_ID , a . REC_STATUS_CD ,
    MAX(a. ACCT_DT ) ACCT_DT
    OF GasStmt one
       WHERE a . REC_STATUS_CD = 'RR'
       GROUP BY a. PLANT_NO , a . ALLOC_WHDV_VOL , a . KW_CTR_REDELIVERED_HV , a . MTR_NO , a . MTR_SFX , a . TRNX_ID , a . REC_STATUS_CD
       HAVING COUNT(a. REC_STATUS_CD ) > 2
       ),
    RemoveData2 AS
       (
    SELECT plant_no "PlantNumber"
       , SUM (-a. ALLOC_WHDV_VOL () 'PlantStandardGrossWellheadMcf'
    ,SUM()KW_CTR_REDELIVERED_HV() 'KeepWholeResidueMMBtu'
    OF RemoveData one
       GROUP BY plant_no
       ),
    OriginalData AS
       (
       SELECT a . PLANT_NO "PlantNumber"
       , SUM (a. ALLOC_WHDV_VOL () 'PlantStandardGrossWellheadMcf'
       , SUM (CASE WHEN a. REC_STATUS_CD = 'RR' THEN -a. KW_CTR_REDELIVERED_HV Else a . KW_CTR_REDELIVERED_HV END () 'KeepWholeResidueMMBtu'
    DE GasStmt un
       LEFT OUTER JOIN (SELECT MTR_NO, MTR_SFX, TRNX_ID, REC_STATUS_CD, MAX(ACCT_DT) ACCT_DT
    DE GasStmt
       WHERE REC_STATUS_CD = 'RR'
    GROUP OF MTR_NO MTR_SFX TRNX_ID REC_STATUS_CD
       HAVING COUNT(TRNX_ID) > 1) b
       ON a . MTR_NO = b . MTR_NO
       AND a . TRNX_ID = b . TRNX_ID
       AND a . Rec_Status_Cd = b . REC_STATUS_CD
       AND a . Acct_Dt = b . ACCT_DT
       WHERE a . ACCT_DT > '1/1/2010'
       AND b . MTR_NO IS NULL
       GROUP BY a. PLANT_NO
       ),
    UnionCTE AS (  
    SELECT *
    OF RemoveData2
    UNION
    SELECT *
    OriginalData
    )
    SELECT PlantNumber , SUM()PlantStandardGrossWellheadMcf() AS PlantStandardGrossWellheadMcf SUM()KeepWholeResidueMMBtu() AS KeepWholeResidueMMBtu
    DE UnionCTE
    GROUP BY PlantNumber

    This is the bottom, select from UnionCTE which is the origin of the problem.  Advice would be appreciated!

    Hello

    Lose the double quotes.

    The column names are case-sensitive in Oracle.  Often, you do not notice that, because that all code that is not inside a kind of quotation marks (quotation marks single or double quotation marks) is capitalized before it is compiled.  So, when you say

    SELECT PlantNumber

    or

    SELECT plantnumber

    or even

    SELECT PlaNTNumBeR

    that you are referencing a column called PLANTNUMBER, all uppercase.  In this case, however, the column alias that you gave was

    SELECT plant_no 'PlantNumber.

    with small letters.

    Again, the best solution is not not to use double quotes.  I know that PlantNumber is easier to read than PLANTNUMBER, so use PlantNumber, but not inside double quotes.  If you really need to display the header of column in mixed case, use your front end (for example, COLUMN...) TOPIC command in SQL * more), or else assign an alias of mixed case in double - quotes in the main request only and use the name without quotes around elsewhere.

    .

    I hope that answers your question.

    I can't test my suggestion, of course, because I do not have your tables.  Whenever you have a problem, it helps if you post a test script complete that people who want to help you can run to recreate the problem and test their ideas.  Include CREATE TABLE and INSERT statements for some examples of data, or to post a question that uses commonly available (such as the scott schema) tables but gets the same error.

    See the froum FAQ: https://forums.oracle.com/message/9362002#9362002

  • Problem with the DATA types, in a UNION

    Hello
    I m trying to disply a custom message when no data found using the structure below. Unfortunately I ve you have a problem with the data types I im trying to union
    I tried different types of data in the 2nd SELECTION tool but the rest of the problem. Help, please.

    SELECT HOSP_NAME 'HOSPITAL' DOC_SUR 'NAME', 'NAME' DOC_NAME, d.DOC_ID ID, diagnosis
    H., DOCTOR d, (SELECT d.DOC_ID, COUNT (d.DIAGN_ID) diagnosis
    OF PATIENT_DIAGNOSIS d
    GROUP BY d.DOC_ID)
    WHERE diagnosis > 1

    UNION ALL

    SELECT TO_CHAR ('test'), TO_CHAR ('test'), TO_CHAR ('test'), TO_CHAR ('test'), 0
    OF THE DOUBLE
    If NOT EXISTS (HOSP_NAME 'HOSPITAL' 'NAME' 'NAME' DOC_NAME DOC_SUR, d.DOC_ID ID, diagnosis
    OF ΝΟΣΟΚΟΜΕΙΟ h, ΙΑΤΡΟΣ d, (SELECT d.DOC_ID, COUNT (d.DIAGN_ID) diagnosis
    OF PATIENT_DIAGNOSIS d
    GROUP BY d.DOC_ID)
    WHERE diagnosis > 1);


    ORA-01790: expression must have same type of data, matching expression
    01790 00000 - "expression must have the same type of data, matching expression.

    DOC_SUR 'NAME' DOC_NAME 'NAME', ID d.DOC_ID, HOSP_NAME "HOSPITAL", diagnosis

    What is the data type for these columns

    To_char('test'), to_char ('test'), to_char ('test'), to_char ('test'), 0

    What you're doing here 'test' is already a character. Why do you use TO_CHAR?

  • Connection problem with Windows Live

    Recently, a change has been introduced whereby it asked me to confirm my mobile number so that MS can send me a verification code that fits into a security process probably intended to check my Windows Live Sign On, however, it happens that it is not possible to select a mobile phone in my country (Malta, European Union).

    I would also like to point out that even though I select Remember me, remember my password within logon, Windows Live Messenger still brings me my username and password for my Windows Live ID account (* address email is removed from the privacy *); This is why does not remember my login credentials.  This happens on my laptop running Win XP SP3.

    I also noticed that I am getting a problem of logon failure, when I try to login to my HP iPAQ which runs on Windows Mobile 2003.
    Hi Emil_d76,
     
    I recommend you post your query in Windows Live Messenger Forums for assistance with this issue.
     
    For the problem with Windows Mobile, post your query in Windows Phone Forums.
  • I got a phone call from a benny edwards who said Microsoft and had found problems with my computer.

    * Original title: defraud my computer

    I got a phone call from a benny edwards who said Microsoft had found problems with my computer and the pirates had gotten him. As I have had some problems recently with the computer, I thought it was authentic and fell for it? After a long telephone conversation, he forced me to accept that my Bullguard anti virus and my malware Remover is not enough to protect the computer and forced me to buy a program from Microsoft (this man of course) not microsoft. It supports the remote computer, and then forced me to give him my details, name, address, telephone number and age and of course the fool that I am, my credit card number, the penny dropped when he asked the Envoy of money via western union.  When I told her that I was closing the phone call, he told fort and wiped a number of things from my computer, the computer wasn't sure.  I ran my scanner (twice) bullguard, run my anti malware program, changed my password and order my credit card, is there something more I can do?

    To protect yourself, your information and your PC, follow these steps:

    • Change your computer password, change the password on your main email account and change the password for all accounts, including your Bank and credit.
    • Immediately scan your PC with the Microsoft Security Scanner to see if you have the tools malicious/phishing software installed on your PC.
    • As a third step, I recommend that you run the verification of Security Essentials on this page. The check will ensure that the security features in Windows are normally very active and running.
    • Personally, I have a clean Windows installation, because something could have been tampered with.

    For more information, visit the Microsoft Internet and Security Safety Center

    For more information on how you can these types of phone scams, visit this site.

    I hope this information has helped. Let us know if you have any additional questions.

  • ODI 11 g multiple table with union join

    Hi all

    I have a problem with joining 4 different tables and union all of them.

    Here I want to generate this query;

    Select * from

    Table1, table2

    Join table2 = table1

    Union of all the

    Select * from

    Table 3, table 4

    Join table3 = table 4

    But I have not the same column that all the table, some are missing. When I write one - PL/SQL query I can easily add a false "NULL column1' column, but I can not how I do with ODI 11 g.

    I tried not to use "Active Mapping", but it does not work.

    I'm newbie ODI 11 g

    Thank you

    Myra

    Hi, Myra,.

    I'd even as in PL/SQL. In your table target add all the columns you need and overall data whatever you're missing some columns just put NULL in the mapping.

    Thank you

    Ajay

  • I have problem with value NULL when the use CASE statement please help this question

    I have problem with value NULL when the use CASE statement please help this question


    Table: digital_val

    SNO cl C2

    1 San1 11

    2 22 San2

    Actual result: expected to A         B

    A            B                                                                           11        22

    11 NULL

    22 NULL



    query:

    Select case when c1 = "san1" then c2,.

    case If c1 = "san2" then c2 B

    of digital_val

    I'm more curious why, when you select 2 rows, you expect a result of row?

    WITH digital_val

    AS (SELECT 1 AS 'Sno', 'San1"C1, c2 FROM DUAL 11)

    UNION ALL

    2 SELECT AS 'Sno', 'San2"C1, c2 FROM DUAL 22)

    SELECT CASE WHEN c1 is "San1" THEN END AS A c2.

    CASE WHEN c1 = "San2" THEN END AS B c2

    OF digital_val;

    With no other input, if you select 2 rows, you get 2 rows.  One of the other solutions use a max function, but is this really what you want, does not specify?

  • Problem with the simple query.

    Hi all

    I am facing problem with the query below

    Select A.COL1, A.COL2

    B.COL1, B.COL2

    FROM TABLE1 A

    TABLE 1 B

    WHERE A.header = '123'

    AND B.header = '123'

    AND nvl (A.COL6, 'ABC') = 'ABC '.

    AND NVL (B.COL6, 'DEF') = 'DEF '.

    Basically, my requiremenyt is: I have only one table, TABLE1 here, which has a line two lines (for the same header) as "ABC" and another is "DEF". Table 1 has two columns (col1, col2) that should be displayed for both lines.

    When the header has two records in table1 top query works. and but if I do not have a record for any header example there are a record for "abc" in col6 only. so my query above does not work because there is no record for 'DEF' in col6. But I want to again request to fecth the output (for b.col1 and b.col2 should have null values)

    could you pls suggest me how to get the 4 columns.

    Thanks in advance

    Kind regards

    UVA.

    Try to place the status of outer join on column: analytical_criterion_code as

    and nvl (AUDIT.analytical_criterion_code, 'AUDIT2') = 'verification2. '

    .

    .

    and nvl (TRANS.analytical_criterion_code, 'TRANS2') = 'TRANS2.

    In the sub query based on the opinions that you have given in post # 1, although there is no value "DEF * ' for col6 due to the condition of outer join on b.col6 (+) line is extracted with b.col [1,2,3] as NULL values. Try to remove the (+) sign b.col6 and test.

    with t as)

    Select 111 col1, col2 'aaa', 'ABC' col6 123 header of all the double union

    Select 222 'bbb', 'DEF' col6, 123 double header

    )

    q as (select 123 double header)

    Select A.COL1, A.COL2, A.COL6

    B.COL1, B.COL2, b.COL6

    q.header

    T a

    t b

    q

    where a.col6 (+) = 'ABC '.

    and b.col6 (+) = "DEF."

    and q.header = a.header (+)

    and q.header = b.header (+)

  • 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.

  • Problems with multipolygons

    Hello!

    I need to merge several polygons in a simple polygon. I'm using Visual Basic with OO4O. In the code of the project is to apply a sdo_geom.union. This is done in a loop, by replacing the parameters of this operation, the coordinates of the vertices of the recordset object. If the resulting geometry is composed of three or more polygons, sdo_geom.union returns the incorrect geometry. Again, if the resulting geometry consists of one or two polygons, sdo_geom.union then returns the appropriate geometry.

    Sorry for my English, I am a Russian :)

    Some functions space Oracle returns a NULL value when there is a problem. Some time ago I had to do the same operation and used a variety of methods to aggregate polygons where a particular method has failed.

    To exclude problems with your code and data, repeat the process of sdo_union even in SqlPlus (again, using faulty data).

    Alternatives:

    [SDO_AGGR_UNION | http://docs.oracle.com/cd/B19306_01/appdev.102/b14255/sdo_aggr.htm#i867161] and there is an example for combining sets of geometries [here | http://docs.oracle.com/cd/B19306_01/appdev.102/b14255/sdo_complex_queries.htm#CIHGJGAA]. SpatialDB Advisor has a post that deals with issues of performance and size with SDO_AGGR_UNION here.

    If you use 10g and it is acceptable to use an approximation, try [SDO_AGGR_CONVEXHULL | http://docs.oracle.com/cd/B19306_01/appdev.102/b14255/sdo_aggr.htm#i867365]

    11g provides the best approximation [SDO_AGGR_CONVEXHULL | http://docs.oracle.com/cd/B28359_01/appdev.111/b28400/sdo_aggr.htm#i867365]

  • Problem with passing the values in a report to the other

    Hello

    I am Agnes, I have developed 2 reports. Summary of the first high level, Mithraeum is detailed. First report is developed using Union (4 union), I have 4 columns. The report generates data. I used the Navigation option on customer column to go to the second report. In the second report with filter I use the easier option. Due to a problem, the customer value of the first report is failed per second. The second report is getting generated for all customers.

    Normally, I have used this option to navigate through other reports and which works very well. I even tested with Union, it works. This time is to give some difficulties.

    Please, let me know what goes wrong.

    Thanks for the help.

    If your Union pivot source then by a simple navigation that you can not pass clicked value to the second report.

    With the help of GoNaV you can pass the selected value source union pivot report to the non-Union target report. If the target report is also union pivot, then it won't pass filters using GoNav.Not sure that because someone talked about a few days back that with the help of GoNav possible to pass the value of a union pivot query to pivot anothet union report.

    Kind regards
    Sandeep

  • problems with, phone, 6, Bluetooth kit, Nissan, after update, for, Rios, 1.0.2

    After the update to ios 10.0.2 - trying to use bluetooth to call my vehicle, it says: "this article is not in your phone book." How can I solve this problem?

    Greetings, joybelino1!

    Thank you for joining the communities Support from Apple! I can't wait to see that you are having problems with your Bluetooth in your car! The good news is that Apple has a great article that will help you with measures to try to resolve the problem. Read this article to gethelp to connect your iPhone, iPad, or iPod touch with your car radio. Even though he talks about problems with the connection, it also has the steps for other questions you may have once connected.

    If you use Bluetooth

    1. Consult the user manual of your car stereo to get the procedure to a Bluetooth device.
    2. On your iOS device, drag up to open Control Center, then press ontwice to turn on Bluetooth and turn it back on.
    3. Restart your iOS device.
    4. On your iOS device, Cancel the twinning of your car radio. On the screen of your car désapparier your iOS device and any other device. Restart your car and your iOS device, then pair and connect again.
    5. Update your iOS device.
    6. Install the updates to the firmware of your car radio.
    7. If you still not connect, contact Apple technical support.

    Have a great day!

  • Anyone having problems with WiFi connectivity after upgrade to Sierra?

    I was wondering if anyone else knows issues with WiFi connectivity since the upgrade to Sierra 10.12? I have not had any problems with connectivity WiFi previously on El Capitan. Now I have regular randomly loose connectivity. My internet is cable and when it is connected I have a 100% connection. My details of iMac and I have used only 10% of my storage.

    No problem with my iphone 6.

    Hello AspDesigns,

    I understand that, since the upgrade to Mac OS Sierra, your Mac seems to have trouble staying connected to Wi - Fi. Fortunately the diagnosis built-in wireless can help identify the source of so much trouble.

    Search for Wi - Fi using your Mac problems

    See you soon!

Maybe you are looking for