Home » SQL & PL/SQL » SQL & PL/SQL » Problem while inserting data in unix env
Problem while inserting data in unix env [message #651681] Mon, 23 May 2016 05:04 Go to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Hi All,

I am trying to insert data in a table using unix environment. In my data, there are special characters.

while loading data into table in unix environment, those special characters get converted into junk character and get inserted into table.

Could you please help me on this?

Reards,
Amit
Re: Problem while inserting data in unix env [message #651682 is a reply to message #651681] Mon, 23 May 2016 05:06 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
How exactly are you loading the data?
What special characters?
What are the they getting converted into - use dump to check?
What's your DB character set?
Re: Problem while inserting data in unix env [message #651683 is a reply to message #651681] Mon, 23 May 2016 05:07 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi,

What is the tool to insert the data into the table? Putty server?
Re: Problem while inserting data in unix env [message #651684 is a reply to message #651682] Mon, 23 May 2016 05:51 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Hi,

I am loading data using simple merge statement if records are present then update else insert.
Sepcial characters like é , á , ó. They are getting converted into '?'.
Database character set is AL32UTF8.

Thanks,
Amit
Re: Problem while inserting data in unix env [message #651685 is a reply to message #651683] Mon, 23 May 2016 05:52 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Hi,

Yes, I am running the script using putty server.

Thanks,
Amit
Re: Problem while inserting data in unix env [message #651686 is a reply to message #651684] Mon, 23 May 2016 05:58 Go to previous messageGo to next message
Michel Cadot
Messages: 68665
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
amit.sonar wrote on Mon, 23 May 2016 12:51
Hi,

I am loading data using simple merge statement if records are present then update else insert.
Sepcial characters like é , á , ó. They are getting converted into '?'.
Database character set is AL32UTF8.

Thanks,
Amit


What is your client NLS_LANG?

Re: Problem while inserting data in unix env [message #651687 is a reply to message #651685] Mon, 23 May 2016 06:00 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
How many rows are inserted ? (by using putty server).

Same issue i got 3 months back.

to resolve this issue.

1) Delete those rows from table.
2)Use TOAD tool to reinsert
Re: Problem while inserting data in unix env [message #651688 is a reply to message #651686] Mon, 23 May 2016 06:00 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Hi

NLS_LANGUAGE= 'ENGLISH'

Regards,
Amit
Re: Problem while inserting data in unix env [message #651689 is a reply to message #651688] Mon, 23 May 2016 06:01 Go to previous messageGo to next message
Michel Cadot
Messages: 68665
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

This is not what I asked.

Re: Problem while inserting data in unix env [message #651690 is a reply to message #651687] Mon, 23 May 2016 06:02 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Hi,

I can not use any third party tool like TOAD to connect db. Could you please suggest any other way?

Regards,
Amit
Re: Problem while inserting data in unix env [message #651691 is a reply to message #651687] Mon, 23 May 2016 06:02 Go to previous messageGo to next message
Michel Cadot
Messages: 68665
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
mist598 wrote on Mon, 23 May 2016 13:00
How many rows are inserted ? (by using putty server).

Same issue i got 3 months back.

to resolve this issue.

1) Delete those rows from table.
2)Use TOAD tool to reinsert


Surely NOT use TOAD. You'll add one level in the mess.
You MUST first understand the problem.

Re: Problem while inserting data in unix env [message #651692 is a reply to message #651690] Mon, 23 May 2016 06:11 Go to previous messageGo to next message
Michel Cadot
Messages: 68665
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
amit.sonar wrote on Mon, 23 May 2016 13:02
Hi,

I can not use any third party tool like TOAD to connect db. Could you please suggest any other way?

Regards,
Amit


Answer my question.

Re: Problem while inserting data in unix env [message #651693 is a reply to message #651691] Mon, 23 May 2016 06:13 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:

Surely NOT use TOAD. You'll add one level in the mess.
You MUST first understand the problem.


Hi Michel,

Yes i have got same issue while using Putty server(DBA people connected APPS user) to insert data into the table.

Next, i deleted those rows from table and inserted using TOAD Tool and it was fine
Re: Problem while inserting data in unix env [message #651695 is a reply to message #651693] Mon, 23 May 2016 06:16 Go to previous messageGo to next message
Michel Cadot
Messages: 68665
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

So you think because something "worked", actually it does not you just have been lucky to get the expected result, it will work for ALL other people, without knowing what was your problem and what is his.

This is a silly behavior.

Re: Problem while inserting data in unix env [message #651696 is a reply to message #651695] Mon, 23 May 2016 06:21 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:

So you think because something "worked", actually it does not you just have been lucky to get the expected result, it will work for ALL other people, without knowing what was your problem and what is his.

This is a silly behavior.


yes it may be luckily.

Can u please suggest us what is the solution and how to check NLS_LANG below query?
SELECT DECODE (parameter,
               'NLS_CHARACTERSET', 'CHARACTER SET',
               'NLS_LANGUAGE', 'LANGUAGE',
               'NLS_TERRITORY', 'TERRITORY'
              ) NAME,
       VALUE
  FROM v$nls_parameters
 WHERE parameter IN ('NLS_CHARACTERSET', 'NLS_LANGUAGE', 'NLS_TERRITORY')
Re: Problem while inserting data in unix env [message #651697 is a reply to message #651696] Mon, 23 May 2016 06:28 Go to previous messageGo to next message
Michel Cadot
Messages: 68665
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

You cannot get it with this query.
If your client is an OCI one, version 11g+, you can get it with V$SESSION_CONNECT_INFO view.

Re: Problem while inserting data in unix env [message #651700 is a reply to message #651683] Mon, 23 May 2016 06:41 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
mist598 wrote on Mon, 23 May 2016 05:07
Hi,

Putty server?


That's a contradiction of terms.
Putty is not a server. Putty is simply an ssh client program.
And in itself it has no capability to interact with a database.

[Updated on: Mon, 23 May 2016 06:42]

Report message to a moderator

Re: Problem while inserting data in unix env [message #651703 is a reply to message #651688] Mon, 23 May 2016 06:59 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Hi Michel,

I have no access on oracle client folder in unix machine since it is managed by infra team. Is there any other option?

Regards,
Amit



Re: Problem while inserting data in unix env [message #651704 is a reply to message #651697] Mon, 23 May 2016 07:20 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Hi Michel,

I tried executing query given by you. I have checked the info but for column CLIENT_CHARSET it is showing value as "UNKNOWN"
Re: Problem while inserting data in unix env [message #651705 is a reply to message #651697] Mon, 23 May 2016 07:23 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Michel Cadot wrote on Mon, 23 May 2016 16:58

You cannot get it with this query.
If your client is an OCI one, version 11g+, you can get it with V$SESSION_CONNECT_INFO view.



I tried executing query given by you. I have checked the info but for column CLIENT_CHARSET it is showing value as "UNKNOWN"

[Updated on: Mon, 23 May 2016 07:24]

Report message to a moderator

Re: Problem while inserting data in unix env [message #651707 is a reply to message #651705] Mon, 23 May 2016 07:58 Go to previous messageGo to next message
Michel Cadot
Messages: 68665
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Just execute "env | grep NLS" from Unix prompt.
You didn't say which client tool you use, is this SQL*Plus?

Re: Problem while inserting data in unix env [message #651708 is a reply to message #651707] Mon, 23 May 2016 08:33 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Michel Cadot wrote on Mon, 23 May 2016 18:28

Just execute "env | grep NLS" from Unix prompt.
You didn't say which client tool you use, is this SQL*Plus?




Yes, sqlplus.
Re: Problem while inserting data in unix env [message #651709 is a reply to message #651707] Mon, 23 May 2016 08:43 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Michel Cadot wrote on Mon, 23 May 2016 18:28

Just execute "env | grep NLS" from Unix prompt.
You didn't say which client tool you use, is this SQL*Plus?




I executed env | grep NLS but no output. seems the env variable has not declared.

Also executed following command and it is cleared that the variable NLS_LANG is not set in the environment.

SQL> @[%NLS_LANG%]
SP2-0310: unable to open file "[%NLS_LANG%].sql"
SQL>


[Updated on: Mon, 23 May 2016 08:57]

Report message to a moderator

Re: Problem while inserting data in unix env [message #651710 is a reply to message #651709] Mon, 23 May 2016 09:18 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
do you have a data storage problem (incorrect characters in the database table)?
or
do you have a data presentation problem (incorrect characters displayed when SELECTED)?

SELECT COLUMN1, ASCIISTR(COLUMN1) FROM TABLEA WHERE ID = 1;

convert SELECT above to work in your environment & post results using COPY & PASTE
Re: Problem while inserting data in unix env [message #651711 is a reply to message #651710] Mon, 23 May 2016 09:22 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
BlackSwan wrote on Mon, 23 May 2016 19:48
do you have a data storage problem (incorrect characters in the database table)?
or
do you have a data presentation problem (incorrect characters displayed when SELECTED)?

SELECT COLUMN1, ASCIISTR(COLUMN1) FROM TABLEA WHERE ID = 1;

convert SELECT above to work in your environment & post results using COPY & PASTE


SQL> desc test_lang
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 LANG                                               NVARCHAR2(50)

SQL> insert into test_lang values('Série');

1 row created.

SQL> select * from test_lang;

LANG
--------------------------------------------------
S??rie

SQL> commit;

Commit complete.

SQL> select lang,ASCIISTR(lang) from test_lang;

LANG
--------------------------------------------------
ASCIISTR(LANG)
--------------------------------------------------------------------------------
S??rie
S\FFFD\FFFDrie

Re: Problem while inserting data in unix env [message #651712 is a reply to message #651711] Mon, 23 May 2016 09:24 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
THANKS

posted response was a FINE & perfect example.

what was learned by example above?
Re: Problem while inserting data in unix env [message #651714 is a reply to message #651709] Mon, 23 May 2016 09:46 Go to previous messageGo to next message
Michel Cadot
Messages: 68665
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
amit.sonar wrote on Mon, 23 May 2016 15:43
Michel Cadot wrote on Mon, 23 May 2016 18:28

Just execute "env | grep NLS" from Unix prompt.
You didn't say which client tool you use, is this SQL*Plus?




I executed env | grep NLS but no output. seems the env variable has not declared.

Also executed following command and it is cleared that the variable NLS_LANG is not set in the environment.

SQL> @[%NLS_LANG%]
SP2-0310: unable to open file "[%NLS_LANG%].sql"
SQL>




If NLS_LANG is not set then you tell Oracle you use the default character set which does not contain any "special" character, so Oracle has to convert these ones to something you know and to do so it replaces these characters by one that is named a replacement character.

Tell Oracle the character set you actually used and there should be no problem.
As you are in Linux, generally your OS character set is UTF8 and so you have to set NLS_LANG with AL32UTF8.
Read Setting the NLS_LANG Environment Variable and Setting NLS_LANG.

Re: Problem while inserting data in unix env [message #651734 is a reply to message #651714] Tue, 24 May 2016 03:21 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Michel Cadot wrote on Mon, 23 May 2016 20:16
amit.sonar wrote on Mon, 23 May 2016 15:43
Michel Cadot wrote on Mon, 23 May 2016 18:28

Just execute "env | grep NLS" from Unix prompt.
You didn't say which client tool you use, is this SQL*Plus?




I executed env | grep NLS but no output. seems the env variable has not declared.

Also executed following command and it is cleared that the variable NLS_LANG is not set in the environment.

SQL> @[%NLS_LANG%]
SP2-0310: unable to open file "[%NLS_LANG%].sql"
SQL>




If NLS_LANG is not set then you tell Oracle you use the default character set which does not contain any "special" character, so Oracle has to convert these ones to something you know and to do so it replaces these characters by one that is named a replacement character.

Tell Oracle the character set you actually used and there should be no problem.
As you are in Linux, generally your OS character set is UTF8 and so you have to set NLS_LANG with AL32UTF8.
Read Setting the NLS_LANG Environment Variable and Setting NLS_LANG.



Is there any other way to do it without changing environmental variable?

Re: Problem while inserting data in unix env [message #651736 is a reply to message #651734] Tue, 24 May 2016 03:34 Go to previous messageGo to next message
Michel Cadot
Messages: 68665
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

With SQL*Plus, no.
What is the problem to set a variable?

Re: Problem while inserting data in unix env [message #651741 is a reply to message #651736] Tue, 24 May 2016 04:44 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Michel Cadot wrote on Tue, 24 May 2016 14:04

With SQL*Plus, no.
What is the problem to set a variable?



It comes under the different teams and it requires lot of approvals. May be I will try to set it.

[Updated on: Tue, 24 May 2016 08:02]

Report message to a moderator

Re: Problem while inserting data in unix env [message #651744 is a reply to message #651741] Tue, 24 May 2016 05:16 Go to previous messageGo to next message
Michel Cadot
Messages: 68665
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

It is an Oracle only variable.
If you not use it you have bad data in your database.
I don't see where is the problem.
So the choice is:

not use it and have bad data <-> use it and have correct data

Just tell that and you will have all approvals.

Re: Problem while inserting data in unix env [message #651750 is a reply to message #651744] Tue, 24 May 2016 07:45 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi Michel,

what columns values we need to fetch and see from V$SESSION_CONNECT_INFO View
Re: Problem while inserting data in unix env [message #651751 is a reply to message #651744] Tue, 24 May 2016 08:05 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Michel Cadot wrote on Tue, 24 May 2016 15:46

It is an Oracle only variable.
If you not use it you have bad data in your database.
I don't see where is the problem.
So the choice is:

not use it and have bad data <-> use it and have correct data

Just tell that and you will have all approvals.



Hi Michel,

Yes, correctly said. Will do it in the same way.

Thank you for your inputs and appreciate your efforts.

Regards,
Amit Sonar
Re: Problem while inserting data in unix env [message #651752 is a reply to message #651751] Tue, 24 May 2016 08:06 Go to previous messageGo to next message
amit.sonar
Messages: 98
Registered: December 2009
Location: Mumbai
Member
Hi All,

Very much appreciated you all for taking efforts to reply my question.

Regards,
Amit

[Updated on: Tue, 24 May 2016 08:11]

Report message to a moderator

Re: Problem while inserting data in unix env [message #651755 is a reply to message #651750] Tue, 24 May 2016 09:33 Go to previous message
Michel Cadot
Messages: 68665
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
mist598 wrote on Tue, 24 May 2016 14:45
Hi Michel,

what columns values we need to fetch and see from V$SESSION_CONNECT_INFO View


What about the documentation?
Hint:
SQL> desc V$SESSION_CONNECT_INFO
 Name                             Null?    Type
 -------------------------------- -------- ----------------------
 SID                                       NUMBER
 SERIAL#                                   NUMBER
 AUTHENTICATION_TYPE                       VARCHAR2(26)
 OSUSER                                    VARCHAR2(30)
 NETWORK_SERVICE_BANNER                    VARCHAR2(4000)
 CLIENT_CHARSET                            VARCHAR2(40)
 CLIENT_CONNECTION                         VARCHAR2(13)
 CLIENT_OCI_LIBRARY                        VARCHAR2(27)
 CLIENT_VERSION                            VARCHAR2(40)
 CLIENT_DRIVER                             VARCHAR2(9)
 CLIENT_LOBATTR                            VARCHAR2(23)

Which one could give the client character set?
Previous Topic: first tuesday of every month ?
Next Topic: Need to populate two more columns
Goto Forum:
  


Current Time: Sun Jun 30 17:38:38 CDT 2024