Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

inconsistent datatypes: expected - got CHAR, Detail view bind variables

vannaJan 28 2013 — edited Feb 1 2013
Hi.
Here is my problem:
I have master detail views connected with a view link. Both of views have bind variables that hold some session info:
It's a menu on database and I am trying to hide some values based on user permissions.
When running application module, everything works fine. The problem occurs when I try to show menu as a tree table, or any other table, on a page.
The root view executes fine, but then I get an
"java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent datatypes: expected - got CHAR"
error in executeQueryForCollection method of detail view. (this method is overridden)

Bind Variables are:
- :menuRoot -> which holds value of Root node. (In detail view it's just a dummy variable. It is explaned later on why i used it.)
- :listOfUserPermmission -> array of user permissions.

My query looks like this:

1.Master View:
SELECT MetVMenu.CHILD_ID, 
       MetVMenu.CHILD_IME_MODULA, 
       MetVMenu.PARENT_ID, 
       MetVMenu.PARENT_IME_MODULA, 
       MetVMenu.ZST, 
       MetVMenu.NIVO, 
       MetVMenu.CHILD_NAZIV_V_MENIJU, 
       MetVMenu.CHILD_TIP_MODULA, 
       MetVMenu.CHILD_OPIS_MODULA
FROM MET_V_MENU MetVMenu
WHERE MetVMenu.PARENT_IME_MODULA like :menuRoot
and MetVMenu.CHILD_IME_MODULA in (SELECT * FROM TABLE(CAST(:listOfUserPermission AS STRARRAY)))
CHILD_IME_MODULA and PARENT_IME_MODULA are also names of permissions.

2.View Link that connects master.CHILD_ID and detail PARENT_ID

3.Detail view, that then links to itself... to get the tree menu.
SELECT MetVMenu.CHILD_ID, 
       MetVMenu.CHILD_IME_MODULA, 
       MetVMenu.PARENT_ID, 
       MetVMenu.PARENT_IME_MODULA, 
       MetVMenu.ZST, 
       MetVMenu.NIVO, 
       MetVMenu.CHILD_NAZIV_V_MENIJU, 
       MetVMenu.CHILD_TIP_MODULA, 
       MetVMenu.CHILD_OPIS_MODULA
FROM MET_V_MENU MetVMenu
WHERE :menuRoot like 'a'
and
MetVMenu.CHILD_IME_MODULA in (SELECT * FROM TABLE(CAST(:listOfUserPermission AS STRARRAY)))
4. ViewLink that connects CHILD_ID and PARENT_ID of this "detail" view.

Both views executeQuery methods are overridden to set Bind variables before execution.
I get an arrayList of strings (permissions) from session and then convert it to Array.

ArrayList permmissionsArray = (ArrayList)MyUserSession.getSessionValue("permissions");
	Array permissions = new Array(permissionsArray.toArray());
        HashMap context = new HashMap();
        context.put(DomainContext.ELEMENT_SQL_NAME, "STRARRAY");
        context.put(DomainContext.ELEMENT_TYPE, String.class);
        
        if(permissions != null){
            permissions.setContext(null, null, context);
            setlistOfUserPermission(permissions);
        }
	//Here I set menuRoot variable.
	
I also noticed that there are problems with how I define bind variables (the order matters).
So when i didn't use menuRoot variable in detail view I got the
“inconsistent datatypes: expected - got CHAR"
error in application module.
This post has been answered by vanna on Feb 1 2013
Jump to Answer

Comments

vijai Jan 28 2013
Hi,

I hope you would have gone through these links

http://jobinesh.blogspot.co.uk/2010/12/using-oraclejbodomainarray-with.html
http://jobinesh.blogspot.co.uk/2011/07/tips-on-using-oraclejbodomainarray-as.html

Hoping so, I guess from the details, since the error is ORA , it is raised by the database. please cross check once where you are setting the bind variables that it is set as you intended.

Last but not the least, please verify if the user used to connect with the database by the application has enough rights on 'STRARRAY' object.
vanna Jan 28 2013
I went through those links, and I am sure the user has enough rights on STRARRAY object.
I noticed that when running application module things work fine if I firstly execute RootView - Master view.
and then double click on VL which shows detail view in table.

The error occurs if I click on ViewLink first. I am not sure if I am even "allowed" to do that.
I set the parameters with "setNamedWhereClauseParam" and print them out before i call super.executeQueryForCollection() and this the output i get:
ExecuteQueryForCollectionRoot
Permission: [AdfIn2Ogrodje.ROOT, AdfIn2Ogrodje.ADMINISTRACIJA, HOME]
[87] MetVMenuRoot1 ViewRowSetImpl.setNamedWhereClauseParam(listOfUserPermission, oracle.jbo.domain.Array@e1af74d9)
[88] MetVMenuRoot1 ViewRowSetImpl.setNamedWhereClauseParam(menuRoot, AdfIn2Ogrodje.ROOT)
//Print before execution.
EXECUTE_MENUROOT menuRoot: AdfIn2Ogrodje.ROOT
EXECUTE_MENUROOT permission: oracle.jbo.domain.Array@e1af74d9
    Permission: AdfIn2Ogrodje.ROOT
    Permission: AdfIn2Ogrodje.ADMINISTRACIJA
    Permission: HOME
[89] MetVMenuRoot1>#q computed SQLStmtBufLen: 537, actual=447, storing=477
[90] SELECT MetVMenu.CHILD_ID,         MetVMenu.CHILD_IME_MODULA,         MetVMenu.PARENT_ID,         MetVMenu.PARENT_IME_MODULA,         MetVMenu.ZST,         MetVMenu.NIVO,         MetVMenu.CHILD_NAZIV_V_MENIJU,         MetVMenu.CHILD_TIP_MODULA,         MetVMenu.CHILD_OPIS_MODULA FROM MET_V_MENU MetVMenu WHERE MetVMenu.PARENT_IME_MODULA like :menuRoot and MetVMenu.CHILD_IME_MODULA in (SELECT * FROM TABLE(CAST(:listOfUserPermission AS STRARRAY)))
[91] ViewObject: [adfin2.menu.model.views.MetVMenuRoot]MetMenuAppModule.MetVMenuRoot1 Created new QUERY statement
[92] Bind params for ViewObject: [adfin2.menu.model.views.MetVMenuRoot]MetMenuAppModule.MetVMenuRoot1
[93] Binding null of type 12 for "menuRoot"
[94] Binding null of type 12 for "listOfUserPermission"
protected void executeQueryForCollection(Object object, Object[] object2, int i) {
        System.out.println("ExecuteQueryForCollectionRoot");
        setParametersForSessionTest(); // method where i set the parameters.
        printExecute(); // printing
        super.executeQueryForCollection(object, object2, i);
    }
After a few clicks on OK button the query executes normally.
What I am guessing is, that executeQueryForCollection just takes whatever is in object2 and that's null at the beginning.
I tried to use this method, which sets the bind variables in object2. And it gives me "Invalid column type" error.
http://packtlib.packtpub.com/library/9781849684767/ch04lvl1sec07
vanna Jan 29 2013
After printing out object2 elements I found out, that I must pass Array as oracle.sql.ARRAY.
I got the Invalid column type because I used oracle.jbo.domain.Array
Any idea how to do that?
vanna Jan 29 2013 — edited on Jan 29 2013
With further exploration I now use only prepareRowSetForQuery(), where bind variables are set before executeQuery or executeQueryForCollection are called.
executeQuery or executeQueryForCollection methods are now not overridden anymore.
public void prepareRowSetForQuery(ViewRowSetImpl viewRowSetImpl) {
        System.out.println("PrepareRowSetForQueryROOT");
       // Number departmentId = vrsImpl.ensureVariableManager().setVariableValue( "DepartmentId", departmentId); super.prepareRowSetForQuery(vrsImpl); }
        viewRowSetImpl.ensureVariableManager().setVariableValue("menuRoot", "ROOT");
        viewRowSetImpl.ensureVariableManager().setVariableValue("listOfUserPermission", getUserPermissionArray().getArray());

        super.prepareRowSetForQuery(viewRowSetImpl);
    }
	
	getUserPermissionArray() returns oracle.jbo.domain.Array
	
It's wokring fine in application module, however on a jsp page I get only the first result of every level in tree table.
For exampe if this is my menu:
ROOT
	 -MENU1
		- ITEM1
		- TTEM2
	 -MENU2
		- ITEM1
		- TTEM2	
the tree table only shows this:
 ROOT
	-MENU1
		-ITEM1
	-MENU2
		-ITEM1	
Edited by: vanna on 29.1.2013 3:33
vanna Feb 1 2013
Answer
prepareRowSetForQuery() solved the problem for me. The Array bind variable was null and that was the reason for inconsistent datatype error.
What concerns the tree error -> it was a mistake in cardinality definition.
Marked as Answer by vanna · Sep 27 2020
1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 1 2013
Added on Jan 28 2013
5 comments
992 views