Condition that takes only one row with the maximum cost of the maximum date
I have to the following query
SELECT distinct b.segment1 ||'.'|| b.segment2 as ITEM,
so.vendor_site_id as SUPPLIER,
'VE' as ORIGIN_COUNTRY_ID,
replace(round(l.mto_costo_neto/l.can_unidades_empaque,2),',','.') as UNIT_COST,
5 as lead_time,
null as pickup_lead_time,
l.can_unidades_empaque as supp_pack_size,
1 as inner_pack_size,
'C' as round_lvl,
50 as ROUND_TO_INNER_PCT,
50 as ROUND_TO_CASE_PCT,
50 as ROUND_TO_LAYER_PCT,
50 as ROUND_TO_PALLET_PCT,
null as MIN_ORDER_QTY,
null as MAX_ORDER_QTY,
'FLAT' as PACKING_METHOD,
'N' as PRIMARY_SUPP_IND,
'Y' as PRIMARY_COUNTRY_IND,
case when b.primary_unit_of_measure like '%KG%' then 'KG'
when b.primary_unit_of_measure like '%Kg%' then 'KG'
when b.primary_unit_of_measure like '%UND%' then 'EA'
when b.primary_unit_of_measure = 'Kilogramo' then 'KG'
when b.primary_unit_of_measure = 'Litro' then 'L'
when b.primary_unit_of_measure = 'Unidad' then 'EA'
else null
end as DEFAULT_UOP,
1 as TI,
1 as HI,
null as SUPP_HIER_TYPE_1,
null as SUPP_HIER_LVL_1,
null as SUPP_HIER_TYPE_2,
null as SUPP_HIER_LVL_2,
null as SUPP_HIER_TYPE_3,
null as SUPP_HIER_LVL_3,
null as CREATE_DATETIME,
null as LAST_UPDATE_DATETIME,
null as LAST_UPDATE_ID,
case when b.primary_unit_of_measure like '%KG%' then 'KG'
when b.primary_unit_of_measure like '%Kg%' then 'KG'
when b.primary_unit_of_measure like '%UND%' then 'EA'
when b.primary_unit_of_measure = 'Kilogramo' then 'KG'
when b.primary_unit_of_measure = 'Litro' then 'L'
when b.primary_unit_of_measure = 'Unidad' then 'EA'
else null
end as COST_UOM,
null as TOLERANCE_TYPE,
null as MAX_TOLERANCE,
null as MIN_TOLERANCE
FROM mrp.mrp_sr_assignments sr , MRP.MRP_SR_RECEIPT_ORG ro , MRP.MRP_SR_SOURCE_ORG so,
inv.mtl_system_items_b b, lcm.cmp_lineas_cotizacion l
WHERE sr.SOURCING_RULE_ID = ro.SOURCING_RULE_ID
and ro.SR_RECEIPT_ID = so.SR_RECEIPT_ID
and sr.inventory_item_id in ((select inventory_item_id from TMP.VIVERES_VEGETALES)
UNION ALL
(select inventory_item_id from TMP.GENERICOS)
UNION ALL
(select inventory_item_id from TMP.HIJOS_GENERICOS))
and sr.inventory_item_id = b.inventory_item_id
and b.organization_id = 136
and sr.inventory_item_id = l.cod_producto_idI need to agregate the following condition
For example, The following query
SELECT l2.fec_ini_vigencia_costo, l2.mto_costo_neto, l2.can_unidades_empaque, l2.cod_producto,
REPLACE(ROUND(l2.mto_costo_neto/l2.can_unidades_empaque,2),',','.') costo_unidad
from cmp_lineas_cotizacion l2
order by cod_producto, fec_ini_vigencia_costo desc, mto_costo_neto descgenerate
FEC_INI_VIGENCIA_COSTO MTO_COSTO_NETO CAN_UNIDADES_EMPAQUE COD_PRODUCTO COSTO_UNIDAD
17/06/2010 382.56 12 1.1000008 31.88 -- THIS ONE
17/06/2010 382.56 12 1.1000008 31.88
17/06/2010 371.0832 12 1.1000008 30.92
17/06/2010 371.0832 12 1.1000008 30.92
18/05/2009 382.56 12 1.1000008 31.88
04/05/2009 245.82 12 1.1000008 20.49
13/04/2009 382.56 12 1.1000008 31.88
23/03/2009 373.2072 12 1.1000008 31.1
23/03/2009 373.2072 12 1.1000008 31.1I need to take only one row with the maximum FEC_INI_VIGENCIA with the maximum COSTO_UNIDAD of the table lcm.cmp_lineas_cotizacion l, which is calculated with the formula ROUND(l2.mto_costo_neto/l2.can_unidades_empaque,2)
A better example
I need only one row the maximum COSTO_UNIDAD for the maximum FEC_INI_VIGENCIA for every cod_producto_id in the table lcm.cmp_lineas_cotizacion
I need to take these values
FEC_INI_VIGENCIA_COSTO MTO_COSTO_NETO CAN_UNIDADES_EMPAQUE COD_PRODUCTO_ID COSTO_UNIDAD
17/06/2010 382.56 12 1.1000008 31.88 -- THIS!
17/06/2010 382.56 12 1.1000008 31.88
17/06/2010 371.0832 12 1.1000008 30.92
17/06/2010 371.0832 12 1.1000008 30.92
18/05/2009 382.56 12 1.1000008 31.88
04/05/2009 245.82 12 1.1000008 20.49
13/04/2009 382.56 12 1.1000008 31.88
17/06/2010 382.56 12 1.1000008 31.88
17/06/2010 382.56 12 1.1000008 31.88
17/06/2010 371.0832 12 1.1000008 30.92
17/06/2010 371.0832 12 1.1000008 30.92
18/05/2009 382.56 12 1.1000008 31.88
04/05/2009 245.82 12 1.1000008 20.49
13/04/2009 382.56 12 1.1000008 31.88
27/10/2010 1171.549344 12 1.1000009 97.63 -- THIS!
13/10/2010 1171.549344 12 1.1000009 97.63
06/09/2010 1171.549344 12 1.1000009 97.63
02/08/2010 1048.825056 12 1.1000009 87.4
28/07/2010 754.8 12 1.1000009 62.9
27/07/2010 614.04 12 1.1000009 51.17
21/06/2010 954.84 12 1.1000009 79.57
27/05/2010 614.04 12 1.1000009 51.17
07/07/2009 1143.17 12 1.1000010 95.26
28/03/2009 1143.17 12 1.1000010 95.26
27/10/2008 1744.644672 12 1.1000010 145.39
01/07/2008 1690.12224 12 1.1000010 140.84
07/07/2009 1143.17 12 1.1000010 95.26 --THIS!
28/03/2009 1143.17 12 1.1000010 95.26
27/10/2008 1744.644672 12 1.1000010 145.39
01/07/2008 1690.12224 12 1.1000010 140.84
07/07/2009 1143.17 12 1.1000010 95.26
28/03/2009 1143.17 12 1.1000010 95.26
27/10/2008 1744.644672 12 1.1000010 145.39
01/07/2008 1690.12224 12 1.1000010 140.84
Similar Messages
-
Keeping only one row with information from several rows?
Hi,
I have a table with companies. The companies appearing more then once in the table, with different information in different columns. How do I keep one row from each company with all information..?
Example:
Company State City Country
CompA WA Seattle null
CompA null null USA
CompB null null USA
CompB TX null null
...and so on.
And I want out of this:
CompA WA Seattle USA
CompB TX null USA
Any tips?declare @temp table
company char(6),
state char(10),
city char(20),
country char(10))
insert into @temp values ('CompA','WA','Seattle',null),('CompA',null,null,'USA')
,('CompB','Tx',null,null),('CompB',null,null,'USA')
select max(company),MAX(state),MAX(city),MAX(country) from @temp
group by company
--Prashanth -
Issue with Selection Listener when the table has only one row
Hi All ,
I have developed a table in which I am using Selection Listener to perform some task when any row is selected.
It is working fine when I have more than 1 row in the table, but when I have only one row in the table , the selection listener do not call the corresponding method in bean.
I understand that selection event will be raised only when the row is changed, but in the use case when only one row is there, what should be done to make the selection listener work ?
In the selection listener I have written code to make the selected row as current row , and perform the required task.
Please suggest a way out for this situation.
Thanks in advance.Hi,
try removing this attr from table
selectedRowKeys="#{bindings.xxx_VO1.collectionModel.selectedRow}" -
Select event not triggered in table with only one row
Hi all,
I am building a BI VC application where query data is displayed in a table. When the user clicks on a table row another query is then triggered and output in a second table. The output from table 1 is linked to the input of query2/table2 with a select event.
The problem that I am facing is that if there is only one row in table 1, the select event is never triggered. If, however there are two or more rows in the table the select event is triggered and query 2 is executed. I have searched the forums but all I could find on select event problems was how to avoid the initial select event.
Has anyone else experienced this issue and what is the workaround or is this a bug in Visual Composer? We are on VC 7.0 SP19.
Cheers,
Astein MelandThanks Chittya,
Yes we have considered this option as well. But as we have more than one table linked together we would like to avoid having to manually click several buttons.
In the end I found Note 1364334 describing bugfixes released in VC 7.0 SP20:
"Normally, when a Visual Composer table is populated from a data service, the first row is selected by default. However, we have found that if only one data row is returned from the data service, this row is not selected by default and cannot be manually selected by clicking on it either."
So I think we will just have to upgrade our Portal to the latest support packs to solve this problem.
Thanks,
Astein -
SQL Server 2012 Undetected Deadlock in a table with only one row
We have migrated our SQL 2000 Enterprise Database to SQL 2012 Enterprise few days ago.
This is our main database, so most of the applications access it.
The day after the migration, when users started to run tasks, the database access started to experiment a total failure.
That is, all processes in the SQL 2k12 database were in lock with each other. This is a commom case of deadlock, but the Database Engine was unable to detect it.
After some research, we found that the applications were trying to access a very simple table with only one row. This table has a number that is restarted every day and is used to number all the transactions made against the system. So, client
applications start a new transaction, get the current number, increment it by one and commit the transaction.
The only solution we found was to kill all user processes in SQL Server every time this situation occurs (no more than 5 minutes when all clients are accessing the database).
No client application was changed in this migration and this process was working very well for the last 10 years.
The problem is that SQL 2k12 is unable to handle this situation compared to SQL 2k.
It seems to occurs with other tables too, but as this is an "entry table" the problem occurs with it first.
I have searched internet and some suggest some workarounds like using table hints to completely lock the table at the begining of the transaction, but it can't be used to other tables.
Does anyone have heard this to be a problem with SQL 2k12? Is there any fixes to make SQL 2k12 as good as SQL 2k?First off re: "Unfortunatelly, this can't be used in production environment as exclusive table lock would serialize the accesses to tables and there will be other tables that will suffer with this problem."
This is incorrect.
Using a table to generate sequence numbers like this is a bad idea exactly because the access must be serialized. Since you can't switch to a SEQUENCE object, which is the correct solution, the _entire goal_ of this exercise to find a way to properly
serialize access to this table. Using exclusive locking will not be necessary for all the tables; just for the single-row table used for generating sequence values with a cursor.
I converted the sample program to VB.NET:
Public Class Form1
Private mbCancel As Boolean = False
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim soConn As ADODB.Connection
Dim soRst As ADODB.Recordset
Dim sdData As Date
Dim slValue As Long
Dim slDelay As Long
'create database vbtest
'go
' CREATE TABLE [dbo].[ControlNumTest](
' [UltData] [datetime] NOT NULL,
' [UltNum] [int] NOT NULL,
' CONSTRAINT [PK_CorreioNumTeste] PRIMARY KEY CLUSTERED
' [UltData] Asc
' )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY]
' ) ON [PRIMARY]
mbCancel = False
Do
' Configure the Connection object
soConn = New ADODB.Connection
With soConn
.ConnectionString = "Provider=SQLNCLI11;Initial Catalog=vbtest;Data Source=localhost;trusted_connection=yes"
.IsolationLevel = ADODB.IsolationLevelEnum.adXactCursorStability
.Mode = ADODB.ConnectModeEnum.adModeReadWrite
.CursorLocation = ADODB.CursorLocationEnum.adUseServer
.Open()
End With
' Start a new transaction
Call soConn.BeginTrans()
' Configure the RecordSet object
soRst = New ADODB.Recordset
With soRst
.ActiveConnection = soConn
.CursorLocation = ADODB.CursorLocationEnum.adUseServer
.CursorType = ADODB.CursorTypeEnum.adOpenForwardOnly
.LockType = ADODB.LockTypeEnum.adLockPessimistic
.Open("SELECT * FROM dbo.ControlNumTest")
End With
With soRst
sdData = .Fields!UltData.Value ' Read the last Date (LOCK INFO 1: See comments bello
slValue = .Fields!UltNum.Value ' Read the last Number
If sdData <> Date.Now.Date Then ' Date has changed?
sdData = Date.Now.Date
slValue = 1 ' Restart number
End If
.Fields!UltData.Value = sdData ' Update data
.Fields!UltNum.Value = slValue + 1 ' Next number
End With
Call soRst.Update()
Call soRst.Close()
' Ends the transaction
Call soConn.CommitTrans()
Call soConn.Close()
soRst = Nothing
soConn = Nothing
txtUltNum.Text = slValue + 1 ' Display the last number
Application.DoEvents()
slDelay = Int(((Rnd * 250) + 100) / 100) * 100
System.Threading.Thread.Sleep(slDelay)
Loop While mbCancel = False
If mbCancel = True Then
Call MsgBox("The test was canceled")
End If
Exit Sub
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
mbCancel = True
End Sub
End Class
And created the table
CREATE TABLE [dbo].[ControlNumTest](
[UltData] [datetime] NOT NULL,
[UltNum] [int] NOT NULL,
CONSTRAINT [PK_CorreioNumTeste] PRIMARY KEY CLUSTERED
[UltData] Asc
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = on, FILLFACTOR = 80) ON [PRIMARY]
) ON [PRIMARY]
go insert into ControlNumTest values (cast(getdate()as date),1)
Then ran 3 copies of the program and generated the deadlock:
<deadlock>
<victim-list>
<victimProcess id="processf27b1498" />
</victim-list>
<process-list>
<process id="processf27b1498" taskpriority="0" logused="0" waitresource="KEY: 35:72057594039042048 (a01df6b954ad)" waittime="1970" ownerId="3181" transactionname="implicit_transaction" lasttranstarted="2014-02-14T15:49:31.263" XDES="0xf04da3a8" lockMode="X" schedulerid="4" kpid="9700" status="suspended" spid="51" sbid="0" ecid="0" priority="0" trancount="2" lastbatchstarted="2014-02-14T15:49:31.267" lastbatchcompleted="2014-02-14T15:49:31.267" lastattention="1900-01-01T00:00:00.267" clientapp="vbt" hostname="DBROWNE2" hostpid="21152" loginname="NORTHAMERICA\dbrowne" isolationlevel="read committed (2)" xactid="3181" currentdb="35" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128058">
<executionStack>
<frame procname="adhoc" line="1" stmtstart="80" sqlhandle="0x020000008376181f3ad0ea908fe9d8593f2e3ced9882f5c90000000000000000000000000000000000000000">
UPDATE [dbo].[ControlNumTest] SET [UltData]=@Param000004,[UltNum]=@Param000005 </frame>
<frame procname="unknown" line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000">
unknown </frame>
</executionStack>
<inputbuf>
(@Param000004 datetime,@Param000005 int)UPDATE [dbo].[ControlNumTest] SET [UltData]=@Param000004,[UltNum]=@Param000005 </inputbuf>
</process>
<process id="processf6ac9498" taskpriority="0" logused="10000" waitresource="KEY: 35:72057594039042048 (a01df6b954ad)" waittime="1971" schedulerid="5" kpid="30516" status="suspended" spid="55" sbid="0" ecid="0" priority="0" trancount="1" lastbatchstarted="2014-02-14T15:49:31.267" lastbatchcompleted="2014-02-14T15:49:31.267" lastattention="1900-01-01T00:00:00.267" clientapp="vbt" hostname="DBROWNE2" hostpid="27852" loginname="NORTHAMERICA\dbrowne" isolationlevel="read committed (2)" xactid="3182" currentdb="35" lockTimeout="4294967295" clientoption1="671156256" clientoption2="128058">
<executionStack>
<frame procname="adhoc" line="1" sqlhandle="0x020000003c6309232ab0edbe0a7790a816a09c4c5ac6f43c0000000000000000000000000000000000000000">
FETCH API_CURSOR0000000000000001 </frame>
<frame procname="unknown" line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000">
unknown </frame>
</executionStack>
<inputbuf>
FETCH API_CURSOR0000000000000001 </inputbuf>
</process>
</process-list>
<resource-list>
<keylock hobtid="72057594039042048" dbid="35" objectname="vbtest.dbo.ControlNumTest" indexname="PK_CorreioNumTeste" id="lockff6e6c80" mode="U" associatedObjectId="72057594039042048">
<owner-list>
<owner id="processf6ac9498" mode="S" />
<owner id="processf6ac9498" mode="U" requestType="wait" />
</owner-list>
<waiter-list>
<waiter id="processf27b1498" mode="X" requestType="convert" />
</waiter-list>
</keylock>
<keylock hobtid="72057594039042048" dbid="35" objectname="vbtest.dbo.ControlNumTest" indexname="PK_CorreioNumTeste" id="lockff6e6c80" mode="U" associatedObjectId="72057594039042048">
<owner-list>
<owner id="processf27b1498" mode="U" />
<owner id="processf27b1498" mode="U" />
<owner id="processf27b1498" mode="X" requestType="convert" />
</owner-list>
<waiter-list>
<waiter id="processf6ac9498" mode="U" requestType="wait" />
</waiter-list>
</keylock>
</resource-list>
</deadlock>
It's the S lock that comes from the cursor read that's the villian here. U locks are compatible with S locks, so one session gets a U lock and another gets an S lock. But then the session with an S needs a U, and the session with a U needs an
X. Deadlock.
I'm not sure what kind of locks were taken by this cursor code on SQL 2000, but on SQL 2012, this code is absolutely broken and should deadlock.
The right way to fix this code is to add (UPDLOCK,SERIALIZABLE) to the cursor
.Open("SELECT * FROM dbo.ControlNumTest with (updlock,serializable)")
So each session reads the table with a restrictive lock, and you don't mix S, U and X locks in this transaction. This resolves the deadlock, but requires a code change.
I tried several things that didn't require a code, which did not resolve the deadlock;
1) setting ALLOW_ROW_LOCKS=OFF ALLOW_PAGE_LOCKS=OFF
2) SERIALIZABLE isolation level
3) Switching OleDB providers from SQLOLEDB to SQLNCLI11
Then I replaced the table with a view containing a lock hint:
CREATE TABLE [dbo].[ControlNumTest_t](
[UltData] [datetime] NOT NULL,
[UltNum] [int] NOT NULL,
CONSTRAINT [PK_CorreioNumTeste] PRIMARY KEY CLUSTERED
[UltData] Asc
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = on, FILLFACTOR = 80) ON [PRIMARY]
) ON [PRIMARY]
go
create view ControlNumTest as
select * from ControlNumTest_t with (tablockx)
Which, at least in my limited testing, resovlved the deadlock without any client code change.
David
David http://blogs.msdn.com/b/dbrowne/ -
Only one row show in table with tablepopin
Hi,
I've a table with a tablecolum with a tablepopintogglecell, and a tablepopin.
I want that only one row show (when i press the togglelink if there is other row open, automatically close that row)Hi,
you should implement the on toggle event,
you will have the importing context_element, so you know which one is triggered,
form your node, get_elements().
loop over the table where ne to context_element, clear the popin attribute,
grtz,
Koen -
Had problem with DSL, now have only one tab with favicon matching that tab.
After a storm I had a problem with my U-Verse DSL. I lost access and got a message that it may be due to a problem with the filters on my phones, fax or satellite box. I disconnected all the items that had filters. I was then able to click on a link that AT&T had sent on the message and I got a response, I previously could not get a response because I had no connection. I got pack to the pages on all my tabs by hitting the back arrow on each one. I now have only one tab with favicon matching this WEB site for that tab, the rest all have the AT&T globe. I tried refresh and also opening a new tab and then going to one of the sites.
This problem is on a different PC that the one I am on now. It has version 21, and is Window 7 Home Premium. I have pasted the trouble shooting info from that PC.Hello,
Many site issues can be caused by corrupt cookies or cache. In order to try to fix these problems, the first step is to clear both cookies and the cache.
Note: ''This will temporarily log you out of all sites you're logged in to.''
To clear cache and cookies do the following:
#Go to Firefox > History > Clear recent history or (if no Firefox button is shown) go to Tools > Clear recent history.
#Under "Time range to clear", select "Everything".
#Now, click the arrow next to Details to toggle the Details list active.
#From the details list, check ''Cache'' and ''Cookies'' and uncheck everything else.
#Now click the ''Clear now'' button.
Further information can be found in the [[Clear your cache, history and other personal information in Firefox]] article.
Did this fix your problems? Please report back to us!
Thank you. -
Can't find last import from iPhone!
Noticed as I imported I had that view where there was only one project symbol, not all my projects showing by date, but even so pictures were imported. It took the time to do them, so where aare they? I have closed and restarted to get back fll view of all dated projects, but nothing can be found from today...have i posted it right...?? no response from apple guys...
-
Display only one row for distinct columns and with multiple rows their valu
Hi,
I have a table having some similar rows for some columns and multiple different rows for some other columns
i.e
o_mobile_no o_doc_date o_status d_mobile_no d_doc_date d_status
9825000111 01-jan-06 'a' 980515464 01-feb-06 c
9825000111 01-jan-06 'a' 991543154 02-feb-06 d
9825000111 01-jan-06 'a' 154845545 10-mar-06 a
What i want is to display only one row for above distinct row along with multiple non distinct colums
ie
o_mobile_no o_doc_date o_status d_mobile_no d_doc_date d_status
9825000111 01-jan-06 'a' 980515464 01-feb-06 c
991543154 02-feb-06 d
154845545 10-mar-06 a
regards,
KumarRe: SQL Help
-
Selecting only one row at a time
Hi experts,
i have following doubt regarding selecting rows from a db:
Is there any way of selecting only one row AT A TIME from a dabase just to collect the data in rows instead of in a unique document containing all the rows?
I would like you to ellaborate on this as i need to send only one row to the IE, and then other row, and so on... without throwing any error!
I have seen that there are SELECT SINGLE and SELECT UP TO 1 ROW, but these two methods are only useful when retrieving only one row, and that does not match my requirements. I need to process all the rows but one by one..
I know that we can use the receiver jdbc adapter as if it was a sender by means of its specific datatype, but how to do it row by row??
Hope i had explained well..
Thanks in advance and best regards,
DavidHi kiran,
Yes, my table has 5 not null fields but i am selecting and updating fixes values so i think that I will definetely go for the next solution:
SELECT * FROM t1 WHERE status='0' and ROWNUM<2;
UPDATE t1 SET status='1' WHERE status='0' and ROWNUM<2;
My only concern is if the update will take the same row that the select.... BTW, I think it will
..What do you guys think?
I ve been trying to operate with your proposed queries but i received some errors. Your queries are very interesting but i think that with the above ones i meet my requirements as the status field will be 0 for not processed rows and 1 for precessed ones (and the update will look for the row that meets the same 'where' clause than the select, and then, and only then, it will set status='1').
The only thing i have to care about is what i questioned before.
Thanks a lot and best regards,
David -
How to restrict only one row in Table ??.
Hi all,
i want to restrict no. of rows to one,
that is not more that one row should be there in the table.
Following trigger works well in all conditions
except:
insert into myTab select 'x' from emp;
inserts 14 rows.
Create or replace trigger one_row_myTab
before insert on myTab
for each row
declare
cnt number;
pragma AUTONOMOUS_TRANSACTION;
Begin
select count(*) into cnt from mydual;
if cnt=1 then
raise_application_error(-20001,'MyDual Can have only one Row');
end if;
end;
i think with trigger it w't be possible because,
same transaction triggers c't query the table (Mutating Table),
Autonomus trans ca't identify uncommited changes.
pls add your suggestions.
Thanks for Reading the Post.
Rajashekhar Ganga,
mail : [email protected]nice try Mulder ! it doesn't work everywhere...
SQL> connect scott/tiger@lsc69
Connected to:
Oracle7 Server Release 7.3.4.5.0 - Production
With the distributed and parallel query options
PL/SQL Release 2.3.4.5.0 - Production
SQL> create table d as select * from dual;
Table created.
SQL> create index i on d(1);
create index i on d(1)
ERROR at line 1:
ORA-00904: invalid column name
SQL> connect scott/tiger@lsc65
Connected to:
Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
JServer Release 8.1.7.4.0 - 64bit Production
SQL> create table d as select * from dual;
Table created.
SQL> create index i on d(1);
Index created.
SQL> connect scott/tiger@lsc68
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - 64bit Production
With the Partitioning and Data Mining options
SQL> create table d as select * from dual
Table created.
SQL> CREATE UNIQUE INDEX i on d(1);
CREATE UNIQUE INDEX i on d(1)
ERROR at line 1:
ORA-03113: end-of-file on communication channel -
How to generate a delayed retriggerable pulse using only one counter with PXI 6070E card
Hi
I have a problem in generating a retriggerable delayed pulse with a single counter(triggered through a signal at gate) using PXI 6070E card. VI was developed in NI LabVIEW traditional DAQ Ver.7.1. I have used the "delayed pulse generator config" VI and a "Start counter" & "Stop counter" VIs for the purpose. But there is no output seen at the out terminal of counter. So I introduced a "wait" VI and set it to 1 sec. Now the pulse output appears but some pulses are missing mometarily after every 1 sec interval. (any solution for this)
I have gone through a few similar requests in the forum but they suggest either to use two counters or to generate a finite pulse train which does'nt fit my application. Moreover PXI 6070E has only 2 counter timers. I am already using one counter to measure the frequency of a pulse train(signal 1). The application requires to generate a delayed retriggerable pulse for every pulse in signal 1. So I have only one counter left.
Can I measure the frequency of signal 1 by analog means.? so that I can use two counters for pulse generation. (Signal 1 is a TTL signal).
Request some help.
Thanks in Advance
RegardsA finite pulse train (N_Pulses >= 2) does require the use of 2 counters on most of our older hardware including your 6070E. If you're just talking about generating a single retriggerable pulse, you would only need one counter.
Here's an example in Traditional DAQ that shows you how to set a retriggerable pulse generation (it also allows you to adjust the characteristics of the pulse on-the-fly).
If you're writing a new program, you might consider switching to DAQmx as it supports NI's latest hardware and recent OSes should you ever need to upgrade. Traditional NI DAQ is no longer in active development. Here's an example of how to implement a retriggerable pulse generation in DAQmx. You should take note that you can't use the two drivers to simultaneously talk to the same piece of hardware, although you should be able to go back and forth by resetting the Traditional DAQ driver before switching to DAQmx.
Best Regards,
John Passiak -
Oracle database link to MySQL select only one row
Hello,
I have created a connection from the Oracle batabase 11.2 to a MySQL database via database link. The following statement shows, that 35 rows are in the mySQL table:
SQL> select count(*) from "main_pages"@MOREWEB;
COUNT(*)
35
But a normal select statement only return 1 row.
SQL> select "subject" from "main_pages"@MOREWEB;
subject
Übersicht: Referenzen
I am using the mysql-connector-odbc-3.51.30-winx64 driver. A newer version cann't be installed because on Windows Server 2008 R2 I get an error with an missing dll-file. The DataDirect-ODBC-driver is not possible, because we like to use the free MySQL-database an DataDirect only support the enterprise edition.
I also have tried to limit the HS_OPEN_CURSORS or dont limit the HS_FDS_FETCH_ROWS, but there is no difference in the result. I always get only one row.
HS Init.ora
# This is a sample agent init file that contains the HS parameters that are
# needed for the Database Gateway for ODBC
# HS init parameters
HS_FDS_CONNECT_INFO = moreweb
HS_FDS_TRACE_LEVEL = ON
HS_FDS_FETCH_ROWS=1
# Environment variables required for the non-Oracle system
#set <envvar>=<value>
HS tracefile
Oracle Corporation --- MITTWOCH NOV 05 2014 13:56:22.066
Heterogeneous Agent Release
11.2.0.1.0
Oracle Corporation --- MITTWOCH NOV 05 2014 13:56:22.066
Version 11.2.0.1.0
HOSGIP for "HS_FDS_TRACE_LEVEL" returned "ON"
HOSGIP for "HS_OPEN_CURSORS" returned "50"
HOSGIP for "HS_FDS_FETCH_ROWS" returned "1"
HOSGIP for "HS_LONG_PIECE_TRANSFER_SIZE" returned "65536"
HOSGIP for "HS_NLS_NUMERIC_CHARACTER" returned ".,"
HOSGIP for "HS_KEEP_REMOTE_COLUMN_SIZE" returned "OFF"
HOSGIP for "HS_FDS_DELAYED_OPEN" returned "TRUE"
HOSGIP for "HS_FDS_WORKAROUNDS" returned "0"
HOSGIP for "HS_FDS_MBCS_TO_GRAPHIC" returned "FALSE"
HOSGIP for "HS_FDS_GRAPHIC_TO_MBCS" returned "FALSE"
HOSGIP for "HS_FDS_RECOVERY_ACCOUNT" returned "RECOVER"
HOSGIP for "HS_FDS_TRANSACTION_LOG" returned "HS_TRANSACTION_LOG"
HOSGIP for "HS_FDS_TIMESTAMP_MAPPING" returned "DATE"
HOSGIP for "HS_FDS_DATE_MAPPING" returned "DATE"
HOSGIP for "HS_FDS_CHARACTER_SEMANTICS" returned "FALSE"
HOSGIP for "HS_FDS_MAP_NCHAR" returned "TRUE"
HOSGIP for "HS_FDS_RESULTSET_SUPPORT" returned "FALSE"
HOSGIP for "HS_FDS_RSET_RETURN_ROWCOUNT" returned "FALSE"
HOSGIP for "HS_FDS_PROC_IS_FUNC" returned "FALSE"
HOSGIP for "HS_FDS_REPORT_REAL_AS_DOUBLE" returned "FALSE"
using mpgw as default value for "HS_FDS_DEFAULT_OWNER"
HOSGIP for "HS_SQL_HANDLE_STMT_REUSE" returned "FALSE"
SQL text from hgopars, id=1, len=36 ...
00: 53454C45 43542043 4F554E54 282A2920 [SELECT COUNT(*) ]
10: 46524F4D 20606D61 696E5F70 61676573 [FROM `main_pages]
20: 60204131 [` A1]
Deferred open until first fetch.
Performing delayed open.
SQL text from hgopars, id=1, len=40 ...
00: 53454C45 43542041 312E6073 75626A65 [SELECT A1.`subje]
10: 63746020 46524F4D 20606D61 696E5F70 [ct` FROM `main_p]
20: 61676573 60204131 [ages` A1]
Deferred open until first fetch.
Performing delayed open.
Please can help me someone.
Thanks.
Biancamxallen wrote:
Bianca,
If you log directly into MySQL and issue the same query (select "subject" from "main_pages";) what data is returned?
I looks to me that you count is the number of rows in the entire table "main_pages"
while you select is for the data in the "subject" column only.
This seems to indicate that you have just one row in that subject column.
Regards,
Matt
WHAATT?
What do you mean by "just one row in that subject column"?
That makes no sense at all. A row is a row. A column is a part of a row. All rows have all columns, though not all columns of all rows will necessarily have an assigned value. Lacking a WHERE clause to filter rows, any SELECT should return all rows. -
Merge only one row out of multiple rows
I need to prepare a merge statement which merge only one row in to a table. Below is the table definition, sample data and merge statement i used.
CREATE TABLE Mob_Attr (NAME VARCHAR2(20), ATTR_1 VARCHAR2(20), ATTR_2 VARCHAR2(20), ATTR_3 VARCHAR2(20));
CREATE TABLE Mob_Desc (NAME VARCHAR2(50), ATTR_1 VARCHAR2(20), ID NUMBER(20));
CREATE TABLE Mob_Main (NAME VARCHAR2(20), ATTR VARCHAR2(20), ID VARCHAR2(10));
insert into Mob_Attr(name, attr_1, attr_2,attr_3) values ('n1','aa',null,null);
insert into Mob_Attr(name, attr_1, attr_2,attr_3) values ('n2','bb',null,null);
insert into Mob_Attr(name, attr_1, attr_2,attr_3) values ('n3','cc',null,null);
insert into Mob_Attr(name, attr_1, attr_2,attr_3) values ('n4','dd',null,null);
insert into Mob_Desc (NAME,ATTR_1,ID) values ('n1','aa',10);
insert into Mob_Desc (NAME,ATTR_1,ID) values ('n1','aa',15);
insert into Mob_Desc (NAME,ATTR_1,ID) values ('n1','aa',123);
insert into Mob_Desc (NAME,ATTR_1,ID) values ('n1','aa',1455);
insert into Mob_Desc (NAME,ATTR_1,ID) values ('n2','bb',455);
insert into Mob_Desc (NAME,ATTR_1,ID) values ('n2','bb',135);
insert into Mob_Desc (NAME,ATTR_1,ID) values ('n3','cc',15);
insert into Mob_Desc (NAME,ATTR_1,ID) values ('n3','cc',52);
insert into Mob_Desc (NAME,ATTR_1,ID) values ('n4','dd',1455);
merge into Mob_Main ma using
(select d.name, d.attr_1,d.id from Mob_Attr a, Mob_Desc d
where a.name = d.name and a.attr_1 = d.attr_1
) q on (ma.name=q.name and ma.attr=q.attr_1)
when not matched then
insert (NAME,ATTR,ID)
values (q.name,q.attr_1,q.ID);
Above merge statement will actually merge entire data . But i want the first row will only get inserted to the base table (Mob_Main). If we take name 'n1' first row from table Mob_Desc with ID as '10' only should get inserted. I can go for a cursor to do this as i have huge data volume i prefer merge instead.MERGE INTO Mob_Main ma
USING (SELECT d.name, d.attr_1, d.id
FROM Mob_Attr a, Mob_Desc d
WHERE a.name = d.name AND a.attr_1 = d.attr_1 AND id = 10
UNION
SELECT d.name, d.attr_1, d.id
FROM Mob_Attr a, Mob_Desc d
WHERE a.name = d.name AND a.attr_1 = d.attr_1 AND id != 10
AND NOT EXISTS
(SELECT 1
FROM Mob_Desc d1
WHERE d.name = d1.name
AND d.attr_1 = d1.attr_1
AND d1.id = 10)) q
ON (ma.name = q.name AND ma.attr = q.attr_1)
WHEN NOT MATCHED
THEN
INSERT (NAME, ATTR, ID)
VALUES (q.name, q.attr_1, q.ID);
COMMIT;
select *
from Mob_Main
order by name, id;
NAME ATTR ID
n1 aa 10
n2 bb 135
n2 bb 455
n3 cc 15
n3 cc 52
n4 dd 1455
6 rows selected. -
Missing rows / output only one row in a Report after applying patchset 2
Hi.
We use Reports Builder for 10g R2. We had the problem with our AS 10g R2 on windows 2003, that some reports creates duplicate rows when it is a ASCII report (desformat = delimited), see Bug 3340546.
Now we apply Patchset 2 on a local machine, to test the functionality. It fix the problem (look in metalink doc ID 398955.1 under "2.12 Oracle Reports Developer Bugs")-
But now most csv reports creates only one row instead of multiple rows.
We run reports on our local machine with OC4N and local started Form (via Forms Builder) to generate the reports (local started report server) from DevSuite).
When we start the reports with desformat=delimited the txt-file has only the header row and one data row (instead of multiple ones).
And when we generate the same report with desformat=delimiteddata it looks fine and generates all rows as expected.
We found neither here in the forum or in metalink knowledge base nor on the internet.
Have you any suggestions for us how to fix this problem?
Using delimiteddata is now acceptable solution for us, because delimited is easier to use.
Thanks for your help!Hey folks.
We have solved the problem. :)
We applied PatchSet2 for 10gR2. But we don´t know how the csv-report outputs only 1 data-row instead of several rows.
Than we create a similar report (with the same sql-query) as a new one with the reports builder assistant.
This one works pretty fine. So we looked for the attributes and see the "max. number datasets for each site" and it was in the new one set to 0 and in our old one set to 1.
So we change this and ... the old one works pretty fine! :)
So the problem is, that this attribute does not had any consequences in the old version. But since we update with PatchSet 2 it respect this attribute but we don´t "see" it.
Hope this helps others.
Maybe you are looking for
-
Hi, X11 crashes after I logged in to remote server and launch the application. ssh -X user@servername matlab I got the following crash report: Process: X11.bin [1775] Path: /Applications/Utilities/XQuartz.app/Contents/M
-
MSI Notebook GX640, black screen with games
I own for two years MSI Notebook G series GX640 (Intel Core i5-460M, Ati Mobility RadeonHD 5850, 4GB RAM, 500 GB HDD). Recently I had to send it to the manufacturer because of a audiocard malfunction. It was the last call to do it on the warranty. It
-
Errors when using migration assistant - do I care about these files??
Went through the migration assistant to move files from my MBP to new iMac (21.5"). After it finished I got a message saying... Items not migrated Some items on your old computer could not be transferred to your new computer: -some files from "BIOsfi
-
Safari Crashes when downloading videos..Help :o(
Hi Guys / Gals Im new here and have been having some problems. Im writing a project for college and will be using some clips from youtube in it (dont worry its all under the fair use act lol) and for some reason anytime i try to down load either dire
-
SAP TechEd 2011 - looking to join group for "Buy 4 get 1 Free"
Hi, I am looking for anyone that has a registration for the "Buy 4 Get 1 Free" to join in on. Please let me know on this post so I can get in touch with you about signing up with your group.