External procedure with Windows 'Handle' datatype
Hi allI want to create an external procedure that use windows kerne32.dll library and GetFileSize function in the dll.
http://msdn.Microsoft.com/en-us/library/aa364955 (v = vs. 85) .aspx
as you can see in this link, GetFileSize has two parameters, the first is a HANDLE type, how can I assign this parameter? String does not work.
DWORD WINAPI GetFileSize(
__in HANDLE hFile,
__out_opt LPDWORD lpFileSizeHigh
);
Create Or Replace Function GetSize (FileName Varchar2, P_Value in out pls_integer) Return binary_double As
Language C Library Mylib Name "GetFileSize"
parameters (FileName by reference String, P_Value int, return double );
/
Declare
X1 number ;
X2 Pls_Integer;
X Number;
Begin
x2 := 40000000;
X1 := Getsize('C:\b.sql', X2);
X := X1;
dbms_output.put_line('x: ' ||x);
End;
/
I always have the value zero, file exist and that its size is greater than zero.what I am doing wrong?
I don't know why you use kernel32.dll to know the file size. This can be done very easily using UTL_FILE.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> CREATE OR REPLACE FUNCTION utl_filesize(pi_dir_name IN VARCHAR2,
2 pi_file_name IN VARCHAR2)
3 RETURN NUMBER IS
4 file_size NUMBER;
5 blk_size BINARY_INTEGER;
6 fexists BOOLEAN;
7 BEGIN
8 UTL_FILE.fgetattr(pi_dir_name,
9 pi_file_name,
10 fexists,
11 file_size,
12 blk_size);
13 RETURN file_size;
14 END utl_filesize;
15 /
Function created.
SQL> SELECT utl_filesize('SAUBHIK','test2.csv') "Size in Bytes" FROM dual;
Size in Bytes
-------------
61
SQL> SELECT utl_filesize('SAUBHIK','Winter.jpg') "Size in Bytes" FROM dual;
Size in Bytes
-------------
105542
SQL>
Now coming to your actual question.
This is a demo, how to call PL/SQL.* kernel32.dll
By the way, I copied the file C:\WINDOWS\system32 kernel32.dll at C:\oracle\product\10.2.0\db_3\bin
My listener.ora configuration
SID_LIST_LISTENEREXTPROC =
(SID_LIST =
(SID_DESC =
(PROGRAM = extproc)
(ENV = "EXTPROC_DLLS=ONLY:C:\oracle\product\10.2.0\db_3\bin\kernel32.dll")
(SID_NAME = extproc)
(ORACLE_HOME = C:\oracle\product\10.2.0\db_3)
)
)
My tnsnames.ora configuration
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
A quick check.
LSNRCTL> stop LISTENEREXTPROC
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=extproc)))
The command completed successfully
LSNRCTL> start LISTENEREXTPROC
Starting tnslsnr: please wait...
TNSLSNR for 32-bit Windows: Version 10.2.0.3.0 - Production
System parameter file is C:\oracle\product\10.2.0\db_3\network\admin\listener.o
a
Log messages written to C:\oracle\product\10.2.0\db_3\network\log\listenerextpr
c.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\extprocipc
))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=extproc)))
STATUS of the LISTENER
------------------------
Alias LISTENEREXTPROC
Version TNSLSNR for 32-bit Windows: Version 10.2.0.3.0 - Prod
ction
Start Date 21-JAN-2011 17:32:26
Uptime 0 days 0 hr. 0 min. 3 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File C:\oracle\product\10.2.0\db_3\network\admin\listener.
ra
Listener Log File C:\oracle\product\10.2.0\db_3\network\log\listenerext
roc.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\extprocipc)))
Services Summary...
Service "extproc" has 1 instance(s).
Instance "extproc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL> exit
C:\Documents and Settings\Administrator>
C:\>tnsping EXTPROC_CONNECTION_DATA
TNS Ping Utility for 32-bit Windows: Version 10.2.0.3.0 - Production on 21-JAN-2
011 21:53:10
Copyright (c) 1997, 2006, Oracle. All rights reserved.
Used parameter files:
C:\oracle\product\10.2.0\db_3\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)
(KEY = EXTPROC1))) (CONNECT_DATA = (SID = PLSExtProc) (PRESENTATION = RO)))
OK (70 msec)
C:\>
Now, the codes.
SQL> CREATE OR REPLACE LIBRARY kernel32 AS 'C:\oracle\product\10.2.0\db_3\bin\kernel32.dll';
2 /
Library created.
SQL> CREATE OR REPLACE FUNCTION CreateFile (FileName VARCHAR2 --1
2 ,p_DesiredAccess BINARY_INTEGER --2
3 ,p_ShareMode BINARY_INTEGER --3
4 ,p_SecurityAttributes BINARY_INTEGER --4
5 ,p_CreationDisposition BINARY_INTEGER --5
6 ,p_FlagsAndAttributes BINARY_INTEGER --6
7 ,p_TemplateFile BINARY_INTEGER )--7
8 Return BINARY_INTEGER
9 IS EXTERNAL
10 LIBRARY kernel32 Name "CreateFileA"
11 PARAMETERS (FileName STRING
12 ,p_DesiredAccess long
13 ,p_ShareMode long
14 ,p_SecurityAttributes long
15 ,p_CreationDisposition long
16 ,p_FlagsAndAttributes long
17 ,p_TemplateFile long
18 ,return long );
19 /
Function created.
SQL> /* This is for closing the handle after use. */
SQL> CREATE OR REPLACE FUNCTION CloseFile (p_FileHandle BINARY_INTEGER)
2 Return BINARY_INTEGER
3 IS EXTERNAL
4 LIBRARY kernel32 Name "CloseHandle"
5 PARAMETERS (p_FileHandle long, return long);
6 /
Function created.
SQL> /* This is the main function for getting size */
SQL> CREATE OR REPLACE FUNCTION GetSize (p_FileHandle BINARY_INTEGER,
2 p_FileSizeHigh IN OUT BINARY_INTEGER)
3 RETURN BINARY_INTEGER
4 IS EXTERNAL
5 LIBRARY kernel32 NAME "GetFileSize"
6 PARAMETERS (p_FileHandle long, p_FileSizeHigh long, return long );
7 /
Function created.
SQL> set serverout on
SQL> DECLARE
2 v_FileSize BINARY_INTEGER;
3 v_FileSizeHigh PLS_INTEGER;
4 v_FileHandle BINARY_INTEGER;
5 v_filename VARCHAR2(500) :='C:\test2.csv';
6 v_dummy BINARY_INTEGER;
7 BEGIN
8 v_FileSizeHigh := 400000000;
9 v_FileHandle:=CreateFile(v_filename -- File name
10 ,0 -- Type of access required (read/write ect)
11 ,0 -- disable share mode
12 ,0 --no securoty attribute
13 ,3 -- Means Open existing
14 ,128 --080h, File attribute normal.
15 ,0); --7
16 v_FileSize := Getsize(v_FileHandle, v_FileSizeHigh);
17 DBMS_OUTPUT.put_line('File Size in Bytes: ' ||v_FileSize);
18 v_dummy:=CloseFile(v_FileHandle);
19 END;
20 /
File Size in Bytes: 61
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL> DECLARE
2 v_FileSize BINARY_INTEGER;
3 v_FileSizeHigh PLS_INTEGER;
4 v_FileHandle BINARY_INTEGER;
5 v_filename VARCHAR2(500) :='C:\Winter.jpg';
6 v_dummy BINARY_INTEGER;
7 BEGIN
8 v_FileSizeHigh := 400000000;
9 v_FileHandle:=CreateFile(v_filename -- File name
10 ,0 -- Type of access required (read/write ect)
11 ,0 -- disable share mode
12 ,0 --no securoty attribute
13 ,3 -- Means Open existing
14 ,128 --080h, File attribute normal.
15 ,0); --7
16 v_FileSize := Getsize(v_FileHandle, v_FileSizeHigh);
17 DBMS_OUTPUT.put_line('File Size in Bytes: ' ||v_FileSize);
18 v_dummy:=CloseFile(v_FileHandle);
19 END;
20 /
File Size in Bytes: 105542
PL/SQL procedure successfully completed.
SQL>
Audit.
C:\>dir test2.csv
Volume in drive C has no label.
Volume Serial Number is 6806-ABBD
Directory of C:\
12/15/2010 01:35 PM 61 test2.csv
1 File(s) 61 bytes
0 Dir(s) 3,405,336,576 bytes free
C:\>dir Winter.jpg
Volume in drive C has no label.
Volume Serial Number is 6806-ABBD
Directory of C:\
10/11/2010 05:27 PM 105,542 Winter.jpg
1 File(s) 105,542 bytes
0 Dir(s) 3,405,336,576 bytes free
C:\>
Tags: Database
Similar Questions
-
Error: Function of ms - dos invalid when copying on external drive with Windows 7
FUNCTION OF MS BACK INVALID WHEN PLAYBACK EXTERNAL DRIVE WITH WIN 7
Hello
1. you try to save a data of the C drive on an external hard drive using the Windows backup feature?
2 does this problem occur when you try to copy / paste normally?
3. What is the accurate and complete error message?If you try to copy and paste the data manually, then try the fix to resolve the problem: -
Drive external monitor with Windows Media Player 11
Original title: Windows Media Player 11
Can I have Windows Media Player 11 monitor my hard drive external, so I can free up space on my c: drive that is nearly full?
If you have problems with getting to the new watched folders on the drive external hard after you move the files, see the following article that can help:http://support.microsoft.com/kb/925718.
I hope this helps (or is not necessary).
Good luck!
Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.
-
Protect S100 - bad image quality on an external display with Windows 7
I just installed Windows 7 but have lost my projector - external source - FN + F5 functionality
It seems to work, but a bad quality image is on the screen and is then lost less than a secondAre there drivers available for Windows 7, I need or it's another question?
Appreciate any help
Hello
You have installed a display driver on your laptop? I doubt you will find a driver for Windows 7 at the moment, but in most cases, the driver for Vista works on Windows 7 too.
Check it!Do you really need Windows 7 or you installed it? It s not released yet and at the moment, the socket driver is not very good.
Welcome them
-
ACS 4.1 external DB with Windows 2008 AD
I have the following scenario:
-ACS worm 4.1.1.23 on Windows 2003 Standard with Service Pack 2, server domain controller
-The main AD database is running on Windows 2008
Anyone know if I have to move from 4.1.X.Y to 4.2.X.Y to users authenticated on Windows 2008 AD database?
Or I only need the 4.2 update when GBA is installed on a Windows 2008 Server?
Thanks in advance.
Oscar Perez
Yes, again, you need to upgrade ACS
Kind regards
~ JG
Note the useful messages
-
Aspire V5 cannot find the external monitor with Windows 10
Before the upgrade of Win10, loation monitor was automatically detected
Now I can not find extenral monitor
Should what drivers I download?
Intel VGA drivers.
-
I need a driver for a Maxtor 3200 external hard drive compatible with windows 7
I need a driver for a Maxtor 3200 external hard drive compatible with windows 7
I just got a chat session with a Seagate tech (formerly Maxtor). He said that the Maxtor 3200 s/n I made in 2006 don't is NOT supported by Win7 and never will be. I just bought the year last from Radio Shack for about $80,00. If anyone has any ideas, I'm open to try. I read a blog by which this guy has followed this procedure and it worked, said: let HD; Start Win7; Turn on HD; restart the pc (NOT reboot). Who has not worked for me.
-
Hi all
After you perform a clean installation of Windows Professional 8.1 on my Pavilion G6 1006sh I can't use my external Samsung monitor connected to the HDMI port.
The windows installation is well unrolled without all the problems of the operating system had builtin readers for all devices. So there is no unknown hardware in Device Manager there is no sound, wifi, LAN, etc. In regards to the video card, I see two different devices. There is a generic VGA in Windows and there is an AMD Radeon HD 7400 installed M. The AMD Catalyst software has been installed successfully. In the graphic properties of windows that I can choose from two different outputs video, one is the general Windows VGA is the Radeon. However, windows detects monitor connected only on VGA General (i.e. integrated laptop display) and nothing on the Radeon so I can't use my external monitor.
Of course, I tried to restart the laptop / monitor repeatedly, unplug / plug the HDMI cable but without success. When I plug the HDMI cable into the laptop the screen displays a message that it is connected, but there is no input signal. The HDMI port on monitor and works in the laptop I used the same setup with Windows 7 x 64 Professional without any problem. It is only the operating system that has changed.
I tried to remove the General VGA device to force using Radeon, but after restarting it that nothing posted on the screen, I saw nothing on built-in or external monitor so I had to restore a previously saved system configuration.
I tired to install the latest version of the graphics driver Radeon downloaded from the website of AMD, but crashed and restarted during the installation process of Windows.
Please help me with this question or make a statement that this version of Windows is not supported on this machine and I must therefore go back to the old system.
Configuration:
model: HP Pavilion G6 1006 SH
RAM: 2 x 4 GB
OS: Windows 8.1 Professional x 64 (HUN)
Drivers: installed and automatically updated by windows
Antivirus: Symantec Endpoint Protection 12.1
Thank you
Zoltan
Hi there @nzole
Welcome to the Forums of HP Support! It's a good place to find the help you need, so many other users, the HP experts and other members of the support staff.
I understand that you have installed Windows 8.1 on your system, but now you can not detect an external HDMI monitor. I'm happy to help you with this.
First of all, in response to your question, this model is not supported for windows 8.1. It was sold only in the versions that have been configured for Windows 7. That would mean there is no drivers especially customized by HP for this model for Windows 8.1. It is possible that you could find a suitable drive for a model that Windows 8.1 which can be strong support enough in terms of hardware, that his driver might work, but there is no guarantee.
Here is the support page for your model: HP Pavilion g6-1006sh Notebook PC
Products HP - what happens if I do not see my operating system?
Do you still have the recovery partitions, or you did a set of recovery discs, before installing Windows 8.1?
-
search for a driver external hp555s updatewon can't work with windows 8
Hi, my cd/dvd rewritable external drive does not work with windows 8, is there an upgrade for this writer, had it for a few years, worked very well with win.7 but can be used with win.8, need help! Thanks Gloves54
Hi, my dvd/cd external driver problem has been resolved, I chatted with the Acer support assistants (my laptop with the problem), they gave me a link to the microsoft driver which solved my problem. My external cd/dvd drivers are now recognized by my computer and can be used. Thanks to the honor student for trying to help me with my problem. Happy holidays!
Gloves54
-
What external optical drives are compatible with the Acer Aspire One with Windows 7 Home Premium 722
What external optical drives are compatible with the Acer Aspire One 722 with Windows 7 Home Premium OS. I need to make the backup disks and install the CD software.
Thank you.
More external ODD will work just make sure it's an external power source. This allows not to take a lot of power to the unit.
-
I have a computer with Windows XP and I just bought a computer with Windows7, can I transfer files to the new computer by using an external hard drive? If so, how?
Hi BarbKe
Try to use this tool, it's called Windows easy transfer, I don't know if it works with an external hard drive or if you want to just manually, you can transfer the file using the method of copy paste...
http://Windows.Microsoft.com/en-us/Windows7/products/features/Windows-easy-transfer
Hope this works
-
Hitachi external hard drive does not work on Sony with windows vista
I use a Sony with Windows vista laptop. I just got a 500 GB Hitachi external hard drive today. It was detected after that I connected, but there is no way that I can access the hard drive and save the files it contains. I tried to go to the administration tool and tried to change the letters of readers and paths, but this isn't an option for me (he is gray and I cannot click on it). It showed that the disk is healthy but unallocated. Could someone help me please? I really need to back up my laptop using this hard drive external. Thank you. Irene
Hello Irene,.
· You get the error message?
· Did you do changes on the laptop before the show?
Follow these methods.
Method 1: Run the fixit of the article.
Hardware devices do not work or are not detected in Windows
Method 2: Follow the steps in the article.
Tips for solving problems of USB devices
Method 3: Try to access to the external hard drive on another computer and check if the problem persists.
-
Is there a driver for external hard drive WDME1600 compatible with windows vista?
Original title: My Passport Essential WDME 1600
Is there a driver for external hard drive WDME1600 compatible with windows vista?
Hello
It says here that if you have a 32-bit Vista system, then a free download is necessary for her. Click on the link to the breast and download the necessary files. I hope this will get this drive works for you.
I hope this helps.
-
For a few years, I have been using a set of VPC on external hard drives (.vmc files both .vhd located on external drives) with the Microsoft Virtual PC/Virtual PC Console on a Windows XP computer. They worked perfectly.
However, I just bought a new computer with Windows 7, and I'm unable to access the VPC on the external hard drive. I installed successfully, Windows Virtual PC and Windows XP mode on the computer, and I copied the file to the host machine's .vmc. However, when I try to open the virtual computer, I get a message saying that the VPC was "impossible to write in one of its virtual hard disks.
I've tried everything I can think of, but the only thing that works is to copy the .vmc and .vhd in the computer file. The problem is that I use the VPC for training online, and I have 16 of them. If I copy everything in the computer, I will use all 500 GB of disk space.
There must be a way to access the VPC for external drives. If I can do it on the old XP computer, it should be possible to do it on the new Windows 7 computer.
Help, please.
Thank you!
For any question on Windows 7:
http://social.answers.Microsoft.com/forums/en-us/category/Windows7
Link above is Windows 7 Forum for questions on Windows 7.
Windows 7 questions should be directed to the it.
You are in the Vista Forums.
See you soon.
Mick Murphy - Microsoft partner
-
I have a new computer with windows 7 and I put as an administrator, but whenever I try to save a file to an external hard disk that is identified on my computer I tells me I don't have permission to back up there.
You must enter the property of your external drive - see here:
http://social.answers.Microsoft.com/forums/en-us/w7network/thread/24bdf172-2DBC-43b8-995d-a99b6a81413c/
Maybe you are looking for
-
Photosmart: black and white printing
I have a HP Photosmart 5520. N set the printer to print in black and white that I rarely need to color option?
-
Port replicator / Docking station for smoker Pro 4600
Hi all Anyone would be skillfully to provide me with info on what docking stations / port replicator is available for Satellite Pro 4600? I try to search the product section but for this model, the variety of the replicators has displayed, sometimes
-
Pair magic keyboard or the magic mouse 2 with multiple Macs
We have two El Capitan 10.11.3 running MacBook Air. We have an office for a docking configuration environment / clamshell with an external monitor, a keyboard of magic and Magic Mouse 2. As one of us needs to use this office Installer, anchor us th
-
WINDOWS MEDIA PLAYER 800700E ERROR
OUT OF THE BLUE MY WMP COMES to the TOP WITH a 700800E ERROR AND a MESSAGE"THE MODULE SPECIFIC IS NOT FOUND" WHAT CAN I DO TO SOLVE THIS PROBLEM, I INSTALLED A NEWER VERSION (7-9), WHICH DID NOT HELP
-
Windows Vista fix KB947821 will not install.
So I meet me the error 800b0100 and he said to download via the website, but whenever I open the download to install, it is just that Initializing installation... done!Installing the hotfix for Windows (KB947821) (update 1 of 1)... and the installati