Lession 3 oca sql fundamental doubts on ora -01858 error
SELECT last_name, hire_date
FROM employees
WHERE hire_date = TO_DATE('May 24, 1999', 'fxMonth DD, YYYY');
books mention it will leave a error (ora-01858 which is an non-numeric error )but the statement running perfectly while
by deleting that "fx"-prefix gives an error called ora-01861.
i am confused here??can anyone show me the right way?
Hi,
The outcome depends on your NLS settings. Probably yours are set to something different than AMERICAN. In you language the month of May may then have a different number of characters(?)
That's why you hit the ORA-01861 with the FX Format Model, and something else without. (Can't see why you should get ORA-01858, though)
Regards
Peter
Similar Messages
-
ORA-01858 error in Application but not in sqlpluss
Hi.
I have this query that runs nicely in sqlpluss and the SQL Commands that came with Expressedition 10g, but when I put it in a report region it produce:
report error:
ORA-01858: a non-numeric character was found where a numeric was expected
query:
SELECT temae.temae, NVL(antall,0) Antall
FROM temae LEFT OUTER JOIN (SELECT temae, count(temae) as antall
FROM okeiko
WHERE person = :P3_PERSON and dag >= to_date(DECODE(SIGN(to_char(current_date,'mm')-5),
-1, to_date('01-NOV-'||to_char(current_date,'yy'))-365,
0, to_date('01-MAY-'||to_char(current_date,'yy')),
1, DECODE(SIGN(to_char(current_date,'mm')-10),
-1,to_date('01-MAY-'||to_char(current_date,'yy')),
0,to_date('01-MAY-'||to_char(current_date,'yy')),
1,to_date('01-NOV-'||to_char(current_date,'yy')))),'dd-mon-yy')
GROUP BY temae) p
ON temae.id = p.temae
where antall > 0
ORDER BY NVL(antall,0) DESC, temae.type, temae.temae
Before I added the decode part for the date it looked like this, and worked nice in the application:
SELECT temae.temae, NVL(antall,0) Antall
FROM temae LEFT OUTER JOIN (SELECT temae, count(temae) as antall
FROM okeiko
WHERE person = :P3_PERSON and dag > to_date('30-apr-06','dd-mon-yy')
GROUP BY temae) p
ON temae.id = p.temae
where antall > 0
ORDER BY NVL(antall,0) DESC, temae.type, temae.temae
This is the data structure
SQL> describe temae
Name Null? Type
ID NOT NULL NUMBER
TEMAE VARCHAR2(20)
TYPE NUMBER
Then it worked nicely in the application to.
SQL> describe okeiko;
Name Null? Type
ID NOT NULL NUMBER
PERSON NOT NULL NUMBER
TEMAE NOT NULL NUMBER
SENSEI NUMBER
REMARK VARCHAR2(4000)
DAG NOT NULL DATE
Can anyone se why application is complaining?
BTW report region also complains to_date('01-may-06','dd-mon-yy') does not have a valid month.Marius,
I am not sure but try this:
SELECT temae.temae, NVL (antall, 0) antall
FROM temae LEFT OUTER JOIN (SELECT temae, COUNT (temae) AS antall
FROM okeiko
WHERE person = :p3_person
AND dag >=
TO_DATE
(DECODE
(SIGN
( TO_CHAR
(CURRENT_DATE,
'mm'
- 5
-1, TO_DATE
( '01-NOV-'
|| TO_CHAR
(CURRENT_DATE,
'yy'
- 365,
0, TO_DATE
( '01-MAY-'
|| TO_CHAR
(CURRENT_DATE,
'yy'
1, DECODE
(SIGN
( TO_CHAR
(CURRENT_DATE,
'mm'
- 10
-1, TO_DATE
( '01-MAY-'
|| TO_CHAR
(CURRENT_DATE,
'yy'
0, TO_DATE
( '01-MAY-'
|| TO_CHAR
(CURRENT_DATE,
'yy'
1, TO_DATE
( '01-NOV-'
|| TO_CHAR
(CURRENT_DATE,
'yy'
GROUP BY temae) p ON temae.ID = p.temae
WHERE antall > 0
ORDER BY NVL (antall, 0) DESC, temae.TYPE, temae.temaeI took out the formating of your to_date function.
Denes Kubicek -
ORA-01858 error from Apex Report on working/valid underlying query
After two days of searching these forums and AskTom, I think I need to post the following problem.
I have what seems to be a valid view of some data created as follows (with an apology for the formatting - doesn't seem to be a way of using a fixed font here):
CREATE OR REPLACE FORCE VIEW "PRICING_CAPABILITY"."POW_EXEC_SUMM010" ("Item",
"Jul-09", "Aug-09", "Sep-09", "Oct-09", "Nov-09", "Dec-09", "Jan-10",
"Feb-10", "Mar-10", "Apr-10", "May-10", "Jun-10", "YTD")
AS
SELECT
"Item",
SUM(DECODE("ItemMonth",'Jul-09',"ItemValue",0)) "Jul-09",
SUM(DECODE("ItemMonth",'Aug-09',"ItemValue",0)) "Aug-09",
SUM(DECODE("ItemMonth",'Sep-09',"ItemValue",0)) "Sep-09",
SUM(DECODE("ItemMonth",'Oct-09',"ItemValue",0)) "Oct-09",
SUM(DECODE("ItemMonth",'Nov-09',"ItemValue",0)) "Nov-09",
SUM(DECODE("ItemMonth",'Dec-09',"ItemValue",0)) "Dec-09",
SUM(DECODE("ItemMonth",'Jan-10',"ItemValue",0)) "Jan-10",
SUM(DECODE("ItemMonth",'Feb-10',"ItemValue",0)) "Feb-10",
SUM(DECODE("ItemMonth",'Mar-10',"ItemValue",0)) "Mar-10",
SUM(DECODE("ItemMonth",'Apr-10',"ItemValue",0)) "Apr-10",
SUM(DECODE("ItemMonth",'May-10',"ItemValue",0)) "May-10",
SUM(DECODE("ItemMonth",'Jun-10',"ItemValue",0)) "Jun-10",
SUM("ItemValue") AS "YTD"
FROM
SELECT
'New Proposals Received' AS "Item",
TO_CHAR(t1.scope_received,'Mon-RR') AS "ItemMonth",
COUNT(*) AS "ItemValue",
10 AS "SortOrder"
FROM
PRICING_CAPABILITY.POW_DATA t1
WHERE
t1.scope_received IS NOT NULL
AND extract(YEAR FROM t1.scope_received) IN (2009,2010)
AND t1.scope_received >= '01-JUL-2009'
GROUP BY
'New Proposals Received',
TO_CHAR(t1.scope_received,'Mon-RR'),
10
UNION
SELECT
'New Proposals Completed' AS "Item",
TO_CHAR(t2.pricing_approval,'Mon-RR') AS "ItemMonth",
COUNT(*) AS "ItemValue",
20 AS "SortOrder"
FROM
PRICING_CAPABILITY.POW_DATA t1
JOIN PRICING_CAPABILITY.POW_LAST_HISTORY t2
ON
t1.POW_DATA_ID = t2.POW_DATA_ID
WHERE
t2.pricing_approval IS NOT NULL
AND extract(YEAR FROM t2.pricing_approval) IN (2009,2010)
AND t2.pricing_approval >= '01-JUL-2009'
GROUP BY
'New Proposals Completed',
TO_CHAR(t2.pricing_approval,'Mon-RR')
GROUP BY
"Item",
"SortOrder"
ORDER BY
"SortOrder" ;
This view works, ie produces the right results when run (ie select * from ...) in SQL Developer and in the SQL Workshop section of Apex.
But when I attempt to produce an Apex report using it as the source of data, I get the following error:
ORA-01858: a non-numeric character was found where a numeric was expected
The error is displayed before any part of the report itself is displayed, ie the Region Header is displayed and then the error message.
So far, anything I've been able to find on the forums or AskTom suggests that it is probably due to a date conversion problem. But the aim here is to summarise dated records by month, so I'm extracted the year and month elements of the date values, converting them to strings (using TO_CHAR), and then using the resulting 'Mon-YY' strings to group the results.
If there is a better way, I'm interested.
But I don't understand why Apex seems to be rejecting what appear to be valid results from a valid working query.
Any ideas? Suggestions?
Cheers,
PeterThanks again, Flavio. I'm learning and I appreciate your patience.
The solution you provided is very similar to the one I came up with after your previous message, but I didn't have the NLS_DATE_LANGUAGE parameter. I'll go back and try it.
I appreciate your explanation re Apex not needing to know and Oracle assuming that the client knows what it is doing, but it puzzles me more.
The way that I originally had things, I think, was consistent with what you have explained, but it didn't work. To make it clear:
1 I had an Oracle view that had no parameters and contained the date literal in the where clause and worked fine in both SQL Developer and in the Apex SQL Workshop.
2 The view did not return any date values. Aside from the column headings and the first column (of character strings), the body of the table comprised integer values only.
3 So, when Apex called the view, I would have expected the Oracle server to independently execute the view and return the (dateless) results to Apex, which would then present the unmodified results in a standard report. This is, I think, what SQL Developer and the Apex SQL Workshop appear to have successfully done.
My expectation seems to be consistent with at least some of your explanation (ie [Oracle assumes] "+that the client knows what it is doing+" and "+apex doesn't need to know anything about the underlying query+"), but is not consistent with actual experience, where Apex seems to know that the underlying query contains a date literal and unsuccessfully (and unnecessarily) attempts to interpret it.
I'm obviously missing something about how Apex and Oracle interact in this situation. While I don't need to know - as I have a working solution now - it is valuable to understand how things work. Makes life easier and more productive.
Cheers,
Peter -
hi every body,
How can i handle exception ora-01858 without
using when others then null;
I want something
like
when user_definded =ora-01858 then null;
when others then
v_ErrorNumber := SQLCODE;
v_ErrorText := SUBSTR(SQLERRM, 1, 2000);in fact ,
I use a procadure that insert values into a table.
I want that when it reaches an ORA-01858 , then the error is ignored and continue
to insert others values,
but now , when I reach error it stops, how to deal with it ?
CREATE OR REPLACE PROCEDURE INSERT_SWAP_FIXINGS (l_num number)
as
v_date varchar2(20);
v_swap varchar2(1000);
conn utl_tcp.connection;
p pls_integer;
line varchar2(4000);
v_ErrorNumber NUMBER; -- Variable to hold the error number
v_ErrorText VARCHAR2(200); -- Variable to hold the error message text
e_Non_Numeric EXCEPTION;
PRAGMA EXCEPTION_INIT(e_Non_Numeric , -1858);
begin
select trunc(sysdate) -l_num into v_date from dual;
select regexp_replace (stringAgg(ticker),',','|') ||';' into v_swap from SWAP_DESC ;
conn := utl_tcp.open_connection(remote_host=>'MY_H0ST',remote_port=>123156);
p := utl_tcp.write_line(conn, v_swap);
p := utl_tcp.write_line(conn, 'PX_Last;');
p := utl_tcp.write_line(conn, v_date );
p := utl_tcp.write_line(conn,';');
p := utl_tcp.write_line(conn, v_date);
p := utl_tcp.write_line(conn, '>');
begin
loop
line := utl_tcp.get_line(conn, TRUE);
if get_token(line,2) like '%N/A%' then
dbms_output.put_line(get_token(line,1)||','||get_token(line,2));
dbms_output.put_line(line);
insert into TMP_SWAP_FIXINGS
values (get_token(line,1),to_date(get_token(line,2),'DD/MM/YYYY'));
else
insert into swap_fixings values (get_token(line,1),to_date(get_token(line,2),'DD/MM/YYYY'),get_token(line,3));
end if;
end loop;
EXCEPTION
WHEN utl_tcp.end_of_input THEN
NULL;
end;
utl_tcp.close_connection(conn);
commit;
declare
ligne varchar2(2000);
corps varchar2(7000);
begin
ligne :=' DATA SWAP INSERTION : '
|| UTL_TCP.crlf || UTL_TCP.crlf
|| RPAD ('TICKER',30,' ')
|| RPAD ('INFO_DATE',40,' ')
|| RPAD ('LAST_PRICE',10,' ');
corps := ligne || UTL_TCP.crlf;
for x in (select ticker,to_char(info_date,'DD/MM/YYYY') "INFO_DATE",LAST_PRICE from SWAP_FIXINGS where trunc(info_date) = v_date)
loop
ligne :=
RPAD (x.TICKER, 30, ' ')
||RPAD (x.info_date,40 ,' ')
||RPAD (x.LAST_PRICE,10,' ');
corps := corps || ligne || UTL_TCP.crlf;
end loop;
corps := '<pre>' || corps || '</pre>';
debug(corps);
end;
EXCEPTION
WHEN e_Non_Numeric then
null;
when OTHERS THEN
v_ErrorNumber := SQLCODE;
v_ErrorText := SUBSTR(SQLERRM, 1, 200);
declare
ligne varchar2(2000);
corps varchar2(7000);
begin
ligne := RPAD (v_ErrorText, 200, ' ');
corps := corps || ligne || UTL_TCP.crlf;
corps := '<pre>' || corps || '</pre>';
debug(corps);
end;
end;
/ -
ORA-01858 error in RMAN during backup backupset format '/test/rman/%U'
Hello!
I am trying to perform bacup using command
RMAN> backup backupset completed after 'sysdate-1' format '/tmp/test/%U';
as described in:
asmcmd scripts
All backupsets are copied to /tmp/test/.
Everything is going fine except the last message from RMAN:
input backupset count=5342 stamp=660348635 creation_time=17-JUL-08
channel ORA_DISK_1: starting piece 1 at 18-JUL-08
piece handle=/tmp/test/6ujlo7mr_1_2 comment=NONE
channel ORA_DISK_1: finished piece 1 at 18-JUL-08
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
input backupset count=5343 stamp=660348722 creation_time=17-JUL-08
channel ORA_DISK_1: starting piece 1 at 18-JUL-08
piece handle=/tmp/test/6vjlo7pi_1_2 comment=NONE
channel ORA_DISK_1: finished piece 1 at 18-JUL-08
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
input backupset count=5344 stamp=660348810 creation_time=17-JUL-08
channel ORA_DISK_1: starting piece 1 at 18-JUL-08
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 07/18/2008 10:59:48
ORA-01858: a non-numeric character was found where a numeric was expected
I suspect that rman is performing, at the end of backup, some internal work (store something in control file based catalog or so) and catches ORA-01858.
The destination catalog is local catalog (not nfs mounted remote dir).
RMAN is spawned from the same node the Oracle Database is running on.
I tested it on two servers.
Error occurs on both of them:
version 10g (ia-32) - flash recovery area on filesystem
and version 11g (Aix) - flash on ASM
RMAN-oracle10> show all ;
using target database controlfile instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
CONFIGURE BACKUP OPTIMIZATION OFF;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 1;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/oracle/10gSE/dbs/snap_dbname.dbf'; # default
RMAN-oracle11> show all ;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name O2DB are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.1.0/dbname_1/dbs/snapcf_dbname.f';
How to diagnose the problem?
How check what RMAN is exactly doing when error occurs?
Or maybe there is better way to achieve this:
I want to move backupset from asm realm to remote server without storing them on local, non asm disk.
Any suggestions kindly welcome!
Thanx!Solution:
NLS_DATE_FORMAT mus be set mannualy;
export NLS_DATE_FORMAT='YYYY_MM_DD'
solved the problem..
https://metalink.oracle.com/metalink/plsql/f?p=130:15:12788270042070262572::::p15_database_id,p15_docid,p15_show_header,p15_show_help,p15_black_frame,p15_font:BUG,6198368,1,1,1,helvetica
Metalinking before posting is the rule of thumb : ) -
Sql@loader-704 and ORA-12154: error messages when trying to load data with SQL Loader
I have a data base with two tables that is used by Apex 4.2. One table has 800,000 records . The other has 7 million records
The client recently upgraded from Apex 3.2 to Apex 4.2 . We exported/imported the data to the new location with no problems
The source of the data is an old mainframe system; I needed to make changes to the source data and then load the tables.
The first time I loaded the data i did it from a command line with SQL loader
Now when I try to load the data I get this message:
sql@loader-704 Internal error: ulconnect OCISERVERATTACH
ORA-12154: tns:could not resolve the connect identifier specified
I've searched for postings on these error message and they all seem to say that SQL Ldr can't find my TNSNAMES file.
I am able to connect and load data with SQL Developer; so SQL developer is able to find the TNSNAMES file
However SQL Developer will not let me load a file this big
I have also tried to load the file within Apex (SQL Workshop/ Utilities) but again, the file is too big.
So it seems like SQL Loader is the only option
I did find one post online that said to set an environment variable with the path to the TNSNAMES file, but that didn't work..
Not sure what else to try or where to look
thanksHi,
You must have more than one tnsnames file or multiple installations of oracle. What i suggest you do (as I'm sure will be mentioned in ed's link that you were already pointed at) is the following (* i assume you are on windows?)
open a command prompt
set TNS_ADMIN=PATH_TO_DIRECTOT_THAT_CONTAINS_CORRECT_TNSNAMES_FILE (i.e. something like set TNS_ADMIN=c:\oracle\network\admin)
This will tell oracle use the config files you find here and no others
then try sqlldr user/pass@db (in the same dos window)
see if that connects and let us know.
Cheers,
Harry
http://dbaharrison.blogspot.com -
Oracle query on dblinked SQL Server tables returns ORA-00904 error
Hi,
I have created a dblink to a SQL Server database from Oracle using Generic Connectivity.
The following query returns ORA-00904 Invalid Identifier error in the WHERE clause (tblEmp.Empno)
SELECT "EmpNo","EmpName", "DeptName"
FROM tblEmp@sqlserver,
tblDept@sqlserver
WHERE tblDept.DeptNo = tblEmp.Empno
I had to enclose the column names in double quotes due to case sensitivitiy of the columns, but I can't do the
same for the WHERE clause.
1) So, how do I fix this error ?
2) Also how do I include Deptno column with table alias in the columns list?
(Deptno is ambiguous in Emp and Dept tables)
Regards,
SamAlex
Because using the aliases all the time can become annoying and lead to disparate standards when used by multiple developers. For a one-off query I would go with aliases in the query but if the linked tables are going to be interrogated extensively I would prefer to create vanilla views of the underlying tables so that the aliases aren't necessary.
Just my opinion, it feels a bit cleaner to do it this way - you only do the work once in creating the view and then you don't need to worry about the case sensitivity of the linked database. You can also refer to the source in the name of the view so you don't have to think about different source databases with the same table names.
Cheers
Ben -
Need help trouble shooting Database Gateway for MS SQL Server setup, getting ORA-28546 error
Dear All,
I am trying to setup Oracle Database Gateway for MS SQL Server(I don't have admin access to the MS SQL Server). When I try to test the dblink connection, I get the following error.
I issued select * from dual@xyz;
ORA-28546: connection initialization failed, probable Net8 admin error
ORA-28511: lost RPC connection to heterogeneous remote agent using SID=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=dg4msql)))
ORA-02063: preceding 2 lines from xyz
28546. 0000 - "connection initialization failed, probable Net8 admin error"
My setup is the following.
1. Oracle 11gR2 running on Oracle Linux 6, the same version gateway is installed on the same server, but different home directory.
2. Oracle DB home directory is /u01/app/oracle/product/11.2.0/dbhome_1, gateway home directory is /u01/gateway.
3. I use the same listener.ora file for both the db and the gateway.
4. the contents of my listener.ora, tnsnames.ora and the initdg4msql.ora are below.
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
#(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = db.abc.com.tw)(PORT = 1522))
mssql =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME=db.abc.com.tw)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=orcl)
SID_LIST_mssql =
(SID_LIST =
(SID_DESC =
(SID_NAME=dg4msql)
(ENVS=LD_LIBRARY_PATH=/u01/gateway/dg4msql/driver/lib:/u01/gateway/lib)
(PROGRAM_NAME=/u01/gateway/bin/dg4msql)
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = db.abc.com.tw)(PORT = 1522))
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db.abc.com.tw)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.abc.com.tw)
dg4msql =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP) (HOST=localhost)(PORT = 1521))
(CONNECT_DATA=(SID=dg4msql))
(HS=OK)
/u01/gateway/dg4msql/admin/initdg4msql.ora
HS_FDS_CONNECT_INFO=[192.168.0.1]:1433//XIETEST
# alternate connect format is hostname/serverinstance/databasename
HS_FDS_TRACE_LEVEL=255
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
dblink was created using statement below.
CREATE DATABASE LINK "xyz.abc.COM.TW"
CONNECT TO SA IDENTIFIED BY
USING 'dg4msql';
Couple more things, that I have done to check the work above.
[oracle@db admin]$ ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=61 time=7.61 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=61 time=7.41 ms
^C
--- 192.168.0.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1818ms
rtt min/avg/max/mdev = 7.417/7.516/7.615/0.099 ms
[oracle@db admin]$ tnsping dg4msql
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 11-SEP-2013 10:53:11
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP) (HOST=localhost)(PORT = 1521)) (CONNECT_DATA=(SID=dg4msql)) (HS=OK))
OK (0 msec)
[oracle@db admin]$ lsnrctl status mssql
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 11-SEP-2013 10:54:23
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
Alias mssql
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 11-SEP-2013 10:09:46
Uptime 0 days 0 hr. 44 min. 37 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/db/mssql/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Services Summary...
Service "dg4msql" has 1 instance(s).
Instance "dg4msql", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
Obviously, I would like to get this setup to work, but I also have couple other questions regarding this setup.
1. When installing the gateway, it asks to run the root.sh script. the root.sh script as for the following.
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The file "dbhome" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: n
The file "oraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: n
The file "coraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: n
is the above answer correct?
Thanks for reading.Dear Klaus,
I did start a new SQL*PLUS session
The output of /u01/gateway/bin/dg4msql is
[oracle@db log]$ /u01/gateway/bin/dg4msql
Oracle Corporation --- WEDNESDAY SEP 11 2013 14:45:06.604
Heterogeneous Agent Release 11.2.0.1.0 - 64bit Production Built with
Oracle Database Gateway for MSSQL
The output of env is
HOSTNAME=db.abc.com.tw
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
ORACLE_UNQNAME=orcl
TMPDIR=/tmp
QTDIR=/usr/lib64/qt-3.3
QTINC=/usr/lib64/qt-3.3/include
USER=oracle
LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib:/lib:/usr/lib
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
ORACLE_SID=orcl
ORACLE_BASE=/u01/app/oracle
ORACLE_HOSTNAME=db.abc.com.tw
MAIL=/var/spool/mail/oracle
PATH=/u01/app/oracle/product/11.2.0/dbhome_1/bin:/usr/sbin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin
PWD=/home/oracle
LANG=en_US.UTF-8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HISTCONTROL=ignoredups
SHLVL=1
HOME=/home/oracle
TMP=/tmp
LOGNAME=oracle
QTLIB=/usr/lib64/qt-3.3/lib
CVS_RSH=ssh
CLASSPATH=/u01/app/oracle/product/11.2.0/dbhome_1/jlib:/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/jlib
LESSOPEN=|/usr/bin/lesspipe.sh %s
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
G_BROKEN_FILENAMES=1
_=/bin/env -
ORA-6571 ERROR (PACKAGE PRAGMA의 사용)
제품 : SQL*PLUS
작성날짜 : 1997-06-03
* ORA-6571 Error ( Package Pragma 의 사용 )
=============================================
SQL문 안에서 Stored function을 call하여 사용하는 경우 ORA-6571 error가
발생할 수 있습니다. 기본적으로 stored function이나 procedure, package에서의
DML 문장의 사용은 보장이 되는 기능이나, sql list에서의 stored function의
사용은 몇 가지 제약 조건을 가지고 수행이 가능합니다.
아래의 자료는 ORA-6571 error가 발생하는 원인에 대하여 기술한 자료이며,
stored function을 SQL EXPRESSION에서 사용하는 경우에 대해서만 적용이 되는
사항입니다.
Calling Stored Functions from SQL Expressions
Stored function은 data dictionary에 저장이 되는 user defined pl/sql
function을 의미하며, 하나의 database object로서 해당 database에 connect하는
application에 의해서도 reference될 수 있습니다.
Function에는 2가지 유형이 제공되고 있는데, package 형태(pl/sql package 내
에서 defined된 function)와, standalone function(독립적인 function)이 있
습니다.
pl/sql version 2.0까지는 stored function을 call하는 부분이 procedural
statement에서만 사용이 가능하였으나, pl/sql version 2.1부터는 sql 문 안에서
도 stored function을 call하여 사용이 가능하게 되었습니다.
2.1 version 이상의 pl/sql engine에서는 select 문이나 values, set, where,
start with, group by, having, order by 등과 같은 sql expression에서
function을 call하여 사용하실 수 있습니다.
즉, user-defined function을 built-in sql function(round, length,
months_between ...)과 같은 형태로 사용이 가능하도록 지원이 됩니다.
이러한 sql 문의 확장 지원은 oracle server 내에서 보다 복잡한 data에 대한
분석 작업을 용이하게 하며 data independency를 증가시킵니다.
Sql expression의 내부에서 사용이 되는 function과는 다르게 stored procedure는
statement로서만 call되며 sql expression에서 direct로 call될 수 없습니다.
Calling Syntax
stored function을 sql expression에서 call하고자 하는 경우에는 다음의 syntax
를 사용하시면 됩니다.
[schema.][package.]function[@dblink][(arg[, arg] ...)]
argument를 넘기는 경우에는 positional notation을 사용하여 작업을 수행하셔야
합니다.
Remote oracle database에 있는 standalone function gross_pay를 call하는
경우를 예로 들어보면 아래와 같이 기술할수 있습니다.
SELECT gross_pay@newyork(eenum, stime, otime) INTO pay FROM dual;
Using Default Values
Stored function gross_pay가 DEFAULT 절을 사용하여 2개의 formal parameter를
넘기는 경우의 function creation은 아래와 같이 기술됩니다.
CREATE FUNCTION gross_pay
(emp_id IN NUMBER,
st_hrs IN NUMBER DEFAULT 40,
ot_hrs IN NUMBER DEFAULT 0) RETURN
NUMBER AS
Procedural statement에서 gross_pay function을 call하는 경우에는 항상
st_hrs의 default 값을 accept할 수 있으며, 이는 named notation을 사용하기
때문에 가능합니다.
그러나, sql expression에서는 ot_hrs의 default값을 accept하지 않는다면,
st_hrs의 default값을 accept할 수 없으며, 이는 named notation을 sql
expression에서는 사용할 수 없기 때문입니다.
/* Named Notation */
IF gross_pay(eenum, ot_hrs => otime) > pay_limit THEN . . .
Meeting Basic Requirements
sql expression에서 call 할 수 있는 user-defined pl/sql function은
아래의 기본 조건을 만족하여야 합니다.
1. Stored function이여야 합니다.
pl/sql block이나 subprogram 내에 define된 function은 사용할 수 없습니다.
2. Row function이여야 하며, column (group) function이여서는 안됩니다.
이는 argument로 전체 column의 data를 사용할 수 없기 때문입니다.
3. Function의 모든 formal parameter는 반드시 IN parameter이여야 합니다.
OUT이나 IN OUT parameter는 사용될 수 없습니다.
4. Formal parameter의 datatype은 oracle server internal type (CHAR,
DATE, NUMBER)이어야 합니다.
pl/sql type(BOOLEAN, RECORD, TABLE)은 사용할 수 없습니다.
5. Return type도 반드시 oracle server internal type이여야 합니다.
아래의 stored function은 상기의 조건을 모두 만족하는 function입니다.
CREATE FUNCTION gross_pay
(emp_id IN NUMBER,
st_hrs IN NUMBER DEFAULT 40,
ot_hrs IN NUMBER DEFAULT 0) RETURN NUMBER
AS
st_rate NUMBER;
ot_rate NUMBER;
BEGIN
SELECT srate, orate INTO st_rate, ot_rate
FROM payroll
WHERE acctno = emp_id;
RETURN st_hrs * st_rate + ot_hrs * ot_rate;
END gross_pay;
Controlling Side Effects
Sql 문에서 call되는 stored function을 실행하기 위하여, oracle server는
해당 function의 purity level(function이 side effect로 부터 free한 영역)을
알고 있어야만 합니다.
Side effect는 database table이나 packaged variable에 대한 reference를
의미합니다.
Side effect는 query의 parallelization을 제한할 수 있는데, 이유는
order-dependent한 결과(indeterminate result)나 user session간에 지속적인
값을 유지(not allowed)하는 package state가 요구되는 경우가 발생하기 때문입
니다.
그러므로, 아래에 기술되는 사항은 sql expression에서 call되는 stored
function에 적용되어야 합니다.
1. Function은 database table을 modify해서는 안된다.
(insert, update, delete statement를 사용할 수 없다.)
2. Remote나 parallelized function은 packaged variable의 값을 읽거나
쓸 수(read or write) 없다.
3. Select, values, set 절에서 call되는 function만이 packaged variable의
값을 write할 수 있다.
4. Function은 앞에 기술된 rules를 어기는 또 다른 subprogram을 call할 수 없다.
마찬가지로 앞에 기술된 rule을 어기는 view를 reference할 수 없습니다.
(Oracle은 view에 대한 reference를 function call을 포함하는 stored SELECT
operation 으로 대체합니다.)
Standalone function에 대하여 oracle은 function body를 checking함으로써,
이러한 rule이 적용되도록 합니다.
그러나, package에 대해서는 packaged function body는 hidden이 되며,
package specification만이 visible하기 때문에, specification 부분에
pragma(compiler directive) RESTRICT_REFERENCES를 기술하여야 합니다.
Pragma는 pl/sql compiler에게 database table이나 packaged variable에
대하여 read/write access를 하지 않는다는 것을 기술합니다.
Function body를 compile하는 도중 pragma에 위반되는 내용이 있다면,
compilation error가 발생합니다.
Calling Packaged Functions
Sql expression에서 packaged function을 call하기 위해서는, package
specification에서 pragma RESTRICT_REFERENCES를 기술함으로써 purity level을
선언하여야 합니다.
Pragma는 function declaration 이후에 기술되어야 하는 사항이며, 주어진
function에 대하여 단지 한 pragma만이 기술될 수 있습니다.
Pragma RESTRICT_REFERENCES를 기술하는 syntax는 아래와 같습니다.
PRAGMA RESTRICT_REFERENCES
(function_name, WNDS [, WNPS] [, RNDS] [,RNPS]);
WNDS means "writes no database state" (does not modify db tables)
WNPS means "writes no package state" (does not change the values of
packaged variables)
RNDS means "reads no database state" (does not query database tables)
RNPS means "reads no package state" (does not reference the values of
packaged variables)
어떤 순서로든 기술된 argument를 passing할 수 있으며, WNDS는 반드시
pass되어야 합니다.
아래의 예는 maximum purity level을 선언한 packaged function이며,
database나 package state에 대하여 read나 write를 전혀 수행하지 않는
function입니다.
CREATE PACKAGE finance AS -- package specification
FUNCTION compound
(years IN NUMBER,
amount IN NUMBER,
rate IN NUMBER )
RETURN NUMBER;
PRAGMA RESTRICT_REFERENCES(compound, WNDS, WNPS, RNDS, RNPS);
END finance;
CREATE PACKAGE BODY finance AS -- package body
FUNCTION compound
(years IN NUMBER,
amount IN NUMBER,
rate IN NUMBER)
RETURN NUMBER IS
BEGIN
RETURN amount * POWER((rate/100) + 1, years);
END compound;
-- no pragma in package body
END finance;
이후에 pl/sql block에서 compound function을 call하는 경우에는 아래와
같이 기술될 수 있습니다.
BEGIN
SELECT finance.compound(yrs, amt, rte) -- function call
INTO interest FROM accounts WHERE acctno = acct_id;
Package는 initialization part를 가질 수 있으며, 이는 package body에는
hidden됩니다.
일반적으로 initialization part는 public variable에 대한 initialize
statement를 기술하게 되며, 아래의 예에서는 prime_rate 이라는 public
variable에 대한 예가 기술되어 있습니다.
CREATE PACKAGE loans AS
prime_rate REAL; -- public packaged variable
END loans;
CREATE PACKAGE BODY loans AS
BEGIN -- initialization part
SELECT prime INTO prime_rate FROM rates;
END loans;
Initialization code는 package가 처음 reference되는 경우에 단지 한번만
수행이 되며, 자신의 것이 아닌 database state나 package state를 read나
write를 하게 되면, side effect의 원인이 될 수 있습니다. 더 나아가
package를 reference하는 stored function은 indirect하게 side effect를
발생시킬 수 있습니다. 그러므로, pragma RESTRICT_REFERENCES를 사용하여
initialization code에 대한 purity level을 명시적으로 선언을 하거나
암시해줄 수 있어야 합니다.
Initialization code에 대한 Purity level을 선언하기 위하여, pragma를
사용하여 작업을 하실 수 있으며, function name을 package name으로
대체하여 기술하시면 됩니다.
Package specification 부분에 기술되는 pragma는 다른 user들에게도
open되어 있는 것이기 때문에, package를 reference 하는 user들은
restriction에 대한 사항을 보게 되며, 해당하는 제약 사항을 따르게 됩니다.
사용되는 syntax는 다음과 같습니다.
PRAGMA RESTRICT_REFERENCES (
package_name, WNDS [, WNPS] [, RNDS] [, RNPS]);
Argument의 의미는 앞에서 기술된 사항과 동일합니다.
아래의 예에서 보면, initialization code는 database state에 대한 read와
package state에 대한 write를 수행합니다. 그러나 WNPS를 선언할 수 있는데
이는 자기 자신의 package state만을 write하는 code이기 때문에 선언이 될
수 있습니다.
만약 public variable prime_rate이 다른 package에 포함되어 있는
것이라면, WNPS는 선언될 수 없습니다.
CREATE PACKAGE loans AS
PRAGMA RESTRICT_REFERENCES (loans, WNDS, WNPS, RNPS);
prime_rate REAL;
END loans;
CREATE PACKAGE BODY loans AS
BEGIN
SELECT prime INTO prime_rate FROM rates;
END loans;
Pragma를 인식함으로 해서 oracle은 initialization code의 purity level을
알 수 있습니다.
( pragma에 의하여 선언된 rule을 위배하여 생성될 수 없기 때문 )
Avoiding Problems
Sql expression에서 packaged function을 call하기 위해서는 pragma
RESTRICT_REFERENCES를 사용하여 function의 purity level을 선언하여야
합니다.
그러나 package가 initialization part를 가지고 있다면, pl/sql
compiler는 function에 허용되는 가장 높은 purity level을 선언하도록
허용하지 않습니다. 결과적으로 function을 remote에서 수행하거나,
parallel하게 또는 sql 절에서 사용할 수 없도록 제한됩니다.
이러한 사항은 packaged function이 package initialization code보다
purity level이 더 높은 경우에 발생하며, 기억하여야 할 것은,
package가 처음 reference되는 때에 initialization code가 실행된다는
사항입니다. 처음 reference하는 것이 function call인 경우,
initialization code에 의하여 부가적인 side effect가 발생하는
원인이 됩니다.
이러한 사항은 initialization code가 function의 purity level보다
낮은 경우에 발생하는 사항입니다.
이러한 문제를 해결하기 위해서는 package initialization code를
subprogram으로 옮겨
주어야 합니다. 이러한 방식으로 변경하는 경우에는 package가 reference
되는 중에 implicitly하게 code를 run하지 않고 explicitly하게 code를
run하게 되며, 이는 packaged function에 영향을 주지 않습니다.
Name Precedence
database column과 argument를 가지지 않는 function이 동일한 이름을
가진다면, sql문안에서 database column이 우선순위를 가지게 됩니다.
CREATE TABLE stats (rand_num NUMBER, . . .);
CREATE FUNCTION rand_num
RETURN NUMBER AS . . . .
위와 같은 상황에서 아래의 sql문을 사용하는 경우 column rand_num을
참조하게 됩니다.
SELECT rand_num INTO start_val FROM stats WHERE . . .
이 경우 stored function rand_num을 사용하기 위해서는 schema를
기술해주어야 합니다.
SELECT scott.rand_num INTO start_val FROM stats WHERE . . .
Overloading
Pl/sql에서는 packaged function에 대해서 overload를 허용합니다.
(standalone은 허용되지 않음) 다시 말하면 넘겨주는 argument가 갯수나,
순서, datatype등이 다르다면, 서로 다른 function에 대해서도 동일한
이름을 사용할 수 있습니다.
그러나 RESTRICT_REFERENCES pragma는 단지 한 function에 대해서만
적용이 되며, 가장 가까운 곳에 선언된 function에 대하여 적용이 됩니다.
아래의 예에서는 두번째 function에 pragma 선언이 적용됩니다.
CREATE PACKAGE tests AS
FUNCTION valid ( x NUMBER)
RETURN CHAR;
FUNCTION valid ( x DATE)
RETURN CHAR;
PRAGMA RESTRICT_REFERENCES (valid, WNDS);You will need to investigate/resolve these errors first before making a decision
2 . ORA-00406: COMPATIBLE parameter needs to be 11.0.0.0.0 or greater ORA-00722:
1 . ORA-00722: Feature "Virtual columns" ORA-06512: at line 31
1 . ORA-00722: Feature "Virtual columns" ORA-06512: at line 43
1 . ORA-06512: at line 31
1 . ORA-06512: at line 43 -
Does RULE hint cause ORA-01555 errors ?
DB Version:9.2.0.5.0
OS:SunOS 5.9
Our DBA is saying that the RULE hint in the below SQL might be causing ORA-01555 error. Is it true? Does RULE hint cause ORA-01555 errors
SELECT /*+ RULE */ COUNT(*)
FROM ( SELECT /*+ RULE */ DISTINCT CAR_HDR.CAR_NBR AS A1, CAR_HDR.PLT_ID AS A29,
CAR_HDR.PKT_CTRL_NBR AS A2, CAR_HDR.TOTAL_QTY AS A21, CAR_HDR.STAT_CODE AS A6,
CAR_HDR.CURR_LOCN_ID AS A12,
CAR_HDR.CAR_NBR AS A145,
CAR_HDR.WN_NBR AS A4, CAR_HDR.PCALL_NBR AS A7, CAR_HDR.CHAIN_CNT AS A119,
CAR_HDR.SHPMT_NBR AS A35, LPN_HDR.WHSE AS A105, CAR_HDR.MISC_CAR AS A146, '' AS A138,
CAR_HDR.CHUTE_ID AS A132, CAR_HDR.MOD_DATE_TIME AS A82, LPN_HDR.LOCN_CLASS AS A106,
LPN_HDR.AREA AS A107, LPN_HDR.ZONE AS A108, LPN_HDR.AISLE AS A109, LPN_HDR.BAY AS A110,
LPN_HDR.LVL AS A111, LPN_HDR.POSN AS A112
FROM INV_MASTER , CAR_DTL , LPN_HDR , CAR_HDR
WHERE CAR_HDR.CAR_NBR=CAR_DTL.CAR_NBR(+)
AND CAR_HDR.CURR_LOCN_ID=LPN_HDR.LOCN_ID(+)
AND CAR_HDR.WHSE=LPN_HDR.WHSE(+)
AND CAR_DTL.SKU_ID=INV_MASTER.SKU_ID(+)
AND CAR_HDR.CT_SEQ = 'ALB10'
AND INV_MASTER.INV_CODE = 98
AND INV_MASTER.TRACK_CODE = 'P10' )
user636669 wrote:
DB Version:9.2.0.5.0
OS:SunOS 5.9
Our DBA is saying that the RULE hint in the below SQL might be causing ORA-01555 error. Is it true? Does RULE hint cause ORA-01555 errorsThe full statement is causing the ORA-01555 error. Each line of the statement is important therefore each line is reponsible for the error. I personally think the DISTINCT keyword has a bigger influence than the RULE hint.
I suggest to check what you want to do with that count result. maybe there are better ways to get the same result. Maybe you can even ignore the distinct keyword or remove some outer joins. Using the CBO might result in the same plan as using the RBO, so you you will never know if that removing the hint will help or if if you'll get the same problem later again. -
I'm trying to write a PL/SQL function to dynamically return a query with varying # of columns. I've done this type of thing before wiith much success, however this is the first time I'm using a cursor for loop within a function to accomplish my task.
here is the error I get:
ORA-01858: a non-numeric character was found where a numeric was expected
Error ERR-1101 Unable to process function body returning query.
Mind you I have tested the PL/SQL from a SQL editor and it works fine. I'm confused.
Code is below.
Thanks in advance!
DECLARE
my_query varchar2(4000);
string1 varchar2(50) := 'select city, ';
string2 varchar2(4000) := '' ;
string3 varchar2(4000):= 'from
( select a.title, a.city, a.start_date, sum(a.total_stu) cnt
from sj_class_summary3 a
group by a.title, a.city, a.start_date
having a.title = :P4_COURSE )
group by title, city';
TYPE date_tab_type IS TABLE OF date INDEX BY PLS_INTEGER;
date_tbl date_tab_type;
i number;
BEGIN
i:=1;
for myrec in (select distinct start_date from sj_class_summary3
where start_date between :P4_START_DATE and :P4_END_DATE order by 1) loop
date_tbl(i) := myrec.start_date;
string2 := string2 || ' max( decode( start_date, ''' || date_tbl(i) || ''', cnt,0) ) "' || date_tbl(i) || '", ';
i := i+ 1;
end loop;
string2 := SUBSTR(string2,1,LENGTH(string2)-2);
string2 := string2 || ' ';
my_query := string1 || string2 || string3;
return my_query;
END;Hi Bob,
you also have another date to character to date conversion in:
decode( start_date, ''' || date_tbl(i) || ''', cnt,0)
does this need to be:
decode( start_date, to_date(''' || to_char(date_tbl(i), 'dd/mm/yyyy') || ''', ''dd/mm/yyyy''), cnt,0)
Regards
Michael -
Ora-00604:error occurred at recursive SQL level 1 and Ora-04023
hi all
i am using oracle linux 5.5 and oracle Database 11g R2 while shutingdown the database i am getting
the following errors.
SQL> shutdown immediate;
Ora-00604:error occurred at recursive SQL level 1
Ora-04023: object select count(*) from reg$SQL>plz can anyone help me out?Couple of questions related to this issue:
1.Is there anything in alert log. Post last 50 lines from alert log.
2.Is there any trace / log generated by Oracle ?
3.What is Memory_Target parameter value ?
4.What is value of statistics_level parameter ?
5.Did you perform any failed upgradation ?
6.Are there any invalid objects in database ?
Generally ORA-00604 is related to insufficient size of shared pool. Now, i am googling how to get a proper value of shared pool size ? I got that there is a view v$shared_pool_advice which will tell me the answer of this question. Ok, it means now question is how do i get the proper value of shared pool from v$shared_pool_advice; i mean how do i interpret this v$shared_pool_advice view ?
No problem docs are there to answer this question : (How i got this link ? Open a new page---http://tahiti.oracle.com---selected 11.2 docs--in the left hand sided there is a search text box i entered v$shared_pool_advice and i got couple of links)
http://download.oracle.com/docs/cd/E11882_01/server.112/e17110/dynviews_3037.htm#REFRN30239
I will read these links and now i will query this and DBA_HIST_SHARED_POOL_ADVICE views, interpret the values. Ok, but what about my original question i.e. ORA-00604 and 4023 ? If i am at this stage, understood all the values, it means now i can understand the meaning / sense of resizing of shared pool.
ALTER SYSTEM SET statistics_level=TYPICAL SCOPE=SPFILE;
You can monitor V$SGA_RESIZE_OPS to identify the range of values that Oracle is automatically resizing the DB_CACHE_SIZE and SHARED_POOL_SIZE components to. Then, pick an appropriate minimum value based on the range. There's no "magic formula". But V$SGA_RESIZE_OPS shows the sizes that Oracle has been automatically been resizing the SGA components to. The Buffer Cache Advisory section of the AWR report or V$DB_CACHE_ADVICE, V$SHARED_POOL_ADVICE, V$SGA_TARGET_ADVICE and DBA_HIST_SGA_TARGET_ADVICE are views that provide advisory information as well. Hemant @ SGA_MAX_SIZE and SGA_TARGET how to set minimum for pools
So, these are the baby steps if i ever gets ORA-00604 and ORA-04023 on my test database. Do all these and feel free to post the next doubt, i am sure you will get the correct answer.
Regards
Girish Sharma -
ORA-00604:error occurred at recursive SQL level string
Hi all,
Oracle Version :- 11.2.0.2
I found a error in a trigger(Statement Level)
ORA-00604:error occurred at recursive SQL level string.
Before Finding this issue,Once the DB Response was slow . Will this be the issue Of DB Slow response. The Above trigger fires for each entry in an transaction table.
The code is Patched and was executed . The above issue was found during another issue and not the DB Slow response.
My Doubt is Whether DB response slow issuewould be because of this. Now after fixing this Slow response was not reported.
Your inputs are highly appreciated.it helps if you can post the complete stack of error messages (I'm suspecting you have several more messages than just ORA-00604).
A cut-n-paste of the SQL*Plus session with the SQL statement and the error message(s) below would give the info as to what the actual problem is.
Do you have INSERT priv. on that table? Are you doing this from within a stored procedure or at SQL prompt? -
ORA-01858: a non-numeric character was found where a numeric was expected
hi ,
This was the code which shows the sales rep invoice amount and collected amount but while running report thru concurrent program its showing the following error:
ORA-01858: a non-numeric character was found where a numeric was expected
WHERE TO_CHAR ( TO_DATE ( PS.GL_DATE , 'DD/MON/YY' ) , 'MON-YYYY' ) BETWEEN TO_CHAR ( TO_DATE ( : ==> P_todate , 'YYYY/MM/DD' ) , 'MON-YYYY' ) AND TO_CHAR ( TO_DATE ( : P_todate , 'YYYY/MM/DD' ) , 'MON-YYYY' ) AND ps.customer_id = cust.custome
The Actual Code was this
SELECT SUBSTR(SALES.name,1,50) salesrep_name_inv,
--ps.CLASS,
SUM(ABS(ps.acctd_amount_due_remaining)) acctd_amt,
SUM(ABS(ps.amount_due_remaining)) amt_due_remaining_inv,
SUM(ABS(ps.amount_adjusted)) amount_adjusted_inv,
SUM(ABS(ps.amount_applied)) amount_applied_inv,
SUM(ABS(ps.amount_credited)) amount_credited_inv,
SALES.salesrep_id,
NULL "REMARKS"
-- ps.gl_date gl_date_inv,
FROM ra_cust_trx_types ctt,
ra_customers cust,
ar_payment_schedules ps,
ra_salesreps SALES,
ra_site_uses site,
ra_addresses addr,
ra_cust_trx_line_gl_dist gld,
gl_code_combinations c,
ra_customer_trx ct
WHERE TO_CHAR(TO_DATE(PS.GL_DATE,'DD/MON/YY'),'MON-YYYY')
BETWEEN TO_CHAR(TO_DATE(:P_todate,'YYYY/MM/DD'),'MON-YYYY') AND TO_CHAR(TO_DATE(:P_todate,'YYYY/MM/DD'),'MON-YYYY')
AND ps.customer_id = cust.customer_id
AND ps.customer_trx_id = ct.customer_trx_id
AND ps.cust_trx_type_id = ctt.cust_trx_type_id
AND NVL(ct.primary_salesrep_id, -3) = SALES.salesrep_id
AND ps.customer_site_use_id+0 = site.site_use_id(+)
AND site.address_id = addr.address_id(+)
AND TO_CHAR(TO_DATE(PS.GL_DATE_CLOSED,'DD/MON/YY'),'MON-YYYY')
BETWEEN TO_CHAR(TO_DATE(:P_todate,'YYYY/MM/DD'),'MON-YYYY') AND TO_CHAR(TO_DATE(:P_todate,'YYYY/MM/DD'),'MON-YYYY')
--AND ps.gl_date_closed > TO_DATE(:P_todate,'MON-YYYY')
AND ct.customer_trx_id = gld.customer_trx_id
AND gld.account_class = 'REC'
AND gld.latest_rec_flag = 'Y'
AND gld.code_combination_id = c.code_combination_id
AND sales.salesrep_id is not null and sales.name is not null
-- and ps.payment_schedule_id+0 < 9999
-- AND SALES.salesrep_id ='1001'
GROUP BY SALES.name,
--ps.CLASS,
SALES.salesrep_idSo to_date function accepts a string as input and returns a date. When a date is input instead, it is implicity converted to the required type of the function paremeter, which is a string, so that to_date can convert it back to a date again.
If you are lucky with the implicit conversion, you get the same date back, if you are not you might get a different date or an error.
From your query it appears that this conversion from a date, to a string, to a date, and then back to a string using to_char this time, is being done to remove the time or day part of the date. The actual range comparison is being done on strings rather than dates, which is dangerous as strings sort differently than dates.
In this example if I sort by date, Jan 01 comes between Dec 00 and Feb 01 as you would expect.
SQL> select * from t order by d;
D
12-01-2000
01-01-2001
02-01-2001When converted to strings, Feb 01 comes between Dec 00 and Jan 01, which is probably not the desired result
SQL> select * from t order by to_char(d,'DD-MON-YY');
D
12-01-2000
02-01-2001
01-01-2001If you want to remove time and day parts of dates you should use the trunc function
trunc(d) removes the time, trunc(d,'mm') will remove the days to start of month.
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/functions201.htm#i79761 -
Oracle error - ociexecute(): OCIStmtExecute: ORA-01858
Using PHP 4.3.11 on Linux and ADODB data abstraction library.
Oracle client version is 10.1.
Can sucessfully connect to remote database (version 9.2.0.6 NLS_LANG AL32UTF8).
When doing a simple select from a view:
select RTS_LOAD from VW_R_PROJECTED_LOAD_OUTPUT
I get the error message:
ociexecute(): OCIStmtExecute: ORA-01858: a non-numeric character was found where a numeric was expected in /opt/devftp/var/www/php/adodb/461/drivers/adodb-oci8.inc.php on line 942
1858: ORA-01858: a non-numeric character was found where a numeric was expected
If in my PHP script I directly query the underlying table that this Oracle view is based on, I have no problem.
Using SQLPlus on the web server I don't have any problems at all selecting from the view, it is definitely a valid view.
Any clues? If so please email as well as posting response here.
Geoff
[email protected]Hi !
I think Your view has to_date function in its definition, and this to_date is called without second parameter: date format. Probably NLS_DATE_FORMAT is set to different values in SQL*Plus and PHP environment. You can check it out by running
select * from v$nls_parameters;
in SQL*Plus and in PHP.
If there are two different values You should modify view to use to_date in form: to_date(some_date_string, poroper_date_format)
Regards,
Pawel
Maybe you are looking for
-
Having TWO problems with my iPod mini.
I've had my ipod mini for a year and a half. I only ever use it 2-3 times a week for 30 mins at a time at the gym, and sometimes in the car. Already I'm having two problems. Problem #1- Battery. I've noticed alot of other people on here seem to be ha
-
Update set of books in implementation options ??
we are doing project setup[ in one of the test instance , How ever while doing thta in implementation options set of books is saved incorrectly and now it is freezed (not able to change the set of books field) ..Navigation setup -->system-->implement
-
Hi, I am living in South Korea and have a 3gs with the latest software (4.2). I am using a 500mb data plan a month but have the option to upgrade / change to unlimited data plan for a slight increase in monthly fees. I was told by my telecom company
-
Touchscreen and trackpad won't work after installing new OS
i want to ask why that after i upgraded my os, and during the start up when i have to scroll down the aggrements text my trackpad and my touchscreen won't work. is that any way to solve this problem? i beg you to answer my question please. i would b
-
Error installing Application Express 3.1.2 on oracle 11g
Hi I was trying to install APEX on Oracle 11g. Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production PL/SQL Release 11.1.0.6.0 - Production CORE 11.1.0.6.0 Production TNS for Linux: Version 11.1.0.6.0 - Production NLSRTL Version 11.1