Oracle, Web, Script, SQLserver, Tips & Trick

June 9, 2016

Print using default printer on local computer (Oracle Developer 6i, windows)

Filed under: dev6i,oracle,windows — sikathabis @ 7:29 am
Tags: , , , , ,

this example, I want to show you how to automate print using default printer on local computer.

PROCEDURE GENERATE_VALIDATION (ID1 number, ID2 number, ID3 DATE) IS
    PL_ID PARAMLIST;
    filename varchar2(255);
    teks varchar2(255);
    IN_FILE TEXT_IO.FILE_TYPE;
BEGIN
    pl_id := Create_Parameter_List('TEMP'); 
    ADD_PARAMETER(PL_ID,'ID_1',TEXT_PARAMETER,ID1);
    ADD_PARAMETER(PL_ID,'ID_2',TEXT_PARAMETER,ID2);
    ADD_PARAMETER(PL_ID,'ID_3',TEXT_PARAMETER,ID3);
--this statement for get default printer and generate to text file
    host('CMD /C wmic printer where default=''TRUE'' get name > '||filename,NO_SCREEN);
--because wmic generate 3 lines, this statement for get only line where the 
--default printer located

    host('CMD /C Powershell "Get-Content '||filename||' | Select-Object -Index 1" > '||filename||'.txt', NO_SCREEN );
    begin
        IN_FILE  := TEXT_IO.FOPEN(filename||'.txt', 'r');   
        TEXT_IO.GET_LINE(IN_FILE,TEKS);
        --Trim TEKS, because there is spaces after default printer name
        TEKS := LTRIM(RTRIM(TEKS));
        TEXT_IO.FCLOSE(IN_FILE);
    exception when others then
        TEXT_IO.FCLOSE(IN_FILE);
    end;  

--erase temporary files

    host('CMD /R DEL '||filename||'.*',NO_SCREEN);    

--if there's default printer then automate print default printer on local computer

    if TEKS is null then
         ADD_PARAMETER(PL_ID,'DESTYPE',TEXT_PARAMETER,'PRINTER');
         ADD_PARAMETER(PL_ID,'DESNAME',TEXT_PARAMETER,TEKS);
--if there's no default printer then show your report
    else
         ADD_PARAMETER(PL_ID,'DESTYPE',TEXT_PARAMETER,'SCREEN');
    end if;     
    Add_Parameter(pl_id,'PARAMFORM', TEXT_PARAMETER, 'NO');
    Add_Parameter(pl_id,'PRINTJOB',  TEXT_PARAMETER,'YES'); 

    Run_Product(REPORTS,'VALIDATION', SYNCHRONOUS, RUNTIME,FILESYSTEM, pl_id, NULL);     
    Destroy_Parameter_List(pl_id);
END;

Reference: https://technet.microsoft.com/en-us/library/hh849895.aspx | https://adamstech.wordpress.com/2010/11/1 | http://stackoverflow.com/questions/17217476..

Notes: For windows XP/2003 you must install powershell, here’s the links:

  1. Microsoft .NET Framework 2.0 Service Pack 1 (x86)
  2. Update for Windows XP (KB968930): includes Windows PowerShell 2.0 and Windows Remote Management (WinRM) 2.0
  3. Update for Windows 2003

 

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Teknologi Pendidikan

Just another WordPress.com weblog

KATAKAMI

Jurnalisme Yang Dapat Dipercaya

Tonk Kosonk Baonk Bunyinya

Penampungan Serapah Tanpa Sumpah

Qey050489's Blog

Ayo Bangkit sobat..!!!!!

B. S. Totoraharjo

Orang Bodoh Yang Tak Kunjung Pandai

culturekitchen foodlab

New Food and Art in Yogyakarta

Wahyu Catur Wibowo

Musafir Dunia Maya

SQL.... Still Learning

My Reference on SQL Server

neinframe

Street Photography is like a box of a chocolates, you're never know what you're gonna get - Thomas Leuthard -

Keluarga Andrivito

-- Andrivito's Journal --

DRK™

This site is about Latest NEWS, Articles, Videos, Books, Course, Presentations, Tips & Tricks related to I.T Pro's

Gaurav Saxena

|| तत् त्वम् असि ||

Be a good Moeslim

Menuju Pribadi Muslim Sejati yang Bertaqwa

TuanSUFI

Manajemen Sholat, renungan spiritual, Teknologi Informasi

Pelangi di khatulistiwa....

Mari berbagi kebaikan, pengalaman dan senyum denganku

angkasa13

Ceritanya saya, Pikirannya saya, Hatinya saya

sikathabis

sikathabis semua informasi disini

%d bloggers like this: