Oracle field displays ??? instead of Russian letters - oracle

I run the follows to update the record
update lims_min.languages
set Apriori = 'Русский'
where langid = 'RUS';
COMMIT;
when I do select, I see the ???? instead of the correct word. Apriori is NVARCHAR2.
Is there another trick here?

This is not an answer but is too long for a comment.
As already said you need to check NLS_LANG but also
your database character sets
what is the tool used to display data
the platform used (Windows, Linux, ...)
if you use Windows are you using a GUI program or a CLI program.
The following works on Linux CLI environment with SQLPlus:
SQL> select banner from v$version where rownum=1;
BANNER
--------------------------------------------------------------------------------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
SQL> host echo $NLS_LANG
American_America.UTF8
SQL> --
SQL> select parameter, value
2 from nls_database_parameters
3 where parameter like '%SET%';
PARAMETER VALUE
------------------------------ --------------------
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_CHARACTERSET AL32UTF8
SQL> --
SQL> create table t(l varchar2(3), a nvarchar2(30));
Table created.
SQL> --
SQL> insert into t values('RUS', 'Русский');
1 row created.
SQL> --
SQL> select * from t;
L A
--------- ------------------------------
RUS Русский
SQL>

Related

Oracle Number issue on 18c vs 19c

Need a confirmation on this below behavior of NUMBER Datatype on both the Oracle versions(18c vs 19c),
In 18c,
select cast(0.003856214813393653 as number(20,18)) from dual;
--output
0.00385621481339365
In 19c,
select cast(0.003856214813393653 as number(20,18)) from dual;
--output
0.003856214813393653
Why does the truncation of last digit happen for 18c?
Is this an issue with version?
Plus 18c seems to to be unable to handle scale values more than 17.
This is related to Oracle / PLSQL developer tool setting issue. please try with the below options to resolve the same
Tools -> Preferences -> SQL Window -> Number fields to_char
This is at the whim of the client settings not the database. For example, I ran all of these on the same database
SQL Plus
========
SQL> select cast(0.003856214813393653 as number(20,18)) from dual;
CAST(0.003856214813393653ASNUMBER(20,18))
-----------------------------------------
.003856215
SQL Developer
=============
select cast(0.003856214813393653 as number(20,18)) from dual;
0.003856214813393653
SQLcl
======
SQL> select cast(0.003856214813393653 as number(20,18)) from dual;
CAST(0.003856214813393653ASNUMBER(20,18))
-----------------------------------------
.00385621481
The client tool decides on the precision to show

How to enter non ascii characters (such as í ) in SQL Developer 18.1

I am using SQL Developer v18.1 and the database version is Oracle 12c.
sql> select * from nls_database_parameters where parameter like 'NLS%CHARACTERSET';
PARAMETER VALUE
------------------------------ -------------------------
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_CHARACTERSET AL32UTF8
I would like to enter some non-ascii characters, such as 'í', but have no clue how to do that, even after some searches here and Google. Actually I am even unable to enter this example character here directly. I just copies it somewhere else and pasted in this question.
Thank you for the helps in advance!
Sam
How about this?
Here's a table which is supposed to contain some data.
SQL> create table test (col varchar2(20));
Table created.
Check ASCII code for the character you'd want to insert, by using the ASCII function:
SQL> select ascii('í') from dual;
ASCII('í')
----------
52103
OK; now we know its code so - insert it, but this time using the CHR function:
SQL> insert into test (col) values (chr(52103));
1 row created.
SQL> select * From test;
COL
--------------------
í
SQL>

Oracle command to create a table from another schema, including triggers?

Using this command, I am able to create a table from another schema, but it does not include triggers. Is it possible to create a table from another schema, including triggers?
create table B.tablename unrecoverable as select * from A.tablename where 1 = 0;
First option is to run CREATE script for those objects, if you have a code repository. I suppose you don't.
If you use any GUI tool, things are getting simpler as they contain the SCRIPT tab that enables you to copy code from source and paste it into target user.
If you're on SQLPlus, it means that you should, actually, know what you're supposed to do. Here's a short demo.
SQL> connect hr/hr#xe
Connected.
SQL> create table detail (id number);
Table created.
SQL> create or replace trigger trg_det
2 before insert on detail
3 for each row
4 begin
5 :new.id := 1000;
6 end;
7 /
Trigger created.
SQL>
SQL> -- you'll have to grant privileges on table to another user
SQL> grant all on detail to scott;
Grant succeeded.
Connect as SCOTT and check what we've got:
SQL> connect scott/tiger#xe
Connected.
SQL> -- now, query ALL_SOURCE and you'll get trigger code
SQL> set pagesize 0
SQL> col text format a50
SQL> select text from all_source where name = 'TRG_DET' order by line;
trigger trg_det
before insert on detail
for each row
begin
:new.id := 1000;
end;
6 rows selected.
SQL>
Yet another option is to export & import table, which will get the trigger as well (I've removed parts that aren't relevant, as Oracle database version):
C:\>exp hr/hr#xe tables=detail file=detail.dmp
About to export specified tables via Conventional Path ...
. . exporting table DETAIL 0 rows exported
Export terminated successfully without warnings.
C:\>imp scott/tiger#xe file=detail.dmp full=y
. importing HR's objects into SCOTT
. importing HR's objects into SCOTT
. . importing table "DETAIL" 0 rows imported
Import terminated successfully without warnings.
C:\>
Check what's imported (should be both table and trigger):
SQL> desc detail
Name Null? Type
----------------------------------------- -------- ---------------
ID NUMBER
SQL> select * From detail;
no rows selected
SQL> insert into detail (id) values (-1);
1 row created.
SQL> select * From detail;
ID
----------
1000
SQL>
Cool; even the trigger works.
There might be some other options, but these 4 should be enough to get you started.

'Invalid input values for pname' during table statistics gathering?

When I'm trying to gather table statistics using GATHER_TABLE_STATS procedure, I'm getting the following error:
ORA-20001: Invalid input values for pname
ORA-06512: at "SYS.DBMS_STATS", line 31513
ORA-06512: at line 2
The code I'm running to gather statistics is
BEGIN
DBMS_STATS.gather_table_stats ('OWNER', 'TABLE_NAME');
END;
/
My Oracle version is Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
I guess you might have misspelled OWNER or TABLE_NAME parameter. Its working fine for me as shown below.
SQL> conn jay/jay
Connected.
SQL> select table_name from tabs;
TABLE_NAME
------------------------------
ROAD
EVENT
ALL_OBS
ACCOUNT
NVARCHAR2_EMAIL
TABLEA
T2
MYTABLE
8 rows selected.
SQL> exec dbms_stats.gather_table_stats('JAY','ROAD');
PL/SQL procedure successfully completed.
Update
As per the My Oracle Support Doc:755577.1, It is possible that the post installation scripts for the patch were not run correctly after a patch was applied.
You may need to reinitialize the DBMS_STATS package using execstat.sql under $ORACLE_HOME/rdbms/admin directory. Or reinstall DBMS_STATS.
Or you might hit the bug- Bug 14479079 : ORA-20001 GATHERING STATS AFTER CPU JULY 2012 PATCH

Can I force SQLPLUS to use NLS_DATE_FORMAT for insert?

Is there a way to force an implicit date conversion on an insert statement (i.e. without using TO_DATE)?
context: I'm importing a data dump from Postgresql to Oracle. Everything is working well except for date formatting. I would prefer not to have to mung the Postgresql output.
(update: this is with 10.2. Strangely, changing the format to RRRR-MM-DD makes everything work!)
SQL> create table a(b date);
Table created.
SQL> ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD';
Session altered.
SQL> insert into a values('2009-12-03');
insert into a values('2009-12-03')
*
ERROR at line 1:
ORA-01843: not a valid month
SQL> insert into a values(to_date('2009-12-03','YYYY-MM-DD'));
1 row created.

Resources