Friday, February 25, 2011

How to make Cursor in SQL Server

Hello in this chapter I will explain about how to make cursor in stored procedure. Cursor is programming language used to access any existing row separately with other record.Cursor is very suitable to solve a difficult problem. In this article I will demonstrate how to make cursor.
1. Create database
create database dbDatabaseExample

2. Create table
create table tbStudent(
NRP varchar(100) primary key not null, Name varchar(100),Address varchar(100)
)

3. Fill data
insert into tbStudent values('0001','Hendry Apryanto','Griya Persada Street')
insert into tbStudent values('0002','Yohan Andreas','Babakan Jeruk Street')
insert into tbStudent values('0003','Tana El San','Semarang Indah Permai Street')
insert into tbStudent values('0004','Tommy Gunawan','Britania Street')

4. Create Procedure


CREATE PROCEDURE SP_SHOWSTUDENTCURSOR
AS
BEGIN
--CURSOR DECLARATION
DECLARE StudentCSR CURSOR
FOR SELECT * FROM tbStudent

--OPEN CURSOR
OPEN StudentCSR

--CURSOR VARIABEL
Declare @NO varchar(100)
Declare @Name varchar(100)
Declare @Address varchar(100)

FETCH NEXT FROM StudentCSR into @NO,@Name,@Address
While @@FETCH_STATUS=0
BEGIN
PRINT '--------------------'
PRINT 'NO '+@NO
PRINT 'NAME '+@Name
PRINT 'ADDRESS '+@Address
PRINT '--------------------'
FETCH NEXT FROM StudentCSR into @NO,@Name,@Address
END

--CLOSE CURSOR
CLOSE StudentCSR

--ALLOCATE CURSOR
DEALLOCATE StudentCSR
END

Note:
Use 'exec [STOREDPROCEDURE_NAME](exec SO_SHOWSTUDENTCURSOR)' if you want to execute.
Result :


Okay that's is it and congratulation you have made Cursor in sql server. I hope this tutorial can help you.Thank you..Have a nice day all..^^

Read More......

Stored Procedure in SQL Server 2005

Okay in this chapter I will explain about store procedure in sql server. Please followng step at bellow:
1. Create database at sql server (In this case I will create dbDatabaseExample)
create database dbDatabaseExample

2. Create table at database (Table Name:tbSTudent)
create table tbStudent(
NO varchar(100) primary key not null, Name varchar(100)
)

3. Fill table data
insert into tbStudent values('0001','Hendry Apryanto')
insert into tbStudent values('0002','Yohan Andreas')
insert into tbStudent values('0003','Tana El San')

4. Create Stored Procedure
A. Stored Procedure without parameter
create procedure SP_SHOWSTUDENT
AS
BEGIN
SELECT * FROM tbStudent
END
Note:
To execute stored procedure use 'exec [STOREPROCEDURE_NAME](EXEC SP_SHOWSTUDENT)'

B. Stored Procedure with parameter
create procedure SP_SHOWSTUDENTPARAMETER
@VARCARI VARCHAR(100)
AS
BEGIN
SELECT * FROM tbStudent WHERE NO=@VARCARI
END
Note:
To execute stored procedure use 'exec [STOREPROCEDURE_NAME][PARAMETER_VALUE](EXEC SP_SHOWSTUDENT('0001'))'

Okay that's is it and congratulation you have make stored procedure in sql server. I hope this tutorial can help you..Thank you...^^GBU

Read More......

Thursday, February 24, 2011

Data Type SQL Server

In this chapter I will show you data type in sql server.
1. Bit
->Integer with value 1 or 0.
2. Int
-> Integer value between -2^31(-2.147.483.648) until 2^31-1(+2.147.384.647).
3. Decimal or Numeric
-> value between -10^38-1 until 10^38-1.
4. Money
-> currency from -2^63( -922.377.203.685.477,5808) until 2^63-1(922.377.203.685.477,5807).

5. Float
-> -214.748,3648 until 1.79E+308.
6. Real
-> -3.40E+308 until 3.40E+38.
7. DateTime
-> 1 January 1973 until 31 December 9999.
8. SmallDateTime
-> 1 January 1900 until 6 Juny 2079, with precision until 1 minute.
9. Char
-> Number of permanent character with maximum size 8000.
10. Varchar
-> Number of variabel character with maximum size 8000.
11. Text
-> Number of variabel character with maximum size 2.147.483.647 .
12. NChar
-> Number of permanent character with maximum size 4000.
13. NVarchar
-> Number of variabel character with maximum size 4000.
14. NText
-> Number of variabel chaacter with maximum size 1.073.741.823 .
15. Binary
-> Number of permanent binary with maximum size 8000.
16. Varbinary
-> Number of variabel binary with maximum size 8000.
17. Image
-> Number of variabel character with maximum size 2.147.483.647.

Okay that's is it. I hope with some knowledge about data type in sql server I can help yout. Thank you for see this tutorial..^^

Read More......

Step by Step Learn Oracle Stored Procedure

Hello everyone, how about your day, in this chapter we will discuss about how to make stored procedure in oracle.First open your IDE for oracle in this case i will use PL/SQL and please following step at bellow:(Log in with system).
1. Create user :
Create user [USER_NAME] identified by [PASSWORD];
grant connect, resources to [USER_NAME] (give permission to access database).

Example:
Create user dbDataService identified by data12345;
grant connect, resource to dbDataService;

Note:
Press F8 to execute query
2. Log in with dbDataService (at this case)-> Create table.
Create table[TABLE_NAME]([PROPERTY_NAME][VARIABEL_TYPE])

Example:
Create table Student (NO varchar2(100) primary key not null, Name varchar2(100));

3. Fill data at Student table
Insert into Student values('1','Hendry');
Insert into Student values('2','Marco');

4. Open SQL WINDOW. After that please copy following code at bellow to make stored procedure.(at this case i will use curosr to read all row).
CREATE OR REPLACE PROCEDURE[STOREDPROCEDURE_NAME]
AS
BEGIN
END;

Example:
CREATE OR REPLACE PROCEDURE SP_SHOWSTUDENT
AS
CUROSR STUDENTCURSOR IS
SELECT NO,NAMA FROM STUDENT;
BEGIN
FOR D IN STUDENTCURSOR LOOP
DBMS_OUTPUT.PUT_LINE('NO'||D.NO);
DBMS_OUTPUT.PUT_LINE('NO'||D.NAMA);
END LOOP;
COMMIT;
END;

5.Execute stored procedure.
BEGIN
[STOREDPROCEDURE_NAME];
END;

Example:
BEGIN
SP_SHOWSTUDENT;
END;

Okay that's is it and finnaly congratulation you have made STORED PROCEDURE in oracle. Thank you for see this tutorial i hope this tutorial can help you..Have a nice day..^^

Read More......

Wednesday, February 9, 2011

User Interface at Flex Part 2

Okay I will continue the last article. In this article I will introduce :
1. CheckBox
Example:







import mx.controls.Alert;
private function clickHandler():void{
if(data1.selected) {
Alert.show("Data 1 is clicked","Warning");
data1.selected=false;
}else if(data2.selected) {
Alert.show("Data 2 is clicked","Warning");
data2.selected=false;
}else if(data3.selected) {
Alert.show("Data 3 is clicked","Warning");
data3.selected=false;
}else if(data4.selected) {
Alert.show("Data 4 is clicked","Warning");
data4.selected=false;
}
}
]]>








Result:


2. Radio Button
Example:









Result:

3.Label
Example






Result:

4.Button
Example:






Result:



Read More......

Tuesday, February 8, 2011

User Interface at Flex Part 1

In this chapter I will show you some example and how use component:
1. Alert
->This component use to display message at monitor.
Example:





import mx.events.CloseEvent;
import mx.controls.Alert;
private function init():void{
Alert.show("Simple Alert","Warning");
}
private function initUser(event:Event):void{
Alert.show("Choose yes or no ?","Warning",3,this,clickHandler);
}
private function clickHandler(event:CloseEvent):void{
if(event.detail==Alert.YES) {
Alert.show("User choose YES","Warning");
}else{
Alert.show("User choose NO","Warning");
}
}
]]>






Result:
User Interface User Alert Button:


User Interface Simple Alert Button:


2. ComboBox
Example of combo box:




import mx.controls.Alert;
import mx.events.MenuEvent;
private function clickHandler():void {
Alert.show(_comboBox.selectedLabel.toString(),"Warning");
}
]]>














Result:


3.List
->Display data list in one component.(In this application click at data do you want display a message alert).
Example:




import mx.controls.Alert;
private function clickHandler() :void{
Alert.show(_list.selectedItem.toString(),"Warning");
}
]]>




Data 1
Data 2
Data 3
Data 4





Result:


4. Tab Bar
Example:























Result:


Source Code:
Visual Component.rar

That's is it and for another component I will publish at next article. Thank you for see this tutorial I hope this tutorial can help you...Have a nice day all...^^

Read More......

Sunday, February 6, 2011

How to make Chat in Flex

In this chapter we will make simple chat in flex.Flex have 2 component. First is Producer, Producer have a utility to send a message to every client. Second is Consumer, consumer have function to accept every message when sent by producer. At bellow is a sample chat with flex:





import mx.controls.Alert;
import mx.messaging.events.MessageEvent;
import mx.messaging.events.MessageFaultEvent;
import mx.messaging.messages.AsyncMessage;

public function onLoad():void{
_consumer.subscribe();
}
public function sendMessage():void {
var message:AsyncMessage=new AsyncMessage();
message.body=_txtInputUser.text+" : "+_txtInputMessage.text;
_producer.send(message);
}
public function messageHandler(event:MessageEvent):void {
_txtArea.text+=event.message.body.toString() +"\n";
_txtInputMessage.text="";
}
public function faultHandler(event:MessageFaultEvent):void {
_txtArea.text=event.faultString;
}
]]>































Note:
1. At Line 2- 25, Make Script and method.
2. At Line 26, Producer component (ID=”_producer”).
3. At Line 27, Consumer component (ID=”_consumer”)
4. At Line 28-54, Declaration User Interface in flex.

Explanation:
1. At method sendMessage it use to send message using procedure component and it will fire when Button is pressed . Message will be retrieved from textInput (with ID =_txtInputUser and _txtInputMessage) and will be stored at SyncMessage.
2. At method messageHandler have a utility to accept every asnycmessage.

After you paste code at above there a have a little setting. Go to LCDS Folder on your computer after that find remotig-config.xml copy the code bellow at xml file (before ""):




true
8




after copt that save a change. go to at messaging-service.xml and copt code at bellow:





Result:


Source Code:
SimpleChat.mxml

Okay that's it and congratulation you have made simple chat using flex. I hope this tutorial can help you..Have a nice day...^^

Read More......

Wednesday, February 2, 2011

How use Data Grid in Flex

Data grid is a essential part in application so we must know how to use it. First open your IDE in this case i will use Eclipse Europa with flex builder plug in.
Please copy code bellow in your flex project:






<_number>123456
<_name>Haruki Takumi
<_address>Kyoto Nippon Street


<_number>654321
<_name>Ichigo Kurosaki
<_address>Tokyo Street


<_number>654123
<_name>Uzumaki Naruto
<_address>Leaf Village















In the example above there a have 2 part, the part number 1 is XMLList it place to put data and the part 2 is DataGrid. So after we have a data in XMLLIST we can bind it to datagrid using data provider. This is a screen shoot after the code run:


Okay finnaly congaratulation you have know about how to use data grid and i hope this tutorial can help you...Thank you...^^

Read More......

Tuesday, February 1, 2011

How to use Menu Bar in Flex

In this chapter we will discuss about flex programming language. I will show you how to make menu bar and access menu. In flex programming language there have a hierarchy(MenuBar->XMListCollection->XMLList->MenuItem). First open your IDE in this case i will use eclipse europa with flex builder plug in. Please copy code bellow in your flex project.

































At code above is example to make menu bar in flex but at menu not have a action to do something so we must add some script. In this case I will click menu 1-1 and will display with message error "Menu 1-1".Please copy code bellow:





import mx.controls.Alert;
import mx.events.MenuEvent;
private function listenerMenu(event:MenuEvent):void {
Alert.show(event.item.@label,"Warning");
}
]]>




























Result


Okat that's is it and finnaly congratulation you have make one component in flex.Thank you for see this tutorial i hope with this tutorial can help you.^^

Read More......