Reg:Error in JDBC Lookup Table
Hi All,
My actual requirement is,A project ID is being triggered to PI which will pull the data from the database(SQL Server 2000) ,from different tables and it has to post to file.Receiver side I will be using the File Adapter.
For this I am using JDBC Lookup table through an User Defined function.
// code
String Query = " ";
Channel channel = null;
DataBaseAccessor accessor = null;
DataBaseResult resultSet = null;
//Build the Query String
Query = "Select proj_id, proj_short_name from PROJECT where proj_id = '"proj_id[0]"'";
try{
channel = LookupService.getChannel("bs_test" ,"cc_test");
//Get a system accessor for the channel. As the call is being made //to an DB, an DatabaseAccessor is obtained.
accessor = LookupService.getDataBaseAccessor(channel);
//Execute Query and get the values in output
resultSet = accessor.execute(Query);
Iterator rows = null;
rows = resultSet.getRows();
while(rows.hasNext())
Map rowMap = (Map)rows.next();
// String proj_id = rowMap.get("proj_id");
// String project_name = rowMap.get("proj_short_name");
result.addValue((String)rowMap.get("proj_id "));
result.addValue((String)rowMap.get("project_short_name "));
//result.addValue(proj_id);
//result.addValue(project_short_name);
catch(Exception ex)
result.addValue(ex.getMessage());
finally{
try{
if (accessor!=null) accessor.close();
catch(Exception e)
result.addValue(e.getMessage());
//@@end
While testing in test tab of Message Mapping,I am getting the value as 'NULL' for the project id and am not able to see the other field.
Please suggest me in this.
Thanks in Advance,
Lavanya.B
Hi All,
My actual requirement is,A project ID is being triggered to PI which will pull the data from the database(SQL Server 2000) ,from different tables and it has to post to file.Receiver side I will be using the File Adapter.
For this I am using JDBC Lookup table through an User Defined function.
// code
String Query = " ";
Channel channel = null;
DataBaseAccessor accessor = null;
DataBaseResult resultSet = null;
//Build the Query String
Query = "Select proj_id, proj_short_name from PROJECT where proj_id = '"proj_id[0]"'";
try{
channel = LookupService.getChannel("bs_test" ,"cc_test");
//Get a system accessor for the channel. As the call is being made //to an DB, an DatabaseAccessor is obtained.
accessor = LookupService.getDataBaseAccessor(channel);
//Execute Query and get the values in output
resultSet = accessor.execute(Query);
Iterator rows = null;
rows = resultSet.getRows();
while(rows.hasNext())
Map rowMap = (Map)rows.next();
result.addValue((String)rowMap.get("proj_id "));
result.addValue((String)rowMap.get("project_short_name "));
catch(Exception ex)
result.addValue(ex.getMessage());
finally{
try{
if (accessor!=null) accessor.close();
catch(Exception e)
result.addValue(e.getMessage());
//@@end
While testing in test tab of Message Mapping,I am getting the value as 'NULL' for the project id and am not able to see the other field value.
Output:
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:mt_test_recv xmlns:ns0="http://xxxx">
<proj_id>null</proj_id>
<proj_short_name />
</ns0:mt_test_recv>
Please suggest me in this.
Thanks in Advance,
Lavanya.B
Edited by: Lavanya Balanandham on Dec 5, 2008 6:51 AM
Similar Messages
-
Error while updating lookup table through PSI
Hi,
I am trying to update a lookuptable through PSI using following code :
$lookupTableGuid = $svcPSProxy.ReadLookupTables($EPMTYString, 0 , 1033).LookupTables | where {$_.LT_NAME -eq $Lookuptablename}
$lookuptable = $svcPSProxy.ReadLookupTablesbyUids($lookupTableGuid.LT_UID, 1 , 1033)
$lookuptablerowValues = $svcPSProxy.ReadLookupTablesbyUids($lookupTableGuid.LT_UID, 0 , 1033).LookupTableTrees
#get lookup table count
$lookuptableValues = $svcPSProxy.ReadLookupTablesbyUids($lookupTableGuid.LT_UID, 0 , 1033).LookupTableTrees
$count = $lookuptableValues.Count +1
#Insert the rows of table in Lookup Table
foreach ($rows in $table)
$value_Code = $rows.Item("Project_code")
$value_Name = $rows.Item("project_desc")
$GUID = [System.Guid]::NewGuid()
$LookupRow = $lookuptable.LookupTableTrees.NewLookupTableTreesRow()
$LookupRow.LT_STRUCT_UID = $GUID
$LookupRow.LT_UID = $lookupTableGuid.LT_UID
$LookupRow.LT_VALUE_TEXT = $value_Code
$LookupRow.LT_VALUE_DESC = $value_Name
$LookupRow.LT_VALUE_SORT_INDEX = ($count ++)
$lookuptable.LookupTableTrees.AddLookupTableTreesRow($LookupRow)
$error.clear()
#Exceptions Handling :
Try
$svcPSProxy.UpdateLookupTables($lookuptable , 0 , 1 , 1033)
Catch
write-host "Error updating the Lookup table, see the error below:" -ForeGroundColor Red -BackGroundColor White
write-host "$error" -ForeGroundColor Red
Initially, I tried to run with value of $value_code as "AACL", the code worked.
But when I tried to insert value of code as "AACL - ALKYL AMINES CHEMICALS LIMITED"
I got following error:
Exception calling "UpdateLookupTables" with "4" argument(s): "Response is not well-formed XML."
I could not understand why this error is appearing as I just added ' - ' to my code value. I checked for validity of ' - 'in the targeted column. No issue with that.
Please help.
Thanks and regards,
JayeshHi All,
The entries are maintained from DB level.
Thanks for the help.
DVRK -
Hi ,
I am developing a scenario file to file with the help of JDBC lookup. Message successfully process in MONI but when I check message payload in Technical Routing desired result not appears it will show some text like
"The returned object is not of type LinkedList: com.sap.aii.adapter.xi.ms.XIMessage" please suggest why this error occurred
Regards,
Amit ShivhareHi Satish,
in JAVA UDF i have put wrong CC. now i have put rec. JDBC channel in UDF but not getting error during mapping testing
Cannot produce target element /ns0:MT_JDBCLOOKUP_REC/row/UPDATE_USER. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd
my database table structure is
DUMMY_KEY NOT NULL VARCHAR2(200)
INTEGRATIONNAME NOT NULL VARCHAR2(60)
DEPLOYMENTNAME NOT NULL VARCHAR2(49)
COMPONENTINSTANCE1 NOT NULL VARCHAR2(40)
COMPONENTINSTANCE2 NOT NULL VARCHAR2(40)
MAXMEMORY NOT NULL NUMBER(4)
MAXCPU NOT NULL NUMBER(3)
FT_LB NOT NULL VARCHAR2(2)
HMA1 NOT NULL VARCHAR2(200)
HMA2 NOT NULL VARCHAR2(200)
ACTIVEFLAG NOT NULL VARCHAR2(5)
UPDATE_USER VARCHAR2(50)
UPDATE_DATE NOT NULL TIMESTAMP(6)
and UDF
//write your code here
//write your code here
String Query = " ";
Channel channel = null;
DataBaseAccessor accessor = null;
DataBaseResult resultSet = null;
// Build the Query String
Query = "Select UPDATE_USER from CMS_PAR_MONITOR where INTEGRATIONNAME = '" + UName[0] + " ' ";
try{
//Determine a channel, as created in the Configuration
channel = LookupService.getChannel("Ser_Test","CC_JDBC_REC_JDBCLookUP");
//Get a system accessor for the channel. As the call is being made to an DB, an DatabaseAccessor is obtained.
accessor = LookupService.getDataBaseAccessor(channel);
//Execute Query and get the values in resultset
resultSet = accessor.execute(Query);
for(Iterator rows = resultSet.getRows();rows.hasNext();){
Map rowMap = (Map)rows.next();
result.addValue((String)rowMap.get("URole"));
catch(Exception ex){
result.addValue(ex.getMessage());
finally{
try{
if (accessor!=null) accessor.close();
catch(Exception e){
result.addValue(e.getMessage());
regards, amit -
Reg.Error in account determination: table T030K key NCCA EXD
Dear Friends
we are doing domestic sales for that I am doing pricing procedure, I create 5 condition types without access sequence,and I manualy enter all the mrp price,mrp discount,bed,eces,shec and cst in billing, during the billing release I am getting the error
" Error in account determination: table T030K key NCCA EXD" Diagnosis In the chart of accounts to be posted to, no accounts are defined for the tax code you used. " in VKOA I maintained the account key ERL,MWS and EXD,and also in OBCN and OB40 but I am getting the same error.
do I need to create separate procure for pricing ? or can I use the same procedure which in SD.
do I need to change the TAXINJ and put the EXD there ? I am unable to solve this problem. Please help me .
Thanks
Rajakumar.KFYI, as per SD pricing for tax condition type is concern, it doesn't require tax procedures to be maintain.
Tax % with correspondingly tax codes are maintain & determine from Condition record in to the pricing of sales doc.
These kind of error occurs due to non determination or missing tax code in sales doc pricing.
In turn, raises error due to accounting interface.
So, as per best practices, tax condition type are determined through condition record in sales document.
Thus, you ought to have access sequence for tax condition type & should create condition record with respective TAX % & Tax code. By, manually processing tax values into pricing, you will be able to maintain tax %, but without TAX CODE.
I hope this can assist you.
Thanks & Regards
JP -
JDBC Lookup - Import table data from a different schema in same DB
Hi XI Experts,
We are facing an issue while importing a Database table into the external definition in PI 7.1.
The details are as below:
I have configured user 'A' in PI communication channel to access the database. But the table that I want to access is present in schema "B". Due to this, I am unable to view the table that I have to import in the list available.
In other words, I am trying to access a table present in a different schema in the same database. Please note that my user has been given all the required permissions to access different schema. Even then, I am unable to access the table in different schema.
Kindly provide your valuable suggestions as to how I can import table which is present in another schema but in the same Database.
Regards,
SubbuIf you are using PI 7.1, then you can do JDBC Lookup to import JDBC meta data (table structures from DB). Configure a jdbc receiver communication channel where you specify username and password which has permission to access schema A and Schema B of database. Specify database name in the connection string. Then you might have access to import both schema.
Please refer these links
SAP PI 7.1 Mapping Enhancements Series: Graphical Support for JDBC and RFC Lookups
How to use JDBC Lookup in PI 7.1 ? -
Is it possible for the JDBC Lookup in PI 7.1 to read other user's table?
Hi,
I have the requirement of using the standard JDBC Lookup in PI 7.1. The user setup in the receiver JDBC adapter is only a service user that has a read access on some tables that are owned by another user or schema. When I am trying to do the import of Table's metadata, I can only see tables that are owned by the user setup in the receiver JDBC adapter.
Is there any any ways on how the user used in the receiver JDBC adapter can read another user's table (given that it has read access) during the import of Table's metadata?
Thank you in advacne for any response.
-NiroHi Matt,
I am struck in a similar kind of problem.
I have to do lookup from a view(not a table) available in a particular schema.
When i am using the external definition --> category dbtab
I am able to see all the tables available in the schema.Whereas i not able to see any views.
Please let me know how to proceed in such scenario?
Thanks,
Sudhansu -
Error with Mapping Lookup API using JDBC
All,
I have an interface that uses a JDBC lookup user defined function. Occassionally we get the following message:
<i>Problem when calling an adapter by using communication channel myJDBCLookup (Party: , Service: myJDBCdbase, Object ID: 0cdb888150ee36638cbfb100ff2e7161) XI AF API call failed. Module exception: 'Error ACK handling failed: java.lang.NullPointerException'. Cause Exception: (No information available)</i>
The only way I can duplicate this error is if I deactivate the myJDBCLookup communication channel and re-run the interface. In this case I get the same exact error. I know the commchannels were active when I ran and got the errors. Typically what I do is just restart the erred message and it runs fine.
I'm thinking I may be running into a timeout problem on the Oracle end of my call and XI is "timing out" or something like that.
My questions are:
1) whether or not XI has some timeout setting that I could increase that would hopefully mitigate this issue (I'm not an XI admin)?
2) would using a different Conflict Resolution (JDBC adapter config) or Number of Retries of Database Transaction on SQL error (JDBC Advanced adapter config) setting help?
3) Is there something altogether different I should be looking at?Hi,
This blog may help u on to optimize the lookup-
/people/sap.user72/blog/2005/12/06/optimizing-lookups-in-xi
/people/sap.user72/blog/2005/10/15/jdbc-adapter-execution-mode-chained-or-unchained
ALso check the Adapter Engine about time out parameters-
hope this helps,
Regards,
moorthy -
Error in Import Manager if Constraints are assigned to lookup table
Hi Folks,
I am using the Repository SRM-MDM Catalog...and in the Console,
For a Role, if I assign a Constraint for the lookup-table Product Groups, System shoots the error message in Import Manager when I try to Map the file.
Scenario: Say I have Product Group from LOC1-LOC5, and for a Z-Catalog Manager Role(Manager1) if I assign the Constraint-LOC1.....and if I Import a file in the Import Manager, system shoots the error message "Unable to retrieve Unique values for Product Groups".Hi Mohan,
Are you updating any Qualified table.Please explain what table and also some more details.
Thanks
Ganesh Kotti -
Reg:JDBC Lookup to pull multiple values
Hi All,
We are trying to pull the data from SQL server and passing it to to RFC through JDBC lookup. Can anyone suggest me how to pull data from different tables and assign it to the target structure (RFC).
Thanks in Advance,
Lavanya.BHi,
You can consider this alternative using Stored Procedure...
At receiver side you can execute stored procedure and return the required values in the Response structure. this response structure you have to map to you RFC structure.
i) You can easily handle your select queries, complex logic in the stored procedure.
ii) It is faster than triggering select queries.
You can check these examples for practice and doubts...
JDBC Stored Procedures
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/5474f19e-0701-0010-4eaa-97c4f78dbf9b
(3rd Scenario in the above pdf)
Also refer
http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/frameset.htm
Regards -
How to use JDBC Lookup in PI 7.1 ?
Hi,
Please advise how to use JDBC lookup in message mapping PI 7.1 ? any reference link / document ?
I have followed this step below :
1. Create the external definition for the database table.
2. Use the external definition (table) in message mapping JDBC Lookup.
But the target still "Yellow colour" meanint the mapping hasnot completed yet ? why ? and when i double click the JDBC lookup
there some error message
"No suitable parameter found; define new parameter of type 'Channel' first"
Please advise.
Thank You and Best Regards
FernandHi Fernand,
JDBC Lookup can be done in PI 7.1 using below mentioned steps :
1) Create a communication channel between PI and the database to connect to database.
2) Import the table data as External Definition.
3) In message mapping where this lookup is to be used select JDBC Lookup under Conversions and map
4) Double Click on JDBC Lookup
5) Select parameter and a database table (imported as the external definition). All the elements of the table will appear in the middle column. Select and move the input parameters to the left side column and the output parameters to the right side column. Click OK.
6) Under message mapping go to signature tab and define the parameter as channel and category as JDBC Adapter Type.
7) Under Operation mapping define the parameter & associate it with parameter defined in Message Mapping.
Thanks
Amit -
JDBC Lookup in PI 7.1 - SELECT ? FROM DUAL and Connection timed out
Hi,
We have a scenarios (Idoc to JMS) with JDBC lookup. We have used graphical JDBC lookup functionality.
We are reading country names for a given country code from SAP in an external database table. The query is so simple. That should not take much time
Now the actual issues is,
When we are executing the scenario, its taking quite a long time. Almost 6 minutes to excute a mapping. Which causing high performance issue in the Porduction.
We started the inviestigation about found some interesting stuff. Here we have used Willy Introscope for the investigation.
1. First few messages are taking quite a long time. LIke 6 minutes per messages. As i can see in the log i am getting below error in Willy,
I dont know why PI is executing below queury apart from real secelt query to fetch the country name. I am getting below error: Error Message: Backends|ABCD2 mydatabase01-1526 (Oracle DB)|SQL|Dynamic|Query|SELECT ? FROM DUAL: java.sql.SQLException: Io exception: Connection timed out
2. After couple of messages, interface works very normal. I mean rest of the messages works pretty fine.
Please let me know if you have any idea about this error. What could be the problem for the issue.
Thank you in advnace.
Best Regards,
Prasad.Did you check how many SQL requests were executed per one message ? Do you have a log of these SQL requests ?
I assume that the country table is quite small, so that lookup should not be an issue.
About this:
>Message: Backends|ABCD2 mydatabase01-1526 (Oracle DB)|SQL|Dynamic|Query|SELECT ? FROM DUAL: >java.sql.SQLException: Io exception: Connection timed out
1. I only know SELECT * FROM DUAL, not SELECT ? FROM DUAL. Better use the former
2. the exception means that the database server can not be reached => check your network configuration
So I assume that there is a network (performance) problem between PI and this Oracle server. Or the Oracle Server is so overloaded that it has (sometimes) problems in processing new requests.
CSY
Edited by: Christian Sy on Mar 9, 2010 10:17 AM -
JDBC Scenario with JDBC Lookup and Updates
Dear Experts,
I am working on a JDBC receiver scenario.
In this scenario, we are also using JDBC lookup to check the maximum EntyNumber which is a primary key. We are manually incrementing this primary key by one and inserting the record into the database.
Both JDBC lookup and JDBC Insert are two differnt tasks. Thus when we send multiple IDOC's concurrently JDBC lookup fetches old values and when we try to insert the record if gives error of PRIMARY KEY VIOLATION.
For example, consider the below scenario,
Assume that there are already 10 records in the database.
1. Two IDOCs No 1 and 2 sent from SAP system at the same time.
2. Now, during the mapping of 1st IDOC we did a lookup and found that latest entry number in the database table is 10 and we mapped the entry number to 11 ( 10+1, i.e. next record )
3. Before updating this record in the database, second IDOC triggered. During JDBC lookup of the sceond IDOC, we got the same entry as the earlier record has yet to be updated.
4. During JDBC call we get the SQL error that "Primary Key Violation" because both the records have same primary key as "11".
Kindly share your ideas.
(SAP system is not sending the IDOC's in any certain order and we need a solution in PI itself. )
- Shri>>> I am actually sending the primary key value to more than one table as a foreign key. I am looking for some solution
If you are passing primary key value to many tables then jdbc lookup would not be solution. Use stored procedure.
Refer this link for data type creation for stored procedure
http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm -
IDOC to JDBC :Error using JDBC
Hi Frnds,
My scenario is Idoc to JDBC scenario, I am getting the follwoing error while trying to process an idoc. Please help me in hadling this error.
Error Message:
JDBC message processing failed; reason Error when attempting to get processing resources: com.sap.aii.af.service.util.concurrent.ResourcePoolException: Unable to create new pooled resource: DriverManagerException: Cannot establish connection to URL 'jdbc:microsoft:sqlserver://180.1.32.194:1433;DatabaseName=CZZ03;': SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
Regards,
ShivHello Shiva,
Are you installed JDBC Drivers?
Go through this links,
/people/varadharajan.krishnasamy/blog/2007/02/27/configuring-jdbc-connector-service-to-perform-database-lookups
http://searchsap.techtarget.com/tip/0,289483,sid21_gci1246926,00.html
To install JDBC driver follow the how to guide.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/xi-how-to-guides/how%20to%20install%20and%20configure%20external%20drivers%20for%20jdbc%20and%20jms%20adapters.pdf
Configuration of JDBC Adapter for SQL Server
JDBC Driver = com.microsoft.jdbc.sqlserver.SQLServerDriver
Connection = jdbc:microsoft:sqlserver://hostname:<port>;DatabaseName=<DBName>
UserID and Password.
If the connection is not working find the correct port number.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40b92770-db81-2a10-8e91-f747188d8033
JDBC- X I - R/3 Scenario
/people/bhavesh.kantilal/blog/2006/07/03/jdbc-receiver-adapter--synchronous-select-150-step-by-step
/people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30
Please check the driver path as mentioned below.
JDBC Driver : sun.jdbc.odbc.JdbcOdbcDriver
Connection:jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=//location of DB table.mdb;
No JDBC driver required.
Receiver JDBC scenario MS access - /people/sameer.shadab/blog/2005/10/24/connecting-to-ms-access-using-receiver-jdbc-adapter-without-dsn
follow this thread
Re: Problem when connecting to MS Access through JDBC Adapter.
SAP Note 850116 has details
Thanks,
Satya Kumar
Reward if it is usefulll -
Hey folks, looking for some insight here.
I've an implementation that contains some custom Enterprise columns mapped to lookup tables. In the instance I'm working with now, it looks like there was/is an issue with one of those columns. In this scenario, I have a column named
ProjectType, created initially with that name, mapped to a lookup table. This field's name was then changed to
Project Type. After that, it looks like another column was created, also called
ProjectType. So now, we have what I would have originally thought was two distinct columns, even though the names used are the same.
Below is the error we're currently getting during the Cube Build Process...
PWA:http://ps2010/PWA, ServiceApp:Project Web App, User:DOMAIN\user, PSI: SqlException occurred in DAL: <Error><Class>1</Class><LineNumber>1</LineNumber><Number>4506</Number><Procedure>MSP_EpmProject_OlapView_B8546719-4D4C-473A-84B1-89DEDA2307E0</Procedure>
<Message> System.Data.SqlClient.SqlError: Column names in each view or function must be unique. Column name 'ProjectType' in view or function 'MSP_EpmProject_OlapView_B8546719-4D4C-473A-84B1-89DEDA2307E0' is specified more than once. </Message>
<CallStack>
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.Office.Project.Server.DataAccessLayer.DAL.SubDal.ExecuteStoredProcedureNoResult(String storedProcedureName, SqlParameter[] parameters) </CallStack> </Error>
I've tried deleting the one column, but the build still gives the above error.
Any thoughts as to how the above could be resolved?
Thanks! - M
Michael Mukalian | Jan 2010 - Dec 2010 MVP SharePoint Services | MCTS: MOSS 2007 Configuration | http://www.mukalian.com/blogWe tried taking it out of the cubes, and it builds fine. The challenge we're having is in building the cubes with that custom field "ProjectType". It's as if the cubes still hold some reference to it even when it's deleted.
Since the OLAP View ('MSP_EpmProject_OlapView_{guid}') is recreated, would it be as simple as deleting that View, and trying to recreate?
Thanks - M
Michael Mukalian | Jan 2010 - Dec 2010 MVP SharePoint Services | MCTS: MOSS 2007 Configuration | http://www.mukalian.com/blog -
Creating a single context index on a one-to-many and lookup table
Hello,
I've been successfully setting up text indexes on multiple columns on the same table (using MULTI_COLUMN_DATASTORE preferences), but now I have a situation with a one-to-many data collection table (with a FK to a lookup table), and I need to search columns across both of these tables. Sample code below, more of my chattering after the code block:
CREATE TABLE SUBMISSION
( SUBMISSION_ID NUMBER(10) NOT NULL,
SUBMISSION_NAME VARCHAR2(100) NOT NULL
CREATE TABLE ADVISOR_TYPE
( ADVISOR_TYPE_ID NUMBER(10) NOT NULL,
ADVISOR_TYPE_NAME VARCHAR2(50) NOT NULL
CREATE TABLE SUBMISSION_ADVISORS
( SUBMISSION_ADVISORS_ID NUMBER(10) NOT NULL,
SUBMISSION_ID NUMBER(10) NOT NULL,
ADVISOR_TYPE_ID NUMBER(10) NOT NULL,
FIRST_NAME VARCHAR(50) NULL,
LAST_NAME VARCHAR(50) NULL,
SUFFIX VARCHAR(20) NULL
INSERT INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME) VALUES (1, 'Some Research Paper');
INSERT INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME) VALUES (2, 'Thesis on 17th Century Weather Patterns');
INSERT INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME) VALUES (3, 'Statistical Analysis on Sunny Days in March');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (1, 'Department Chair');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (2, 'Department Co-Chair');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (3, 'Professor');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (4, 'Associate Professor');
INSERT INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME) VALUES (5, 'Scientist');
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (1,1,2,'John', 'Doe', 'PhD');
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (2,1,2,'Jane', 'Doe', 'PhD');
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (3,2,3,'Johan', 'Smith', NULL);
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (4,2,4,'Magnus', 'Jackson', 'MS');
INSERT INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX) VALUES (5,3,5,'Williard', 'Forsberg', 'AMS');
COMMIT;I want to be able to create a text index to lump these fields together:
SUBMISSION_ADVISORS.FIRST_NAME
SUBMISSION_ADVISORS.LAST_NAME
SUBMISSION_ADVISORS.SUFFIX
ADVISOR_TYPE.ADVISOR_TYPE_NAME
I've looked at DETAIL_DATASTORE and USER_DATASTORE, but the examples in Oracle Docs for DETAIL_DATASTORE leave me a little bit perplexed. It seems like this should be pretty straightforward.
Ideally, I'm trying to avoid creating new columns, and keeping the trigger adjustments to a minimum. But I'm open to any and all suggestions. Thanks for for your time and thoughts.
-JamieI would create a procedure that creates a virtual document with tags, which is what the multi_column_datatstore does behind the scenes. Then I would use that procedure in a user_datastore, so the result is the same for multiple tables as what a multi_column_datastore does for one table. I would also use either auto_section_group or some other type of section group, so that you can search using WITHIN as with the multi_column_datastore. Please see the demonstration below.
SCOTT@orcl_11gR2> -- tables and data that you provided:
SCOTT@orcl_11gR2> CREATE TABLE SUBMISSION
2 ( SUBMISSION_ID NUMBER(10) NOT NULL,
3 SUBMISSION_NAME VARCHAR2(100) NOT NULL
4 )
5 /
Table created.
SCOTT@orcl_11gR2> CREATE TABLE ADVISOR_TYPE
2 ( ADVISOR_TYPE_ID NUMBER(10) NOT NULL,
3 ADVISOR_TYPE_NAME VARCHAR2(50) NOT NULL
4 )
5 /
Table created.
SCOTT@orcl_11gR2> CREATE TABLE SUBMISSION_ADVISORS
2 ( SUBMISSION_ADVISORS_ID NUMBER(10) NOT NULL,
3 SUBMISSION_ID NUMBER(10) NOT NULL,
4 ADVISOR_TYPE_ID NUMBER(10) NOT NULL,
5 FIRST_NAME VARCHAR(50) NULL,
6 LAST_NAME VARCHAR(50) NULL,
7 SUFFIX VARCHAR(20) NULL
8 )
9 /
Table created.
SCOTT@orcl_11gR2> INSERT ALL
2 INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME)
3 VALUES (1, 'Some Research Paper')
4 INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME)
5 VALUES (2, 'Thesis on 17th Century Weather Patterns')
6 INTO SUBMISSION (SUBMISSION_ID, SUBMISSION_NAME)
7 VALUES (3, 'Statistical Analysis on Sunny Days in March')
8 SELECT * FROM DUAL
9 /
3 rows created.
SCOTT@orcl_11gR2> INSERT ALL
2 INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
3 VALUES (1, 'Department Chair')
4 INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
5 VALUES (2, 'Department Co-Chair')
6 INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
7 VALUES (3, 'Professor')
8 INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
9 VALUES (4, 'Associate Professor')
10 INTO ADVISOR_TYPE (ADVISOR_TYPE_ID, ADVISOR_TYPE_NAME)
11 VALUES (5, 'Scientist')
12 SELECT * FROM DUAL
13 /
5 rows created.
SCOTT@orcl_11gR2> INSERT ALL
2 INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
3 VALUES (1,1,2,'John', 'Doe', 'PhD')
4 INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
5 VALUES (2,1,2,'Jane', 'Doe', 'PhD')
6 INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
7 VALUES (3,2,3,'Johan', 'Smith', NULL)
8 INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
9 VALUES (4,2,4,'Magnus', 'Jackson', 'MS')
10 INTO SUBMISSION_ADVISORS (SUBMISSION_ADVISORS_ID, SUBMISSION_ID, ADVISOR_TYPE_ID, FIRST_NAME, LAST_NAME, SUFFIX)
11 VALUES (5,3,5,'Williard', 'Forsberg', 'AMS')
12 SELECT * FROM DUAL
13 /
5 rows created.
SCOTT@orcl_11gR2> -- constraints presumed based on your description:
SCOTT@orcl_11gR2> ALTER TABLE submission ADD CONSTRAINT submission_id_pk
2 PRIMARY KEY (submission_id)
3 /
Table altered.
SCOTT@orcl_11gR2> ALTER TABLE advisor_type ADD CONSTRAINT advisor_type_id_pk
2 PRIMARY KEY (advisor_type_id)
3 /
Table altered.
SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD CONSTRAINT submission_advisors_id_pk
2 PRIMARY KEY (submission_advisors_id)
3 /
Table altered.
SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD CONSTRAINT submission_id_fk
2 FOREIGN KEY (submission_id) REFERENCES submission (submission_id)
3 /
Table altered.
SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD CONSTRAINT advisor_type_id_fk
2 FOREIGN KEY (advisor_type_id) REFERENCES advisor_type (advisor_type_id)
3 /
Table altered.
SCOTT@orcl_11gR2> -- resulting data:
SCOTT@orcl_11gR2> COLUMN submission_name FORMAT A45
SCOTT@orcl_11gR2> COLUMN advisor FORMAT A40
SCOTT@orcl_11gR2> SELECT s.submission_name,
2 a.advisor_type_name || ' ' ||
3 sa.first_name || ' ' ||
4 sa.last_name || ' ' ||
5 sa.suffix AS advisor
6 FROM submission_advisors sa,
7 submission s,
8 advisor_type a
9 WHERE sa.advisor_type_id = a.advisor_type_id
10 AND sa.submission_id = s.submission_id
11 /
SUBMISSION_NAME ADVISOR
Some Research Paper Department Co-Chair John Doe PhD
Some Research Paper Department Co-Chair Jane Doe PhD
Thesis on 17th Century Weather Patterns Professor Johan Smith
Thesis on 17th Century Weather Patterns Associate Professor Magnus Jackson MS
Statistical Analysis on Sunny Days in March Scientist Williard Forsberg AMS
5 rows selected.
SCOTT@orcl_11gR2> -- procedure to create virtual documents:
SCOTT@orcl_11gR2> CREATE OR REPLACE PROCEDURE submission_advisors_proc
2 (p_rowid IN ROWID,
3 p_clob IN OUT NOCOPY CLOB)
4 AS
5 BEGIN
6 FOR r1 IN
7 (SELECT *
8 FROM submission_advisors
9 WHERE ROWID = p_rowid)
10 LOOP
11 IF r1.first_name IS NOT NULL THEN
12 DBMS_LOB.WRITEAPPEND (p_clob, 12, '<first_name>');
13 DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.first_name), r1.first_name);
14 DBMS_LOB.WRITEAPPEND (p_clob, 13, '</first_name>');
15 END IF;
16 IF r1.last_name IS NOT NULL THEN
17 DBMS_LOB.WRITEAPPEND (p_clob, 11, '<last_name>');
18 DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.last_name), r1.last_name);
19 DBMS_LOB.WRITEAPPEND (p_clob, 12, '</last_name>');
20 END IF;
21 IF r1.suffix IS NOT NULL THEN
22 DBMS_LOB.WRITEAPPEND (p_clob, 8, '<suffix>');
23 DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r1.suffix), r1.suffix);
24 DBMS_LOB.WRITEAPPEND (p_clob, 9, '</suffix>');
25 END IF;
26 FOR r2 IN
27 (SELECT *
28 FROM submission
29 WHERE submission_id = r1.submission_id)
30 LOOP
31 DBMS_LOB.WRITEAPPEND (p_clob, 17, '<submission_name>');
32 DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r2.submission_name), r2.submission_name);
33 DBMS_LOB.WRITEAPPEND (p_clob, 18, '</submission_name>');
34 END LOOP;
35 FOR r3 IN
36 (SELECT *
37 FROM advisor_type
38 WHERE advisor_type_id = r1.advisor_type_id)
39 LOOP
40 DBMS_LOB.WRITEAPPEND (p_clob, 19, '<advisor_type_name>');
41 DBMS_LOB.WRITEAPPEND (p_clob, LENGTH (r3.advisor_type_name), r3.advisor_type_name);
42 DBMS_LOB.WRITEAPPEND (p_clob, 20, '</advisor_type_name>');
43 END LOOP;
44 END LOOP;
45 END submission_advisors_proc;
46 /
Procedure created.
SCOTT@orcl_11gR2> SHOW ERRORS
No errors.
SCOTT@orcl_11gR2> -- examples of virtual documents that procedure creates:
SCOTT@orcl_11gR2> DECLARE
2 v_clob CLOB := EMPTY_CLOB();
3 BEGIN
4 FOR r IN
5 (SELECT ROWID rid FROM submission_advisors)
6 LOOP
7 DBMS_LOB.CREATETEMPORARY (v_clob, TRUE);
8 submission_advisors_proc (r.rid, v_clob);
9 DBMS_OUTPUT.PUT_LINE (v_clob);
10 DBMS_LOB.FREETEMPORARY (v_clob);
11 END LOOP;
12 END;
13 /
<first_name>John</first_name><last_name>Doe</last_name><suffix>PhD</suffix><submission_name>Some
Research Paper</submission_name><advisor_type_name>Department Co-Chair</advisor_type_name>
<first_name>Jane</first_name><last_name>Doe</last_name><suffix>PhD</suffix><submission_name>Some
Research Paper</submission_name><advisor_type_name>Department Co-Chair</advisor_type_name>
<first_name>Johan</first_name><last_name>Smith</last_name><submission_name>Thesis on 17th Century
Weather Patterns</submission_name><advisor_type_name>Professor</advisor_type_name>
<first_name>Magnus</first_name><last_name>Jackson</last_name><suffix>MS</suffix><submission_name>The
sis on 17th Century Weather Patterns</submission_name><advisor_type_name>Associate
Professor</advisor_type_name>
<first_name>Williard</first_name><last_name>Forsberg</last_name><suffix>AMS</suffix><submission_name
Statistical Analysis on Sunny Days inMarch</submission_name><advisor_type_name>Scientist</advisor_type_name>
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- user_datastore that uses procedure:
SCOTT@orcl_11gR2> BEGIN
2 CTX_DDL.CREATE_PREFERENCE ('sa_datastore', 'USER_DATASTORE');
3 CTX_DDL.SET_ATTRIBUTE ('sa_datastore', 'PROCEDURE', 'submission_advisors_proc');
4 END;
5 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- index (on optional extra column) that uses user_datastore and section group:
SCOTT@orcl_11gR2> ALTER TABLE submission_advisors ADD (any_column VARCHAR2(1))
2 /
Table altered.
SCOTT@orcl_11gR2> CREATE INDEX submission_advisors_idx
2 ON submission_advisors (any_column)
3 INDEXTYPE IS CTXSYS.CONTEXT
4 PARAMETERS
5 ('DATASTORE sa_datastore
6 SECTION GROUP CTXSYS.AUTO_SECTION_GROUP')
7 /
Index created.
SCOTT@orcl_11gR2> -- what is tokenized, indexed, and searchable:
SCOTT@orcl_11gR2> SELECT token_text FROM dr$submission_advisors_idx$i
2 /
TOKEN_TEXT
17TH
ADVISOR_TYPE_NAME
AMS
ANALYSIS
ASSOCIATE
CENTURY
CHAIR
CO
DAYS
DEPARTMENT
DOE
FIRST_NAME
FORSBERG
JACKSON
JANE
JOHAN
JOHN
LAST_NAME
MAGNUS
MARCH
PAPER
PATTERNS
PHD
PROFESSOR
RESEARCH
SCIENTIST
SMITH
STATISTICAL
SUBMISSION_NAME
SUFFIX
SUNNY
THESIS
WEATHER
WILLIARD
34 rows selected.
SCOTT@orcl_11gR2> -- sample searches across all data:
SCOTT@orcl_11gR2> VARIABLE search_string VARCHAR2(100)
SCOTT@orcl_11gR2> EXEC :search_string := 'professor'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> SELECT s.submission_name,
2 a.advisor_type_name || ' ' ||
3 sa.first_name || ' ' ||
4 sa.last_name || ' ' ||
5 sa.suffix AS advisor
6 FROM submission_advisors sa,
7 submission s,
8 advisor_type a
9 WHERE CONTAINS (sa.any_column, :search_string) > 0
10 AND sa.advisor_type_id = a.advisor_type_id
11 AND sa.submission_id = s.submission_id
12 /
SUBMISSION_NAME ADVISOR
Thesis on 17th Century Weather Patterns Professor Johan Smith
Thesis on 17th Century Weather Patterns Associate Professor Magnus Jackson MS
2 rows selected.
SCOTT@orcl_11gR2> EXEC :search_string := 'doe'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> /
SUBMISSION_NAME ADVISOR
Some Research Paper Department Co-Chair John Doe PhD
Some Research Paper Department Co-Chair Jane Doe PhD
2 rows selected.
SCOTT@orcl_11gR2> EXEC :search_string := 'paper'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> /
SUBMISSION_NAME ADVISOR
Some Research Paper Department Co-Chair John Doe PhD
Some Research Paper Department Co-Chair Jane Doe PhD
2 rows selected.
SCOTT@orcl_11gR2> -- sample searches within specific columns:
SCOTT@orcl_11gR2> EXEC :search_string := 'chair'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> SELECT s.submission_name,
2 a.advisor_type_name || ' ' ||
3 sa.first_name || ' ' ||
4 sa.last_name || ' ' ||
5 sa.suffix AS advisor
6 FROM submission_advisors sa,
7 submission s,
8 advisor_type a
9 WHERE CONTAINS (sa.any_column, :search_string || ' WITHIN advisor_type_name') > 0
10 AND sa.advisor_type_id = a.advisor_type_id
11 AND sa.submission_id = s.submission_id
12 /
SUBMISSION_NAME ADVISOR
Some Research Paper Department Co-Chair John Doe PhD
Some Research Paper Department Co-Chair Jane Doe PhD
2 rows selected.
SCOTT@orcl_11gR2> EXEC :search_string := 'phd'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> SELECT s.submission_name,
2 a.advisor_type_name || ' ' ||
3 sa.first_name || ' ' ||
4 sa.last_name || ' ' ||
5 sa.suffix AS advisor
6 FROM submission_advisors sa,
7 submission s,
8 advisor_type a
9 WHERE CONTAINS (sa.any_column, :search_string || ' WITHIN suffix') > 0
10 AND sa.advisor_type_id = a.advisor_type_id
11 AND sa.submission_id = s.submission_id
12 /
SUBMISSION_NAME ADVISOR
Some Research Paper Department Co-Chair John Doe PhD
Some Research Paper Department Co-Chair Jane Doe PhD
2 rows selected.
SCOTT@orcl_11gR2> EXEC :search_string := 'weather'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> SELECT s.submission_name,
2 a.advisor_type_name || ' ' ||
3 sa.first_name || ' ' ||
4 sa.last_name || ' ' ||
5 sa.suffix AS advisor
6 FROM submission_advisors sa,
7 submission s,
8 advisor_type a
9 WHERE CONTAINS (sa.any_column, :search_string || ' WITHIN submission_name') > 0
10 AND sa.advisor_type_id = a.advisor_type_id
11 AND sa.submission_id = s.submission_id
12 /
SUBMISSION_NAME ADVISOR
Thesis on 17th Century Weather Patterns Professor Johan Smith
Thesis on 17th Century Weather Patterns Associate Professor Magnus Jackson MS
2 rows selected.
Maybe you are looking for
-
Am encountering an issue with "media manager" in FCP. I wanted to create one master file for my latest project with all relevant clips and resources, so i made a "copy" of the project in media manager and then chose to "delete" (though not permanentl
-
Dear All is it possible assign more than a purchasing organization to one company code? best regards Ramin
-
Conditionally format PDF output
Hi In my report, I use this technique to highlight in red some rows: case when a.completed_date is null then '<div style="color:red">'||a.action_description||'</div>' else a.action_description end action_description,However, the
-
ImportError: No module named rhpl.translate
Hi, I am trying to setup RPM repository. The job seems to have failed at the last step. Step: DownloadAdvisories (Failed) Traceback (most recent call last): File "/<path>/emagent/gcagent/em_staging/dwldAdvisories.py", line 4, in <module> fr
-
How sholud we call one jframe class from another jframe class
Hi In my application i am calling one jframe class from another jframe clas. how sholud we make previous jframe inactve when another jframe is invoked?(user sholud not able to make any changes on on parent jframe window when another jframe is invoked