APEX sum different fields on a form - oracle

I want to create a page item display only that sums 2 other page itens on a form.
P1_A is a number field with a mask of currency.
P1_B is a display only field based on a database query that returns a single value.
My P1_C is a display only field that I am trying to use as a source the following query:
select :P1_A+:P1_B from dual;
However, this is my result :
Error computing item source value for page item P1_C.
ORA-01722: número inválido
Technical Info (only visible for developers)
is_internal_error: true
apex_error_code: WWV_FLOW_FORMS.ITEM_SOURCE_ERR
ora_sqlcode: -1722
ora_sqlerrm: ORA-01722: número inválido
component.type: APEX_APPLICATION_PAGE_ITEMS
component.id: 283302822642071708
component.name: P1_C
error_backtrace:
ORA-06512: em "SYS.DBMS_SYS_SQL", line 1942
ORA-06512: em "SYS.WWV_DBMS_SQL", line 1334
ORA-06512: em "SYS.WWV_DBMS_SQL", line 1358
ORA-06512: em "SYS.WWV_DBMS_SQL", line 1375
ORA-06512: em "APEX_040100.WWV_FLOW_DYNAMIC_EXEC", line 776
ORA-06512: em "APEX_040100.WWV_FLOW_FORMS", line 580
I believe it has been caused by the currency format, but I can not remove it. So, what did I miss to avoid this error?

Just convert the text (P1_A) to number when using it in the sum calculations.
Example: TO_NUMBER('$94 567,00', 'L999G999D00', NLS_NUMERIC_CHARACTERS ', ')

Related

ORACLE: Table or View Not found using Semantic Sparql query

On a Windows Server 19 based Oracle 19c Enterprise database, as the EE user, I created a Triple table, a user owned network and user owned model:
CREATE TABLE EE.RDF_WORDNET (TRIPLE MDSYS.SDO_RDF_TRIPLE_S)
COLUMN TRIPLE NOT SUBSTITUTABLE AT ALL LEVELS TABLESPACE USERS
LOGGING COMPRESS NOCACHE PARALLEL MONITORING;
exec sem_apis.create_sem_network('semts', network_owner=>'EE', network_name=>'EE_WordNet' );
exec sem_apis.create_sem_model('wn','RDF_WORDNET','triple', network_owner=>'EE', network_name=>'EE_WordNet');
Then bulk-load in a ton of data from the Princeton Wordnet, which all goes in with out error....and create the entailment
exec SEM_APIS.CREATE_ENTAILMENT('rdfs_rix_wn',
SEM_Models('wn'),
SEM_Rulebases('RDFS'),
network_owner=>'EE',
network_name=>'EE_WordNet');
I can check the tables and all the data looks like its good, and the views/tables created in the network_owner (EE) schema look right, but when I run a SPARQL query as the EE user (network/model owner), I get ORA-00942: table or view does not exist, and I can't figure out what it can't see....
Select *
From Table(Sem_Match('(?s <wn20schema:containsWordSense> ?ws)
( ?ws <wn20schema:word> ?w)
( ?w <wn20schema:lexicalForm> ?l )
( ?s <wn20schema:containsWordSense> ?ws2)
( ?ws2 <wn20schema:word> ?w2)
( ?w2 <wn20schema:lexicalForm> ?l2 )',
Sem_Models('wn'), Null, Null, Null))
Where Upper(L) = Upper('Gold');
Results in:
ORA-00942: table or view does not exist
ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 161
ORA-06512: at "MDSYS.RDF_APIS_INTERNAL", line 8702
ORA-06512: at "MDSYS.S_SDO_RDF_QUERY", line 26
ORA-06512: at "MDSYS.RDF_APIS_INTERNAL", line 8723
ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 144
ORA-06512: at line 4
There are 25 tables created in the EE schema when the model is created:
EE_WORDNET#RDF_CLIQUE$
EE_WORDNET#RDF_COLLISION$
EE_WORDNET#RDF_CRS_URI$
EE_WORDNET#RDF_DELTA$
EE_WORDNET#RDF_GRANT_INFO$
EE_WORDNET#RDF_HIST$
EE_WORDNET#RDF_LINK$
EE_WORDNET#RDF_MODEL$_TBL
EE_WORDNET#RDF_MODEL_INTERNAL$
EE_WORDNET#RDF_NAMESPACE$
EE_WORDNET#RDF_NETWORK_INDEX_INTERNAL$
EE_WORDNET#RDF_PARAMETER
EE_WORDNET#RDF_PRECOMP$
EE_WORDNET#RDF_PRECOMP_DEP$
EE_WORDNET#RDF_PRED_STATS$
EE_WORDNET#RDF_RI_SHAD_2$
EE_WORDNET#RDF_RULE$
EE_WORDNET#RDF_RULEBASE$
EE_WORDNET#RDF_SESSION_EVENT$
EE_WORDNET#RDF_SYSTEM_EVENT$
EE_WORDNET#RDF_TERM_STATS$
EE_WORDNET#RDF_TS$
EE_WORDNET#RDF_VALUE$
EE_WORDNET#RENAMED_APPTAB_RDF_MODEL_ID_1
EE_WORDNET#SEM_INDEXTYPE_METADATA$
and 41 views, including the RDF_WORDNET, which was originally created as the Triple table above...
EE_WORDNET#RDFI_RDFS_RIX_WN
EE_WORDNET#RDFM_WN
EE_WORDNET#RDFR_OWL2EL
EE_WORDNET#RDFR_OWL2RL
EE_WORDNET#RDFR_OWLPRIME
EE_WORDNET#RDFR_OWLSIF
EE_WORDNET#RDFR_RDF
EE_WORDNET#RDFR_RDFS
EE_WORDNET#RDFR_RDFS++
EE_WORDNET#RDFR_SKOSCORE
EE_WORDNET#RDFT_WN
EE_WORDNET#RDF_DTYPE_INDEX_INFO
EE_WORDNET#RDF_MODEL$
EE_WORDNET#RDF_PRIV$
EE_WORDNET#RDF_RULEBASE_INFO
EE_WORDNET#RDF_RULES_INDEX_DATASETS
EE_WORDNET#RDF_RULES_INDEX_INFO
EE_WORDNET#RDF_VMODEL_DATASETS
EE_WORDNET#RDF_VMODEL_INFO
EE_WORDNET#SEMI_RDFS_RIX_WN
EE_WORDNET#SEMM_WN
EE_WORDNET#SEMP_WN
EE_WORDNET#SEMR_OWL2EL
EE_WORDNET#SEMR_OWL2RL
EE_WORDNET#SEMR_OWLPRIME
EE_WORDNET#SEMR_OWLSIF
EE_WORDNET#SEMR_RDF
EE_WORDNET#SEMR_RDFS
EE_WORDNET#SEMR_RDFS++
EE_WORDNET#SEMR_SKOSCORE
EE_WORDNET#SEMT_WN
EE_WORDNET#SEM_DTYPE_INDEX_INFO
EE_WORDNET#SEM_INF_HIST
EE_WORDNET#SEM_MODEL$
EE_WORDNET#SEM_NETWORK_INDEX_INFO
EE_WORDNET#SEM_RULEBASE_INFO
EE_WORDNET#SEM_RULES_INDEX_DATASETS
EE_WORDNET#SEM_RULES_INDEX_INFO
EE_WORDNET#SEM_VMODEL_DATASETS
EE_WORDNET#SEM_VMODEL_INFO
RDF_WORDNET
As a test, I granted Select, Insert, Update to MDSYS on all these tables and views, made no difference...
I might add on an Oracle 12.2 database with a system owned network, and the same data bulk-loaded into the same model, this query returns the expected data, so this has something to do with it being a user owned network...
Any thoughts as to who needs permissions to what for this to work?

ORACLE APEX - Getting download BLOB link working from different table

i am having an issue with downloading blob stored in table ORDERSIN from report that is based on table ORDERS. I am able to make it work if I create a report from table where the file is stored with no issues.
My report SQL
SELECT j.ID,
m.ITEMNUMBER||' : '||m.NAME as NAZEV,
c.CUSTOMERNAME AS ZAKAZNIK,
dbms_lob.getlength("DOCUMENTS") PDF_OPEN,
j.EXPEDITIONDATE AS EXPEDICE,
o.ID AS OBJEDNAVKA,
j.STATE AS STAV,
j.AMOUNTEXPEDITED AS EXPEDOVANO,
j.UNITPRICE AS CENA,
j.RECIEPT AS DODAK,
j.ORDEREDAMOUNT AS OBJEDNANO,
j.INVOICENR
FROM JOBS j
LEFT JOIN MASTERITEMS m ON j.MASTERITEM_ID = m.ID
LEFT JOIN CUSTOMERS c ON m.CUSTOMER_ID = c.ID
LEFT JOIN ORDERSIN o ON j.ORDERSIN_ID = o.ID
If I execute the page and set the column PDF_OPEN as download blob type it properly shows the download link in report but upon clicking if returns:
Technical Info (only visible for developers)
is_internal_error: true
apex_error_code: APEX.UNHANDLED_ERROR
ora_sqlcode: 100
ora_sqlerrm: ORA-01403: no data found ORA-06512: at "APEX_200200.WWV_FLOW_CODE_EXEC_PLSQL", line 124 ORA-06512: at "APEX_200200.WWV_FLOW_DYNAMIC_EXEC", line 2301 ORA-06512: at line 1 ORA-06512: at "SYS.DBMS_SYS_SQL", line 2120 ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_200200", line 679 ORA-06512: at "APEX_200200.WWV_FLOW_DYNAMIC_EXEC", line 2262 ORA-06512: at "APEX_200200.WWV_FLOW_CODE_EXEC_PLSQL", line 96 ORA-06512: at "APEX_200200.WWV_FLOW_CODE_EXEC_PLSQL", line 301 ORA-06512: at "APEX_200200.WWV_FLOW_CODE_EXEC", line 340 ORA-06512: at "APEX_200200.WWV_FLOW_DML", line 1922
component.type: APEX_APPLICATION_PAGES
component.id: 100000000034
error_backtrace:
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_SYS_SQL", line 2120
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_200200", line 679
ORA-06512: at "APEX_200200.WWV_FLOW_DYNAMIC_EXEC", line 2262
ORA-06512: at "APEX_200200.WWV_FLOW_CODE_EXEC_PLSQL", line 124
ORA-06512: at "APEX_200200.WWV_FLOW_DYNAMIC_EXEC", line 2301
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_SYS_SQL", line 2120
ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_200200", line 679
ORA-06512: at "APEX_200200.WWV_FLOW_DYNAMIC_EXEC", line 2262
ORA-06512: at "APEX_200200.WWV_FLOW_CODE_EXEC_PLSQL", line 96
ORA-06512: at "APEX_200200.WWV_FLOW_CODE_EXEC_PLSQL", line 301
ORA-06512: at "APEX_200200.WWV_FLOW_CODE_EXEC", line 340
ORA-06512: at "APEX_200200.WWV_FLOW_DML", line 1922
ORA-06512: at "APEX_200200.WWV_FLOW_DML", line 2475
error_statement:
begin begin select "DOCUMENTS" into wwv_flow.g_dml_blob from "ORDERSIN" where "ID" = :b1; end;
end;
Can someone help? My guess is that there is no information on what table this is referring to: dbms_lob.getlength("DOCUMENTS") PDF_OPEN
Thank you
Jakub

Oracle LPAD() function

Question: For every part description that begins with the letter “b”, list the part description, and then pad each part description with a “+”on the left side so that all these part descriptions are 15 characters in length.
And I wrote like
SELECT
LENGTH(PART_PART_DESCRIPTION), LPAD(PART_PART_DESCRIPTION,15,'+'),
PART_PART_DESCRIPTION, CONCAT('+', PART_PART_DESCRIPTION) FROM PART
WHERE SUBSTR(PART_PART_DESCRIPTION,1,1)='B'
but the output doesn't show 15 of '+' on left side.
Here is the output table
Your column PART_PART_DESCRIPTION is of CHAR data type with 285 data length. so BLENDER in your column has a total 285 (7 + 278 trailing spaces) length. that is why you are facing the problem.
See this:
SQL> select LPAD(CAST('BLENDER' AS CHAR(285)),15,'+') FROM DUAL;
LPAD(CAST('BLENDER'ASCHAR(285)),15,'+')
------------------------------------------------------------
BLENDER
SQL> select LPAD('BLENDER',15,'+') FROM DUAL;
LPAD('BLENDER',
---------------
++++++++BLENDER
SQL>
You need to use TRIM to properly use the LPAD on CHAR datatype column Something like the following:
LPAD(trim(PART_PART_DESCRIPTION),15,'+')
Most probably your data is padded with spaces. Try this
SELECT
LENGTH(PART_PART_DESCRIPTION), LPAD(TRIM(PART_PART_DESCRIPTION),15,'+'),
PART_PART_DESCRIPTION, CONCAT('+', PART_PART_DESCRIPTION) FROM PART
WHERE SUBSTR(PART_PART_DESCRIPTION,1,1)='B'

how to paste numbers with thousand separator from excel to sqldeveloper table editor

There's data exported to excel:
MS_ID STARTDATETIME
3 704 285 09.11.2014 11:29:25
3 704 285 09.11.2014 11:29:25
I want to paste it back to Oracle using sqldeveloper table data editor.
For date column I do
alter session set NLS_DATE_FORMAT = 'mm.dd.yyyy HH24:mi:ss';
But I'm also getting:
INSERT INTO "PPB"."CDRGPRS" (MS_ID, STARTDATETIME) VALUES ('3 704 285', TO_DATE('09.11.2014 11:29:25', 'mm.dd.yyyy HH24:mi:ss'))
ORA-01722: invalid number
ORA-06512: at line 1
The SQL above is generated by sqldeveloper.
There's no NLS_NUMBER_FORMAT. How to make Oracle format and parse numbers with spaces as thousand separator?
TO_NUMBER() allows you to specify whatever separators you want using nls_numeric_characters.
SQL> select to_number( '100 123,23'
2 , '999G999G999D99'
3 , 'nls_numeric_characters = '', '''
4 ) as no
5 from dual;
NO
----------
100123.23
G is the number format model corresponding to the separator, which is the second option of your nls_numeric_characters.
If you want to convert it into a number improperly you can REPLACE() the spaces:
SQL> select to_number(replace( '100 12323', ' ')) as no
2 from dual;
NO
--------
10012323
Wrote this macro and put it to Personal.xlsb
Sub nospace()
Application.FindFormat.NumberFormat = "#,##0"
Application.ReplaceFormat.NumberFormat = "0"
Cells.Replace What:="", Replacement:="", _
SearchFormat:=True, ReplaceFormat:=True
End Sub

Oracle java exception when trying to use NVL()

I have the following SQL statement in Oracle that is giving me some headache. I am trying to return an empty geometry if the value held in the Oracle table is null however it simply fails with the following error:
The Error
*
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.NullPointerException ORA-06512: at "MDSYS.SDO_UTIL", line
2421 ORA-06512: at "MDSYS.SDO_UTIL", line 2443 ORA-06512: at
"MDSYS.SDO_GEOMETRY", line 36
*
The Code
select CLUSTER_ID,
NUM_POINTS,
FEATURE_PK,
A.CELL_CENTROID.SDO_POINT.X,
A.CELL_CENTROID.SDO_POINT.Y,
A.CLUSTER_CENTROID.SDO_POINT.X,
A.CLUSTER_CENTROID.SDO_POINT.Y,
TO_CHAR (A.CLUSTER_EXTENT.GET_WKT ()),
TO_CHAR (A.CELL_GEOM.GET_WKT ()),
A.CLUSTER_EXTENT.SDO_SRID,
TPHS_PHASE_ID
from (SELECT CLUSTER_ID,
NUM_POINTS,
FEATURE_PK,
SDO_CS.transform (CLUSTER_CENTROID, 4326) cluster_centroid,
SDO_CS.TRANSFORM(NVL(CLUSTER_EXTENT, MDSYS.SDO_GEOMETRY(2001,4326 ,MDSYS.SDO_POINT_TYPE(NULL,NULL,NULL),NULL,NULL)),4326) CLUSTER_EXTENT ,
SDO_CS.transform (CELL_CENTROID, 4326) cell_centroid, CELL_GEOM FROM
V_CLUSTER_1000M) a
LEFT JOIN RWOL_TMA_ROADWORKS
ON a.FEATURE_PK = RWOL_TMA_ROADWORKS.TPHS_PHASE_ID
where sdo_filter( A.CELL_GEOM, SDO_CS.transform(mdsys.sdo_geometry(2003,4326, NULL, mdsys.sdo_elem_info_array(1,1003,3),mdsys.sdo_ordinate_array(-25.43623984375,44.257784519021, 21.62918984375, 60.752403080295)),81989)) = 'TRUE'
Anybody got any idea what is going wrong here? I am no Oracle dev so any help is appreciated as well as an explanation.
The problem here was caused by the line
TO_CHAR (A.CLUSTER_EXTENT.GET_WKT ()),
This line is attempting to get a well known text item from the returned column and because we do not supply a valid one it is failing. Strange error really.

Resources