Using orcl:query-database to return a number of Columns
I have a BPEL process that is pulling data from some Database tables everything is working fine.
I now need to perform a lookup on the database to pull in some additional information (3 additional attributes) within the stylesheet, where each attribute comes from a separate table.
i.e.
select a.col1, b.col1, c.col1
from tab1 a
,tab2 b
, tab3 c
where a.col2 = b.col2
and .......blah blah blah....
I have used the orcl:database-query successfully to retrieve a single column and a single row and it works great.
However i'd like to run the above query as one statement, rather than 3 separate queries.
I've googled the fucntion for examples where it returns a nodelist or XML snippet, but to no avail.
I've tried it before and couldn't get it to work.
Does anyone have any examples.
Thanks in advance.
Stuart
I have a BPEL process that is pulling data from some Database tables everything is working fine.
I now need to perform a lookup on the database to pull in some additional information (3 additional attributes) within the stylesheet, where each attribute comes from a separate table.
i.e.
select a.col1, b.col1, c.col1
from tab1 a
,tab2 b
, tab3 c
where a.col2 = b.col2
and .......blah blah blah....
I have used the orcl:database-query successfully to retrieve a single column and a single row and it works great.
However i'd like to run the above query as one statement, rather than 3 separate queries.
I've googled the fucntion for examples where it returns a nodelist or XML snippet, but to no avail.
I've tried it before and couldn't get it to work.
Does anyone have any examples.
Thanks in advance.
Stuart
Similar Messages
-
Orcl:query-database ERROR
I am getting following error when I use orcl:query-database() function. JNDI name is correct and working for DB adapters. I dont knwo whats wrong with this..
<subLanguageExecutionFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="code"><code>XPathExecutionError</code>
</part><part name="summary"><summary>XPath expression failed to execute.
Error while processing xpath expression, the expression is "orcl:query-database('select testan_s.nextval from dual',false(),false(),'eis/DB/TEST)", the reason is message can't be null.
Please verify the xpath query.
</summary>
</part></subLanguageExecutionFault>Using JNDI name gives this freak error. If you use jdbc url string then it works in the last parameter.
It is really sad that these kind of simple functions are not working even in 10.1.3.3 which makes it very difficult to design the process in a simple way.
When will these will be fixed? is there any workaround? I need to use this in XSL transformations. any one has a clue? -
Orcl:query-database gives error when using to_char function in select stmt
hi
Use Case : We get a csv file ("bank_import_<MMDDYYYYY>.csv") from the bank containing the transactions occured for the month. The date in the filename is retrieved into string and i need to convert this string to the format "MON-DD-YYYY". This is the required format for an header table which takes this string as primary key.
Code:
statement_name = '11302206'.........
<copy>
<from expression="concat("'select to_char(to_date('",bpws:getVariableData('statement_name') ,"','MMDDYYYY'),'MON-DD-YYYY') from dual'")"/>
<to variable="xpath"/>
</copy>
<copy>
<from expression="orcl:query-database(bpws:getVariableData('xpath'),false(),false(),'jdbc:oracle:thin:apps/apps@croaker:1529:RSICMI')"/>
<to variable="statement_name"/>
</copy>
Error:
[2006/12/06 19:13:04] Updated variable "xpath" less
<xpath>'select to_char(to_date('10302006','MMDDYYYY'),'MON-DD-YYYY') from dual'</xpath>
[2006/12/06 19:13:04] "XPathException" has been thrown. less
XPath expression failed to execute.
Error while processing xpath expression, the expression is "orcl:query-database(bpws:getVariableData("xpath"), false(), false(), "jdbc:oracle:thin:apps/apps@croaker:1529:RSICMI")", the reason is .
Please verify the xpath query.
Log Message:
<2006-12-06 19:13:04,595> <DEBUG> <UAT.collaxa.cube.xml> <XPathUtil::evaluate> XPathQuery[concat("'select to_char(to_date('", bpws:getVariableData("statement_name"), "','MMDDYYYY'),'MON-DD-YYYY') from dual'")], XPath Result: class=java.lang.String value='select to_char(to_date('10302006','MMDDYYYY'),'MON-DD-YYYY') from dual'
<2006-12-06 19:13:04,595> <DEBUG> <UAT.collaxa.cube.xml> <XPathUtil::initXPath> namespaceMapping is: rootMap: {bpws=http://schemas.xmlsoap.org/ws/2003/03/business-process/, xp20=http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20, ns4=http://xmlns.oracle.com/pcbpel/adapter/db/top/BAIBankUpload, ldap=http://schemas.oracle.com/xpath/extension/ldap, xsd=http://www.w3.org/2001/XMLSchema, ns5=http://xmlns.oracle.com/pcbpel/adapter/file/, client=http://xmlns.oracle.com/BAI_BankUpload, ora=http://schemas.oracle.com/xpath/extension, ns1=http://xmlns.oracle.com/pcbpel/adapter/file/readBAIBankImportCSV/, ns3=http://TargetNamespace.com/readBAIBankImportCSV, ns2=http://xmlns.oracle.com/pcbpel/adapter/db/Insert_SI_CE_STATEMENT_LINES_INT/, bpelx=http://schemas.oracle.com/bpel/extension, orcl=http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc, =http://schemas.xmlsoap.org/ws/2003/03/business-process/}
scopedMap: {}
<2006-12-06 19:13:04,751> <DEBUG> <UAT.collaxa.cube.xml> <XPathUtil::evaluate> XPathQuery :orcl:query-database(bpws:getVariableData("xpath"), false(), false(), "jdbc:oracle:thin:apps/apps@croakercom:1529:RSICMI")
org.collaxa.thirdparty.jaxen.FunctionCallException
at org.collaxa.thirdparty.jaxen.FunctionCallException.fillInStackTrace(FunctionCallException.java:124)
at java.lang.Throwable.<init>(Throwable.java:195)
at java.lang.Exception.<init>(Exception.java:41)
at org.collaxa.thirdparty.jaxen.saxpath.SAXPathException.<init>(SAXPathException.java:83)
at org.collaxa.thirdparty.jaxen.JaxenException.<init>(JaxenException.java:82)
at org.collaxa.thirdparty.jaxen.FunctionCallException.<init>(FunctionCallException.java:86)
at oracle.tip.pc.services.functions.ExtFuncFunction$QueryDatabaseFunction.call(ExtFuncFunction.java:190)
at org.collaxa.thirdparty.jaxen.expr.DefaultFunctionCallExpr.evaluate(DefaultFunctionCallExpr.java:184)
at org.collaxa.thirdparty.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:107)
at org.collaxa.thirdparty.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:724)
at org.collaxa.thirdparty.jaxen.BaseXPath.selectNodes(BaseXPath.java:253)
at org.collaxa.thirdparty.jaxen.BaseXPath.evaluate(BaseXPath.java:210)
at com.collaxa.cube.xml.xpath.XPathUtil.evaluate(XPathUtil.java:93)
at com.collaxa.cube.engine.ext.wmp.BPELAssignWMP.evalFromValue(BPELAssignWMP.java:501)
at com.collaxa.cube.engine.ext.wmp.BPELAssignWMP.__executeStatements(BPELAssignWMP.java:122)
at com.collaxa.cube.engine.ext.wmp.BPELActivityWMP.perform(BPELActivityWMP.java:188)
at com.collaxa.cube.engine.CubeEngine.performActivity(CubeEngine.java:3408)
at com.collaxa.cube.engine.CubeEngine.handleWorkItem(CubeEngine.java:1836)
at com.collaxa.cube.engine.dispatch.message.instance.PerformMessageHandler.handleLocal(PerformMessageHandler.java:75)
at com.collaxa.cube.engine.dispatch.DispatchHelper.handleLocalMessage(DispatchHelper.java:166)
at com.collaxa.cube.engine.dispatch.DispatchHelper.sendMemory(DispatchHelper.java:252)
at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:5438)
at com.collaxa.cube.engine.CubeEngine.createAndInvoke(CubeEngine.java:1217)
at com.collaxa.cube.engine.delivery.DeliveryService.handleInvoke(DeliveryService.java:511)
at com.collaxa.cube.engine.ejb.impl.CubeDeliveryBean.handleInvoke(CubeDeliveryBean.java:335)
at ICubeDeliveryLocalBean_StatelessSessionBeanWrapper16.handleInvoke(ICubeDeliveryLocalBean_StatelessSessionBeanWrapper16.java:1796)
at com.collaxa.cube.engine.dispatch.message.invoke.InvokeInstanceMessageHandler.handle(InvokeInstanceMessageHandler.java:37)
at com.collaxa.cube.engine.dispatch.DispatchHelper.handleMessage(DispatchHelper.java:125)
at com.collaxa.cube.engine.dispatch.BaseScheduledWorker.process(BaseScheduledWorker.java:70)
at com.collaxa.cube.engine.ejb.impl.WorkerBean.onMessage(WorkerBean.java:86)
at com.evermind.server.ejb.MessageDrivenBeanInvocation.run(MessageDrivenBeanInvocation.java:123)
at com.evermind.server.ejb.MessageDrivenHome.onMessage(MessageDrivenHome.java:755)
at com.evermind.server.ejb.MessageDrivenHome.run(MessageDrivenHome.java:928)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
at java.lang.Thread.run(Thread.java:534)
Root cause:
java.lang.ClassCastException
at oracle.tip.pc.services.functions.ExtFuncFunction$QueryDatabaseFunction.call(ExtFuncFunction.java:158)
at org.collaxa.thirdparty.jaxen.expr.DefaultFunctionCallExpr.evaluate(DefaultFunctionCallExpr.java:184)
at org.collaxa.thirdparty.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:107)
at org.collaxa.thirdparty.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:724)
at org.collaxa.thirdparty.jaxen.BaseXPath.selectNodes(BaseXPath.java:253)
at org.collaxa.thirdparty.jaxen.BaseXPath.evaluate(BaseXPath.java:210)
at com.collaxa.cube.xml.xpath.XPathUtil.evaluate(XPathUtil.java:93)
at com.collaxa.cube.engine.ext.wmp.BPELAssignWMP.evalFromValue(BPELAssignWMP.java:501)
at com.collaxa.cube.engine.ext.wmp.BPELAssignWMP.__executeStatements(BPELAssignWMP.java:122)
at com.collaxa.cube.engine.ext.wmp.BPELActivityWMP.perform(BPELActivityWMP.java:188)
at com.collaxa.cube.engine.CubeEngine.performActivity(CubeEngine.java:3408)
at com.collaxa.cube.engine.CubeEngine.handleWorkItem(CubeEngine.java:1836)
at com.collaxa.cube.engine.dispatch.message.instance.PerformMessageHandler.handleLocal(PerformMessageHandler.java:75)
at com.collaxa.cube.engine.dispatch.DispatchHelper.handleLocalMessage(DispatchHelper.java:166)
at com.collaxa.cube.engine.dispatch.DispatchHelper.sendMemory(DispatchHelper.java:252)
at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:5438)
at com.collaxa.cube.engine.CubeEngine.createAndInvoke(CubeEngine.java:1217)
at com.collaxa.cube.engine.delivery.DeliveryService.handleInvoke(DeliveryService.java:511)
at com.collaxa.cube.engine.ejb.impl.CubeDeliveryBean.handleInvoke(CubeDeliveryBean.java:335)
at ICubeDeliveryLocalBean_StatelessSessionBeanWrapper16.handleInvoke(ICubeDeliveryLocalBean_StatelessSessionBeanWrapper16.java:1796)
at com.collaxa.cube.engine.dispatch.message.invoke.InvokeInstanceMessageHandler.handle(InvokeInstanceMessageHandler.java:37)
at com.collaxa.cube.engine.dispatch.DispatchHelper.handleMessage(DispatchHelper.java:125)
at com.collaxa.cube.engine.dispatch.BaseScheduledWorker.process(BaseScheduledWorker.java:70)
at com.collaxa.cube.engine.ejb.impl.WorkerBean.onMessage(WorkerBean.java:86)
at com.evermind.server.ejb.MessageDrivenBeanInvocation.run(MessageDrivenBeanInvocation.java:123)
at com.evermind.server.ejb.MessageDrivenHome.onMessage(MessageDrivenHome.java:755)
at com.evermind.server.ejb.MessageDrivenHome.run(MessageDrivenHome.java:928)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
at java.lang.Thread.run(Thread.java:534)
<2006-12-06 19:13:04,751> <ERROR> <UAT.collaxa.cube.xml> ORABPEL-09500
XPath expression failed to execute.
Error while processing xpath expression, the expression is "orcl:query-database(bpws:getVariableData("xpath"), false(), false(), "jdbc:oracle:thin:apps/apps@croaker:1529:RSICMI")", the reason is .
Please verify the xpath query.Hi,
QAbdul wrote:
when I tried to execute the followingin XMLQuery by calling TO_CHAR() whithin this query I am getting this error"ORA-19237: XP0017 - unable to resolve call to function - fn:TO_CHARTO_CHAR is a SQL function, XQuery is unaware of it.
XPath 2.0 specifications define a fn:format-date function but Oracle has not included yet in its XQuery implementation.
Easiest way to go is A_Non's solution, but if you need to format at multiple places in the query, you can declare a local XQuery function.
For example, to format to "DD/MM/YYYY" from the canonical xs:date format "YYYY-MM-DD" :
{code}
declare function local:format-date($d as xs:date) as xs:string
let $s := xs:string($d)
return concat(
substring($s, 10, 2), "/",
substring($s, 7, 2), "/",
substring($s, 2, 4)
{code}
and an example of use :
{code}
SQL> CREATE TABLE test_xqdate AS SELECT sysdate dt FROM dual;
Table created
SQL> SELECT *
2 FROM XMLTable(
3 'declare function local:format-date($d as xs:date) as xs:string
4 {
5 let $s := xs:string($d)
6 return concat(
7 substring($s, 10, 2), "/",
8 substring($s, 7, 2), "/",
9 substring($s, 2, 4)
10 )
11 }; (: :)
12 for $i in ora:view("TEST_XQDATE")/ROW/DT
13 return element e {
14 attribute xs_date_format { $i/text() },
15 attribute local_format { local:format-date($i) }
16 }'
17 COLUMNS
18 xs_date_format VARCHAR2(10) PATH '@xs_date_format',
19 local_format VARCHAR2(10) PATH '@local_format'
20 )
21 ;
XS_DATE_FORMAT LOCAL_FORMAT
2010-10-28 28/10/2010
{code} -
Use of sql group function in orcl:query-database - urgent
All,
Version: 10.1.3.4
Two requirements for me:
1. I want to use sum function in orcl:query-database. How to use it?
For ex: I tried the following
<xsl:value-of select='orcl:query-database("select sum(salary) from emp",false(),false(),"jdbc/DB1")'/>
I got the following error
oracle.xml.sql.OracleXMLSQLException: Character ')' is not allowed in an XML tag name.
When I tried without sum function, it works fine
2. I used the same table, but without the sum function as below
<xsl:value-of select='orcl:query-database("select salary from emp",false(),false(),"jdbc/DB1")'/>
This time, it returns the first employees salary!! I dont understand this logic. I expected either the query returns all the rows else it throws error, but none of them were true!
Can anyone pls explain what is the behavior? I want your reply for both the queries!
Currently I'm in a project where I'm working in the similar scenario, so please guru's let me know ASAP.
Thanks,
SenHi Sen,
Create a normal variable variable in XSLT.
Then use that variable.
I mean variable name='Var_1' select='Your Query'
Now use Var_1/yourcollection/...
I am giving some example
<xsl:variable name="Stopdetails" select="/ns0:MyEBM/ns0:DataArea/ns0:MyEBO/ns0:Stops/ns0:Stop[ns0:StopID=$TempStopId]"/>
<xsl:variable name="AccStopTypeVar">
<xsl:value-of select="$Stopdetails/ns0:StopType"/>
</xsl:variable>If you want you can loop on the created variable.
You can do these in XSL.
But DB calls those things ...it would be better , if u take them out. Spme debugging problems are there with XSL.
Regards
PavanKumar.M -
XPath function orcl:query-database usage
According to the limited documentation I can find for this XPath function, I should be able to return a nodeset enclosed in xml elements -
"Returns a node-set by executing the sql-query against the specified database. The second parameter rowset indicates if the rows should be enclosed in a element. The third parameter row indicates if each row should be enclosed in a element."
However, whatever second and third parameters I pass in to this function, it always returns a single string consisting of the selected fields and rows concatenated together.
Does anyone know how (or if) I can use this function to return a resultset as an XML nodeset? (All the examples I've been able to find for this function set the second & third parameters = false())Try this example (it uses internal orabpel table):
orcl:get-content-as-string(orcl:query-database('select id, process_instance from bpel_variable_sensor_values where id < 30',true(),true(),'jdbc/BPELServerDataSourceWorkflow'))
it generates something like this (string):
<ROWSET> <ROW num="1"> <ID>23.0</ID> <PROCESS_INSTANCE>21.0</PROCESS_INSTANCE> </ROW> <ROW num="2"> <ID>25.0</ID> <PROCESS_INSTANCE>21.0</PROCESS_INSTANCE> </ROW> <ROW num="3"> <ID>27.0</ID> <PROCESS_INSTANCE>21.0</PROCESS_INSTANCE> </ROW> <ROW num="4"> <ID>29.0</ID> <PROCESS_INSTANCE>21.0</PROCESS_INSTANCE> </ROW> </ROWSET>
or define this element type in your wsdl file (or your xsd):
<element name="ROWSET">
<complexType>
<sequence>
<element name="ROW">
<complexType>
<sequence>
<element name="ID" type="string"/>
<element name="PROCESS_INSTANCE" type="string"/>
</sequence>
<attribute name="num"/>
</complexType>
</element>
</sequence>
</complexType>
</element>
and try to assign the output to variable of that type(without orcl:get-content-as-string). It should work. -
Orcl:query-database in transform
Hi,
Suppose I am assigning the result of following to a field EmpId on the right had side of the transformation.
orcl:query-database(concat("select empno from emp where empno=",/tns:Root-Element/tns:Data/:tns:Empno),false(),false(),"jdbc/DbConnection")
Couple questions.
1) Can I use the above result in any subsequent queries in transformation, say get salary for this EmpID?
2) I am also worried about performance with this, as it doesn't look like the Empno is passed as a bind variable.
3) Is it possible to get the above query into a variable to be able to reuse later?
Appreciate your help.
Thanks1) You cannot use for subsequent queries in transformation. Every time you need to define this function....
2) Performance may be an issue if transaction load is higher. You can see the time it takes for transform activity on BPEL Console.
3) You should be able to. Just go to Expression Builder in Assign activity and write orcl and ctrl+space. You should be able to view the options. This may help you http://blogs.oracle.com/rammenon/2007/05/passing_bpel_variable_contents.html -
Query Syntax Bug in orcl:query-database function
Hi,
I have a 'Transform' process activity, I have a Description and I intend to get the corresponding Id on the basis of the "text Description".
e.g.
Input: "Jack"
table: EMP [i.e. Employee Table]
Expected Query: SELECT EMP_ID FROM EMP WHERE EMP_NAME = "Jack"
<SNIP>
<ns0:empId>
<xsl:value-of select="orcl:query-database('SELECT EMP_ID FROM EMP WHERE EMP_NAME="Jack"', false(), false(), 'jdbc:oracle:thin:soaadmin/soaadmin@localhost:1521:XE')"/>
</ns0:empId>
</SNIP>
Presently Resulting as:
oracle.xml.sql.OracleXMLSQLException: ORA-00904: "Jack": invalid identifier
Details:
It seems that it is not accepting quotes in the query.
- I tried escaping quote however it did not work.
- I tried giving " or amp;quot; or " - nothing worked.
Please Suggest me something on this.
regards
JoyHow about:
<ns0:empId>
<xsl:value-of select="orcl:query-database('SELECT EMP_ID FROM EMP WHERE EMP_NAME=&apos;Jack&apos;', false(), false(), 'jdbc:oracle:thin:soaadmin/soaadmin@localhost:1521:XE')"/>
</ns0:empId>
? -
SSIS OLE DB Source in Data Flow Task calling SP that returns variable number of column as output
We have one old Stored Proc that I need to reuse. But that stored proc returns different number of Columns as output depending on input Parameter. Say, if I pass 1 to 9 it will return 'ID', if i pass 10 to 33 it will return 'ID', 'Name', if I pass
34 to 51 it will return 'ID', 'Name', 'DefaultPosition'
In this way.
Now I wanted to use this in OLE DB Source in SSIS DFT.
During that time immediately it is picking all possible columns in Available External Columns. Even if I manually select/delete those, package is failing at Runtime, because in Runtime the parameter this will get, it should always return one & only one
column which is ID. [Because in this package I will only have to pass parameters like, 1 or 2 or 5 or 7 or 9.
Which in every case should return only ID from stored proc.
Any Idea how I can get this please?
Regards, Avik M.Has any one tried something like it? Could you please provide me a sample if you have done it.
I tried these options but always got errors as
[usp_return [64]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E55.An OLE DB record is available. Source:
"Microsoft SQL Server Native Client 10.0" Hresult: 0x80040E55 Description: "Column does not exist.".
[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "usp_return" (64) returned error code 0xC0202009. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning
of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.
~ Thank you so much
Regards, Avik M. -
Problem in using oraext:query-database() command in xslt
Hi,
I am querying a function through the query-database() command in a certain xslt within a BPEL Process as below:
<xsl:variable name="Corporation">
<xsl:value-of select="string('CORPORATION')"/>
</xsl:variable>
<xsl:variable name="CustAccIdFrmDB">
<xsl:value-of select='orext:query-database(concat("select xx_egytrans_integration.get_xid(",$getCustAccID,",",$Corporation,") from dual"),false(),false(),string("jdbc/otmdatasource"))'/>
</xsl:variable>
But, after deploying the BPEL Process and while running it, I am getting error at run-time.
Below is the error,
<bpelFault><faultType>0</faultType><subLanguageExecutionFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="summary"><summary>XPath expression failed to execute. An error occurs while processing the XPath expression; the expression is ora:doXSLTransformForDoc('xsl/Transformation__CustomerUpdate.xsl', $Invoke_getProfileOptions_getProfileOptions_OutputVariable.getProfileOptionsOutputCollection, 'Invoke_CustomerUpdateProc_Customer_UpdateProc_OutputVariable.OutputParameters', $Invoke_CustomerUpdateProc_Customer_UpdateProc_OutputVariable.OutputParameters, 'Invoke_CustAccProc_getCustAccID_OutputVariable_1.OutputParameters', $Invoke_CustAccProc_getCustAccID_OutputVariable_1.OutputParameters, 'Invoke_GetCustTaxExempt_getCustTaxExempStatus__Update_OutputVariable.OutputParameters', $Invoke_GetCustTaxExempt_getCustTaxExempStatus__Update_OutputVariable.OutputParameters, 'Invoke_getCustContactUpd_get_cust_acc_site_contactUpd_OutputVariable.OutputParameters', $Invoke_getCustContactUpd_get_cust_acc_site_contactUpd_OutputVariable.OutputParameters). The XPath expression failed to execute; the reason was: javax.xml.transform.TransformerException: XML-22900: (Fatal Error) An internal error condition occurred.. Check the detailed root cause described in the exception message text and verify that the XPath query is correct. </summary></part><part name="code"><code>XPathExecutionError</code></part></subLanguageExecutionFault></bpelFault>
Could you please let me know the probable reason for the error? Please help at the earliest.
Thanks,
PromitHi Anshul,
Thanks for replying.
The query upon executing in SQL Plus returns proper value. The result is either a concatenated string or 'NO_DATA'.
Please note that: $getCustAccID --> x-path expression and $Corporation --> hardcoded value - 'CORPORATION'.
I have tried formatting the string of the query in various ways, but no luck.. In all cases the error is same.
Waiting for your reply.
Thanks in advance..
Regards,
Promit -
OracleDataAdapter returning wrong number of columns
Hello All,
I have an issue of an oracle data adapter not returning all columns in my select statement. When I use code similar to below, the data adapter returns 2 columns per row instead of 5. And they are out of order (ie, DataRow(0) could be column 1 and DataRow(1) could be column 4 -- so I don't see which columns have been dropped without looking at the value).
The database id XE on the local machine. The connection works fine. And the internal VS.NET PL/SQL debugger returns the query just fine.
Some of the columns I'm trying to get are null -- in fact, most are. But they are changed during the program. So I still need them to show up in the dataset.
BTW, I have had zero success getting OracleCommand.BindByName and OracleParameters to work, so I punted. Since I can get what I want out of readers and datasets, I can live without'em -- or can I?!?!
I think my problem has something to do with handling null values. So I have tried the select statement with NVL wrapping the fields that could be null. But still no success.
Any ideas?
Table:
account char(30) not null
col_code as NUMBER(1,0) null ok
columnIDontNeed as whatever null ok
sum1 as char(1) null ok
sum2 as char(1) null ok
sum3 as char(1) null ok
anotherColumnIDontNeed as whatever null ok
Sample Code:
dim oconn as New OracleConnection(conStrBldr.toString)
Dim cmdLedger As OracleCommand = oconn.CreateCommand
cmdLedger.BindByName = True ' seems to affect nothing! ever!
cmdLedger.AddToStatementCache = False ' no noticable affect
cmdLedger.CommandText = " SELECT account,col_code,sum1,sum2,sum3 "
cmdLedger.CommandText &= "FROM gl.ledger "
cmdLedger.CommandText &= "ORDER BY gl.ledger.account "
cmdLedger.CommandType = CommandType.Text
' Create DataAdapter based on main Ledger SELECT
Dim cmdLedgerDA As New OracleDataAdapter(cmdLedger)
cmdLedgerDA.ReturnProviderSpecificTypes = True ' same results with False
' Create DataSet and Fill it.
' After this, we can now use this dataset
' to iterate through the GL ledger data.
Dim cmdLedgerDS As New DataSet("GLBal")
Try ' to fill dataset with Ledger SELECT
' fill dataset from OracleDataAdapter and the
' previously defined Oracle Command.
cmdLedgerDA.Fill(cmdLedgerDS, "GL.LEDGER") ' tried with and without src
Catch ex As OracleException
ShowEx(ex)
End Try ' to fill dataset with Ledger SELECT
These are the typical test from within VB that I've run to check what was returned:
console.writeline(cmdLedgerDS.Tables(0).Rows(0).ItemArray.Length)
2
dim row as DataRow = cmdLedgerDS.Tables(0).Rows(0)
console.writeline(row(0).toString & row(1).toString & row(2).toString & row(3).toString & row(4).toString) ' EXCEPTION IS THROWNI cannot reproduce the error using basic code below. What is the specific exception you get?
And BindByName is not necessary since you're not using bind variables
Sub Main()
Dim da As OracleDataAdapter
Dim sqlstr As String
Dim connstr As String
Dim ds As DataSet
Dim dr As DataRow
Dim dc As DataColumn
Try
sqlstr = "select employee_id, first_name, last_name, null, salary "
sqlstr &= "from employees where rownum < 10"
connstr = "Data Source=xe;User ID=hr;Password=hr;"
da = New OracleDataAdapter(sqlstr, New OracleConnection(connstr))
ds = New DataSet("EmployeeDS")
da.Fill(ds, "employees")
For Each dc In ds.Tables("employees").Columns
Console.Write(dc.ColumnName & " ")
Next
Console.WriteLine()
For Each dr In ds.Tables("employees").Rows
Console.WriteLine(dr(0).ToString & " " & _
dr(1).ToString & " " & dr(2).ToString & " " & _
dr(3).ToString & " " & dr(4).ToString)
Next
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End SubOutput should look like
EMPLOYEE_ID FIRST_NAME LAST_NAME NULL SALARY
100 Steven King 24000
101 Neena Kochhar 17000
102 Lex De Haan 17000
103 Alexander Hunold 9000
104 Bruce Ernst 6000
105 David Austin 4800
106 Valli Pataballa 4800
107 Diana Lorentz 4200
108 Nancy Greenberg 12000I am using VS2005, ODP 10.2.0.2.21 and OracleXE on remote machine.
NH
Message was edited by:
nurhidayat -
Is it posible a query that builds dynamically the number of columns?
Hi experts!
I have a query that shows amounts in 12 columns corresponding on the calendar months of the year. Now, I need to change that getting in a previous screen how many months the user wants to see. The query has to build dynamically the number of columns to show. Can I do that with query designer? How?
I am working in V7.0.
I appreciate your help.
Thanks!
Ada.Hi experts!
I have a query that shows amounts in 12 columns corresponding on the calendar months of the year. Now, I need to change that getting in a previous screen how many months the user wants to see. The query has to build dynamically the number of columns to show. Can I do that with query designer? How?
I am working in V7.0.
I appreciate your help.
Thanks!
Ada. -
Bex query that returns variable number of columns based upon variable value
I have a request to create a query that, at excution time, has a variable for 'nbr of months', and based on the value entered by the user, returns data for only the specified number of months. Value that can be entered can vary from 1 to 12. A simple example is, if the user enters 1, then they would only want to see one column, and if they entered 6, then they'd like to see 6 columns in the workbook. All suggestions on how to implement this dynamic columns on a workbook will be appreciated.
Thanks.
BNHi,
Do this->
1) first create a New Structure in Rows-> Place your New Selection and drag your KF.
2) Nw Create a New Formual under this structure. Now Create a Formula variable ( "ZFVXXX")with user-entry and ready for input and dimension as NUmber. and place in formula area. And hide this formula.
3)Now Create a New Customer-Exit variable on 0CALMONTH name as "ZCECMON" with following atrribute->Mandatory, Range(Interval) and remove check for Ready for entry.
4)Drag your 0CALMONTH in Rows above That Structure and restrict it to "ZCECMON".
5) Now go to CMOD and write this code.
INCLUDE ZXRSRU01 *
DATA: L_S_RANGE TYPE RSR_S_RANGESID. 'In global area
DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT. 'In global area
DATA: zmonth like /bi0/0calmonth.
CASE I_VNAM.
WHEN 'ZCECMON'.
IF i_step = 2.
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZFVXXX'.
zyear = sy-datum(4).
zmonth = sy-datum+4(2).
l_s_range-low = zmonth.
zmonth = zmonth + loc_var_range-low.
l_s_range-HIgh = zmonth.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
APPEND l_s_range TO e_t_range.
ENDIF.
ENDCASE.
6) activate the porject and go to rsrt and run there first.
Regards,
San!
Message was edited by: San! -
Query database and return result set to cells.
hello all i have vsto solution im building im trying to put together a generic query text box for my end user the only problem is that it appears to be that with oracle data access when you do a query you must pass all the values to a variable.
Sub Orcl()
Dim oradb As String = "Data Source=(DESCRIPTION=(ADDRESS_LIST=" _
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=xxx)(PORT=1521)))" _
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=xxx)));" _
+ "User Id=xx;Password=xx;"
Dim conn As New Oracle.DataAccess.Client.OracleConnection(oradb) ' Visual Basic
conn.Open()
Query = select * from fabinvh
Dim cmd As New Oracle.DataAccess.Client.OracleCommand
cmd = conn.CreateCommand()
cmd.Connection = conn
cmd.CommandText = Query
Dim dr As Oracle.DataAccess.Client.OracleDataReader = cmd.ExecuteReader()
While dr.Read()
Globals.ThisAddIn.Application.ActiveCell.Value = (dr.Item(1))''' HOW DO I CHANGE HERE TO JUST BRING IN ALL THE COLUMNS AND HEADERS?
Globals.ThisAddIn.Application.ActiveCell.Offset(1, 0).Select()
End While
dr.Dispose()
cmd.Dispose()
conn.Dispose()
End Subthanks in advance im able to do this with oo4o rather easily but I'm tryint go learn more of the odp.net oracle data access and learning is pretty slow right now.ok I think im getting closer to my answer i believe i need to use the
GetValues. property. does anyone have an example on how to use this i keep getting errors when i try it. -
SELECT query & Database Table Difference in number of records
Hi All,
In program it’s selecting 3 records based on selection parameters whereas when i execute SE16 with same selection criteria gives 4 records.
Please suggest when we will face these kind of issue
Thanks,
SpandanaSELECT objnr wlges
FROM bpge
INTO TABLE t_bpge
FOR ALL ENTRIES IN t_prps
WHERE lednr EQ c_0002
AND objnr EQ t_prps-objnr
AND wrttp EQ c_41.
Here t_prps-objnr has the following values
PR00473170
PR00397060
PR00397061
PR00397062
PR00397063
PR00397064
PR00397065
For this selection criteria there are 4 records in BPGE table where as the program is fetching only 3 -
Database best practice: max number of columns
I have two questions that I would appreciate comments on...
We have a table titled TRANSACTION with 160 columns and a view titled TRANSACTIONS_VIEW with 233 columns in it. This was designed by someone a while ago. I am wondering if it is against best practice to have this many columns in a table? I have never before seen a table with this many columns in it and feel that there must be a way to split the data into multiple tables to make it more manageable.
My second question is on partitions, the above table TRANSACTION is partitioned by manually specifying partitions with max values on the transaction date starting august 2008 through january 2010 at 1 month increments. Isn't it much better to specify automatic partitioning using the interval clause?kev374 wrote:
thanks for the response, yes there are many columns that violate 3NF and that is why the column count is so high.
Regarding the partition question, by better I meant by using "interval" the partitions could be created automatically at the specified interval instead of having to create them manually.The key is to understand the logic behind these tables and columns. Why it was designed like this, if it's business requirement then 200 some columns are not bad, if it's design flaw 20 columns could be too much. It's not necessarily always good to have strict 3NF design, sometime for various reason you can denormalize the tables to get better performance.
As to partitioning Q, you have to do the rolling window (drop/add partition as time goes by) type of partitioning scheme manually so far.
Maybe you are looking for
-
Photoshop CC Crashes Regularly on OSX 10.9.2 (Only 14.1+)
Hello, I have a problem that's been going on since 14.1+ came out. It doesn't seem to be triggered by anything specific and happens randomly although regularly; about every 10 minutes. I haven't had the time to troubleshoot this as I have to get work
-
Follow-up to HP Photosmart C6180 Scan Problem
I posted the below a few days ago and since then have spoken with a few people who have experienced the same difficulty. We came to the conclusion this problem began after a recent driver update from Apple (sorry we can't remember exactly which one-a
-
HP Officejet 5610 all in one Communication Error Message on Mac with 10.10.2
Hi, I got a new MAC computer running 10.10.2 Yosemite. I own the HP 5610 Officejet all in one printer. The new computer doesn't recognize the printer or scanner. I went to my applications folder and tried to uninstall the HP software but the printer
-
Tiger & PS CS2&3 image redraw with hand tool.
Having aproblem with Adobe Photoshop CS2 and 3 after I up graded to Mac OSX Tiger. Currently, I am on version 10.4.8. Does anybody know how to fix image redraw problem I am experiencing? It does not happen every time, but it happens enough to be very
-
Auto Duplex Unit on Officejet pro K550
Auto Duplex Unit works but will not carry over two-sided printing to next two-sided print job after exiting print. Must setup every time I need to print two-sided. This question was solved. View Solution.