DO $$
DECLARE
x INTEGER;
begin
x :=1;
loop
insert into zz_test_insert VALUES (x);
x := x + 1;
exit when x > 101;
end loop;
end $$;
----
DO $$
DECLARE
x INTEGER;
begin
x :=1;
FOR x IN 1..100 LOOP
insert into zz_test_insert VALUES (x);
x := x + 1;
end loop;
end $$;
-------------------------------------
DO $$
DECLARE idkartu INTEGER;
DECLARE bulan_ke INTEGER;
Declare harga bigint;
Declare jangka int;
Declare tglbeli date;
declare aset record;
begin
idkartu :=(select COALESCE(max(id),0) idmax from m_kartu_depresiasi) + 1;
bulan_ke :=1;
loop
select jangka_waktu, id into aset from m_aset_inventaris where id=1592;
insert into m_kartu_depresiasi
(id, depresiasi_bulan_ke, id_aset_inventaris,status_depresiasi) values (idkartu, bulan_ke, aset.id, false);
idkartu := idkartu + 1;
bulan_ke := bulan_ke + 1;
exit when bulan_ke > aset.jangka_waktu;
end loop ;
END $$;
Langganan:
Posting Komentar (Atom)
Dynamic Query - SQL Server
Berikut adalah contoh dari bentuk dari Dynamic Query di SQL Server yang dibungkus ke dalam Store Procedure: USE [Data00] GO SET ANSI_NULLS ...
Popular Posts
-
select round(5.123456 , 2) from dual ==> 5.12 select round(5.87654 , 2) from dual ==> 5.88 select floor(5.89) from dual ==> 5 s...
-
round((case when adjpk.nilai_jaminan<>0 then ((tabkredit.baki*100)/(COALESCE(adjpk.nilai_jaminan,0))) els...
-
USE [DATABASENYA] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[SendEmailHardiskSize] as begin ...
Tidak ada komentar:
Posting Komentar