OM裡±£Áô記錄備·ÝSQL
First:
create table gobo.gobo_om_reservations_2008b as
select * from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')<'2008'
delete from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')<'2008'
commit
After 2009Year:
create table gobo.gobo_om_reservations_????b as --????=to_char(sysdate-400,'yyyy')
select * from gobo.gobo_om_reservations_2008b
insert into gobo.gobo_om_reservations_????b
select * from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')<'????'
delete from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')<'????'
commit
ϵ統TABLE£ºmtl_reservations
µÄTRRIGERÈçÏ£º
--OTCµÄ訂單ÔÚOM發·Å¹¤單時£¬會×Ô動±£Áô¡£
--¼´°Ñ訂單與¹¤單聯ϵÆð來£¬¿É當訂單銷貨áᣬ
--»ò¹¤單Í깤áᣬ該關聯¼´Ïûʧ
--為Á˱£³Ö聯ϵ啟ÓÃ備·ÝµÄ·½·¨¡£
CREATE OR REPLACE TRIGGER gobo_om_reservations_in
after insert on mtl_reservations
for each row
begin
--舊µÄ·½Ê½備·Ýµ½gobo_om_reservations
insert into gobo_om_reservations
values( :new.SUPPLY_SOURCE_HEADER_ID,
:new.ORGANIZATION_ID,
:new.INVENTORY_ITEM_ID,
:new.DEMAND_SOURCE_TYPE_ID,
:new.DEMAND_SOURCE_HEADER_ID,
:new.DEMAND_SOURCE_LINE_ID,
:new.RESERVATION_QUANTITY,
:new.SUPPLY_SOURCE_TYPE_ID,
:new.CREATION_DATE,
:new.LAST_UPDATE_DATE );
--еķ½Ê½£¬°ÑWIP_JOD_ID寫µ½訂單LINE裡
--為ÁËÈËÁô舊ÉÏÃæµÄ·½Ê½£¬¹Ê²»È¡ÏûÉÏÃæµÄ·½·¨¡£
update oe_order_lines_all
set attribute19=:new.supply_source_header_id
where line_id= :new.demand_source_line_id
-- and header_id=:new.demand_source_header_id
and attribute19 is null;
end;
Ïà¹ØÎĵµ£º
ÓÐʱºò£¬ÔÚ¹¤×÷ÖлáÓöµ½½«Ò»¸öÊý¾Ý¿âÖбíµÄÊý¾Ýµ¼µ½ÁíÒ»¸öÊý¾Ý¿âµÄ±íÖУ¬µ«Êǹ¤¾ßÓÖûÓÐÌṩÕâÑùµÄ¹¦ÄÜ
ÏÂÃæÄÜͨ¹ýSQLÓï¾äÉú³ÉInsertÓï¾ä£¬ÔÙ²åÈëµ½ÁíÒ»¸öÊý¾Ý¿âÖС£
MSSQL:
SELECT 'INSERT INTO StatInfo(UserName,CardId,Address,WageCount,Pension)'+
' VALUES('''+a.UserName+''','''+a.CardId+''','''+a.Ad ......
¸Ð¾õ×Ô¼ºÊDZȽϱ¿µÄ£¬Ñ§Ï°¹ýSQLÓïÑÔ£¬µ«ÊÇÈ´·Ö²»Ì«Çå³þDDL¡¢DML¡¢DCLÓïÑÔ£¬ËùÒÔÄØ£¬½ñÌì¾Íºñ×ÅÁ³Æ¤ÎÊÁËÀÏʦ£¬ÏÖÔÚ¾Í×Ô¼ºÄ¿Ç°µÄÁ˽âÀ´×ܽáһϡ£
1¡¢DDL£¨DATA DEFINITION LANGUAGE£©Êý¾ÝÃèÊöÓïÑÔ
DDLÓï¾ä²»»á²úÉú»¹ÔÊý¾Ý£¬ËùÒÔɾ³ýµÄÊý¾ÝÒ²ÊÇÎÞ·¨»Ö¸´µÄ
CREATE - to ......
ת×Ôhttp://lavasoft.blog.51cto.com/62575/23373
SQLÓïÑÔµÄCASEÓï¾ä±¸Íü
¸ÅÊö£º
SQLÓï¾äÖеÄCASEÓï¾äÓë¸ß¼¶ÓïÑÔÖеÄswitchÓï¾ä£¬ÊDZê×¼SQLµÄÓï·¨£¬ÊÊÓÃÓëÒ»¸öÌõ¼þÅжÏÓжàÖÖÖµµÄÇé¿öÏ·ֱðÖ´Ðв»Í¬µÄ²Ù×÷¡£Áé»îÓ¦ÓÃCASEÓï¾ä¿ÉÒÔʹSQLÓï¾ä±äµÃ¼ò½àÒ×¶Á£¬ÏÂÃæÔÚDB2»·¾³ÏÂͨ¹ýÒ»¸ö¼òµ¥µÄ²éѯÀ´Õ¹Ê¾SQL CASEÓ ......
·½°¸1 ÊÊÓÃÓÚoracle9iÒÔÉÏ£¡
select * from
(select row_number() over(order by sendid desc) rn,m.* from xxt_msgreceive m )
where rn <1010 and rn>=1000
·½°¸2
SELECT * from (SELECT A.*, ROWNUM RN from (SELECT * from xxt_msg where sendstatus=1 order by msgid desc) A WHERE ROWNUM < ......
´æ´¢¹ý³ÌgetRecordfromPageµÄÄÚÈÝ
//getRecordfromPage.sql
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[getRecordfromPage]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[getRecordfromPage]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
G ......