Tuesday, October 1, 2013

Get multiple result rows from sybase store procedure



Sometime we need get multiple result rows  from some query in store procedure.

For security purposes, I had to change some variable, column
and table names, but here is my stored procedure:

Create Proc dbo.sp_GetMultiple (
@parm_keyField varchar(100) = null,
@parm_dbMyName char(30) = null Output,
@parm_dbState char(2) = null Output,
@parm_dbUniqueId varchar(16) = null Output,
@parm_dbField2 varchar(8) = null Output,
@parm_dbField3 varchar(8) = null Output,
@parm_dbField4 varchar(16) = null Output,
@parm_dbField5 varchar(8) = null Output,
@parm_dbPeriod varchar(8) = null Output
)
As
Begin
/**********************************************************
*Procedure Name: sp_GetMultiple
*********************************************************/

/*** declare variables ***/

declare @er integer

declare @varState varchar(2)
declare @varUniqueId varchar(16)
declare @varField2 varchar(8)
declare @varField3 varchar(8)
declare @varField4 varchar(8)
declare @varField5 varchar(16)
declare @varPeriod varchar(8)

/*** retrieve data ***/

declare resultList cursor for
SELECT LEFT(myName, 30) AS myName, State, column2, column3,
column4, column5, Period, UniqueId
FROM Table1 T1
LEFT OUTER JOIN Table2 T2 ON T1.CatId = T2.CatIdFK
WHERE T2.keyField = @parm_keyField
ORDER BY 1, 2

open resultList

if @@sqlstatus != 0 return

fetch resultList
into @parm_dbMyName, @varState, @varField2, @varField3,
@varField4, @varField5, @varPeriod, @varUniqueId


/* if cursor result set is not empty, then process each
row of information */
while (@@sqlstatus = 0)
begin
/* decrypt the data */
exec dbo.sp_DecryptVar @varState, @parm_dbState
output
exec dbo.sp_DecryptVar @varUniqueId, @parm_dbUniqueId
output
exec dbo.sp_DecryptVar @varField2, @parm_dbField2
output
exec dbo.sp_DecryptVar @varField3, @parm_dbField5
output
exec dbo.sp_DecryptVar @varField4, @parm_dbField3
output
exec dbo.sp_DecryptVar @varField5, @parm_dbField4
output
exec dbo.sp_DecryptVar @varPeriod, @parm_dbPeriod
output

/*** get next record from cursor ***/
fetch resultList into @parm_dbMyName, @varState,
@varField2, @varField3, @varField4, @varField5, @varPeriod,
@varUniqueId
end

close resultList

return

End



than... 
How do you return data to the client ?

And how does the client proces the data ?

If you have multiple selects in a procedure, you get multiple
result sets sent to the client, so the client should process more
than one result set. A way to avoid this is to insert the
data in a temp table first and then select from the temp table.

Tuesday, July 2, 2013

You and I – Scorpions

I lose control because of you, babe
I lose control when you look at me like this
There’s something in your eyes
That is saying tonight
I’m not a child anymore
Life has opened the door
To a new exciting life
I lose control whem I’m close to you, babe
I lose control don’t look at me like this
There’s something in your eyes
Is this love at first sight?

Like a flower that grows
Life just wants you to know
All the secrets of life
It’s all written down in your lifelines
It’s written down inside your heart
You and I just have a dream
To find our love a place, where we can hide away
You and I, we’re just made
To love each other now, forever and a day, yeah
I lose control because of you, babe
I lose control don’t look at me like this
There’s something in your eyes
That is saying tonight
I’m so curious for more
Just like never before
In my innocent life
It’s all written down in your lifelines, yeah
It’s written down inside your heart
You and I just have a dream
To find our love a place, where we can hide away
You and I, we’re just made
To love each other now, forever and a day, yeah
The time stands still
When the days of innocence
Are falling for the night
I love you, girl, I always will
I swear, I’m there for you
Till the day I die
You and I just have a dream
To find our love a place, where we can hide away
You and I, we’re just made
To love each other now, forever and a day, yeah

Rock You Like a Hurricane – Scorpions

It’s early morning
The Sun comes out
Last night was shaking
And pretty loud
My cat is purring
And scratches my skin
So what is wrong
With another sin
The bitch is hungry
She needs to tell
So give her inches
And feed her well
More days to come
New places to go
I’ve got to leave
It’s time for a show

Here I am, rock you like a hurricane
Here I am, rock you like a hurricane
My body is burning
It starts to shout
Desire is coming
It breaks out loud
Lust is in cages
Till storm breaks loose
Just have to make it
With someone I choose
The night is calling
I have to go
The wolf is hungry
He runs the show
He’s licking his lips
He’s ready to win
On the hunt tonight
For love at first sting
Here I am, rock you like a hurricane (Are you ready baby?)
Here I am, rock you like a hurricane
Here I am, rock you like a hurricane (Come on, come on baby)
Here I am, rock you like a hurricane
Rock you like a hurricane
It’s early morning
The Sun comes out
Last night was shaking
And pretty loud
My cat is purring
And scratches my skin
So what is wrong
With another sin
The night is calling
I have to go
The wolf is hungry
He runs the show
He’s licking his lips
He’s ready to win
On the hunt tonight
For love at first sting
Here I am, rock you like a hurricane (Are you ready baby?)
Here I am, rock you like a hurricane
Here I am, rock you like a hurricane (Come on, come on, come on, come on, come on)
Here I am, rock you like a hurricane
Here I am

Holiday Lyrics - Scorpions

Let me take you far away
You’d like a holiday
Let me take you far away
You’d like a holiday
Exchange the cold days for the sun
A good time and fun
Let me take you far away
You’d like a holiday
Let me take you far away
You’d like a holiday
Let me take you far away
You’d like a holiday
sumber www.rizkyonline.com
Exchange your troubles for some love
Wherever you are
Let me take you far away
You’d like a holiday
Longing for the sun you will come
To the island without name
Longing for the sun be welcome
On the island many miles away from home
Be welcome on the island without name
Longing for the sun you will come
To the island many miles away from home

Always Somewhere Lyrics - Scorpions

Arrive at seven the place feels good
No time to call you today
Encores till eleven then Chinese food
Back to the hotel again

I call your number the line ain't free
I like to tell you come to me
A night without you seems like a lost dream
Love I can't tell you how I feel

Always somewhere
Miss you where I've been
I'll be back to love you again

Another morning another place
The only day off is far away
But every city has seen me in the end
And brings me to you again

Always somewhere
Miss you where I've been
I'll be back to love you again.

Wind Of Change - Scorpions

I Follow The Moskva
Down To Gorky Park
Listening To The Wind Of Change
An August Summer Night
Soldiers Passing By
Listening To The Wind Of Change
The World Is Closing In
Did You Ever Think
That We Could Be So Close, Like Brothers
The Future's In The Air
I Can Feel It Everywhere
Blowing With The Wind Of Change
[Chorus:]
Take Me To The Magic Of The Moment
On A Glory Night
Where The Children Of Tomorrow Dream Away
In The Wind Of Change

Walking Down The Street
Distant Memories
Are Buried In The Past Forever

I Follow The Moskva
Down To Gorky Park
Listening To The Wind Of Change

Take Me To The Magic Of The Moment
On A Glory Night
Where The Children Of Tomorrow Share Their Dreams
With You And Me

Take Me To The Magic Of The Moment
On A Glory Night
Where The Children Of Tomorrow Dream Away
In The Wind Of Change

The Wind Of Change Blows Straight
Into The Face Of Time
Like A Stormwind That Will Ring
The Freedom Bell For Peace Of Mind
Let Your Balalaika Sing
What My Guitar Wants To Say

Take Me To The Magic Of The Moment
On A Glory Night
Where The Children Of Tomorrow Share Their Dreams
With You And Me

Take Me To The Magic Of The Moment
On A Glory Night
Where The Children Of Tomorrow Dream Away
In The Wind Of Change

Monday, July 1, 2013

Trik mencetak ke printer yang menggunakan Port LPT to USB di Windows 7




Trik ini dilakukan untuk mengatasi permasalahan pencetakan dari sebuah printer yang menggunakan Port LPT ( Paralel ) to USB. Saat ini hampir semua komputer PC tidak menyediakan port LPT untuk koneksi ke printer,  yang tersedia biasanya hanya port USB.
Dengan demikian untuk jenis-jenis printer tertentu seperti printer dot matrix(Epson dan sejenisnya) , printer passbook , printer pencetak struk yang menggunakan port LPT tidak dapat berfungsi.
Biasanya untuk dapat terkoneksi kita memerlukan kabel konektor atau kabel LPT to USB. Namun hal itu belum dapat mengatasi permasalahan terhadap program atau aplikasi yang hanya dapat membaca Port LPT ( Paralel Port ). Untuk itu kita dapat melakukan trik-trik dibawah ini.

a.       Lakukan Setting Microsoft Loopback Adapter, dengan langkah-langkah sebagai berikut :
1.          Pilih Control Panel
2.          Kilk 2x Device Manager
3.          Pilih Add legacy hardware pada menu Action
4.          Klik tombol Next
5.          Pilih opsi Install the hardware that I manually select from a list
6.          Klikt tombol Next
7.          Pilih Network Adapters, kemudian klik tombol Next
8.          Pilih Microsoft pada List Manufacturer, kemudian Pilih Microsoft Loopback Adapter
9.          Klik tombol Next
10.      Tunggu sampai tampil window berikut ini, kemudian klik tombol Finish

b.      Lakukan Setting Network
1.          Pilih Network and Sharing Center pada menu Control Panel
2.          Klik Local Area Conection 2
3.          Klik tombol Properties, pilih Internet Protocol Version 4 (TCP/IPv4) , kemudian klik tombol Properties
4.          Pilih Use the following IP Address, isi IP  Address dan Subnet mask, kemudian klik tombol OK
5.          Klik tombol Close sampai selesai


c.       Lakukan Setting Printer ( jika printer belum terinstall )
1.          Pilih Devices and Printers dari menu utama Window
2.          Klik Add printer, kemudian pilih Add a Local printer

3.          Pilih Use an existing port, pilih Port USB yang sesuai, kemudian klik tombol Next
4.          Pilih jenis printer yang sesuai, kemudian klik tombol Next
5.          Klik tombol Next
6.          Klik tombol Finish
7.          Lakukan Sharing Printer dengan mengklik 2x pada icon printer yang diinginkan, atau mengklik kanan mouse, kemudian pilih Printer Properties

8.          Pilih tab Sharing, kemudian klik tombol Change Sharing Options
9.          Pilih Share this printer, kemudian ubah Share name menjadi printlpt atau nama lain yang gampang diingat
10.      Klik tombol OK atau Apply


d.      Jalankan perintah NET USE di command prompt (cmd)
1.          Ketik cmd pada menu Start Window
2.          Ketik perintah  NET USE LPT1: \\nama komputer\nama printer /PERSISTENT:YES
Contoh : NET USE LPT1: \\192.168.1.1\Printlpt /PERSISTENT:YES


Jika artikel ini bermanfaat untuk anda , jangan lupa beri komentar :-)

Promosi :

Anda atau Perusahaan anda tertarik belajar PowerBuilder atau Sybase??
Hubungi segera 085319158373...
Dapatkan penawaran menarik...


Monday, June 24, 2013

Mengatasi Error Installasi Database PostgreSQL di Window 7

Pernah mengalami error saat Installasi database PostgreSQL di Window 7 ? dengan pesan error : The 'Secondary Logon' is not running seperti gambar berikut :



Solusinya sebagai berikut :
1. Buka Control Panel
2. Pilih ( klik 2x ) Administrative Tools
3. Pilih ( klik 2x ) Services
4. Pilih 'Secondary Logon'
5. Pilih StartUp Type menjadi Automatic
6. Klik tombol Start 

















Selamat mencoba...

Cara Membuka File Help (*.hlp) di Window 7


File Dokumen Help atau file berekstention *.hlp tidak dapat dibuka pada OS Window 7.
Agar  File Help (*.hlp) tersebut dapat dibuka pada Window 7 maka Cara Membuka File Help (*.hlp) di Window 7 tersebut yaitu dengan mendownload update KB917607 dengan langah-langkah berikut:

Silahkan Download Update dari Microsoft KB917607 di bawah ini :

1. For 32-bit (x86) (687,31 KB) untuk kapasitas netbook
2. For 64-bit (x64) (701,33 KB) untuk kapasitas laptop dan komputer

Setelah Download maka akan terbuka proses instalasi update dari Microsoft KB917607,
Silahkan Klik OK, 
Kemudian pilih I Accept menyatan setuju untuk di instal dan proses berlanjut lainnya, hingga proses instalasi selesai ok, 
Close.

Selamat mencoba... :-)












Saturday, June 8, 2013

Backup Database Sybase

Description

Makes a backup copy of the entire database, including the transaction log, in a form that can be read in with load database. Dumps and loads are performed through Backup Server.
The target platform of a load database operation need not be the same platform as the source platform where the dump database operation occurred. dump database and load database are performed from either a big endian platform to a little endian platform, or from a little endian platform to a big endian platform.

Syntax

dump database database_name
 to [compress::[compression_level::]]stripe_device
  [at backup_server_name]
  [density = density_value, 
  blocksize = number_bytes, 
  capacity = number_kilobytes, 
  dumpvolume = volume_name, 
  file = file_name] 
  with verify[ = header | full]
 [stripe on [compress::[compression_level::]]stripe_device
  [at backup_server_name]
  [density = density_value, 
  blocksize = number_bytes,
  capacity = number_kilobytes, 
  dumpvolume = volume_name,
  file = file_name]] 
 [[stripe on [compress::[compression_level::]]stripe_device
  [at backup_server_name]
  [density = density_value, 
  blocksize = number_bytes,
  capacity = number_kilobytes, 
  dumpvolume = volume_name,
  file = file_name]]...]
 [with { 
  density = density_value, 
  blocksize = number_bytes,
  capacity = number_kilobytes, 
  compression = compress_level
  dumpvolume = volume_name,
  file = file_name,
  [dismount | nodismount],
  [nounload | unload],
  passwd = password,
  retaindays = number_days,
  [noinit | init],
  notify = {client | operator_console}
  } ] 

Parameters

database_name
is the name of the database from which you are copying data. The database name can be specified as a literal, a local variable, or a stored procedure parameter.
compress::compression_level
is a number between 0 and 9, with 0 indicating no compression, and 9 providing the highest level of compression. If you do not specify compression_level, the default is 1. See Chapter 28, “Backing Up and Restoring User Databases” in the System Administration Guide for more information about the compress option.
NoteSybase recommends the native "compression = compress_level" option as preferred over the older "compress::compression_level" option. The native option allows compression of both local and remote dumps, and the dumps that it creates will describe their own compression level during a load. The older option is retained for compatibility with older applications.
to stripe_device
is the device to which to copy the data. See “Specifying dump devices” in this section for information about what form to use when specifying a dump device.
at backup_server_name
is the name of the Backup Server. Do not specify this parameter when dumping to the default Backup Server. Specify this parameter only when dumping over the network to a remote Backup Server. You can specify as many as 32 remote Backup Servers with this option. When dumping across the network, specify the network name of a remote Backup Server running on the machine to which the dump device is attached. For platforms that use interfaces files, the backup_server_name must appear in the interfaces file.
density = density_value
overrides the default density for a tape device. Valid densities are 800, 1600, 6250, 6666, 10000, and 38000. Not all values are valid for every tape drive; use the correct density for your tape drive.
blocksize = number_bytes
overrides the default block size for a dump device. The block size must be at least one database page (2048 bytes for most systems) and must be an exact multiple of the database page size. For optimal performance, specify the blocksize as a power of 2, for example, 65536, 131072, or 262144.
capacity = number_kilobytes
is the maximum amount of data that the device can write to a single tape volume. The capacity must be at least five database pages and should be less than the recommended capacity for your device.
A general rule for calculating capacity is to use 70 percent of the manufacturer’s maximum capacity for the device, allowing 30 percent for overhead such as record gaps and tape marks. The maximum capacity is the capacity of the device on the drive, not the drive itself. This rule works in most cases, but may not work in all cases due to differences in overhead across vendors and across devices.
On UNIX platforms that cannot reliably detect the end-of-tape marker, indicate how many kilobytes can be dumped to the tape. You must supply a capacity for dump devices specified as a physical path name. If a dump device is specified as a logical device name, the Backup Server uses the size parameter stored in the sysdevices system table unless you specify a capacity.
compression = compress_level
is a number between 1 and 9, with 9 providing the highest level of compression. There is no default compression level; if you do not specify compression = compress_level, Adaptive Server does not compress the dump.
NoteSybase recommends the native "compression = compress_level" option as preferred over the older "compress::compression_level" option. The native option allows compression of both local and remote dumps, and the dumps that it creates will describe their own compression level during a load. The older option is retained for compatibility with older applications.
dumpvolume = volume_name
establishes the name that is assigned to the volume. The maximum length of volume_name is 6 characters. Backup Server writes the volume_name in the ANSI tape label when overwriting an existing dump, dumping to a new tape, or dumping to a tape whose contents are not recognizable. The load database command checks the label and generates an error message if the wrong volume is loaded.
WARNING!  Label each tape volume as you create it so that the operator can load the correct tape.
with verify[ = header | full]
allows the backupserver to perform a minimal header or structural row check on the data pages as they are being copied to the archives. There are no structural checks done at this time to gam, oam, allocation pages, indexes, text, or log pages. The only other check is done on pages where the page number matches to the page header.
stripe on stripe_device
is an additional dump device. You can use as many as 32 devices, including the device named in the to stripe_device clause. The Backup Server splits the database into approximately equal portions, and sends each portion to a different device. Dumps are made concurrently on all devices, reducing the time required to make a dump and requiring fewer volume changes during the dump. See “Specifying dump devices” for information about how to specify a dump device.
dismount | nodismount
on platforms that support logical dismount, determines whether tapes remain mounted. By default, all tapes used for a dump are dismounted when the dump completes. Use nodismount to keep tapes available for additional dumps or loads.
nounload | unload
determines whether tapes rewind after the dump completes. By default, tapes do not rewind, allowing you to make additional dumps to the same tape volume. Specify unload for the last dump file to be added to a multidump volume. This rewinds and unloads the tape when the dump completes.
passwd = password
is the password you provide to protect the dump file from unauthorized users. The password must be between 6 and 30 characters long.
retaindays = number_days
on UNIX systems – when dumping to disk, specifies the number of days that Backup Server protects you from overwriting the dump. If you try to overwrite the dump before it expires, Backup Server requests confirmation before overwriting the unexpired volume.
NoteThis option is meaningful only when dumping to a disk. It is not meaningful for tape dumps.
The number_days must be a positive integer or 0, for dumps that you can overwrite immediately. If you do not specify a retaindays value, Backup Server uses the tape retention in days value set by sp_configure.
noinit | init
determines whether to append the dump to existing dump files or reinitialize (overwrite) the tape volume. By default, Adaptive Server appends dumps following the last end-of-tape mark, allowing you to dump additional databases to the same volume. New dumps can be appended only to the last volume of a multivolume dump. Use init for the first database you dump to a tape to overwrite its contents.
Use init when you want Backup Server to store or update tape device characteristics in the tape configuration file. For more information, see the System Administration Guide.
file = file_name
is the name of the dump file. The name cannot exceed 17 characters and must conform to operating system conventions for file names. For more information, see “Dump files”.
notify = {client | operator_console}
overrides the default message destination.
On operating systems that offer an operator terminal feature, volume change messages are always sent to the operator terminal on the machine on which Backup Server is running. Use client to route other Backup Server messages to the terminal session that initiated the dump database.
On operating systems that do not offer an operator terminal feature, such as UNIX, messages are sent to the client that initiated the dump database. Use operator_console to route messages to the terminal on which Backup Server is running.

Examples

Example 1

Dumps the database pubs2 to a tape device. If the tape has an ANSI tape label, this command appends this dump to the files already on the tape, since the init option is not specified:
dump database pubs2 
    to "/dev/nrmt0"

Example 2

For UNIX – dumps the pubs2 database, using the REMOTE_BKP_SERVER Backup Server. The command names three dump devices, so the Backup Server dumps approximately one-third of the database to each device. This command appends the dump to existing files on the tapes. On UNIX systems, the retaindays option specifies that the tapes cannot be overwritten for 14 days:
dump database pubs2
    to "/dev/rmt4" at REMOTE_BKP_SERVER
    stripe on "/dev/nrmt5" at REMOTE_BKP_SERVER
    stripe on "/dev/nrmt0" at REMOTE_BKP_SERVER
with retaindays = 14

Example 3

The init option initializes the tape volume, overwriting any existing files:
dump database pubs2
    to "/dev/nrmt0"
    with init

Example 4

Rewinds the dump volumes upon completion of the dump:
dump database pubs2
    to "/dev/nrmt0"
    with unload

Example 5

For UNIX – the notify clause sends Backup Server messages requesting volume changes to the client which initiated the dump request, rather than sending them to the default location, the console of the Backup Server machine:
dump database pubs2
    to "/dev/nrmt0"
    with notify = client

Example 6

Creates a compressed dump of the pubs2 database into a local file called dmp090100.dmp using a compression level of 4:
dump database pubs2 to 
    "compress::4::/opt/bin/Sybase/dumps/dmp090100.dmp"
Alternatively, you can create a compressed dump of the pubs2 database into a local file called dmp090100.dmp using a compression level of 4 using compression = compression_level syntax
dump database pubs2 to "/opt/bin/Sybase/dumps/dmp090100.dmp" 
    with compression = 4

Example 7

Dumps the pubs2 database to the remote machine called “remotemachine” and uses a compression level of 4:
dump database pubs2 to "/Syb_backup/mydb.db" at remotemachine 
    with compression = "4"
 
 

src : http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.commands/html/commands/commands68.htm