PL/SQL Function Returning Query Error / ORA-01858: a non-numeric char.....
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
Similar Messages
-
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 -
Ora-01858 a non numeric found where numeric was found
Hello All,
When I am trying to query a view i am getting the follwoing error.
ora-01858 a non numeric found where numeric was found
When checked in all_objects the view status is showing as VALLID.
Please let me know how do we come over this error.
Kind Regards.I can think of two options:
1-Create the view with the same datatype as the underlying column, then in your application handle the logic of conversion
2-Keep the view with the same datatypes, but use a function that takes the value in the column as IN paramter and returns the date. Add exception handling to ignore the exception when a non-date value is encoutered
Regards
AK -
I'm trying to pull data from an Oracle database using SSIS. When I try to select a few fields from the source table, it returns the following error message:
[OLE DB Source [47]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14.
An OLE DB record is available. Source: "OraOLEDB" Hresult: 0x80040E14 Description: "ORA-01858: a non-numeric character was found where a numeric was expected".
An OLE DB record is available. Source: "OraOLEDB" Hresult: 0x80004005 Description: "ORA-01858: a non-numeric character was found where a numeric was expected".
The source columns are a combination of numeric and texts, and I've also tried selecting one of them, which didn't work. I'm using the Oracle client 11.2.0.1, and it works fine with any other data sources I have connected to so far. How can I resolve this
error?Hi H.James,
According to your description, the issue is a non-numeric character was found where a numeric was expected while pulling data from an Oracle database in SSIS.
Based on the error message, the issue should be you are comparing a number column to a non-number column in a query. Such as the query below (ConfID is a number, Sdate is a date):
where C.ConfID in (select C.Sdate
from Conference_C C
where C.Sdate < '1-July-12')
Besides, a default behavior for the Oracle OleDb Provider that change the NLS Date Format of the session to 'YYYY-MM-DD HH24:MI:SS can also cause the issue. For more details about this issue, please refer to the following blog:
http://blogs.msdn.com/b/dataaccesstechnologies/archive/2012/01/20/every-bug-is-a-microsoft-bug-until-proven-otherwise.aspx
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
ORA-01858: a non-numeric character found where a digit was expected
Hi,
I'll cut introductions short. We're trying to read data from a flat file (OWB ver.9.2. by the way). After successfully mapping, then generating (with two insignificant warnings), we execute.
Although it says the execution was 'successful', more than a dozen errors return in the form of ORA-01858: a non-numeric character found where a digit was expected
a - Here is the error:
Record 1: Rejected - Error on table "TOPSSTAGE"."FLTR_DCS_IRREG", column "OPERATIVE_FLIGHT_LEG_DATE".
ORA-01858: a non-numeric character was found where a numeric was expected
*it's actually repeated 20 times (Record 1, Record 2, and so on and so forth...) with the same exact error description and details.
b - Here's the part of the OWB-generated script that defines the creation of that field/column:
"OPERATIVE_FLIGHT_LEG_DATE" DATE "mm/dd/yyyy"
c - And here's the data from the flat file (1 of 4 rows)
"2/20/2007","I","0899","N","TPE","MNL","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","750","950","746","955"," P3231",,"04","32","32",,,,,,,,"758","946",,"A000","4","D000","5","000","0","0","0","0","D","P","0","0","0","0","0","0","0","0","0","0","0","2/22/2007","000","012","144","2/20/2007","2/20/2007"
*the part where it is in bold is the one that is mapped from the column OPERATIVE_FLIGHT_LEG_DATE to the OPERATIVE_FLIGHT_LEG_DATE column (flat to physical, right?)
it is set as DATE in all settings (mapping, file, etc..)
Any form of help will be greatly appreciated :)
Thanks!
Regards,
_lilimHi Bharadwaj,
Yes, I believe you are right. And yes that column is designated a primary key. The weird thing is, we do have null values being entered into the table from the flat file, but these values are far from the "OPERATIVE_FLIGHT_LEG_DATE" column (index-wise). Let me give you an example of our case:
this is a row in the flat file: (sample data only)
"2/20/2007","I","0899","N","TPE","MNL","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","750","950","746","955"," P3231",,"04","32","32",,,,,,,,"758","946",,"A000","4","D000","5","000","0","0","0","0","D","P","0","0","0","0","0","0","0","0","0","0","0","2/22/2007","000","012","144","2/20/2007","2/20/2007"
as you can see, I've made the 'null' values bold, as well as the data for OPERATIVE_FLIGHT_LEG_DATE (which shows up, as you can see, at the end of the row).
Now, in the OWB table, the OPERATIVE_FLIGHT_LEG_DATE column is set as a primary key (or foreign, i think, I'll check again) and, thus, is set as one of those columns to first receive data transferred from the flat file.
We see nothing wrong with our mask (which is mm/dd/yyyy by the way) as well as with our data type settings. It has to be with the flat file I guess. We're gonna try putting in dummy values in place of the null ones in the flat file. I'll get back to you asap. Thanks for helping out. :D
Regards,
_lilim -
JDBCaccess message ORA-01858: a non-numeric character was found where a num
When trying to read a cloumn from a table using JDBC I get the above message
Below is a copy of the code;
Connection conn=null;
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
System.out.println ("Driver registered"); // Print Driver Connected
try
{ // <-- 1.1
conn = DriverManager.getConnection("jdbc:oracle:thin:@***.******.**:1521:orcl", "********", "*******");
// @machineName:port:SID, userid, password
} // <-- 1.1
catch (SQLException exc_1)
{ // <-- 1.1
//System.out.println("SQL Connect failed with: '" + exc_1.getMessage() + "'");
exc_1.printStackTrace();
System.exit(1);
} //<-- 1.1
System.out.println ("Connected - User/Password"); // Print Connected User/Password
Statement stmt = conn.createStatement();
System.out.println ("Instansiate SQL Statement "); // Print Instansiate
String sql = "select BASE_CURRENCY_CODE from WH_ENT_MODEL.V_FX_DAILY_RATES ";
try
oracle.jdbc.driver.OracleLog.startLogging();
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
oracle.jdbc.driver.OracleLog.stopLogging();
System.out.println ("Create SQL Statement resultset "); // Print SQL Statement
while (rs.next())
System.out.println (rs.getString("BASE_CURRENCY_CODE")); // Print Base_Currency_Code
stmt.close();
catch(Exception e)
e.printStackTrace();
System.exit(1);
The error I get is;
java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:153)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:330)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:287)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:742)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:215)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:930)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1131)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:983)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1257)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3467)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3512)
at com.exchange.interfaces.dbAccess.main(dbAccess.java:69)
This is a test class to prove we can access the database from within Java program.
Any help much appreciated.Hi Deepak,
I would first look at your session state, this should show what was passed to the procedure.
I would suggest that if you have a select list showing a null value that that would be the issue as it passes %null% through.
Regards
Michael -
ORA-01858: a non-numeric at OracleConnectionPoolDataSource
I have OracleConnectionPoolDataSource. When I run my JSP , I am getting error
java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
Error line is showing at OracleConnectionPoolDataSource ocpds = new OracleConnectionPoolDataSource();
What could be the reason?
Thanks in advanceselect to_date('ERROR')
ERROR at line 1:
ORA-01858: a non-numeric character was found where a numeric was expectedPlease see (OERR: ORA 1858 "a non-numeric character was found where a numeric was expected" [ID 19182.1]).
Thanks,
Hussein -
Plugin with PL SQL function returning query
Hi all,
I have created plugin using SQL query many times. But can we create a plugin from scratch using PL SQL function returning SQL query? Any ideas or sample.
Thanks
Sunil BhatiaHi Scott,
By this i mean, i have created a region type plugin for integrating jqx Grid into oracle apex. This takes input parameter as SQL statement, and creates jqx grid for me on page. Now my question is, can i do this using PL SQL function returning SQL, because when i try to give return statement, plugin gives error "SQL statement mandatory'. I hope i am clear enough now.
Thanks
Sunil Bhatia -
Pl/sql function returning query - syntax question
Hi,
I'm trying to figure out the syntax for the following query:
BEGIN
RETURN 'select name from table1 where name like '%' || :p1_name';
END;
It doesn't work because of the single-quotes around the % sign, plus the quotes for the query itself. How can I handle the % sign quotes? Any suggestions would be appreciated!
Thanks,
NoraNora,
If you want to use quotes within a quoted string, you have to duplicate the quotes.
BEGIN
RETURN 'select name from table1 where name like ''%'' || :p1_name';
END;
Fred. -
National Language Support and Error ORA-01858
Hi,
I have a problem using NLS.
When I use NLS for Italian,I become the error ORA-01858 -->
"a non-numeric character was found where a numeric was
expected".
But with the same query I use for NLS_Italian,it works with
NLS_German and NLS_English.
I use this date-formats "DD.Month YYYY" , "DD.MM.YYYY", "DD.MM"
For example:
Select to_char(sd.Datum,'DD.Month YYYY') Datum ,
sd.FONDSVERMOEGEN, sd.AKTIEN, sd.KASSE, sd.RENTEN,sd.FUTURES,
sd.WERTPAPIERE, sd.IMMOBILIEN,
sd.KUPON, sd.DURCHSCHNITT_RENDITE, sd.DURCHSCHNITT_RL from
Strukturdaten sd,fondsdaten_allgemein fd
where sd.match=fd.match and sd.match=amfcomm .
Can somebody help me??Can you tell us what the value of sd.Datum is in the queries?
-
Nationnal Language Support and Error ORA-01858
Hi,
I have a problem using NLS.
When I use NLS for Italian,I become the error ORA-01858 -->
"a non-numeric character was found where a numeric was expected".
But with the same query I use for NLS_Italian,it works with
NLS_German and NLS_English.
I use this date-formats "DD.Month YYYY" , "DD.MM.YYYY", "DD.MM"
For example:
Select to_char(sd.Datum,'DD.Month YYYY') Datum ,
sd.FONDSVERMOEGEN, sd.AKTIEN, sd.KASSE, sd.RENTEN,sd.FUTURES,
sd.WERTPAPIERE, sd.IMMOBILIEN,
sd.KUPON, sd.DURCHSCHNITT_RENDITE, sd.DURCHSCHNITT_RL from
Strukturdaten sd,fondsdaten_allgemein fd
where sd.match=fd.match and sd.match=amfcomm .
Can somebody help me??Can you tell us what the value of sd.Datum is in the queries?
-
ORA-06503: PL/SQL: Function returned without value
Hello
Having a bit of a problem with piplined functions.
Why does this work :
SET SERVEROUTPUT ON
DECLARE
TYPE SARRAY IS TABLE OF VARCHAR2(4000);
CURSOR CU IS SELECT * FROM DX_XML_ATTENDANCE WHERE STUD_ID = 107777 AND BASE_ID = 94;
T_STUD NUMBER(10);
T_BASE NUMBER(10);
T_DATE DATE;
T_MARKS VARCHAR2(1000);
LEN_MARKS NUMBER;
PDATE DATE;
SDATE DATE;
EDATE DATE;
SLEN NUMBER;
WEEKLEN NUMBER;
INIPOS NUMBER;
MARRAY VARCHAR2(1000);
SUBARRAY SARRAY := SARRAY();
SFILL VARCHAR2(14) := '--------------';
EPOS NUMBER;
MY_REC DX_XML_ATTENDANCE%ROWTYPE;
BEGIN
SUBARRAY.EXTEND(17);
DBMS_OUTPUT.ENABLE(100000000);
--FOR MY_REC IN CU
OPEN CU;
LOOP
FETCH CU INTO MY_REC;
EXIT WHEN (CU%NOTFOUND);
T_STUD := MY_REC.STUD_ID;
T_BASE := MY_REC.BASE_ID;
T_DATE := TO_DATE(MY_REC.START_DATE, 'DD/MM/YYYY');
T_MARKS := MY_REC.MARKS;
LEN_MARKS := LENGTH(T_MARKS);
EPOS := LEN_MARKS / 2;
SDATE := ROUND(TO_DATE(T_DATE), 'W') - 1;
INIPOS := TO_NUMBER(TO_CHAR(T_DATE, 'D'));
SLEN := INIPOS + 3;
PDATE := SDATE;
EDATE := SDATE + EPOS;
MARRAY := SUBSTR(T_MARKS, 1, SLEN);
WEEKLEN := LENGTH(MARRAY);
IF WEEKLEN < 14 THEN
MARRAY := SUBSTR(SFILL, 1, 14 - WEEKLEN) || MARRAY;
END IF;
SUBARRAY(1) := T_STUD;
SUBARRAY(2) := T_BASE;
SUBARRAY(3) := PDATE;
FOR i IN 4 .. 17 LOOP
SUBARRAY(i) := SUBSTR(MARRAY, i - 3, 1);
END LOOP;
DBMS_OUTPUT.PUT_LINE(SUBARRAY(1)||' '||SUBARRAY(2)||' '||SUBARRAY(3)||' '||SUBARRAY(4)||' '||
SUBARRAY(5)||' '||SUBARRAY(6)||' '||SUBARRAY(7)||' '||SUBARRAY(8)||' '||SUBARRAY(9)||' '||
SUBARRAY(10)||' '||SUBARRAY(11)||' '||SUBARRAY(12)||' '||SUBARRAY(13)||' '||SUBARRAY(14)||' '||
SUBARRAY(15)||' '||SUBARRAY(16)||' '||SUBARRAY(17));
WHILE PDATE < EDATE LOOP
PDATE := PDATE + 7;
MARRAY := SUBSTR(T_MARKS, SLEN + 1, 14);
WEEKLEN := LENGTH(MARRAY);
IF WEEKLEN < 14 THEN
MARRAY := MARRAY || SUBSTR(SFILL, 1, 14 - WEEKLEN);
END IF;
FOR i IN 4 .. 17 LOOP
SUBARRAY(i) := SUBSTR(MARRAY, i - 3, 1);
END LOOP;
SUBARRAY(3) := PDATE;
DBMS_OUTPUT.PUT_LINE(SUBARRAY(1)||' '||SUBARRAY(2)||' '||SUBARRAY(3)||' '||SUBARRAY(4)||' '||
SUBARRAY(5)||' '||SUBARRAY(6)||' '||SUBARRAY(7)||' '||SUBARRAY(8)||' '||SUBARRAY(9)||' '||
SUBARRAY(10)||' '||SUBARRAY(11)||' '||SUBARRAY(12)||' '||SUBARRAY(13)||' '||SUBARRAY(14)||' '||
SUBARRAY(15)||' '||SUBARRAY(16)||' '||SUBARRAY(17));
PDATE := PDATE + 7;
SLEN := SLEN + 14;
END LOOP;
END LOOP;
END;
and this does not :
CREATE OR REPLACE PACKAGE BODY PARSE_ATTENDANCE AS
FUNCTION ENUM_MARKS(SEL_SQL IN VARCHAR2)
RETURN TMP_ATT_DATA_TBL PIPELINED
IS
V_SQL VARCHAR(1000):= SEL_SQL;
V_CURSOR SYS_REFCURSOR;
V_ROW TMP_ATT_HOLDING:=TMP_ATT_HOLDING(NULL, NULL, NULL, NULL);
T_STUD NUMBER(10);
T_BASE NUMBER(10);
T_DATE DATE;
T_MARKS VARCHAR2(1000);
LEN_MARKS NUMBER;
PDATE DATE;
SDATE DATE;
EDATE DATE;
SLEN NUMBER;
WEEKLEN NUMBER;
INIPOS NUMBER;
MARRAY VARCHAR2(1000);
SUBARRAY SARRAY := SARRAY();
SFILL VARCHAR2(14) := '--------------';
EPOS NUMBER;
BEGIN
SUBARRAY.EXTEND(17);
OPEN V_CURSOR FOR V_SQL;
LOOP
FETCH V_CURSOR INTO V_ROW.STUD_ID, V_ROW.BASE_ID, V_ROW.START_DATE, V_ROW.MARKS;
EXIT WHEN V_CURSOR%NOTFOUND;
T_STUD := V_ROW.STUD_ID;
T_BASE := V_ROW.BASE_ID;
T_DATE := TO_DATE(V_ROW.START_DATE, 'DD/MM/YYYY');
T_MARKS := V_ROW.MARKS;
LEN_MARKS := LENGTH(T_MARKS);
EPOS := LEN_MARKS / 2;
SDATE := ROUND(TO_DATE(T_DATE), 'W') - 1;
INIPOS := TO_NUMBER(TO_CHAR(T_DATE, 'D'));
SLEN := INIPOS + 3;
PDATE := SDATE;
EDATE := SDATE + EPOS;
MARRAY := SUBSTR(T_MARKS, 1, SLEN);
WEEKLEN := LENGTH(MARRAY);
IF WEEKLEN < 14 THEN
MARRAY := SUBSTR(SFILL, 1, 14 - WEEKLEN) || MARRAY;
END IF;
SUBARRAY(1) := T_STUD;
SUBARRAY(2) := T_BASE;
SUBARRAY(3) := PDATE;
FOR i IN 4 .. 17 LOOP
SUBARRAY(i) := SUBSTR(MARRAY, i - 3, 1);
END LOOP;
PIPE ROW(TMP_ATT_DATA_OBJ(SUBARRAY(1),SUBARRAY(2),SUBARRAY(3),SUBARRAY(4),
SUBARRAY(5),SUBARRAY(6),SUBARRAY(7),SUBARRAY(8),SUBARRAY(9),
SUBARRAY(10),SUBARRAY(11),SUBARRAY(12),SUBARRAY(13),SUBARRAY(14),
SUBARRAY(15),SUBARRAY(16),SUBARRAY(17)));
WHILE PDATE < EDATE LOOP
PDATE := PDATE + 7;
MARRAY := SUBSTR(T_MARKS, SLEN + 1, 14);
WEEKLEN := LENGTH(MARRAY);
IF WEEKLEN < 14 THEN
MARRAY := MARRAY || SUBSTR(SFILL, 1, 14 - WEEKLEN);
END IF;
FOR i IN 4 .. 17 LOOP
SUBARRAY(i) := SUBSTR(MARRAY, i - 3, 1);
END LOOP;
SUBARRAY(3) := PDATE;
PIPE ROW(TMP_ATT_DATA_OBJ(SUBARRAY(1),SUBARRAY(2),SUBARRAY(3),SUBARRAY(4),
SUBARRAY(5),SUBARRAY(6),SUBARRAY(7),SUBARRAY(8),SUBARRAY(9),
SUBARRAY(10),SUBARRAY(11),SUBARRAY(12),SUBARRAY(13),SUBARRAY(14),
SUBARRAY(15),SUBARRAY(16),SUBARRAY(17)));
PDATE := PDATE + 7;
SLEN := SLEN + 14;
END LOOP;
END LOOP;
END ENUM_MARKS;
END PARSE_ATTENDANCE;
(This is then called like SELECT * FROM
TABLE(
PARSE_ATTENDANCE.ENUM_MARKS(
'SELECT STUD_ID, BASE_ID, START_DATE, MARKS
FROM DX_XML_ATTENDANCE WHERE STUD_ID = 107777
AND BASE_ID = 94'))
I get the same error, around this section near the bottom :
PDATE := PDATE + 7;
SLEN := SLEN + 14;
Can any one help?Here is an example. you are missing an return statement.
SQL> create or replace type varchar2_table is table of varchar2(10) ;
2 /
Type created.
SQL> show errors
No errors.
SQL> create or replace function get_data return varchar2_table pipelined is
2 begin
3 pipe row(('Test')) ;
4 end ;
5 /
Function created.
SQL> show errors
No errors.
SQL> select * from table(get_data) ;
ERROR:
ORA-06503: PL/SQL: Function returned without value
ORA-06512: at "KKISHORE.GET_DATA", line 3
no rows selected
SQL> create or replace function get_data return varchar2_table pipelined is
2 begin
3 pipe row(('Test')) ;
4 return ;
5 end ;
6 /
Function created.
SQL> show errors
No errors.
SQL> select * from table(get_data) ;
COLUMN_VAL
Test
SQL> -
ORA 28817 PLSQL function returned an error . when Access instance apex 4 2
Hello,
I have just upgraded from apex 4.1 to apex 4.2. Everything is fine except for this error that I get when I try to access Instance Setting on the Admin App (localhost/apex/apex_admin)
ORA-28817: PL/SQL function returned an errorWhat could be the problem ?? How can we fix it ..
I am working on Win server 2012 machine .. apex 4.2 with apex listener 2 deployed on Glassfish 3.1.2.
Best Regards,
FatehHello Fateh,
we are already aware of that problem, although it is not yet present on our Known Issues webpage. The reason for this error is that the new installation overwrites an instance-wide encryption key. Values in the instance preferences that were encrypted with the old value (the SMTP password and the wallet password) are invalid after the upgrade and decryption causes this error. As a work around, you can use the apex_instance_admin package to overwrite the invalid passwords.
The following code shows how decryption throws ORA-28817:
SYS@a411> select apex_instance_admin.get_parameter('SMTP_PASSWORD') from dual;
select apex_instance_admin.get_parameter('SMTP_PASSWORD') from dual
ERROR at line 1:
ORA-28817: PL/SQL function returned an error.
ORA-06512: at "SYS.DBMS_CRYPTO_FFI", line 67
ORA-06512: at "SYS.DBMS_CRYPTO", line 44
ORA-06512: at "APEX_040200.WWV_FLOW_CRYPTO", line 89
ORA-06512: at "APEX_040200.WWV_FLOW_INSTANCE_ADMIN", line 239You can fix this by entering new passwords:
SYS@a411> exec apex_instance_admin.set_parameter('SMTP_PASSWORD','my smtp password');
PL/SQL procedure successfully completed.
SYS@a411> exec apex_instance_admin.set_parameter('WALLET_PWD','my wallet password');
PL/SQL procedure successfully completed.
SYS@a411> select apex_instance_admin.get_parameter('SMTP_PASSWORD') from dual;
APEX_INSTANCE_ADMIN.GET_PARAMETER('SMTP_PASSWORD')
my smtp password
1 row selected.Regards,
Christian -
Procedure Erroring: ORA-01858
Hello: Here is the call stack from SQL Plus (9i):
ORA-06512: at "SYS.CALLHIST_CSV", line 147
ORA-01858: a non-numeric character was found where a numeric was expected
ORA-06512: at line 1
I have another procedure similar that runs well. I tried isolating the issue by running the sql solo and the query returns fine but when run in this procedure it errors. Originally I didn't have all the NVL and CAST. I did that to try to compensate for the error plus I need the output file to be in unicode.Thanks!
These are the field types that I thought to look out for (the others are varchars):
NUMBER DATE
CUSTOMER_ID SHIP_DATE
SEQNO STAUS_DATE_TIME
INSTALLER_ID CREATION_DATE
ESCALATION_ID COMPLETION_DATE
PROBLEM_ID
SUBJECT_ID
STATUS_ID
REASON_ID
RESOLUTION_ID
CLASS_ID
CREATE OR REPLACE PROCEDURE CALLHIST_CSV
IS
CURSOR c_data IS
SELECT /*+ USE_HASH ( a b) */
CAST(to_char(NVL(b.start_date_time,'08-MAR-68'),'DD-MON-YY') AS nvarchar2(20)) As actualstart,
CAST(NVL(a.model_desc,' ') As nvarchar2(150)) As ModelDesc, CAST(c.customer_id As nvarchar2(25)) As CustomerID,
CAST(NVL(b.call_id,' ')As nvarchar2(25)) As CallID, CAST(NVL(c.model_number,' ') AS nvarchar2(100)) As ModelNumber,
CAST(NVL(c.date_code,' ')As nvarchar2(20)) As DateCode,
CAST(NVL(c.date_of_purchase,' ') As nvarchar2(20)) As DatePurchased,
CAST(to_char(NVL(o.completion_date,'08-MAR-68'),'DD-MON-YY')As nvarchar2(20)) As actualend,
CAST(NVL(o.order_status,' ') As nvarchar2(1)) As OrderStatus,
CAST(NVL(f.subject_desc,' ') As nvarchar2(150)) As subject, CAST(NVL(g.problem_desc,' ') As nvarchar2(150)) As kategory,
CAST(NVL(h.resolution_desc,' ') As nvarchar2(150)) As Resolution,
CAST(NVL(i.reason_desc,' ') As nvarchar2(150)) As Reason,
decode(e.notes, null, '', 'AGENT NOTES: ' || e.notes) || ' ' || decode(q.notes, null, '', 'QP NOTES: ' || q.notes) As Notes,
CAST(NVL(j.escalation_id, 0) As nvarchar2(2)) as EscalationID,
CAST(NVL(j.escalation_desc, ' ') As nvarchar2(150))as EscalationDesc,
CAST(NVL(k.agent_id,' ') As nvarchar2(25)) As ownerid, CAST(NVL(k.first_name,' ') As nvarchar2(30)) As AgentFirstName,
CAST(NVL(k.last_name,' ') As nvarchar2(50)) As AgentLastName
FROM GENIECS.model a, GENIECS.contact_record b,
GENIECS.product_record c, GENIECS.warranty d,
GENIECS.call_detail e, GENIECS.subject f,
GENIECS.problem g, GENIECS.resolution h, GENIECS.reason i,
GENIECS.escalation j, GENIECS.agent k,
GENIECS.order_record o, GENIECS.qa q
WHERE b.customer_id < 1000
AND b.customer_id = c.customer_id
AND b.model_id = c.model_number
AND b.seqno = c.seqno
AND c.model_number = a.model_number
AND d.model_number = a.model_number
AND e.call_id = b.call_id
AND e.subject_id = f.subject_id
AND e.problem_id = g.problem_id
AND e.resolution_id = h.resolution_id
AND i.reason_id(+) = e.reason_id
AND j.escalation_id(+) = b.escalation_id
AND b.agent_id = k.agent_id
AND b.call_id=o.call_id(+)
AND o.order_id=q.order_id(+)
ORDER BY c.customer_id;
v_file UTL_FILE.FILE_TYPE;
BEGIN
-- | WRITE CONTENTS OF THE LOB TO A FILE |
-- The maximum line length that can be written is 32K in 9i.
v_file := UTL_FILE.FOPEN(location => 'EXTRACT_DIR',
filename => 'callhist_csv.csv',
open_mode => 'w',
max_linesize => 32767);
FOR cur_rec IN c_data LOOP
UTL_FILE.PUT_LINE(v_file,
cur_rec.actualstart || '|' ||
cur_rec.ModelDesc || '|' ||
cur_rec.CustomerID || '|' ||
cur_rec.CallID || '|' ||
cur_rec.ModelNumber || '|' ||
cur_rec.DateCode || '|' ||
cur_rec.DatePurchased || '|' ||
cur_rec.actualend || '|' ||
cur_rec.OrderStatus || '|' ||
cur_rec.subject || '|' ||
cur_rec.kategory || '|' ||
cur_rec.Resolution || '|' ||
cur_rec.Reason || '|' ||
cur_rec.Notes || '|' ||
cur_rec.EscalationID || '|' ||
cur_rec.EscalationDesc || '|' ||
cur_rec.ownerid || '|' ||
cur_rec.AgentFirstName || '|' ||
cur_rec.AgentLastName);
END LOOP;
UTL_FILE.FCLOSE(v_file);
EXCEPTION
WHEN UTL_FILE.INVALID_PATH THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20000, 'File location is invalid.',True);
WHEN UTL_FILE.INVALID_MODE THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20001, 'The open_mode parameter in FOPEN is invalid.',True);
WHEN UTL_FILE.INVALID_FILEHANDLE THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20002, 'File handle is invalid.',True);
WHEN UTL_FILE.INVALID_OPERATION THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20003, 'File could not be opened or operated on as requested.',True);
WHEN UTL_FILE.READ_ERROR THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20004, 'Operating system error occurred during the read operation.',True);
WHEN UTL_FILE.WRITE_ERROR THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20005, 'Operating system error occurred during the write operation.',True);
WHEN UTL_FILE.INTERNAL_ERROR THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20006, 'Unspecified PL/SQL error.',True);
WHEN UTL_FILE.CHARSETMISMATCH THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20007, 'A file is opened using FOPEN_NCHAR, but later I/O ' ||
'operations use nonchar functions such as PUTF or GET_LINE.',True);
WHEN UTL_FILE.FILE_OPEN THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20008, 'The requested operation failed because the file is open.',True);
WHEN UTL_FILE.INVALID_MAXLINESIZE THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20009, 'The MAX_LINESIZE value for FOPEN() is invalid; it should ' ||
'be within the range 1 to 32767.',True);
WHEN UTL_FILE.INVALID_FILENAME THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20010, 'The filename parameter is invalid.',True);
WHEN UTL_FILE.ACCESS_DENIED THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20011, 'Permission to access to the file location is denied.',True);
WHEN UTL_FILE.INVALID_OFFSET THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20012, 'The ABSOLUTE_OFFSET parameter for FSEEK() is invalid; ' ||
'it should be greater than 0 and less than the total ' ||
'number of bytes in the file.',True);
WHEN UTL_FILE.DELETE_FAILED THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20013, 'The requested file delete operation failed.',True);
WHEN UTL_FILE.RENAME_FAILED THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20014, 'The requested file rename operation failed.',True);
WHEN OTHERS THEN
UTL_FILE.FCLOSE(v_file);
RAISE_APPLICATION_ERROR(-20015, 'Error.',True);
-- reraise the current exception
--RAISE;
END;sorry wrong forum
-
Column order in SQL Query (PL/SQL function returning a query)
Hi,
when I define a PL/SQL function returning a query inside a region, I often find that the column order is arbitrarily changed.
How do I enforce the column order ?
Bye,
FlavioI removed the 11th column called service_name from this dynamic query: and now the report says: report error:
ORA-01403: no data found. I messed around with the Headiuns Type. It was set to Custom. I changed it to Column Names. There is no difference.
I am not sure how to fix?
declare topqry varchar2(32000);
whereqry varchar2(32000);
finalqry varchar2(32000);
var_status varchar2(100);
division_status varchar2(50);
office_status varchar2(1000);
user_status varchar2(1000);
overdue_status varchar2(1000);
begin
if :P10_FALLBACK = 'All' then
var_status:= ' and vp.status in (''FA'',''FBA'',''FBI'',''25%'',''50%'',''90%'',''Closed'') ';
elsif :P10_FALLBACK = 'Active' then
var_status:= ' and vp.status in (''FA'',''25%'',''50%'',''90%'',''FBA'') ';
elsif :P10_FALLBACK = 'FB' then
var_status:= ' and vp.status in (''FBA'',''FBI'') ';
elsif :P10_FALLBACK = 'Closed' then
var_status:= ' and vp.status in (''Closed'') ';
elsif :P10_FALLBACK = 'Inactive' then
var_status:= ' and vp.status in (''FBI'') ';
end if;
if :P10_DIVISION = 'All' then
division_status:= ' and vp.vms_division in (''News'',''Ad Services'') ';
elsif :P10_DIVISION = 'News' then
division_status:= ' and vp.vms_division in (''News'') ';
elsif :P10_DIVISION = 'Ad' then
division_status:= ' and vp.vms_division in (''Ad Services'') ';
end if;
if :P10_OFFICE = '%' then
office_status:= ' and OFFICE_ID in (select office
from VMS_OFFICE_ACCESS
where user_id = lower(:P0_user) ) ';
else
office_status:= ' and OFFICE_ID in :P10_OFFICE ';
end if;
if :P10_LIMIT_USER = '%' then
user_status := ' and SALESPERSON in (select first_name || '' '' || last_name
from VMS_PROSPECT_users u
join vms_office_access o
on u.office_id = OFFICE
where o.user_id = lower(:P0_USER) ) ';
else
user_status:= ' and SALESPERSON in (:P10_LIMIT_USER ) ';
end if;
if :P10_SHOW_OVERDUE = 'Show' then
overdue_status:= ' and target_close_date <= sysdate ';
var_status:= ' and vp.status in (''25%'',''50%'',''90%'',''FBA'') ';
else
overdue_status:= ' and FIRST_APPOINTMENT between
nvl(to_date(:P10_FIRST_APPT_START, ''mm/dd/yyyy''),FIRST_APPOINTMENT) and
nvl(to_date(:P10_FIRST_APPT_END,''mm/dd/yyyy''),FIRST_APPOINTMENT) ';
end if;
topqry := 'SELECT OFFICE_ID ,vp.PROSPECT_ID ,ENTRY_DATE ,ACCOUNT , NEXT_CONTACT_DATE ,ACTION_STEP ,
TARGET_CLOSE_DATE ,vp.STATUS ,SALESPERSON ,vp.SALES_TYPE ,service_name , FIRST_APPOINTMENT ,MODIFY_DATE ,EST_ANNUAL_REVENUE ,EST_INCREMENTAL_REVENUE ,
pi.NOTES , pi.SALES_TYPE ,pi.STATUS ,Contact ,Origin_Source FROM VMS_PROSPECTING_ITEMS pi right outer join VMS_PROSPECTS vp on vp.PROSPECT_ID = pi.PROSPECT_ID left outer join VMS_SERVICES vs on vs.service_ID = pi.service_ID where 1 = 1 ';
whereqry := ' and (not exists (select *
from VMS_PROSPECTING_ITEMS i3
where vp.prospect_id = i3.prospect_id)
or exists (select *
from VMS_PROSPECTING_ITEMS i2
where i2.order_id = pi.order_id
and active = ''Y'' )) and instr(upper(ACCOUNT),upper(nvl(:P10_ACCOUNT,ACCOUNT))) > 0 ';
whereqry := whereqry || var_status || division_status || office_status || user_status || overdue_status;
finalqry := topqry || whereqry;
return finalqry ;
end;
Maybe you are looking for
-
The earbuds that came with my ipad have never worked. They have sound that comes out of the outside hole of the earbuds. When you put them in your ears no sound can be heard. Has this been a problem or did mine just come broken?
-
How to add images/photos to multiple item entries quickly?
We've got about 10,000 items in our database, and we've got pictures of all of them. We've got all of the items in the Business One database individually, with price and cost and barcode, etc. But we want to add the photo of each one to its respectiv
-
Failed iOS5 update now 3gs stuck in recovery
every time I try to update it in itunes it gives error 37. Has done it on 3 different computers (imac, snow leopard/macbook pro, lion, dell/windows 7). please help!
-
BEx abap query analyzer with wrong port in url adress
Hi Starting TA RSRT you can open ABAP WEB query in separatly browser window. For that an url adress is generated. Normaly it looks like <server>:8000/xxx. One my workstation it works well & fine. In the other hand some of our coleagues get url with a
-
HI all..Please help
HI Gurus, I have 3 radio buttons on the screen in SE80. If the user checks a radio option and clicks the Submit button, table updation will be done in the background and a success message will be displayed. Now, the problem is, once the Submit bu