CONNECT and ALTER statements in a Procedure. COPY command in SQL*Plus
Hi people,
Is it possible to use the SQL commands, "CONNECT" and "ALTER TABLE" in a procedure, function or trigger?
In one of my audit procedures, I need to connect to a financial database (FROM the applications database), and then proceed to alter a number of tables based on certain data. I'm sure I've done it before, but I can't remember how! Isn't there a command such as "EXEC_SQL" or something?
Another question:
I need to copy a table from one database ("OPS$TSLIVE") to another ("TRACKER"). Here is an excerpt of my code, as well as an error! I've never had this error before!
JOHANN> copy from ops$tslive/pwd@cds to tracker/pwd@tracker create new_alerts using select * from alertcodesfile;
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
select * from alertcodesfile
Error in SELECT statement: ORA--1002: Message -1002 not found; product=RDBMS; facility=ORA
Please help!
Kind regards,
Johann.
You are refering to 'execute immediate' (>=8i). As far as I know it is not possible to do connects. Alter table perhaps, if it is in the local database (try it). If you want to perform dml in a remote database, create a database link and use that to perform you dml on. a DB link can also be used to call a remote procedure (That perhaps does the alters for you). Try it.
The oracle doc says this about ORA-1002:
ORA-01002 fetch out of sequence
Cause: In a host language program, a FETCH call was issued out of sequence.
A successful parse-and-execute call must be issued before a fetch. This can
occur if an attempt was made to FETCH from an active set after all records have
been fetched. This may be caused by fetching from a SELECT FOR UPDATE
cursor after a commit. A PL/SQL cursor loop implicitly does fetches and may
also cause this error.
Action: Parse and execute a SQL statement before attempting to fetch the data.It looks like a bug, ask Oracle support.
L.
Similar Messages
-
Am trying to use the copy command in SQL*Plus to copy a table
from an Oracle database to a local table on my machine in
another format. Keep getting errors. It seems to contact the
remote machine fine, but can't locate my local machine or figure
out where to put it. Any suggestions on how to set up my
Windows 95 machine to get the copy command working would be
greatly appreciated. Thank you.
nullHi,
Here is an example :
SQL> copy from scott/tiger@q4_production_server create ord -
using select * from ord;Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
Table ORD created.
21 rows selected from scott@q4_production_server.
21 rows inserted into ORD.
21 rows committed into ORD at DEFAULT HOST connection.
Hope this helps,
Bala
Laura Michaels (guest) wrote:
: Am trying to use the copy command in SQL*Plus to copy a table
: from an Oracle database to a local table on my machine in
: another format. Keep getting errors. It seems to contact the
: remote machine fine, but can't locate my local machine or
figure
: out where to put it. Any suggestions on how to set up my
: Windows 95 machine to get the copy command working would be
: greatly appreciated. Thank you.
null -
COPY command in SQL*Plus 8.1.6 returns ORA-65535
The COPY command in the windows version of SqlPlus (SQLPLUSW) does not work any more. I get the following error
<< Array fetch/bind size is 5. (arraysize is 5)
Will commit after every array bind. (copycommit is 1)
Maximum long size is 80. (long is 80)
ERROR:
ORA-65535: Message 65535 not found; product=RDBMS; facility=ORA >>
Interestingly, I can run the same COPY command successfully if I use SQLPLUS.exe ( the command line version ). No error & it completes the copy.
I recently changed my Oracle client from 7.3 to v8.1.6.
I had not encountered this problem with the same command in v7.3.You may have run into bug 1504702. As a workaround you will need to use command line, as you've already figured out. I don't think a patch is available for Windows yet, although there is for Solaris (in the 8.1.7.4 patch set).
Alison -
What is the Copy Command in SQL ?
COPY Command is used to COPY database table from one Schema to another Schema.
-
I seem to be unable to copy and paste text using the "highlight text and right-click" procedure in Sql*Plus 8.0.6.0.0. The right-mouse button seems to work in everything else so it doesn't seem to be the mouse that is the problem. Does anybody know if this could be due to the way Sql*Plus is set up or some other Oracle related problem?
You can either do SET PAGESIZE 0 which turns off all headings.
Of you can do SET PAGESIZE 50000 which will reprint the headings every 50,000 lines.
50,000 is the max. I don't know of a way to show the headings once, and only once. (you can turn off headings and fake them one time with a select ... from dual before your main query). -
Calling a remote procedure with db link - SQL Plus hangs
I am trying to call a procedure from a remote database with a db link, within a local procedure. The purpose of the calling the procedure is to get the server time from that database. When I try to compile this procedure on the local database SQL Plus hangs without giving any error message, I have to close SQL Plus. Below are my two procedures:
Local procedure:
CREATE OR REPLACE PROCEDURE get_server_time(p_remotetime IN OUT VARCHAR2)
IS
/*Grabs the system time from remote database .
l_remotetime varchar2(16) ;
BEGIN
get_remote_time(l_remotetime);
p_remotetime := l_remotetime;
END ;
Remote procedure:
CREATE OR REPLACE PROCEDURE get_remote_time(p_remotetime in out VARCHAR2)
IS
/* Grabs the system time from remote database and returns it to the
calling proc.
l_remotetime varchar2(16) ;
BEGIN
SELECT to_char(sysdate,'YYYYMMDDHH24MISS')
INTO l_remotetime
FROM dual ;
p_remotetime := l_remotetime ;
END ;
I personaly do not see anything unusall with the two procedures, but cant figure out what is making SQL*Plus hang.
Any help would be much appreciated.
Thanks In AdvanceHello
Are you able to run the procedure connected to the livetolocal database directly? It looks as if you either have a missing table or the permisions for the user associated with the database link are not sufficient.
As for calling the procedure, it would probably be more managable if you created a public synonym for it to hide the actual location. That way if you want to change the name of the DB link, or where it points to, no-one has to change their code, you just have to change the synonym.
HTH
David -
Debugging procedure or packages using sql*plus reg
Dear all,
I am new to oracle, can any body provide me some information related to this below issues.
a) suppose i have created a procedure using sql*plus tool then next day i wanted to debug or modify my stored procedure.
Then what could approach using sql*plus
b) same case if we consider for packages then for any specific stored procedure or functions what would be the approach to debug or modify using sql*plus
yours cordination will be highly appreciate
Thanks n regards
LaxmanUsing SQL*Plus you can debug your stored pl/sql code only adding some "prints" in your code:
SQL> create or replace procedure test is
2 begin
3 dbms_output.put_line('starting...');
4 --do something here
5 dbms_output.put_line('done step 1');
6 --do something else here
7 dbms_output.put_line('end procedure...');
8 end;
9 /
Procedura creata.
SQL> set serverout on
SQL> exec test
starting...
done step 1
end procedure...
Procedura PL/SQL completata correttamente.Or writing logs in a log table:
SQL> create table logtab(ts timestamp(9),mess varchar2(4000));
Tabella creata.
SQL> create or replace procedure test is
2 begin
3 insert into logtab values(systimestamp,'starting...');
4 --do something here
5 insert into logtab values(systimestamp,'done step 1');
6 --do something else here
7 insert into logtab values(systimestamp,'end procedure...');
8 end;
9 /
Procedura creata.
SQL> exec test
Procedura PL/SQL completata correttamente.
SQL> col ts for a40
SQL> col mess for a40
SQL> select * from logtab;
TS MESS
25-DIC-09 15:33:13,656000000 starting...
25-DIC-09 15:33:13,656000000 done step 1
25-DIC-09 15:33:13,656000000 end procedure...Max
[My Italian Oracle blog|http://oracleitalia.wordpress.com] -
How do you run procedure with declare on sql plus
Hi i am a newbie in sqlplus so please forgive if my question sounds to0 silly as i was watching a tutorial on sqlplus procedures i know how to run a simple IN procedure like
create or replace procedure inparameter
p_name IN VARCHAR2
)AS
BEGIN
DBMS_OUTPUT.PUT_LINE('Hello' || p_name);
end;
to run
start inparameter;
procedure created
set serveroutput on;
exec inparameter ('newbie');
hello newbie
procedure successfuly completed
but now i have a procedure with a declare
now wich from what i see on the video tutorial as two box to create procedure and on the next the declare i dont know if i am meant to put them together and run it as one this how it looks like
DO I RUN THE FIRST BOX AS MY PREVIOUS PROCEDURE DESCRIBED ABOVE (start procedure, then exec procedure)
then run the second box which is the declare as the same way or do i put the all code in one single box (start declare then exec declare)
BOX 1
Create or replace procedure addition
P_A IN NUMBER
,P_B IN NUMBER
,P_C OUT NUMBER
)AS
BEGIN
P_C := P_A +P_B;
END ADDITION
BOX 2
declare
x number;
addition (5,5,x);
dbms_output.put_line('the result is' || x);
end;
the tutorial can be seen on this youtube link
[http://www.youtube.com/watch?v=Vvn30o_ctpk&feature=related]
fastforward to about 9mins 18 to see the boxes that i mean
sorry in advance if its a stupid questionYou have to create the first procedure (addition), then run the pl/sql block:
SQL> Create or replace procedure addition
2 (
3 P_A IN NUMBER
4 ,P_B IN NUMBER
5 ,P_C OUT NUMBER
6 )AS
7 BEGIN
8 P_C := P_A +P_B;
9 END ADDITION;
10 /
Procedure created.
SQL> declare
2 x number;
3 begin
4 addition (5,5,x);
5 dbms_output.put_line('the result is' || x);
6 end;
7 /
the result is10
PL/SQL procedure successfully completed.The procedure is stored in the database, the pl/sql block is anonymous, it's not stored in the db.
Max -
Change default settings and commands in sql plus
everytime i execute sql plus I have to change environment commands maually
(like linesize , wrap ...etc )
is there is a way to load those defaults not to reexecute them every time I access sql plus
Anyone have answer ????????glogin.sql (%ORACLE_HOME%/sqlplus/admin/glogin.sql) is executed whenever any user starts SQL*Plus on the machine. login.sql (on Windows, defaulted to %ORACLE_HOME%/bin but can be changed by setting the SQLPATH environment variable) is executed for a particular user.
You change the default linesize, or execute any other SQL*Plus commands, in either of these files.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
I'm having problems with the copy command in sql plus
Here's my command
COPY FROM tib_oms/tib_oms@odb1 -
TO gbonk/gbonk@stage -
INSERT -
gbonk.products ( id_manufacturer, id_sku, category ) -
USING -
select id_mfr, sku, prodcat from tib_oms.pricinghistory
The error I receive is...
CPY0007: Select list has fewer columns than destination table
I'm selecting 3 columns and I'm specifing 3 columns so I don't get what's up.
null<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Greg Bonk ([email protected]):
Well i gave it a shot. Here's my modified copy command....
copy from tib_oms/tib_oms@odb1 -
TO gbonk/gbonk@stage -
insert -
gbonk.products ( "ID_MANUFACTURER", "ID_SKU", "CATEGORY" ) -
using -
select "ID_MFR", "SKU", "PRODCAT" from tib_oms.pricinghistory;
But I still recieve the same error. Is there anything else that I could trouble shoot?<HR></BLOCKQUOTE>
did u check if the destination & target columns have the same structure. maybe one of the is a composite datatype (i.e varray,nested tables etc) ?
null -
Auto copy command for terminal?
I want to make Safri history folder auto copy to the other folder as it gets new history. So I can monitor activities.
Hi,
Here is an example :
SQL> copy from scott/tiger@q4_production_server create ord -
using select * from ord;Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
Table ORD created.
21 rows selected from scott@q4_production_server.
21 rows inserted into ORD.
21 rows committed into ORD at DEFAULT HOST connection.
Hope this helps,
Bala
Laura Michaels (guest) wrote:
: Am trying to use the copy command in SQL*Plus to copy a table
: from an Oracle database to a local table on my machine in
: another format. Keep getting errors. It seems to contact the
: remote machine fine, but can't locate my local machine or
figure
: out where to put it. Any suggestions on how to set up my
: Windows 95 machine to get the copy command working would be
: greatly appreciated. Thank you.
null -
Using Copy statement in Stored procedure
The following statement works in sqlplus session:
copy from comment/password@servername append amcomment_temp using
select * from amcomment
where commentid in(1,2,3,4)
I want to use this in a stored procedure. There is a long datatype in this table. The
procedure will not compile. Have tried execute immediate and compiler rejects this statement also.'COPY' is a SQL*Plus command, not PL/SQL. This is why the PL/SQL compiler throws it out.
-
Runtime environment error 4, connection broken server state 4.
He intentado realizar un recovery de la base de datos de MaxDB del sistema SAP con SAP MaxDB Database Studio y despues de varias horas de operar me ha saltado el siguiente mensaje:
Runtime environment error 4, connection broken server state 4.
La copia de seguridad desde el cual he querido realizar la operación se encuentra en otra pc y se monta en la pc que se encuentra la base de datos. La copia tiene más de 100 Gb de datos.
Obs: la copia tiene se realizó desde una aplicación de windows y el recovery se intentó realizar desde linux.
Ver imagen del error
Si no funciona el link ver aqui--> http://img829.imageshack.us/img829/1097/errorsapmaxdbdatabasest.png¿Qué versión de base de datos se utilizan?
¿Cuál es el contenido de "knldiag.err"?
Este es un foro Inglés, más gente podrá ayudar si usted publica en Inglés.
Markus -
HR Schema DDL and DML Statements
Dear all,
I want all tables and datas for practicing purpose.(HR Schema)
In Oracle site where can I get these DDL and DML Statements.
Can Any one post all statements..
Thanks in advance.Unlocking the Sample Tables
The Human Resources (HR) Sample Schema is installed as part of the default Oracle Database installation. The HR account is locked by default.
You need to unlock the HR account before you can use the HR sample schema. To unlock the HR account, log in as the SYSTEM user and enter the following command, where your_password is the password you want to define for the user HR:
ALTER USER HR IDENTIFIED BY your_password ACCOUNT UNLOCK;
For further information about unlocking the HR account, see the Oracle Database Sample Schemas guide. The HR user is primarily to enable you to access the HR sample schema and is necessary to enable you to run the examples in this guide.
Each table in the database is "owned" by a particular user. You may wish to have your own copies of the sample tables to use as you try the examples in this guide. To get your own copies of the HR tables, see your DBA or see the Oracle Database Sample Schemas guide, or you can create the HR tables with the script HR_MAIN.SQL which is located in the following directory on UNIX:
$ORACLE_HOME/DEMO/SCHEMA/HUMAN_RESOURCES/HR_MAIN.SQL
And on the following directory on Windows:
%ORACLE_HOME%\DEMO\SCHEMA\HUMAN_RESOURCES\HR_MAIN.SQL
To create the HR tables from command-line SQL*Plus, do the following:
1.
Ask your DBA for your Oracle Database account username and password.
2.
Login to SQL*Plus.
3.
On UNIX, enter the following command at the SQL*Plus prompt:
SQL> @?/DEMO/SCHEMA/HUMAN_RESOURCES/HR_MAIN.SQL
On Windows, enter the following command at the SQL*Plus prompt:
SQL> @?\DEMO\SCHEMA\HUMAN_RESOURCES\HR_MAIN.SQL
To remove the sample tables, perform the same steps but substitute HR_DROP.SQL for HR_MAIN.SQL.
Regards
Asif Kabir -
How to connect and export specific schemas in SQL plus
Hello,
Wanted to clarify on a few things.
- Can an Oracle 10g Release 10.2 client be used to connect to a oracle 10.1 database?
- Is there an option to "connect" (not refer) to a specific schema, say "SchemaA" in SQL plus in order to run a specific sql code on this schema alone?
- How can we export a specific schema as a dump file in SQL plus-what is the syntax? Assuming username=U;password = PW; Database=DB and schema = Sch
Thanks a lot.- Can an Oracle 10g Release 10.2 client be used to connect to a oracle 10.1 database?
Yes. O10gR2 client can be used to connect all version of Oracle instance.
- Is there an option to "connect" (not refer) to a specific schema, say "SchemaA" in SQL plus in order to run a specific sql code on this schema alone?
connect ShcemaA/pwd@hoststring.
for e.g.
connect scott/tiger@oradev
conn scott/tiger@oradev
- How can we export a specific schema as a dump file in SQL plus-what is the syntax? Assuming username=U;password = PW; Database=DB and schema = Sch
Export can be done on Command promt not on SQLPLUS prompt.
try the following to know all the parameters and usage of exp command.
c:\> exp help=y
exp scott/tiger FILE=scott.dmp OWNER=scott GRANTS=y ROWS=y COMPRESS=y
Maybe you are looking for
-
How can I get my music from icloud to my ipod?
I;ve beenm trying to put music I bought from Apple into my ipod from icloud It keeps telling me i have wrong apple id I've changed my password 10 times today It's really ******* me off
-
I have configured interest calculation for customers. the customers are given 30 days grace period in addition to the payment terms. e.g. payment terms are payable within 30 days and the grace days are 30 days. In total the customer has 60 days for w
-
Hello, one of the download files for CS6 is DesignWebPremium_CS6_LS16.7z which lists on the download site as being 4.6Gb. I have downloaded it twice with no reported errors but the file downloaded is only 489Mb. When I try to extract the install file
-
How do I set up PayPal Standard?
I have been through the tutorial and the help files, but, I keep getting an 'invalid vendor account'. I only want to use Standard, but originally set up PayPal PayFlow, which is in the settings. Not sure what to do to clear out PayFlow and just use S
-
[SOLVED] Lenovo T530 UEFI Arch/Ubuntu Dual boot - Arch fails to boot.
Hi All, I have installed Arch to my Lenovo T530 to dual boot with Ubuntu using UEFI and Grub. After installation, Arch is presented to me as an option when my laptop fires up. However, if I select it, the loader goes to a purple screen and then hangs