How 2 login in 10g on ubuntu at sql prompt
conn system/umarERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
means did i install successfully? please tel me somebody?
This should help:
Installation on Ubuntu 10.04, Lucid Lynx
Note: this is what I have in my envOraXEclient (you can name it anything you want) under the oracle account of Ubuntu:
export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
export TNS_ADMIN=$ORACLE_HOME/network/admin
export TWO_TASK=XE
export LD_LIBRARY_PATH=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib
export PATH=$ORACLE_HOME/bin:${PATH}
R/ Zaf
Similar Messages
-
How to connect access database through oracle sql prompt
i want to connect access database via oracle , i am trying to import all the data in Access table into oracle table how it is possible .
A.RThe simplest way, if You have already created tables in Oracle DB, is to open the Access MDB, link Oracle tables via ODBC and build a query to append rows reading from Access tables to Oracle tables.
Hope this helps
Max -
How to pass a structure in PL/SQL external proc.
This is for educational purpose only. I am trying to implement kernel32.dll and shell32.dll in PL/SQL using external proc. Everything is working fine, except When there is a structure in OUT parameter.
My database version.
SQL> SELECT * FROM v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - ProductionI have set up the listner.ora and tnsnames.ora and written a package called dbms_kernel32sb.
There are 9 program units.
1. CreateFile -- working fine
2. CloseFile -- working fine
3. GetSize -- working fine
4. FindFirstFile -- NOT working, because one OUT parameter has the structure type WIN32_FIND_DATA.
5. GetFileTime -- NOT working, because one OUT parameter has the structure type FILETIME
6. GetDiskFreeSpace -- working fine
7. GetDriveType -- working fine.
8. GetLastError -- working fine
9. ExecuteCommand -- working fine.
Here is the package specification:
CREATE OR REPLACE PACKAGE dbms_kernel32sb AS
Name: dbms_kernel32sb.pks
Author: Saubhik Banerjee
Date: 24th Jan 2011
Version: 1.0
Comment: This package is to implement some functionality from kernel32.dll.
Usng extproc
OPEN_EXISTING_FILE CONSTANT PLS_INTEGER :=3;
FILE_ATTRIBUTE_NORMAL CONSTANT PLS_INTEGER :=128;
DISABLE_FILE_SHARE_MODE CONSTANT PLS_INTEGER :=0;
NO_FILE_SECURITY_ATTRIBUTE CONSTANT PLS_INTEGER :=0;
NO_TEMPLATE_FILE CONSTANT PLS_INTEGER :=0;
GENERIC_FILE_ACCESS CONSTANT PLS_INTEGER :=0;
FILE_SIZE_HIGH CONSTANT PLS_INTEGER :=400000000;
EXECUTE_FILE CONSTANT VARCHAR2(4):='open';
PRINT_FILE CONSTANT VARCHAR2(5):='print';
NO_PARAMATER CONSTANT VARCHAR2(2):=' ';
FUNCTION CreateFile(pi_FileName VARCHAR2 --1, File name
,pi_DesiredAccess BINARY_INTEGER --2, Type of access required (read/write ect)
,pi_ShareMode BINARY_INTEGER --3, share mode
,pi_SecurityAttributes BINARY_INTEGER --4, securoty attribute
,pi_CreationDisposition BINARY_INTEGER --5, open existing, create new etc
,pi_FlagsAndAttributes BINARY_INTEGER --6, File attribute- normal
,pi_TemplateFile BINARY_INTEGER) --Not required.
Return BINARY_INTEGER;
FUNCTION CloseFile (pi_FileHandle BINARY_INTEGER)
Return BINARY_INTEGER;
FUNCTION GetSize (pi_FileHandle BINARY_INTEGER,
pio_FileSizeHigh IN OUT BINARY_INTEGER)
RETURN BINARY_INTEGER;
FUNCTION FindFirstFile ( pi_FileName VARCHAR2
,pio_Win32_Find_data OUT
WIN32_FIND_DATA
RETURN BINARY_INTEGER;
FUNCTION GetFileTime ( pi_FileHandle BINARY_INTEGER
,pio_FileCreationTime IN OUT FILETIME
,pio_LastAccessTime IN OUT FILETIME
,pio_LastWriteTime IN OUT FILETIME
RETURN BINARY_INTEGER;
FUNCTION GetDiskFreeSpace ( pi_RootPathName VARCHAR2
,pio_SectorsPerCluster OUT BINARY_INTEGER
,pio_BytesPerSector OUT BINARY_INTEGER
,pio_NumberOfFreeClusters OUT BINARY_INTEGER
,pio_TotalNumberOfClusters OUT BINARY_INTEGER
RETURN BINARY_INTEGER;
FUNCTION GetDriveType( pi_driveLetter VARCHAR2) RETURN VARCHAR2;
FUNCTION GetLastError RETURN BINARY_INTEGER;
FUNCTION ExecuteCommand ( pi_OperationType VARCHAR2
,pi_FileName VARCHAR2
,pi_Parameters VARCHAR2
,pi_DefaultDirectory VARCHAR2
RETURN VARCHAR2;
END dbms_kernel32sb;
Here is the package body:
CREATE OR REPLACE PACKAGE BODY dbms_kernel32sb AS
/* Name: dbms_kernel32sb.pkb
Author: Saubhik Banerjee
Date: 24th Jan 2011
Version: 1.0
Comment: This package is to implement some functionality from kernel32.dll.
Usng extproc
FUNCTION
CreateFile( pi_FileName VARCHAR2 --1
, pi_DesiredAccess BINARY_INTEGER --2
, pi_ShareMode BINARY_INTEGER --3
, pi_SecurityAttributes BINARY_INTEGER --4
, pi_CreationDisposition BINARY_INTEGER --5
, pi_FlagsAndAttributes BINARY_INTEGER --6
, pi_TemplateFile BINARY_INTEGER) --7
Return BINARY_INTEGER IS EXTERNAL LIBRARY kernel32 Name "CreateFileA"
PARAMETERS( pi_FileName STRING
, pi_DesiredAccess long
, pi_ShareMode long
, pi_SecurityAttributes long
, pi_CreationDisposition long
, pi_FlagsAndAttributes long
, pi_TemplateFile long
, return long);
FUNCTION CloseFile (pi_FileHandle BINARY_INTEGER)
Return BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 Name "CloseHandle"
PARAMETERS (pi_FileHandle long, return long);
FUNCTION GetSize (pi_FileHandle BINARY_INTEGER,
pio_FileSizeHigh IN OUT BINARY_INTEGER)
RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 NAME "GetFileSize"
PARAMETERS (pi_FileHandle long, pio_FileSizeHigh long, return long );
FUNCTION GetFileTime ( pi_FileHandle BINARY_INTEGER
,pio_FileCreationTime IN OUT FILETIME
,pio_LastAccessTime IN OUT FILETIME
,pio_LastWriteTime IN OUT FILETIME
RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 NAME "GetFileTime"
WITH CONTEXT
PARAMETERS ( CONTEXT,
pi_FileHandle long
, pio_FileCreationTime OCIColl
, pio_FileCreationTime INDICATOR SHORT
, pio_LastAccessTime OCIColl
, pio_LastAccessTime INDICATOR SHORT
, pio_LastWriteTime OCIColl
, pio_LastWriteTime INDICATOR SHORT
, return long );
FUNCTION FindFirstFile ( pi_FileName VARCHAR2
,pio_Win32_Find_data OUT
WIN32_FIND_DATA
RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 NAME "FindFirstFileA"
--WITH CONTEXT
PARAMETERS
( --CONTEXT,
pi_FileName STRING--, pi_FileName INDICATOR SHORT
, pio_Win32_Find_data BY REFERENCE OCIColl--,pio_Win32_Find_data INDICATOR long
, return long );
FUNCTION GetDiskFreeSpace ( pi_RootPathName VARCHAR2
,pio_SectorsPerCluster OUT BINARY_INTEGER
,pio_BytesPerSector OUT BINARY_INTEGER
,pio_NumberOfFreeClusters OUT BINARY_INTEGER
,pio_TotalNumberOfClusters OUT BINARY_INTEGER
RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 NAME "GetDiskFreeSpaceA"
PARAMETERS ( pi_RootPathName STRING
, pio_SectorsPerCluster BY REFERENCE long
, pio_BytesPerSector BY REFERENCE long
, pio_NumberOfFreeClusters BY REFERENCE long
, pio_TotalNumberOfClusters BY REFERENCE long
, return long );
FUNCTION GetDriveTypeA( pi_driveLetter VARCHAR2) RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 NAME "GetDriveTypeA"
PARAMETERS (pi_driveLetter STRING, RETURN long);
FUNCTION GetDriveType( pi_driveLetter VARCHAR2) RETURN VARCHAR2 IS
BEGIN
CASE GetDriveTypeA(pi_driveLetter)
WHEN 2 THEN RETURN 'Removable';
WHEN 3 THEN RETURN 'Drive Fixed';
WHEN 4 THEN RETURN 'Remote';
WHEN 5 THEN RETURN 'Cd-Rom';
WHEN 6 THEN RETURN 'Ram disk';
ELSE RETURN 'Unrecognized';
END CASE;
END;
FUNCTION GetLastError RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY kernel32 NAME "GetLastError"
PARAMETERS (return long);
FUNCTION ShellExecute( pi_Hwnd BINARY_INTEGER
,pi_Operation VARCHAR2
,pi_FileName VARCHAR2
,pi_Parameters VARCHAR2
,pi_DefaultDirectory VARCHAR2
,pi_ShowCmd BINARY_INTEGER
) RETURN BINARY_INTEGER
IS EXTERNAL
LIBRARY SHELL32 NAME "ShellExecuteA"
PARAMETERS (pi_Hwnd long,pi_Operation STRING,pi_FileName STRING
,pi_Parameters STRING,pi_DefaultDirectory STRING
,pi_ShowCmd long, return long
FUNCTION ExecuteCommand ( pi_OperationType VARCHAR2
,pi_FileName VARCHAR2
,pi_Parameters VARCHAR2
,pi_DefaultDirectory VARCHAR2
RETURN VARCHAR2 IS
v_return_val BINARY_INTEGER;
BEGIN
v_return_val:= ShellExecute(0,pi_OperationType
,pi_FileName,pi_Parameters
,pi_DefaultDirectory,0
IF v_return_val <=32 THEN
RETURN 'Error!';
ELSE RETURN 'Success!';
END IF;
END;
END dbms_kernel32sb;
Now the working demos:
SQL> SET SERVEROUT ON
SQL> /* Demo I:- How to obtain file size */
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 := DBMS_KERNEL32SB.FILE_SIZE_HIGH;
9 v_FileHandle:=DBMS_KERNEL32SB.CreateFile(v_filename -- File name
10 ,DBMS_KERNEL32SB.GENERIC_FILE_ACCESS
11 ,DBMS_KERNEL32SB.DISABLE_FILE_SHARE_MODE
12 ,DBMS_KERNEL32SB.NO_FILE_SECURITY_ATTRIBUT
13 ,DBMS_KERNEL32SB.OPEN_EXISTING_FILE
14 ,DBMS_KERNEL32SB.FILE_ATTRIBUTE_NORMAL
15 ,DBMS_KERNEL32SB.NO_TEMPLATE_FILE);
16 v_FileSize := DBMS_KERNEL32SB.Getsize(v_FileHandle, v_FileSizeHigh)
17 DBMS_OUTPUT.put_line('File Size in Bytes: ' ||v_FileSize);
18 v_dummy:=DBMS_KERNEL32SB.CloseFile(v_FileHandle);
19 END;
20 /
File Size in Bytes: 61
PL/SQL procedure successfully completed.
SQL>
SQL> /* Demo II:- How to find free disk space */
SQL> DECLARE
2 v_rootpath VARCHAR2(500) :='C:\';
3 v_dummy BINARY_INTEGER;
4 v_sectorspercluster BINARY_INTEGER;
5 v_bytespersector BINARY_INTEGER;
6 v_numberoffreeclusters BINARY_INTEGER;
7 v_totalnumberofclusters BINARY_INTEGER;
8 v_freespace NUMBER;
9 v_totalspace NUMBER;
10 BEGIN
11 v_dummy:=DBMS_KERNEL32SB.GetDiskFreeSpace(v_rootpath
12 ,v_sectorspercluster
13 ,v_bytespersector
14 ,v_numberoffreeclusters
15 ,v_totalnumberofclusters
16 );
17
18 DBMS_OUTPUT.put_line('Sector pre Cluster: ' ||v_sectorspercluster);
19 DBMS_OUTPUT.put_line('Bytes per sector: ' ||v_bytespersector);
20 DBMS_OUTPUT.put_line('Number Of Free Clusters: ' ||v_numberoffreeclusters);
21 DBMS_OUTPUT.put_line('Total Number Of Clusters: ' ||v_totalnumberofclusters);
22 v_freespace:=v_numberoffreeclusters/1024/1024/1024;
23 v_freespace:=ROUND(v_freespace*v_sectorspercluster*v_bytespersector,3);
24 v_totalspace:=v_totalnumberofclusters/1024/1024/1024;
25 v_totalspace:=ROUND(v_totalspace*v_sectorspercluster*v_bytespersector,3);
26 DBMS_OUTPUT.put_line('Total Space (GB):' ||v_totalspace);
27 DBMS_OUTPUT.put_line('Total number of Free space (GB): '||v_freespace );
28 END;
29 /
Sector pre Cluster: 8
Bytes per sector: 512
Number Of Free Clusters: 739477
Total Number Of Clusters: 9765622
Total Space (GB):37.253
Total number of Free space (GB): 2.821
PL/SQL procedure successfully completed.
SQL>
SQL> /* Demo IV:- How to get drive type*/
SQL> SELECT dbms_kernel32sb.GetDriveType('C:\') FROM dual;
DBMS_KERNEL32SB.GETDRIVETYPE('C:\')
Drive Fixed
SQL> SELECT dbms_kernel32sb.GetDriveType('D:\') FROM dual;
DBMS_KERNEL32SB.GETDRIVETYPE('D:\')
Cd-Rom
SQL> SELECT dbms_kernel32sb.GetDriveType('E:\') FROM dual;
DBMS_KERNEL32SB.GETDRIVETYPE('E:\')
Unrecognized
SQL>
SQL> /* Demo V:- How to execute an Operating System Command*/
SQL> DECLARE
2 v_FileToExecute VARCHAR2(20):='test.bat';
3 v_Parameter VARCHAR2(20):='test1.csv';--dbms_kernel32sb.NO_PARAMATER
4 v_DefaultDirectory VARCHAR2(20):='C:\';
5 v_ReturnValue VARCHAR2(20);
6 BEGIN
7 v_ReturnValue:=dbms_kernel32sb.ExecuteCommand(dbms_kernel32sb.EXECUTE_FILE
8 ,v_FileToExecute
9 ,v_Parameter
10 ,v_DefaultDirectory
11 );
12 DBMS_OUTPUT.put_line('Status: '||v_ReturnValue);
13 END;
14 /
Status: Success!
PL/SQL procedure successfully completed.
SQL> Now the sub programs with structures are NOT getting called successfully.
SQL> /* Demo III:- How to obtain file time */
SQL> DECLARE
2 v_FileHandle BINARY_INTEGER;
3 v_filename VARCHAR2(500) :='C:\test2.csv';
4 v_dummy BINARY_INTEGER;
5 v_filecreationtime FILETIME;
6 v_lastaccesstime FILETIME;
7 v_lastwritetime FILETIME;
8 v_err BINARY_INTEGER;
9 BEGIN
10 v_FileHandle:=DBMS_KERNEL32SB.CreateFile(v_filename -- File name
11 ,DBMS_KERNEL32SB.GENERIC_FILE_ACCESS
12 ,DBMS_KERNEL32SB.DISABLE_FILE_SHARE_MODE
13 ,DBMS_KERNEL32SB.NO_FILE_SECURITY_ATTRIBUTE
14 ,DBMS_KERNEL32SB.OPEN_EXISTING_FILE
15 ,DBMS_KERNEL32SB.FILE_ATTRIBUTE_NORMAL
16 ,DBMS_KERNEL32SB.NO_TEMPLATE_FILE);
17 v_dummy := DBMS_KERNEL32SB.GetFileTime( v_FileHandle
18 ,v_filecreationtime
19 ,v_lastaccesstime
20 ,v_lastwritetime
21 );
22 v_err:=DBMS_KERNEL32SB.GetLastError;
23 DBMS_OUTPUT.put_line('File Size in Bytes: ' ||v_dummy);
24 DBMS_OUTPUT.put_line('Error:'||v_err);
25 v_dummy:=DBMS_KERNEL32SB.CloseFile(v_FileHandle);
26 END;
27 /
File Size in Bytes: 0
Error:203
PL/SQL procedure successfully completed.
SQL> So, I have noticed that, Where ever a STRUCTURE is involved in external routine, there is a problem. I want to know, How to implement functions with STRUCTURE as OUT parameter.
Forgot to mention: This is my FILETIME object which corresponds to FILETIME structure of win32.
CREATE OR REPLACE TYPE FILETIME_rec IS OBJECT
( LowDateTime NUMBER
,HighDateTime NUMBER
CREATE OR REPLACE TYPE FILETIME IS TABLE OF FILETIME_rec;Edited by: Saubhik on Feb 1, 2011 4:15 PMSaubhik wrote:
This is for educational purpose only. I am trying to implement kernel32.dll and shell32.dll in PL/SQL using external proc. Interesting. Familiar with the Wn32 API, but do not run Oracle on Windows and never looked at this aspect of integration.
So, I have noticed that, Where ever a STRUCTURE is involved in external routine, there is a problem. I want to know, How to implement functions with STRUCTURE as OUT parameter.
Forgot to mention: This is my FILETIME object which corresponds to FILETIME structure of win32.The problem is that this passes the parameter by reference and not value. In a vanilla C/C++/Delphi program, you will create a variable of that struct and then pass a long pointer to that variable when making the API call. That pointer will be dereferenced and the memory it points to, populated. This is not a problem as the underlying DLL you call that does this, uses your process's data segment.
Extproc is different. In order to protect the integrity of the database server process, an external call is done by a "proxy" process. It acts as the interface between your PL/SQL code and the actual external call.
In this case, this "proxy" process will be doing the implicit LoadLibrary() call to load kernel32.dll interface - and the DLL will expect to dereference and access this process's memory struct to populate it. This "proxy" process in turn needs to know that despite it calling the interface by reference, it needs to return that parameter to PL/SQL by value - as your PL/SQL code cannot dereference a pointer passed back by that "proxy" process and access its memory to gain access to that struct.
In basic terms - that argument is a 32 bit number containing a pointer. That is what the "proxy" process needs to pass to the interface call. Your code is passing a struct and not a pointer, right?
And that is the basic problem I believe. How to address this.. not sure. You can have your own DLL as interface that does not use pointers but expect arguments to be passed by value. But this will suck as you then need to include a custom DLL to deploy and have PL/SQL call that, instead of simply accessing and calling the native kernel interface.
Doubt that many Win32 programmers with OCI (Oracle Call Interface) frequents this forum. So perhaps this is not the best place to ask. I would be hitting Metalink (support.oracle.com) search function in your sho3s though as there should be support notes dealing with this subject matter. -
How to create user defined metrics for SQL Server target?
The customer is not able to create a user defined metrics for SQL Server target.
This is very important for him to use this product.
He is asking how to create user defined metrics?
I sent him Note 304952.1 How to Create a User-Defined SQL Metric in EM 10g Grid Control
But it would work for an Oracle DB, but his target is SQL Server DB
Not able to find the "User-Defined Metrics" link from Database home page.
How to create user defined metrics for SQL Server target?http://download-uk.oracle.com/docs/cd/B14099_19/manage.1012/b16241/Monitoring.htm
-
Hi All,
As i m trying to connect to the database in the Oracle 10g in ubuntu i am getting the following error
I did
SQL> connect
Enter user-name: scott
Enter password: tiger
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
Please help
NehaHi Rahul,
If i am trying to connect to database, in "oracle database 10g Express Edition" if i am clicking on start database then i am getting a warning as "Operation failed. neha is not a member of 'dba' group.
and if i am trying to "Go To Database Home Page " then its taking me to url http://127.0.0.1/apex whic says:-
Unable to connect
Firefox can't establish a connection to the server at 127.0.0.1.
* The site could be temporarily unavailable or too busy. Try again in a few
moments.
* If you are unable to load any pages, check your computer's network
connection.
* If your computer or network is protected by a firewall or proxy, make sure
that Firefox is permitted to access the Web. -
How to get Listener Information using PL/SQL code
How to get Listener Information using PL/SQL code
user2075318 wrote:
How to get Listener Information using PL/SQL codeThis approach (somewhat of a hack) can be used - but it does not really provide meaningful data at application layer.
SQL> create or replace function TnsPing( ipAddress varchar2, port number default 1521 ) return varchar2 is
2 type THexArray is table of varchar2(2);
3 --// tnsping packet (should be 10g and 11g listener compatible)
4 TNS_PING_PACKET constant THexArray := new THexArray(
5 '00', '57', '00', '00', '01', '00', '00', '00',
6 '01', '39', '01', '2C', '00', '00', '08', '00',
7 '7F', 'FF', '7F', '08', '00', '00', '01', '00',
8 '00', '1D', '00', '3A', '00', '00', '00', '00',
9 '00', '00', '00', '00', '00', '00', '00', '00',
10 '00', '00', '00', '00', '00', '00', '00', '00',
11 '00', '00', '00', '00', '00', '00', '00', '00',
12 '00', '00', '28', '43', '4F', '4E', '4E', '45',
13 '43', '54', '5F', '44', '41', '54', '41', '3D',
14 '28', '43', '4F', '4D', '4D', '41', '4E', '44',
15 '3D', '70', '69', '6E', '67', '29', '29'
16 );
17
18 socket UTL_TCP.connection;
19 txBytes number;
20 rxBytes number;
21 rawBuf raw(1024);
22 resp varchar2(1024);
23 begin
24 socket := UTL_TCP.open_connection(
25 remote_host => ipAddress,
26 remote_port => port,
27 tx_timeout => 10
28 );
29
30 --// convert hex array into a raw buffer
31 for i in 1..TNS_PING_PACKET.Count loop
32 rawBuf := rawBuf || HexToRaw( TNS_PING_PACKET(i) );
33 end loop;
34
35 --// send packet
36 txBytes := UTL_TCP.write_raw( socket, rawBuf, TNS_PING_PACKET.Count );
37
38 --// read response
39 rxBytes := UTL_TCP.read_raw( socket, rawBuf, 1024 );
40
41 UTL_TCP.close_connection( socket );
42
43 --// convert response to varchar2
44 resp := UTL_RAW.Cast_To_Varchar2( rawBuf );
45
46 --// strip the header from the response and return the text only
47 return( substr(resp,13) );
48 end;
49 /
Function created.
SQL>
SQL> select tnsping( '10.251.93.30' ) as TNSPING from dual;
TNSPING
(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=0)(ALIAS=LISTENER))
SQL> select tnsping( '10.251.95.69' ) as TNSPING from dual;
TNSPING
(DESCRIPTION=(TMP=)(VSNNUM=0)(ERR=0)(ALIAS=LISTENER))
SQL> -
How to send/receive e-mails with sql or pl/sql
Hello,
I must send and receive e-mail (something like e-mail client) done with oracle database and oracle forms.
How can I receive e-mails with SQL? Is there any way?
I read threads about using utl_smtp but i could not send an e-mail. May be I need to use servers without password?
Best regards
P.S. I'm using Forms 10g R2 and database 9iHi,
try below code.
change mailhost ip to u r mail server ip.
CREATE or REPLACE PROCEDURE SimpleTextMessage IS
mailHOST VARCHAR2(64) := '192.168.0.21';
mailFROM VARCHAR2(64);
mailTO VARCHAR2(64);
mailCONN utl_smtp.connection;
mailDATE VARCHAR2(20);
vreply utl_smtp.reply;
vreplies utl_smtp.replies;
i number;
BEGIN
mailFROM := '[email protected]';
mailTO := '[email protected]';
SELECT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS') INTO mailDATE FROM dual;
vreply := utl_smtp.open_connection(mailHOST, 25, mailCONN);
vreplies := utl_smtp.help(mailCONN, 'HELP');
for i in 1..vreplies.count loop
dbms_output.put_line( 'text = ' || vreplies(i).text );
end loop;
vreplies := utl_smtp.ehlo(mailCONN, mailHOST);
for i in 1..vreplies.count loop
dbms_output.put_line( 'text = ' || vreplies(i).text );
end loop;
vreply := utl_smtp.mail(mailCONN, mailFROM);
vreply := utl_smtp.rcpt(mailCONN, mailTO);
vreply := utl_smtp.open_data(mailCONN);
utl_smtp.write_data(mailCONN, 'Subject: '|| 'Hi' || chr(13));
utl_smtp.write_data(mailCONN, 'From: '||mailFROM || chr(13));
utl_smtp.write_data(mailCONN, 'Date: '||mailDATE || chr(13));
utl_smtp.write_data(mailCONN, 'To: '||mailTO || chr(13));
utl_smtp.write_data(mailCONN, 'CC: '||mailFROM || chr(13));
utl_smtp.write_data(mailCONN, chr(13));
utl_smtp.write_data(mailCONN, 'Hello Friend how r u.' || chr(13));
vreply := utl_smtp.close_data(mailCONN);
END;
/ -
How to run @?/rdbms/admin/utlrp.sql from OEM?
After I make database changes I have to run utlrp.sql to compile all the invalid objects. I know how to do it from the host. But now I'm running this release from the OEM as sql jobs.
Is there any equivalent of @?/rdbms/sadmin/utlrp.sql running from OEM?
error msg:
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
utl_recomp.recomp_parallel(threads);
ERROR at line 4:
ORA-06550: line 4, column 4:
PLS-00201: identifier 'UTL_RECOMP.RECOMP_PARALLEL' must be declared
ORA-06550: line 4, column 4:
PL/SQL: Statement ignored
Elapsed: 00:00:00.01
SELECT dbms_registry_sys.time_stamp('utlrp_end') as timestamp from dual
ERROR at line 1:
ORA-00904: "DBMS_REGISTRY_SYS"."TIME_STAMP": invalid identifier
Elapsed: 00:00:00.00
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01
DOC> The following query reports the number of objects that have compiled
DOC> with errors (objects that compile with errors have status set to 3 in
DOC> obj$). If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
select COUNT(*) "OBJECTS WITH ERRORS" from obj$ where status = 3
ERROR at line 1:
ORA-00942: table or view does not existHi,
How can you create job in OEM to use EXEC UTL_RECOMP.recomp_serial(); inorder to compile all db objects.
I tried few things but all resulting in error.
I am creating OEM job as SQL script and where it ask for SQL script I am giving below code:
1.
WHENEVER SQLERROR EXIT FAILURE;
EXEC UTL_RECOMP.recomp_serial;Error:
SQL> SQL> SQL> SQL> SQL> BEGIN utl_recomp.recomp_serial ; END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'UTL_RECOMP.RECOMP_SERIAL' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
2.when trying with using utlrp.sql:
WHENEVER SQLERROR EXIT FAILURE;
@?/rdbms/admin/utlrp.sql;Error:
SQL> SQL> SQL> SQL> SQL> SELECT dbms_registry_sys.time_stamp('utlrp_bgn') as timestamp from dual
ERROR at line 1:
ORA-00904: "DBMS_REGISTRY_SYS"."TIME_STAMP": invalid identifier
I can run utlrp.sql without any error manually from sql prompt as sys user.
I am login into OEM as SYSTEM user and also with user who has privilege for backup.
thanks, -
How to print a something in oracle sql developer
Hello all
Do you know How to print a something in oracle sql developer? i mean for example in the query we write something, (offcourse i dont mean comments)
thank u in advance.
best1003209 wrote:
Hello all
Do you know How to print a something in oracle sql developer? i mean for example in the query we write something, (offcourse i dont mean comments)
thank u in advance.
bestDBMS_OUTPUT() -
Oracle 10g on Ubuntu 8.04
I tried to install Oracle 10g on Ubuntu 8.04 followed the steps on this page http://kdevendr.wordpress.com/2009/01/21/installing-oracle-10g-on-linux-mint-and-ubuntu.
When i type sqlplus “/as sysdba”, it said ORA-12547: TNS : lost contact. When i tried to access http://vic4ever-laptop:5560/isqlplus, it didn't work.
Plz help! Thanks.I've found these two files and what I'm supposed to do ?
These are some errors from the installs...log
INFO: Detecting the IP.....:127.0.1.1
INFO: RunTime Error
INFO: Actual Result: :java.lang.NullPointerException:Exception/Error Occurred
Check complete. The overall result of this check is: Not executed <<<<
INFO: --------------------------------------------------------------------------------
INFO: Prerequisite checks completed : Sat Apr 11 14:36:27 ICT 2009
WARNING: Some recommended prerequisite checks have failed. You might get errors during installation. Do you want to proceed?
INFO: User Selected: Yes/OK
INFO: make: *** [opt/oracle/product/10.2.0/rdbms/lib/oracle] Error 1
INFO: End output from spawned process.
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'ioracle' of makefile '/opt/oracle/product/10.2.0/rdbms/lib/ins_rdbms.mk'. See '/opt/oracle/oraInventory/logs/installActions2009-04-11_02-35-06PM.log' for details.
Exception Severity: 1
INFO: The output of this make operation is also available at: '/opt/oracle/product/10.2.0/install/make.log'
INFO: make: *** [liborasdkbase] Error 1
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'all_no_orcl ihsodbc' of makefile '/opt/oracle/product/10.2.0/rdbms/lib/ins_rdbms.mk'. See '/opt/oracle/oraInventory/logs/installActions2009-04-11_02-35-06PM.log' for details.
From make.log
make: *** [opt/oracle/product/10.2.0/rdbms/lib/oracle] Error 1
/usr/bin/make -f ins_net_client.mk nnfgt.o mkldflags client_sharedlib ORACLE_HOME =/opt/oracle/product/10.2.0/rm -f nnfgt.*
make: *** [liborasdkbase] Error 1
/usr/bin/make -f ins_rdbms.mk all_no_orcl ihsodbc ORACLE_HOME=/opt/oracle/product/10.2.0/chmod 755 /opt/oracle/product/10.2.0/bin
rm -f oracle dbv tstshm maxmem orapwd dbfsize cursize genoci extproc extproc32 hsalloci hsots hsdepxa dgmgrl dumpsga mapsga osh sbttest expdp impdp imp exp sqlldr rman nid extjob extjobo genezi ikfod grdcscan /opt/oracle/product/10.2.0/rdbms/lib/ksms.s /opt/oracle/product/10.2.0/rdbms/lib/ksms.o
make: *** [liborasdkbase] Error 1
/usr/bin/make -f ins_rdbms.mk ipc_udp/rm -f /opt/oracle/product/10.2.0/lib/libskgxp10.so
cp /opt/oracle/product/10.2.0/lib//libskgxpu.so /opt/oracle/product/10.2.0/lib/libskgxp10.so
/usr/bin/make -f ins_emdb.mk collector ORACLE_HOME=/opt/oracle/product/10.2.0/make -f /opt/oracle/product/10.2.0/sysman/lib/ins_emdb.mk relink_exe EXENAME=nmccollector -
How to pass a col of pl/sql tab to a parametrized cursor?
Hi,
I'm getting this error constantly:
Error on line 1
declare
j number :=1;
cursor f
ORA-06550: line 9, column 20:
PLS-00103: Encountered the symbol "TABLE" when expecting one of the following:
constant exception <an identifier>
<a double-quoted delimited-identifier> table LONG_ double ref
char time timestamp interval date binary national character
nchar
Code Snippet:
declare
j number :=1;
cursor firstquery (c_item in varchar2) is
SELECT SEARCH, NAME, ID FROM tablename
WHERE name LIKE c_item;
first_rec_tbl_type is table of firstquery%rowtype index by binary_integer;
first_rec_tbl first_rec_tbl_type;
type act_str_tbl_type is table of varchar2(50) index by binary_integer;
act_put_str_tbl act_str_tbl_type;
begin
this is executing fine as i have executed it as a standalone script also
act_put_str_tbl table has values here.passing these to below:
----------------------------------- i guess the problem lies here------------------------
begin
dbms_output.put_line('reached second begin');
For i in act_put_str_tbl.first..act_put_str_tbl.last
loop
dbms_output.put_line('inside loop of second begin');
open firstquery(act_put_str_tbl(i));
loop
fetch firstquery into first_rec_tbl(j);
j:=j+1;
exit when firstquery%notfound or firstquery is null;
end loop;
close firstquery;
end loop;
How to use parametrized cursor with PL/SQL table, any help is appreciated in the above snippet.
ThanksSatyaki_De wrote:
first_rec_tbl_type is table of firstquery%rowtype index by binary_integer;Create this type in side any package like ->
create or replace package patch_array
is
first_rec_tbl_type is table of firstquery%rowtype index by pls_integer;
end;But, you have to use explicit record type instead of firstquery%rowtype here.
And, then refer this type inside your parametrized cursor to use that properly, that might solve your current problem - i guess.
So, you cursor should look something like this ->
cursor firstquery (c_item in patch_array.first_rec_tbl_type)
is
SELECT SEARCH, NAME, ID
FROM tablename
WHERE name LIKE c_item; N.B.:Not Tested...
Regards.
Satyaki De.
Edited by: Satyaki_De on Dec 28, 2008 1:32 AM??? No package is needed:
SQL> declare
2 j number := 1;
3 cursor firstquery(
4 c_item in varchar2
5 )
6 is
7 SELECT ename,
8 sal
9 FROM emp
10 WHERE ename LIKE c_item;
11 type first_rec_tbl_type is table of firstquery%rowtype index by binary_integer;
12 first_rec_tbl first_rec_tbl_type;
13 type act_str_tbl_type is table of varchar2(50) index by binary_integer;
14 act_put_str_tbl act_str_tbl_type;
15 begin
16 act_put_str_tbl(1) := 'S%';
17 act_put_str_tbl(2) := '%L%';
18 act_put_str_tbl(3) := 'KING';
19 begin
20 dbms_output.put_line('reached second begin');
21 For i in 1..nvl(act_put_str_tbl.count,0) loop
22 dbms_output.put_line('inside loop of second begin');
23 dbms_output.put_line('act_put_str_tbl(' || i || ') = ' || act_put_str_tbl(i));
24 open firstquery(act_put_str_tbl(i));
25 loop
26 fetch firstquery into first_rec_tbl(j);
27 exit when firstquery%notfound;
28 dbms_output.put_line('first_rec_tbl(' || j || ').ename = ' || first_rec_tbl(j).enam
e);
29 dbms_output.put_line('first_rec_tbl(' || j || ').sal = ' || first_rec_tbl(j).sal);
30 j:=j+1;
31 end loop;
32 close firstquery;
33 end loop;
34 end;
35 end;
36 /
reached second begin
inside loop of second begin
act_put_str_tbl(1) = S%
first_rec_tbl(1).ename = SMITH
first_rec_tbl(1).sal = 800
first_rec_tbl(2).ename = SCOTT
first_rec_tbl(2).sal = 3000
inside loop of second begin
act_put_str_tbl(2) = %L%
first_rec_tbl(3).ename = ALLEN
first_rec_tbl(3).sal = 1600
first_rec_tbl(4).ename = BLAKE
first_rec_tbl(4).sal = 2850
first_rec_tbl(5).ename = CLARK
first_rec_tbl(5).sal = 2450
first_rec_tbl(6).ename = MILLER
first_rec_tbl(6).sal = 1300
inside loop of second begin
act_put_str_tbl(3) = KING
first_rec_tbl(7).ename = KING
first_rec_tbl(7).sal = 5000
PL/SQL procedure successfully completed.
SQL> To OP. It is better to use BULK COLLECT:
SQL> declare
2 cursor firstquery(
3 c_item in varchar2
4 )
5 is
6 SELECT ename,
7 sal
8 FROM emp
9 WHERE ename LIKE c_item;
10 type first_rec_tbl_type is table of firstquery%rowtype index by binary_integer;
11 first_rec_tbl first_rec_tbl_type;
12 type act_str_tbl_type is table of varchar2(50) index by binary_integer;
13 act_put_str_tbl act_str_tbl_type;
14 begin
15 act_put_str_tbl(1) := 'S%';
16 act_put_str_tbl(2) := '%L%';
17 act_put_str_tbl(3) := 'KING';
18 begin
19 dbms_output.put_line('reached second begin');
20 For i in 1..nvl(act_put_str_tbl.count,0) loop
21 dbms_output.put_line('inside loop of second begin');
22 dbms_output.put_line('act_put_str_tbl(' || i || ') = ' || act_put_str_tbl(i));
23 open firstquery(act_put_str_tbl(i));
24 fetch firstquery bulk collect into first_rec_tbl;
25 for j in 1..nvl(first_rec_tbl.count,0) loop
26 dbms_output.put_line('first_rec_tbl(' || j || ').ename = ' || first_rec_tbl(j).enam
e);
27 dbms_output.put_line('first_rec_tbl(' || j || ').sal = ' || first_rec_tbl(j).sal);
28 end loop;
29 close firstquery;
30 end loop;
31 end;
32 end;
33 /
reached second begin
inside loop of second begin
act_put_str_tbl(1) = S%
first_rec_tbl(1).ename = SMITH
first_rec_tbl(1).sal = 800
first_rec_tbl(2).ename = SCOTT
first_rec_tbl(2).sal = 3000
inside loop of second begin
act_put_str_tbl(2) = %L%
first_rec_tbl(1).ename = ALLEN
first_rec_tbl(1).sal = 1600
first_rec_tbl(2).ename = BLAKE
first_rec_tbl(2).sal = 2850
first_rec_tbl(3).ename = CLARK
first_rec_tbl(3).sal = 2450
first_rec_tbl(4).ename = MILLER
first_rec_tbl(4).sal = 1300
inside loop of second begin
act_put_str_tbl(3) = KING
first_rec_tbl(1).ename = KING
first_rec_tbl(1).sal = 5000
PL/SQL procedure successfully completed.
SQL> SY.
Edited by: Solomon Yakobson on Dec 27, 2008 12:32 PM -
How do I create a view in SQL Server in Visual Studio Express 2013 for Desktop?
Hi
I've got a SQL Server database set up using the internal SQL Server in Visual Studio Express 2013 for Desktop. I want to create a view (using tables with one to many relationships) but I don't
know how to do it.
Where can I find a good tutorial on creating views in SQL Server in Visual Studio Express 2013 for Desktop? I think Visual Studio Express 2013 for Desktop doesn't have some view designer that
exists in the non-express version of Visual Studio (if I'm not mistaken). So I think I'd need a tutorial on how to do the actual SQL, unless there is some tool I don't know about.
ThanksHi ,
According to your description, if you install SQL Server SQL Server 2014 Express and SQL Server Manager Studio tools (SSMS), if you want to create a view, you can use SSMS. Then if you want to connect to and Diagram your SQL Express Database in Visual Studio
2013, you can attach the database file by using the .NET Framework Data Provider for SQL Server in Visual Studio, and create a database diagram via expanding the “Database Diagrams” node.
For more information, there is similar issue about how to connect to and Diagram your SQL Express Database in Visual Studio 2012 , you can review the following article,
http://blogs.msdn.com/b/bethmassi/archive/2011/10/27/how-to-connect-to-and-diagram-your-sql-express-database-in-visual-studio-lightswitch.aspx.
Regards,
Sofiya Li
Sofiya Li
TechNet Community Support -
How to delete number (00) in a SQL Server column ?
how to delete number (00) in a SQL Server column ?
example :
column : Births before Births
after
199900
1999
198200
1982
200400
2004
help queryYou use REPLACE function to selectively replace text inside a string in SQL Server. The REPLACE function is easy to use and very handy with an UPDATE statement.
SELECT Replace(births, '00', '')
or
update .....
Also you can use STUFF()
This function can be used for delete a certain length of the string and insert a new string in the deleted place.
Select STUFF ('199900', 5, 2, '')
--result 1900,1982,....
Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/ -
How can I execute a Procedure with OUT variable is %ROWTYPE on SQL Prompt
Hi,
I have a procedure with OUT variable is %ROWTYPE
How can I execute the following procedure on SQL prompt.
(without creating anonymous block)
CREATE OR REPLACE PROCEDURE zz_sp_EMP(VEMPNO IN EMP.EMPNO%TYPE,
V_REC IN OUT EMP%ROWTYPE)
AS
BEGIN
SELECT * INTO V_REC FROM EMP WHERE EMPNO = VEMPNO;
END;
Thanks & Regards,
Nareshas previous posters said: it's not possible to do this without declaring a variable in the anonymous block.
With anonymous block it would look like this (had to change it a bit, since i'm using hr-schema on oracle XE):
declare
l_rec EMPLOYEES%ROWTYPE;
begin
zz_sp_EMP(VEMPNO => 100, V_REC => l_rec);
DBMS_OUTPUT.PUT_LINE ( 'first_name = ' || l_rec.first_name );
DBMS_OUTPUT.PUT_LINE ( 'last_name = ' || l_rec.last_name );
end;
first_name = Steven
last_name = King -
How to use Temporary Table in PL-SQL
In MySQL there is no Temporary table concept.
So for intermediate calculation I have created a table as below
create table SequenceTempTable
SessionId VARCHAR(50),
Sequence VARCHAR(500),
CreatedDate DATE
) ENGINE=MEMORY;
Whenever I invoke a SP, I load the data into SequenceTempTable using Session Id as below
CREATE PROCEDURE `GetSequence`(
IN Start_Date VARCHAR(25),
IN End_Date VARCHAR(25)
BEGIN
SELECT UUID() INTO v_SessionId;
INSERT INTO SequenceTempTable values (v_SessionId,'1,2,5,3',now());
required code
DELETE FROM SequenceTempTable WHERE SessionId = v_SessionId;
COMMIT;
END;
i.e. I have created a table as temporary table (created once),
and load the data using Session Id and once session specific intermediate computation done,
I deleted the session specific data.
Could you give me examples of How to use Temporary table in PL-SQL code with respect to my above example.
Because I have gone through creating Temporary table but I stuck with use in PL-SQL. I mean to say Is there any need of creating table in advance before invoking SP.
And one more thing as in MySQL temp table I created which is using MEMORY engine i.e. this table will always be in MEMORY so there is no need of writing data on disk.
Regards
SanjeevHi Sanjeev
Read about GTT here
http://www.oracle-base.com/articles/8i/TemporaryTables.php
GTT always contains just session specific data. \
In case you want to use the GTT in the same session again you can use option
ON COMMIT PRESERVE ROWS;
Or if it is used just once in the session use can use
ON COMMIT DELETE ROWS;
Do remember that for GTT the data of one session can not be accessed in other session.
Also you can go away with Delete from GTT if not used again in same session.
Regards
Arun
Maybe you are looking for
-
Downpayment request-Payment terms
Hi Gurus, We need to activate payment terms while posting Downpayment request, i tried to activate in the field status and posting key. it will not work out. Our business need to assign payment terms, while posting downpayment request. Highly apprici
-
Error at Step 9 of 32 while Installing CE7.11 Trail Version.
Hi All, i am getting the following error while installing CE 7.1 SP1 Downloaded from sdn.. download area... I am using Windows 64 Bit.. I also tried with Windows 7 64bit OS..AStill the same.... Running msiexec failed with return code 1603: undefined
-
Java 1.4.2.17
Hi All, Is Java 1.4.2.17 stable or are there any issues ? Regards Shaji
-
DateFormat from regional setting
Hi, I have requirement to display the date in the format what is selected in the system's regional setting. I am able pick the format with the help of code written below ((SimpleDateFormat)DateFormat.getInstance(DateFormat.Short, Locale.getDefault)).
-
How to reconnect files that I can't find on my computer now?
When I got onto my computer and went to Final Cut Express, a couple of my files had apparently gone offline and whilst I know how to fix that I don't know how to reconnect files that I for some reason can't find in the same file, on my computer, that