Notes
Notes - notes.io |
GO
/****** Object: StoredProcedure [dbo].[SP3_Yerlesim_Listesi] Script Date: 5.12.2019 11:48:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[SP3_Yerlesim_Listesi]
@pYerlesimYeriTuru INT,
@pAranacakIfade VARCHAR(10)
AS
BEGIN
DECLARE @cvBolgeNo INTEGER
DECLARE @cvBolgeAdi VARCHAR (100)
DECLARE @cvIlKodu VARCHAR(2)
DECLARE @cvIlAdi VARCHAR(100)
DECLARE @cvIlceKodu VARCHAR(100)
DECLARE @cvIlceAdi VARCHAR (100)
DECLARE @cvYerlesimYeriTuru VARCHAR(100)
DECLARE @cvYerlesimYeriID VARCHAR(100)
DECLARE @cvYerlesimYeriAdi VARCHAR(100)
DECLARE @SQL VARCHAR(MAX)
IF @pYerlesimYeriTuru = 1 -- BÖLGELER
BEGIN
DECLARE curBolgeler CURSOR FAST_FORWARD FOR
SELECT bolge_no, bolge_adi
FROM S_BOLGELER
WHERE pasif_mi=0
AND bolge_adi LIKE '%' +
SUBSTRING(@pAranacakIfade,1, 10) + '%'
ORDER BY bolge_adi;
OPEN curBolgeler
FETCH NEXT FROM curBolgeler
INTO @cvBolgeNo, @cvBolgeAdi
PRINT ('İçinde "' + @pAranacakIfade +
'" ifadesi geçen BÖLGELER:');
SET @SQL = '';
WHILE @@FETCH_STATUS = 0
BEGIN
SET @SQL = CAST(@cvBolgeNo AS VARCHAR) + '. ' + @cvBolgeAdi;
PRINT (@sql)
FETCH NEXT FROM curBolgeler
INTO @cvBolgeNo, @cvBolgeAdi
END
CLOSE curBolgeler
DEALLOCATE curBolgeler
END
ELSE IF @pYerlesimYeriTuru = 2 -- ILLER
BEGIN
DECLARE curIller CURSOR FAST_FORWARD FOR
SELECT il_kodu, il_adi
FROM S_ILLER
WHERE pasif_mi=0
AND il_adi LIKE '%' +
SUBSTRING(@pAranacakIfade,1, 10) + '%'
ORDER BY il_adi;
OPEN curIller
FETCH NEXT FROM curIller
INTO @cvIlKodu, @cvIlAdi
PRINT ('İçinde "' + @pAranacakIfade +
'" ifadesi geçen ILLER:');
SET @SQL = '';
WHILE @@FETCH_STATUS = 0
BEGIN
SET @SQL = CAST(@cvIlKodu AS VARCHAR) + '. ' + @cvIlAdi;
PRINT (@sql)
FETCH NEXT FROM curIller
INTO @cvIlKodu, @cvIlAdi
END
CLOSE curIller
DEALLOCATE curIller
END
ELSE IF @pYerlesimYeriTuru = 3 -- ILCELER
BEGIN
DECLARE curIlceler CURSOR FAST_FORWARD FOR
SELECT ilce_kodu, ilce_adi
FROM S_ILCELER
WHERE pasif_mi=0
AND ilce_adi LIKE '%' +
SUBSTRING(@pAranacakIfade,1, 10) + '%'
ORDER BY ilce_adi;
OPEN curIlceler
FETCH NEXT FROM curIlceler
INTO @cvIlceKodu, @cvIlceAdi
PRINT ('İçinde "' + @pAranacakIfade +
'" ifadesi geçen ILCELER:');
SET @SQL = '';
WHILE @@FETCH_STATUS = 0
BEGIN
SET @SQL = CAST(@cvIlceKodu AS VARCHAR) + '. ' + @cvIlceAdi;
PRINT (@sql)
FETCH NEXT FROM curIlceler
INTO @cvIlceKodu, @cvIlceAdi
END
CLOSE curIlceler
DEALLOCATE curIlceler
END
IF @pYerlesimYeriTuru = 0
BEGIN
DECLARE curHepsi CURSOR FAST_FORWARD FOR
SELECT 'BÖLGE' AS yerlesim_yeri_turu, bolge_no, bolge_adi
FROM S_BOLGELER
WHERE pasif_mi = 0 AND bolge_adi LIKE '%' + SUBSTRING(@pAranacakIfade, 1, 10) + '%'
UNION
SELECT 'İLLER' AS yerlesim_yeri_turu, il_kodu, il_adi
FROM S_ILLER
WHERE pasif_mi = 0 AND il_adi LIKE '%' + SUBSTRING(@pAranacakIfade, 1, 10) + '%'
UNION
SELECT 'İLÇELER' AS yerlesim_yeri_turu, ilce_kodu, ilce_adi
FROM S_ILCELER
WHERE pasif_mi = 0 AND ilce_adi LIKE '%' + SUBSTRING(@pAranacakIfade, 1, 10) + '%'
ORDER BY 1, 3
OPEN curHepsi
FETCH NEXT FROM curHepsi
INTO @cvYerlesimYeriTuru, @cvYerlesimYeriID, @cvYerlesimYeriAdi
PRINT ( 'İçinde "' + @pAranacakIfade + '" ifadesi geçen ilçeler iller bölgeler ');
SET @SQL = '';
WHILE @@FETCH_STATUS = 0
BEGIN
SET @SQL = @cvYerlesimYeriTuru + '. ' + @cvYerlesimYeriID + '. ' + @cvYerlesimYeriAdi ;
PRINT (@sql)
FETCH NEXT FROM curHepsi
INTO @cvYerlesimYeriTuru, @cvYerlesimYeriID, @cvYerlesimYeriAdi
END
CLOSE curHepsi
DEALLOCATE curHepsi
END
----------------------------------------------------------
END
GO
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team