apparently there are many ora-00904 errors out there, but I can't find similar case with mine.
my case is related to ref() function in oracle: https://docs.oracle.com/cloud/latest/db112/SQLRF/functions145.htm#SQLRF00694
according to the example in the link above, you can query like below without problem:
select ref(x) from some_table x
but what I get is error ora-00904 invalid column name and it highlighted the x in ref(x)
I can't remove the ref() function from my query as it is added automatically by oracle forms.
Anyone have similar experience? is there some settings to set?
BTW, I am using an ancient oracle form 6i on top of oracle 8i
The ref() function is used in conjunction with user defined types; hence the table alias used by the function needs to refer to a table of a user defined type.
Related
I need to mask first and last name. Our requirement is to use the first name only. How can I access the FIRST_NM field when masking the LAST_NM?
LAST_NM=substr(FIRST_NM,1,4)||'LAST'
select T.EE_FIRST_NM, T.EE_LAST_NM from MY_TABLE
Original:
Lakshmanan Ramaswamy
Expected Result:
LaksFIRST LaksLAST
Looks like REMAP_DATA is available from Oracle 11g on. The issue is the REMAP_DATA parameter takes one column as input and a PL/SQL package/function to process that data; so you wouldn't really be able to figure out what first name goes with what last name. There is a good DataPump REMAP_DATA PDF on a sample package & function would work; but it won't solve your problem.
What you could do, depending on your Oracle version, is define a virtual column named LAST_NAME_MASKED on your MY_TABLE that contains a function to do your substr, and then exclude the LAST_NM column from the DataPump export.
I did search for a similar question, but if I overlooked an existing answer I am glad to be redirected there.
I am working to untangle an Oracle Stored Proceedure in a legacy system written by a long departed developer.
The focus of the proceedure is to upload user data into the existing table structure in a bulk collection and save keystroke time adding 1-x-1 records.
The procedure appears to work without error and the user group would like to expand it to allow additional data to load to separate but related tables.
The author is using the NEXTVAL and CURRVAL commands to add primary key information as new records are added using the CSV data.
But I am confused because my understanding of NEXTVAL/CURRVAL was that they required context and declaration to be used correctly.
For example the Proceedure has the following:
SELECT seq_site.nextval INTO v_curr
FROM DUAL;
UPDATE temp_table
SET site_id = seq_site.currval
However [SEQ_SITE] is not declared anywhere in the preceding lines of the Procedure.
Am I inferring correctly that the clause [SELECT seq_site.nextval INTO v_curr] is the declaration for [SEQ_Record_count]?
(...v_curr is declared an integer early in the procedure declarations btw...)
We have a legacy application we cannot modify that connects to Oracle 11g and at some point runs a query and returns a result. The application however is using the "generated" column name from Oracle to read the result.
Consider the following query:
select nvl(1,0.0) from DUAL;
As this query does not specify an alias, the generated column name would be "nvl(1,0.0)"
However on another server the generated column name is "nvl(1,0)" (notice 0 and not 0.0) and the application fails.
Is there a configuration that can be changed for Oracle? I've searched for formatting and locale configurations and they are equal on both servers.
Any help would be appreciated
It turns out there's a parameter called cursor_sharing that was set to FORCE instead of EXACT
select nvl(1,0.0) from DUAL;
The query above returns the following depending on the value of the parameter:
FORCE=NVL(1,0)
EXACT=NVL(1,0.0)
I use in a Java Application JDBC to query the DBMS. The application works correctly with Sql Server but I get this error in DB2 during one insert:
com.ibm.db2.jcc.am.SqlDataException: DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=1, DRIVER=3.63.75
The insert is made using the ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE.
My query is a plain select of the table, then I declare my PreparedStatement, passing the parameters and afterwards with the ResultSet I do first the moveToInsertRow() and then the insertRow().
Do you know if there are any problems with this approach using DB2?
As I told you before the same code works correctly with Sql Server.
SQL Code -302 on DB2 means:
THE VALUE OF INPUT VARIABLE OR PARAMETER NUMBER position-number IS INVALID OR TOO LARGE FOR THE TARGET COLUMN OR THE TARGET VALUE
So it seems like you are trying to insert a value into a column which is too large or too short (e.g. Hello World into a varchar(5)). Probably the column has a different length in DB2 and sql-server or you are inserting different values.
Probably too late to add to this thread.. but someone else might find it useful
Got the same SQL Exception when trying to do a SELECT : didn't realize the property value in WHERE clause was exceeding the limit on the corresponding column
SELECT * FROM <schema>.<table_name> WHERE PropertyName = 'value';
value was a VARCHAR type but exceeded the Length limit
Detailed exception does say it clearly that data integrity was violated: org.springframework.dao.DataIntegrityViolationException
So a good idea would be to do a length check on the value(s) that are being set on the properties before firing any queries to the database.
I have a trouble querying view in Oracle.
Here is the view (my_cool_view) definition:
SELECT *
FROM mview1 JOIN
mview2 USING(col_id)
where mview1 and mview2 is materialized views. I can't access to definition of this materialized views. I've tried this query:
select r.title from my_cool_view r;
and got ORA-00918: column ambiguously defined error. I got this error for subset of columns in my_cool_view.
If I run this query:
select * from my_cool_view;
all works fine.
You are asking about desc my_cool_view in comments, sorry I can't provide schema information because it's confidential. The only I can say it contains about 80 columns, and only one (col_id) don't cause above error.
Do you have any ideas what is the case and how to fix it?
Thanks in advance.
Sorry for misled you, the first version of question was too bad.
You probably have 2 columns called title from different tables/views that you've joined. If you select * then this will work as the duplicate title columns will get a different alias (like TITLE1). When you explicitly ask for one of the title columns the database needs to know which one you want and thus throws the error.
Just make sure that the title columns have a different alias:
select EMP.TITLE EMP_TITLE, DEPT.TITLE DEPT_TITLE
FROM ...