Dynamic sql in BPEL SOA DB Adapters
Hi,
My requirement is to pass parameters to IN clause in SQL query in DB adapter. But my existing query has more than 1 where clause which fetched the details for single employee. Now I want to modify that query.
Existing Query:select a.last_name as LAST_NAME, a.first_name as FIRST_NAME from people a, assignments b where (a.employee_number = #EmpNum1 or a.npw_number = #EmpNum2) and trunc(sysdate) between a.EFFECTIVE_START_DATE and a.EFFECTIVE_END_DATE and a.person_id = b.person_id and b.primary_flag = 'Y' and b.assignment_status_type_id <> 3 and b.effective_start_date = (select max(effective_start_date) from assignments where person_id in (select distinct person_id from people where (employee_number = #EmpNum3 or npw_number = #EmpNum4) and trunc(sysdate) between effective_start_date and effective_end_date) and primary_flag = 'Y' and assignment_status_type_id <> 3) and rownum < 2
For dynamic parameter passing i found that we need to put In clause as shown in link:Neeraj Sehgal - Experimenting with SOA: Pass multiple parameters, dynamic query in Pure SQL in Database Adapter
How to frame original query to have IN clause?
answered in:
Bind variables in SQL query of DBAdapter
Similar Messages
-
Hi All,
Is it possible to construct dynamic SQl query in BPEL/ in DBadapter..?
My usecase is
1)BPEL receives input
2) Input contains <document-id> tags at various parts of input XML, each time no of <document-id> tags may vary
3) I want to include <document-id> tag values in Query construction, but I dont know how many times <document-id> reapeats in the Input..
How to do this case...?
Any suggestions..?
Thanksanswered in:
Bind variables in SQL query of DBAdapter -
Error while testing SOA sample adapters-db-101-File2StoredProcedure
Dear all,
I am testing SOA application adapters-db-101-File2StoredProcedure from SOA samples and I got the error:
<messages>
<input>
<Invoke_API_AddCustomers_InputVariable>
<part name="InputParameters">
<InputParameters>
<C>
<C_ITEM>
<FNAME>John</FNAME>
<LNAME>Doe</LNAME>
<LOC>
<STREET>123 Main Street</STREET>
<CITY>Anytown</CITY>
<STATE>CA</STATE>
<ZIP>12345</ZIP>
</LOC>
<EMAIL>[email protected]</EMAIL>
<PHONE>567-123-9876</PHONE>
</C_ITEM>
<C_ITEM>
<FNAME>Jane</FNAME>
<LNAME>Doe</LNAME>
<LOC>
<STREET>987 Sunset Blvd</STREET>
<CITY>Sometown</CITY>
<STATE>CA</STATE>
<ZIP>34567</ZIP>
</LOC>
<EMAIL>[email protected]</EMAIL>
<PHONE>567-123-9876</PHONE>
</C_ITEM>
</C>
</InputParameters>
</part>
</Invoke_API_AddCustomers_InputVariable>
</input>
<fault>
<bpelFault>
<faultType>0</faultType>
<bindingFault>
<part name="summary">
<summary>Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'AddCustomers' failed due to: Stored procedure invocation error. Error while trying to prepare and execute the ADD_CUSTOMERS API. An error occurred while preparing and executing the ADD_CUSTOMERS API. Cause: java.sql.SQLSyntaxErrorException: ORA-00902: invalid datatype ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary>
</part>
<part name="detail">
<detail>ORA-00902: invalid datatype </detail>
</part>
<part name="code">
<code>902</code>
</part>
</bindingFault>
Does anybody tried to execute this sample?
Best regardsSorry,
I was reading about DB adapter and tried to solve a problem with insert data from file into a table, but the order of data is not correct, so I then desided to
use insert of type instead.
That is the reason for post here. -
Build dynamic SQL query in Database Adapter.
Hi All,
I have a requirement to build dynamic sql query at Database Adapter.
My BPEL process is getting search spec as input from siebel. I need to process this searchspec in BPEL and need to build the SQL query dynamically at Database Adapter to fetch the records from DB.
it goes like this....
1. Sieble Search Spec: city1 OR city2 OR city3 OR city4 .....
I need to build query as
select * from S_ADDR_PER where city like 'city1' OR city like 'city2' OR city like 'city3' OR city like 'city4' ......
2. Siebel Search spec: city1 AND country1 AND state1....
I need to build query as
Select * from S_ADDR_PER where city like 'city1' AND country like 'country1' AND state like 'state1' ....
3. Siebel Search spec: state
I need to build query as
select * from S_ADDR_PER where state like '%state%';
Is it feasible in Database Adapter? if its Yes.
Any guidelines to achieve this?
Thank you
ChandraHi All,
I have a requirement to build dynamic sql query at Database Adapter.
My BPEL process is getting search spec as input from siebel. I need to process this searchspec in BPEL and need to build the SQL query dynamically at Database Adapter to fetch the records from DB.
it goes like this....
1. Sieble Search Spec: city1 OR city2 OR city3 OR city4 .....
I need to build query as
select * from S_ADDR_PER where city like 'city1' OR city like 'city2' OR city like 'city3' OR city like 'city4' ......
2. Siebel Search spec: city1 AND country1 AND state1....
I need to build query as
Select * from S_ADDR_PER where city like 'city1' AND country like 'country1' AND state like 'state1' ....
3. Siebel Search spec: state
I need to build query as
select * from S_ADDR_PER where state like '%state%';
Is it feasible in Database Adapter? if its Yes.
Any guidelines to achieve this?
Thank you
Chandra -
Service Registry's Dynamic Lookup of BPEL Partner Link not working
Hi,
Software : SOA 10.1.3.1
OS : Windows XP, 2000
I have deployed webservice application (GetMaxOfTwo) which will give me max of 2 values. Registered the WS in OWSM with user authentication. Registered newly generated WSDL in OSR (Oracle Service Registry). A simple BPEL Process will call service as PartnerLink, which is configured as "Enabling Dynamic Lookup of BPEL Partner Link Endpoints". As mentioned in the document made entry in bpel.xml as registryServiceKey property containing the serviceKey value to the partnerLinkBinding section.
The entire scenario is working fine and changed the servicekey value to wrong value in bpel.xml and redeployed, as expected it was giving me error message saying invalid servicekey.
Now deployed GetMaxOfTwo in another application server and registered in OWSM. Intentionally stopped the first GetMaxOfTwo application. In the OSR Service changed the binding with new WSDL of OWSM. As BPEL process enabled with dynamic lookup it should execute without any error. But the results in this case was giving error saying the service was down. (Means it is referring to the old GetMaxOfTwo webservice.
What could be the reason?, something is missing in the configuration?
Regards
Venkata M Rao
+91 80 4107 5437Hi
I am having trouble making the BPEL and Systinet to work together. I have Systinet and BPEL installed separately on 2 different servers. I deployed my web services and registered them in UDDI. I created a new BPEL process and added a partner link to refer to one of the web service I have registered in UDDI. When I create the partner link, it is forcing me to give the wsdl and it also gives an error message " There are no partner link types defined in current wsdl. Do you want create that will by default create partner link type for you?". If I say "NO' then deployment fails. If I say "Yes", then it creates a new wsdl file on the local server etc and gives "<Faulthttp://schemas.xmlsoap.org/soap/envelope/>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>com.oracle.bpel.client.delivery.ReceiveTimeOutException: Waiting for response has timed out. The conversation id is 75164a0815ea471a:-3be8c246:117cc377894:-537b. Please check the process instance for detail.</faultstring>". Any help is appreciated. -
If table testrh2 has the following columns and data
col1 --> NULL
col2 --> 2
and table testrh has the following columsn and data
col1 --> NULL
How could I write a dynamic SQL statement to join on the nulls? I've written the following block as a starting point.
declare
cursor c1 is select col1 from isis.testrh;
lval varchar2(1000);
lval2 varchar2(1000);
begin
for r1 in c1 loop
lval := 'select col2 from isis.testrh2 where col1 = '||r1.col1;
execute immediate lval into lval2;
dbms_output.put_line(lval2);
end loop;
end;You can't compare null values with '=' in Oracle SQL.
Null can only be compared with <column> is null .
You can see it when you try these two queries:
select * from dual where null is null; -- you will see one row
select * from dual where null=null; -- you will see no rowsThat's why you have to write something like
(<column1>=<column1> or (<column1> is null and <column2> is null))This should also work with null:
decode(<column1>,<column2>,1,0)=1By the way, why do you use dynamic sql?
lval := 'select col2 from isis.testrh2 where col1 = '||r1.col1;
I think you could replace your two lines ( lval:= ... AND execute immediate) by this:
begin
select col2
into lval
from isis.testrh2
where decode(col1,r1.col1,1,0)=1;
dbms_output.put_line('lval='||lval);
exception
when no_data_found then
dbms_output.put_line('no data found'); -- or whatever you want
end;Edited by: hartmutm on 02.10.2010 23:54 -
How to rename C00n generic column names in a Dynamic SQL report
I have a an interface whereby the user can select 1 to 60 (upper limit) columns out of 90 possible columns (using a shuttle) from one table before running a report.
To construct the SQL that will eventually execute, I'm using a "PLSQL function body returning SQL query" with dynamic SQL. The only problem is that I have to use "Generic Column Names" option to be able to compile the code and end up with c001 to c060 as the column names.
How can I use the names of the selected columns as the report headings rather than c001, C002... etc?
I do not know beforehand which columns, or how many columns or the order of the selected columns.
I know Denes K has a demo called Pick Columns but I can't access his code. I have a hunch though that he may be just using conditions to hide/show the apropriate columns.
thanks in advance
PaulPHi Paul
I would change the Heading Type in the Report Details screen to PLSQL and use the shuttle item to return the column values. e.g.
RETURN :p1_shuttle;
I'm assuming the shuttle already has a colon separated list of the column headings in the correct order?
I hope that helps
Shunt -
hi all,
I am using oracle 10g version.
I have one table but i do not have any unique id to identify the row.
I want to have a unique id temporarily in my select statement (dynamic sql) in a stored procedure while fetching the results, so that i can return my results along with the unique id through the cursor.
Please help me...
Thanks in advance to all...it depends if you have a more than one column that you can uniquely identify and put them together by concatenating you can have a unique id. or a rowid might help you to temporarily identify a row.
SQL> select e.* from employee e;
FNAME MINIT LNAME SSN BDATE ADDRESS SEX SALARY SUPERSSN DNO
John B Smith 123456789 09-Jan-1965 731 fONDREN, hOUSTON, TX M 30000.00 333445555 5
Frankin T Wong 333445555 08-Dec-1955 683 Voss, Houston,Tx M 40000.00 888665555 5
Alicia J Zelaya 999887777 19-Jul-1968 3321Castle, Spring, TX F 25000.00 987654321 4
Jennifer S Wallace 987654321 20-Jun-2041 291 Berry, Bellaire, TX F 43000.00 888665555 4
Ramesh K Narayan 666884444 15-Sep-1962 975 Fire Oak, Humble, TX F 38000.00 333445555 5
Joyce A English 453453453 31-Jul-1972 5631 Rice,Houston,TX F 25000.00 333445555 5
Ahmad V Jabbar 987987987 29-Mar-1969 980 Dallas,Houston, TX M 25000.00 987654321 4
James E Borg 888665555 10-Nov-2037 450 Stone, Houston, TX M 55000.00 1
8 rows selected
SQL> select rowid, e.* from employee e;
ROWID FNAME MINIT LNAME SSN BDATE ADDRESS SEX SALARY SUPERSSN DNO
AAD8pbAAJAAAJ4fAAA John B Smith 123456789 09-Jan-1965 731 fONDREN, hOUSTON, TX M 30000.00 333445555 5
AAD8pbAAJAAAJ4fAAB Frankin T Wong 333445555 08-Dec-1955 683 Voss, Houston,Tx M 40000.00 888665555 5
AAD8pbAAJAAAJ4fAAC Alicia J Zelaya 999887777 19-Jul-1968 3321Castle, Spring, TX F 25000.00 987654321 4
AAD8pbAAJAAAJ4fAAD Jennifer S Wallace 987654321 20-Jun-2041 291 Berry, Bellaire, TX F 43000.00 888665555 4
AAD8pbAAJAAAJ4fAAE Ramesh K Narayan 666884444 15-Sep-1962 975 Fire Oak, Humble, TX F 38000.00 333445555 5
AAD8pbAAJAAAJ4fAAF Joyce A English 453453453 31-Jul-1972 5631 Rice,Houston,TX F 25000.00 333445555 5
AAD8pbAAJAAAJ4fAAG Ahmad V Jabbar 987987987 29-Mar-1969 980 Dallas,Houston, TX M 25000.00 987654321 4
AAD8pbAAJAAAJ4fAAH James E Borg 888665555 10-Nov-2037 450 Stone, Houston, TX M 55000.00 1
8 rows selected
SQL> -
Can we use Dynamic SQL in Oracle Reports ?
Hi ,
Can we use Dynamic SQL in Oracle Reports ?
If yes please give some examples .
Thanx
sriniI believe the built-in package SRW.Do_Sql is what you are looking for
Example from the document:
/* Suppose you want to create a "table of contents" by getting the
** first character of a columns value, and page number on which its
** field fires to print. Assume that you want to put the "table of
contents"
** into a table named SHIP. You could write the following construct:
DECLARE
PAGE_NO NUMBER;
PAGE_FOR INDEX NUMBER;
SORT_CHAR CHAR(1);
CMD_LINE CHAR(200);
BEGIN
SORT_CHAR := :SORT_NAME ;
IF :CALLED = Y THEN
SRW.GET_PAGE_NUM(PAGE_FOR_INDEX);
SRW.USER_EXIT(RWECOP PAGE_FOR_INDEX
P_START_PAGENO);
SRW.MESSAGE(2,TO_CHAR(:P_START_PAGENO));
END IF;
SRW.GET_PAGE_NUM(PAGE_NO);
CMD_LINE := INSERT INTO SHIP VALUES
(||SORT_CHAR||,||TO_CHAR(PAGE_NO)||);
SRW.MESSAGE(2,CMD_LINE);
SRW.DO_SQL(CMD_LINE);
COMMIT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
NULL;
WHEN SRW.DO_SQL_FAILURE THEN
SRW.MESSAGE(1,FAILED TO INSERT ROW INTO SHIP TABLE);
WHEN OTHERS THEN
COMMIT;
END; -
How to mention numbers in array while creating dynamic sql
Hi,
I am creating a dynamic sql and in that I am selecting some rows from the table and storing it into the array.
I am firing this sql statement within trigger.
But i got the error:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
I took the same sql statement (the one which was created dynamically) in the procedure and tried to run it but it gave me the same error.
=========================================================
Begin
type NewValueArray is table of varchar2(4000);
nVal_Array NewValueArray;
Begin
Select
DISCOVERYHOSTNAME,
DISCOVERYMACPRIMARYPHYSICAL,
DISCOVERYSERIALNUMBER
into
nVal_Array(1),
nVal_Array(2),
nVal_Array(3)
from ALT_42_Consolidated
where rowid = 'AAEWNEABXAAAAkxAAA';
EXCEPTION
WHEN others THEN
Raise;
End;
=========================================================
I tried using to_number but still the same error.
Can some body please inform me where I am goofing.
Thanks!I got a different error, but you need to initialise your nval_array and make sure it can hold three values. The following should work:
declare
type NewValueArray is table of varchar2(4000);
nVal_Array NewValueArray := NewValueArray();
Begin
nval_array.extend(3);
Select col1, col2, col3
into nVal_Array(1), nVal_Array(2), nVal_Array(3)
from tab1
where rowid = 'AAAGJZAAGAAAAAWAAV';
EXCEPTION
WHEN others THEN
Raise;
End;
/ -
Hi all,
I'm under 10G r1
I want to execute a dynamic SQL with merge in it
when I try with insert ,update it works
but I just want to use merge if possible
this is the code
CREATE OR REPLACE
PROCEDURE I_COLUMN_CDS_FIXINGS
v_ticker VARCHAR2,
v_date DATE,
v_tenor VARCHAR2,
v_bid NUMBER,
v_ask NUMBER)
AS
l_column VARCHAR2(80);
v_column_bid VARCHAR2(80);
v_column_ask VARCHAR2(80);
v_source VARCHAR2(60) :='CMAN@BBG';
v_gen_order pls_integer;
BEGIN
SELECT 'CDS_SPREAD_'
||v_TENOR
||'_BID'
INTO v_column_bid
FROM dual;
SELECT 'CDS_SPREAD_'
||v_TENOR
||'_ASK'
INTO v_column_ask
FROM dual;
dbms_output.put_line(v_ticker||' '||v_column_ask||' '||v_column_bid||' '||v_bid|| ' '||v_ask||' '||v_date);
EXECUTE immediate 'MERGE into CDS_FIXINGS C
using ( select v_ticker,'
||v_column_bid
||','
||v_column_ask
||',trunc(v_date) info_date ,v_bid,v_ask from dual ) B
on (C.cds_ticker=b.v_ticker and c.info_date=b.info_date)
WHEN MATCHED THEN
update set '||v_column_bid||'=:1,'||v_column_ask||'=:2 using v_bid,v_ask
WHEN NOT MATCHED THEN
INSERT
CDS_TICKER ,
INFO_DATE ,
'||v_column_bid||' ,
'||v_column_ask||' ,
SOURCE
VALUES (:1, :2,:3,:4,:5) ' using v_ticker,
v_date ,
v_bid ,
v_ask ,
v_source
---EXCEPTION
---when others then raise;
end;
when I launch hte procedure
exec i_column_cds_fixings('TEST',trunc(sysdate-1),'8Y',4232.01,4234.02);
I get
ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at "OWNER_HISTO.I_COLUMN_CDS_FIXINGS", line 26
ORA-06512: at line 1
How can I deal with this
Thanks
babata
I getSorry
this is formatted one
REATE OR REPLACE PROCEDURE i_Column_cds_FixIngs
(v_Ticker VARCHAR2,
v_Date DATE,
v_Tenor VARCHAR2,
v_Bid NUMBER,
v_Ask NUMBER)
AS
l_Column VARCHAR2(80);
v_Column_Bid VARCHAR2(80);
v_Column_Ask VARCHAR2(80);
v_Source VARCHAR2(60) := 'CMAN@BBG';
v_gen_Order PLS_INTEGER;
BEGIN
SELECT 'CDS_SPREAD_'
||v_Tenor
||'_BID'
INTO v_Column_Bid
FROM Dual;
SELECT 'CDS_SPREAD_'
||v_Tenor
||'_ASK'
INTO v_Column_Ask
FROM Dual;
dbms_Output.Put_Line(v_Ticker
||' '
||v_Column_Ask
||' '
||v_Column_Bid
||' '
||v_Bid
||' '
||v_Ask
||' '
||v_Date);
EXECUTE IMMEDIATE 'MERGE into CDS_FIXINGS C
using ( select v_ticker,'
||v_Column_Bid
||','
||v_Column_Ask
||',trunc(v_date) info_date ,v_bid,v_ask from dual ) B
on (C.cds_ticker=b.v_ticker and c.info_date=b.info_date)
WHEN MATCHED THEN
update set '
||v_Column_Bid
||'=:1,'
||v_Column_Ask
||'=:2 USING v_bid,v_ask
WHEN NOT MATCHED THEN
INSERT
CDS_TICKER ,
INFO_DATE ,
||v_Column_Bid
||' ,
||v_Column_Ask
||' ,
SOURCE
VALUES
:1,
:2,
:3,
:4,
:5
USING v_Ticker,v_Date,v_Bid,v_Ask,v_Source;
---EXCEPTION
---when others then raise;
END;
/ -
We are running an oracle sql procedure that uses a LOT of dynamic sql. We are using a 3rd party package (SQR) as a sort of shell to run the sql procedure. The 3rd party package passes to us an oracle error. This error says, in effect, that there are no inactive database cursors available and that the sql program is too large to process. We conclude from this that we must increase one or more of the cursor parameters in init.ora (v$parameters). Is this the correct assumption? If not, does anyone know what we can do? We'd prefer not to break up the sql procedure into smaller pieces.
increase the parameter for open cursors.
check, wether all cursors in your programs are closed in time, or if you are using ref cursors from front-ends (e.g. Java JDBC) that this front-ends close these ref cursors , too.
If you want to decrease the size of procedures get rid of comments, superfluos spaces, tabs, etc.
keep a commented version outside vor documentation purposes.
Hope thsi helps -
Dynamic SQL and 255 bytes per line limit
I would like to create a Dynamic SQL statement that is longer than 255 bytes. What do I need to do to embed a carriage return or something so that the resultant string is broken up into multiple lines?
Please ignore. This was a stupid question!
-
Dynamic SQL and GRANT CREATE ANY TABLE
hi gurus,
i have a dynamic SQL in a procedure where a table will be created from an existing table without data.
strSQL:='create table ' || strTemp || ' as select * from ' || strArc || ' where 1=2';
execute immediate strSQL;
without GRANT CREATE ANY TABLE for the user, *"ORA-01031: insufficient privileges"* error during execution.
Is there a way to tackle this issue without providing GRANT CREATE ANY TABLE privilige?
many thanks,
Charlesravikumar.sv wrote:
The problem is not because of dynamic sql...It probably has something to do with dynamic SQL or, more accurately, dynamic SQL within a stored procedure.
From a SQL*Plus command prompt, you can create a table if your account has the CREATE TABLE privilege either granted directly to it or granted to a role that has been granted to your account. Most people probably have the CREATE TABLE privilege through a role (hopefully a custom "developer role" that has whatever privileges you grant to users that will own objects but potentially through the default RESOURCE role). That is not sufficient to create tables dynamically via a definer's rights stored procedure. Only privileges that are granted directly to the user, not those granted via a role, are visible in that case.
I expect that the DBAs are granting the CREATE ANY TABLE privilege directly to the account in question rather than through whatever role(s) are being used which is why that appears to solve the problem.
Justin -
Dynamic SQL and IN CLAUSE from Pro C code
Hi Guys,
Tyring to embed sql in Pro C. Here I don't know in hand how many items will be there in the IN Clause of my dynamic sql. Tried this with a loop and then adding actual values to the stement and then executing it. This worked but as this hard coding makes it literal sql and hence hampers performance. Can any one help me with how to put bind variables where we don't know how many of them will be there in a dynamic sql.
Thanks,Dynamic SQL supports user defined types, try passing a collection and using TABLE(CAST(collection)) in the SQL statement.
In the current approach (creating IN clause at runtime) keep in mind that in a IN clause you can put a maximum of 255 elements...
Max
Maybe you are looking for
-
FCP Studio will not boot up after Snow leopard upgrade.
Everything was working fine on Leopard but decided to upgrade to Snow Leopard. Now the program stats up and we get to the splash screen then it quits. Anybody help me? so far Snow Leopard has been a complete waste of time, After effects on Mac will n
-
How to Re-install Photoshop CC after installing Photoshop CC 2014 and un-installing Photoshop CC
Hi all, What I did: 1) Installed Photoshop CC 2014 from Creative Cloud. 2) Removed Photoshop CC. Now I would like to re install Photoshop CC because not all my extensions are compatible with Photoshop CC 2014. I don't want to uninstall Photoshop CC 2
-
No suitable driver - testing Application Module
I'm using the AVEconnect JDBC Driver which I've registered successfully with the IDE as well as placed in my ClassPath. I've created entity and view objects using the aforementioned driver and placed them in an application module. To verify the appli
-
BPC75NW: How to update DataManager debug log
Hi Experts, I am currently implementing scripts conversions in ABAP. Question: Through BAdI, how do I write a warning message in DM debug log indicating the list of dimension member values in the log ? Regards, Pankaj
-
Als ik gebruik maak van een zoekmachine, krijg ik wel de resultaten, maar is het niet mogelijk om een pagina te openen. Firefox reageert dan niet meer. Het maakt niet uit welke zoekmachine, bij iedere gebeurt dit. Dit is direct na de upgrade begonnen