Custom adapter DB SQL statement
Is it possible to pass where clause parameters to a SQL statement custom DB adapter on the fly?In querry custom wizard, you simply put:
Select entrydate, projectid, Billable, sum (duration) duration
of Dailyactivity_invoice
where projectid = * #p_project_id *.
Entrydate group, projectid, billable
This will make p_project_id an input parameter, you can set using assign before call for adapter
Adam
Tags: Fusion Middleware
Similar Questions
-
Hi all
We have a problem with the profile option "initialize SQL statement - Custom." We put this at the user level. After awhile, we have erased the value of the this user profile option.
But you can still see the trace files generated are getting updated. We checked this files trc pathname returned at the bottom of the query.
Select name, value
the parameter $ v
WHERE name like 'user_dump_dest;
Please help us on how to solve this problem. We use Oracle Apps R 12.1.2 version.
Thanks in advance
Rambaud
Find the trace file creation session and kill this session
HTH
Srini -
Custom on-the-fly SQL statement
Is it possible to build the dynamic SQL statement in the DB adapter on the fly?You can do bulk collect and return the collection of pl/sql procedure.
Prasanna-
-
FDM generated SQL statement in the log file?
Hello everyone, hopefully a simple question:When you perform an import using FDM, I know that behind the scenes of a SQL SELECT statement statement composed and performed on the database server. My question: the actual SQL statement is retained in a newspaper somewhere (so that we can see it?) In our case, it's an Oracle DB server and we use the ERPI adapter; not sure if it's relevant. We would like to enter this SQL statement and use it as a starting point for other things.
Thanks in advance for anything you can offer.
The statement SQL is not written in the journal of the adapter. The only things that are registered are what show in the file card log if you enable loggin to the adapter source ERPi in action 'Get Data'.
-
How to 'show' a static pseudo index using SQL statement select?
Hello again,
I have to post a time of 24 hours as an index. (00:00 - 23:00)
It's easy, if data are available.
But, if the data are not regularly exist on specific time (the time is not regular, IE: 00:00, 01:00, 05:00, 08:00, 10:00, 11:00, 23:00), then it of OK for a TABLE, but not for a CHART.
Here is the story:
I've written a SQL statement that can 'choose' what to display respectively the time available. The result will appear on the map: days or the time is used for the x-axis and the respective value on axis y.
Example:
+ If the data consists of 'days' (ie: the last 5 days from now on, 16/07/2012, 17/07/2012, 18/07/2012, 19/07/2012, 20/07/2012), the chart will display these dates on the x-axis.
+ If the data consists of 'hours' (ie: only 1 day, hour 00:00 - 23:00), then the chart shows the hours on the x-axis.
If the 'hours' are not regular, means: there is no data on the specific hours, the result of the query is not as regular, average: the value of X - axis "jumps" irregularly.
Question:
Is it possible to interrogate our own static value?
for example:
Select 'Hello' from dual-> result: 'Hello', 1 column, 1 line
But how to display it into several lines, i.e.:
Time
*****
0
1
2
3
4
5
...
...
23
Note:
the x-axis on the graph model can be customized only for 1 single mode, example: 'Days',
but of course it will not appear correctly if the result of the query are "hours."
This means: I have to find the workaround on the SQL query.
DB: ORA 11
Thank you and best regards.You can generate mulltiple rows if you use LEVEL and CONNECT BY:
SQL> select level 2 from dual 3 connect by level <= 10; LEVEL ---------- 1 2 3 4 5 6 7 8 9 10 10 rows selected. SQL> select sysdate+level-1 2 from dual 3 connect by level <= 10; SYSDATE+LEVEL-1 ------------------- 20-07-2012 12:48:26 21-07-2012 12:48:26 22-07-2012 12:48:26 23-07-2012 12:48:26 24-07-2012 12:48:26 25-07-2012 12:48:26 26-07-2012 12:48:26 27-07-2012 12:48:26 28-07-2012 12:48:26 29-07-2012 12:48:26 10 rows selected. SQL> select to_char(trunc(sysdate), 'hh24')+level-1 2 from dual 3 connect by level <= 24; TO_CHAR(TRUNC(SYSDATE),'HH24')+LEVEL-1 -------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 rows selected.
-
FIFO in the sql statement...
Hello
Suppose we have two tables:
(1) deliveries of items according to a contract
create the table contracted_dlv
(item_id number (2),)
date of contracted_date,
number of contracted_qty);
(2) actual delivery of items in the warehouses of the customer
create the table real_dlv
(item_id number (2),)
date of dlv_date,
number of dlv_qty);
As the two tables can be connected to each other completely... because there is not
the information in the real_dlv table that delivery of X in the warehouse takes place in
conformity of the delivery as contracted, the FIFO algorithm must be used as:
The first quantity delivered (table real_dlv) is made in order to accomplish the first
quantity (table contracted_dlv) required / contract, until the first contracted
amount would come true. Then the second contract qty... etc
For example: item_id: 10
insert into contracted_dlv (item_id, contracted_date, contracted_qty)
values(10,'03/01/2011',6);
insert into contracted_dlv (item_id, contracted_date, contracted_qty)
values(10,'03/02/2011',15);
insert into real_dlv (item_id, dlv_date, dlv_qty)
values(10,'7/01/2011',3);
insert into real_dlv (item_id, dlv_date, dlv_qty)
values(10,'17/01/2011',2);
insert into real_dlv (item_id, dlv_date, dlv_qty)
values(10,'23/01/2011',5);
insert into real_dlv (item_id, dlv_date, dlv_qty)
values(10,'23/02/2011',4);
insert into real_dlv (item_id, dlv_date, dlv_qty)
values(10,'27/02/2011',6);
insert into real_dlv (item_id, dlv_date, dlv_qty)
values(10,'02/03/2011',5);
Now I want in sql statement (even using a pl/sql function that can be used in sql)
an output such as:
item_id contracted_date contracted_qty dlv_qty
03/01/2011 10, 6 6 (1 *)
03/02/2011 10, 15 19 (2 *)
(1 *) the dlv_qty arises as the result of what follows (3 + 2 + (5-4)) to fill the 6pieces of
the first delivery as contracted.
(2 *) the dlv_qty arises as the result of what follows (4 + 4 + 6 + 5) to fill the 15pieces of
the second delivery under contracted (note that for this second contract delivery the 4pieces)
the issue of the third actual delivery is used).
How I write a sql stmt to achieve the above...?
Notes:
(1) for simplicity, I wrote only two main tables and columns in them.
(2) if the sum (contracted_qty) < sum (dlv_qty) then you should consider that deliveries carry out
then contracted quantity (as has happened in some examples of data that I posted above).
(3) it must be by point so many records there are in the contracted_dlv table.
(4) I use DB 10 g v.2
Thank you
SIMHello
That's what you asked for:
WITH contracted_rt AS ( SELECT item_id, contracted_date, contracted_qty , SUM (contracted_qty) OVER ( PARTITION BY item_id ORDER BY contracted_date ) AS total_qty FROM contracted_dlv ) , real_rt AS ( SELECT item_id, dlv_date, dlv_qty , SUM (dlv_qty) OVER ( PARTITION BY item_id ORDER BY dlv_date ) AS total_qty FROM real_dlv ) , real_final AS ( SELECT item_id , SUM (dlv_qty) AS total_qty , MAX (dlv_date) AS dlv_date FROM real_dlv GROUP BY item_id ) SELECT c.item_id , c.contracted_date , c.contracted_qty , CASE WHEN f.total_qty IS NULL THEN 0 WHEN c.total_qty <= r.total_qty THEN c.contracted_qty ELSE GREATEST ( f.total_qty - (c.total_qty - c.contracted_qty) , 0 ) END AS dlv_qty , CASE WHEN c.total_qty < r.total_qty THEN ( SELECT MIN (dlv_date) FROM real_rt WHERE item_id = c.item_id AND total_qty > c.total_qty - c.contracted_qty ) WHEN c.total_qty = r.total_qty THEN r.dlv_date WHEN f.total_qty > c.total_qty - c.contracted_qty THEN f.dlv_date END AS dlv_date FROM contracted_rt c LEFT OUTER JOIN real_rt r ON c.item_id = r.item_id AND c.total_qty BETWEEN r.total_qty - r.dlv_qty AND r.total_qty LEFT OUTER JOIN real_final f ON c.item_id = f.item_id ORDER BY c.item_id , c.contracted_date ;
Sorry, I don't have time for an explanation now. I'll post one tomorrow, if I can.
-
I am getting error - ORA-00900: invalid SQL statement when executing the following statement:
SanjaySELECT * FROM CUSTOMER
Have you looked at the suggestions of fanny?
You can try selecting ANY table in a DIFFERENT pattern?You have not provided your version of DB, try and throw more light on the issue, otherwise its going to be the exercise trail and error.
-
Hello
I have this SQL statement like below:
Select the data for the customer whose name = "John" and customer_id NOT IN (SELECT customer_id customer where customer_id = '111');
Is it possible to do or should I change it?Hello
SELECT c.data FROM customer c, orders o WHERE c.NAME = 'John' AND c.customer_id = o.customer_id AND o.customer_id != '111';
Kind regards
-
SQL statement to check if a file exists
Good afternoon
I thought I saw once a post that had a SQL statement that would check a table to check if a record exists and return true or false... He would return all records, just a Boolean... Such a function exists? I searched the forums, but I don't remember what I was ready when I found this...
Thanks in advance for any help you can offer.
DonaldHi Donald,.
Oracle SQL is not a Boolean data type (see: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#sthref19 for types available).
As a general rule, a custom function returns 0 or 1 or 'Y' or ' no 'TRUE' or 'FALSE' or something similar, like a number or a varchar2.
Depending on what you need to do and where you need to do, there are other options available. For example, a validation of the page, you could do a validation EXISTS of:
SELECT 1 FROM TableX WHERE Field1 = value
This would amount to true or false and validation would be success or failure as a result.
Within a process, you would do something like:
DECLARE vCOUNT NUMBER; BEGIN SELECT COUNT(*) INTO vCOUNT FROM TableX WHERE Field1 = value; IF vCOUNT > 0 THEN do something if there is a record; ELSE do something if there isn't a record; END IF; END;
Andy
-
SQL statement - display expected results
I have this SQL statement:
With the following results:SELECT DISTINCT ch.ch_status,cu.customer_id FROM contract co, contract_history ch, customer cu WHERE co.co_id = ch.co_id AND co.customer_id = cu.customer_id AND (cu.passportno= 'S1234567A' ) AND cu.customer_id != 12345 AND ch.ch_seqno in (SELECT MAX(ch_seqno) FROM contract_history WHERE co_id = co.co_id) and co.co_id IN (SELECT co_id FROM contract_history GROUP BY co_id HAVING(SUM(CASE WHEN ch_status = 'a' AND (ch_status = 'd' or ch_status = 's' or ch_status = 'o') THEN 1 WHEN ch_status = 'a' THEN 1 ELSE 0 END) > 0)) ORDER BY decode(ch.ch_status,'d',1,'a',2,'s',3,'o',4)ASC;
How am I suppose to change my SQL statement in such a way, the results appear only that?CH_STATUS CUSTOMER_ID d 100 d 200 d 300 a 100 a 200
Expected results
Only the ch_status 'a' is displayed even if it has the status was "too. However, if customer_id has only a status was ', it will be displayed.CH_STATUS CUSTOMER_ID d 300 a 100 a 200
I don't get what you're trying to do...
Once you have the slider you can use the cursor... y u still need with clause,...
But yes its possible
QL> SQL> Declare 2 Cursor c1 Is 3 With t As 4 ( 5 Select 'd' CH_STATUS ,129 CUSTOMER_ID From dual Union All 6 Select 'd' ,62031 From dual Union All 7 Select 'd' ,858347 From dual Union All 8 Select 'a' ,129 From dual Union All 9 Select 'a' ,62031 From dual 10 ) Select ch_status,customer_id 11 From 12 ( 13 Select ch_status, customer_id, 14 Case When ch_status = 'd' And lag(ch_status) over (Partition By customer_id Order By ch_status) = 'a' Then 0 Else 1 End new_status 15 From t 16 ) Where new_status = 1; 17 18 r1 c1%Rowtype; 19 Begin 20 Open c1; 21 Loop 22 Fetch c1 Into r1; 23 Exit When c1%Notfound; 24 dbms_output.put_line(r1.CH_STATUS); 25 End Loop; 26 End; 27 / a a d PL/SQL procedure successfully completed SQL>
-
I have this PreExpression at a stage of SQL statement:
Locals.SQL_LatestResult = "SELECT UUT_RESULT.ID, UUT_RESULT. UUT_SERIAL_NUMBER, UUT_RESULT. START_DATE_TIME UUT_RESULT WHERE (((UUT_RESULT. UUT_SERIAL_NUMBER) =------"' + Locals.serial + ' \ ') AND ((UUT_RESULT." START_DATE_TIME) = (SELECT MAX (UUT_RESULT2. START_DATE_TIME) OF UUT_RESULT AS UUT_RESULT2 WHERE UUT_RESULT. UUT_SERIAL_NUMBER = UUT_RESULT2. UUT_SERIAL_NUMBER))); »
Locals.SQL_LatestResult has this value after the PreExpression:
SELECT UUT_RESULT.ID, UUT_RESULT. UUT_SERIAL_NUMBER, UUT_RESULT. START_DATE_TIME UUT_RESULT WHERE (((UUT_RESULT. UUT_SERIAL_NUMBER) = "15514011") AND ((UUT_RESULT. START_DATE_TIME) = (SELECT MAX (UUT_RESULT2. START_DATE_TIME) OF UUT_RESULT AS UUT_RESULT2 WHERE UUT_RESULT. UUT_SERIAL_NUMBER = UUT_RESULT2. UUT_SERIAL_NUMBER)));
I get the number of records = 0, if I run the sequence.
If I copy the exact same SQL query in access I get what I want to know a record.
If I remove that part of the query:
((UUT_RESULT. UUT_SERIAL_NUMBER) =------"" + Locals.serial + "\") "
I get 388 records which is correct and it run directly in access.
What's not here?
I was too fast for this post... it's my fault, the database link was wrong, so data were there...
Statements are very good!
-
With the help of a number variable in a SQL statement
Hello
I am trying to use a variable in a sql statement, and I ran into problems when the variable is a number. The following line of code works if the variable is a string, but not if it is a number.
"SELECT PAGE 1 UUT_STATUS OF UNIT_UUT_RESULT WHERE UnitID = '" + Locals.LocalUnitID + "' ORDER BY DESC START_DATE_TIME.
Is there a difference in the use of single and double quotes and the sign for numbers variables +?
Thank you
Stuart
Jervin is almost correct in the post above.
While it is correct that numbers in SQL are not enclosed in single quotes ('), we still need the entire expression to a string. If Locals.LocalUnitID is stored as a number to TestStand, you will need to cast to a string so that the string concatination works properly.
I believe that the correct form is as follows:
"SELECT PAGE 1 UUT_STATUS OF UNIT_UUT_RESULT WHERE UnitID ="+ Str (Locals.LocalUnitID) + 'ORDER BY DESC START_DATE_TIME'
-
Game of demand does not pick up the good period open to active fixed from the SQL statement
Hello
We have a demand that could kick off the simultaneous application of the value: Ixr: list of asset by period and Ixr: reserve book report.
ON overall demand, we set the parameter: default period based on a SQL = select period_name from FA_DEPRN_PERIODS where book_type_code = 'PER2011' and period_close_date is null
The query runs with the good period, until we open the new period, the game application will still come closed period.
When I run this script on the database, it gives the correct name of the open period.
Why all the demand does not pick up the open period?
Rock
Hello
When planning, the parameter values that you gave when planning will not change.
For the test, for a simultaneous program, I create a parameter and has given the value 100 tank and default type sql statement and the value as below.
Select to_char (sysdate, 'dd-mon-yyyy hh24:mi:ss') of double
If, at the time of the program, it shows a default value such as the date and time with seconds. Then I planned it for every minute.
When you check in for each race it is seen the first time only, it does not.
so in your case, you must plan its new after change of period.
Hope this will help you...
-
What are these SQL statements?
Hello!
We are our applications running on Windows Server 2003 where it works fine, using Oracle via OCI 12.1.
Now, we have the application installed on Windows Server 2012 and it works very slowly.
When comparing these two environments trace files came a surprise: Oracle generates a lot of SQL statements when run on Windows Server 2012! By operating on Windows2003 it only executes the SQL from the applicaton instructions. These additional SQL statements must be the reason for the slowness, but why Oracle it generates them and how could we get arrested?
An example:
PARSING IN CURSOR #46985062096816 len = 210 dep = 2 uid = 0 oct = cover 3 = 0 tim = hv 1439277877325893 = ad 864012087 = "4db599f28" sqlid = "96g93hntrzjtr."
Select / * + rule * / bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp #, sample_size, minimum, maximum, distcnt, lowval, hival, density, col #, spare1, spare2, hist_head avgcln $ where obj #=: 1 and intcol #=: 2
END OF STMT
ANALYSIS #46985062096816:c = 1000, e = 456, p = 0, cr = 0, cu = 0, put = 1, r = 0, dep = 2, og = 3, plh = 0, tim = 1439277877325890
EXEC #46985062096816:c = 0, e = 498, p = 0, cr = 0, cu = 0, put = 1, r = 0, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326455
FETCH #46985062096816:c = 0, e = 56, p = 0, cr = 3, cu = 0, set = 0, r = 1, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326533
STAT #46985062096816 id = 1 cnt = 1 pid = 0 obj = op 411 = pos = 1 "TABLE ACCESS BY INDEX ROWID HIST_HEAD$ (cr = 3 pr = 0 pw = time 0 = 55 US)"
"STAT #46985062096816 id = 2 cnt = 1 pid = 1 pos = 1 obj = op 413 ='INDEX RANGE SCAN I_HH_OBJ #_INTCOL # (cr = 2 pr = 0 pw = time 0 = 32 US)"
OUTCOME #46985062096816:c = 0, e = 37, dep = 2, type = 3, tim = 1439277877326601
EXEC #46985062096816:c = 0, e = 23, p = 0, cr = 0, cu = 0, set = 0, r = 0, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326702
FETCH #46985062096816:c = 0, e = 18, p = 0, cr = 3, cu = 0, set = 0, r = 1, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326738
OUTCOME #46985062096816:c = 0, e = 8, dep = 2, type = 3, tim = 1439277877326765
EXEC #46985062096816:c = 0, e = 19, p = 0, cr = 0, cu = 0, set = 0, r = 0, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326837
FETCH #46985062096816:c = 0, e = 21, p = 0, cr = 3, cu = 0, set = 0, r = 1, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326923
OUTCOME #46985062096816:c = 0, e = 10, dep = 2, type = 3, tim = 1439277877326954
Thank you very much in advance!
Best regards
Jaakko Terhonen
Thank you all for the reply! This time, the reason was a problem in network traffic (TCP protocol): a lot of retransmissions for a still unknown reason. If it had nothing to do with Oracle after all.
I cried for help here because as a common application programmer, I wasn't familiar with the Interior details of SQL analysis and after seeing it in the trace, I assumed that these strange SQL statements - which, for some reason, is appeared only in W2012-trace - were the reason for the slowness.
Thank you, I'm a little wiser now - and I hope that many others find this thread before asking the same question!
Best regards
Jaakko Terhonen
-
How can I pass a condition of the table in the sql statement?
For example, in the table in the COND Varchar2 column (200) there is the value ' VAR > 10'.
| COND |
|' VAR > 10' |
where VAR is the name of the table column. I would like to make statement CASE WHEN VAR > 10 AND 0... I tried with as subquery
WHEN BOX (SELECT COND FROM TABLE WHERE...) THEN 0, but it does not work.
Hello
You can do this by using dynamic SQL.
that is to say:
declare v_stm varchar2(4000); v_cond varchar2(100); v_result integer; begin select cond into v_cond from yourtable where a=1; v_stm := 'select case when '||v_cond||' then 0 ...'; -- dynamic sql execute immediate v_stm into v_result; end; /
Remember that, in general, dynamic SQL has a performance degradation that SQL static and should be avoided when possible.
Storage condition or the SQL statements in the tables is not a good practice.
Kind regards.
Alberto
Maybe you are looking for
-
April 29, 2014, Mozilla has offered a new update and let it install. Now, the bar tools Firefox or whatever orange line allows me to look for sites of course is not there. Where is he?
-
Compaq Presario: NVIDIA GeForce 6150SE nForce 430 chipset is not compatible with Windows 10
I try to upgrade to Windows 10 and I get message that current chipset is not compatible with Windows 10. My PC is Compaq Presario motherboard M2N68-(NARRA5). Is there a graphics card for this motherboard is compatible Windows 10?
-
My laptop Equium A60 asked me to uninstall Norton Antivirus because of problem with it. Upon restart, the computer would not boot at all. I use Windows XP and no BIOS is available when I turn on the computer and the computer was just a white screen.
-
Intel, Bluetooth (N 2230) disappeared after upgrade Win8
Hi all I own and DV6 7078 ca (6 months warranty) equipped with Intel Centrino Wireless - N 2230. With Win7, I used the bluetooth without any problem and there was a device in the Device Manager with a name similar to "Intel Bluetooth" under network a
-
Get information from change of color over time
Hi all I am new to LabView and on this forum, so I hope I'm in the right subforum. If this isn't the case, it would be nice if a mod could move this thread. My problem is the following: Let's say I have a white spot I want to observe with a camera. T