Can i pass output from PL/SQL Block (Urgent)
Dear All,
I am calling ABC.sql from Shell Script using input parameters.
eg.
Declare
X varchar(12) := &1;
Begin
Select..........................
Exception
End;
This &1 parameter i am passing from shell script.
Like that, is it possible to pass output parameter to Shell script.
Thanks,
Vikas
I don't usually do Windows but ...
C:\TEMP>type t.bat
@@echo off
for /f %%D in ('sqlplus -s user/password@instance @t.sql 1') do (
set res=%%D)
echo result is %res%
C:\TEMP>type t.sql
var x VARCHAR2(10);
set pages 0 feedback off echo off verify off;
BEGIN
SELECT 'Hello' INTO :x
FROM dual
WHERE 1 = &1;
END;
print x;
exit;
C:\TEMP>t.bat
result is Hellosprings to mind as one way to do it.
Amiel:
Yes, you can use the sqlplus exit command to return a value but there are couple of limitations. The return value must be a number (enforced by sqlplus), and it must be less than 256, and on some operating systems less than 128.
John
Similar Messages
-
Can we pass objects to pl/sql block
hi,
can we pass objects to pl/sql block.i think we can.how to pass it.help me in getting the examples of "passing objects to pl/sql block"What exactly do you mean ? You can pass objects like any other parameters
into and out from procedures/functions:
SQL> create or replace procedure get_object(myobj in out nocopy my_obj)
2 is
3 begin
4 dbms_output.put_line('ID : ' || myobj.empno);
5 dbms_output.put_line('Salary : ' || myobj.sal);
6 dbms_output.put_line('Department : ' || myobj.deptno);
7 myobj.sal := myobj.sal*2;
8 end;
9 /
Procedure created.
SQL> declare
2 mo my_obj := my_obj(1,1000,10);
3 begin
4 get_object(mo);
5 dbms_output.put_line('New salary : ' || mo.sal);
6 end;
7 /
ID : 1
Salary : 1000
Department : 10
New salary : 2000
PL/SQL procedure successfully completed.Rgds. -
Pass output from PL/SQL proc back to ODI for logging
Hi,
In ODI (10g), is there any way to pass output from a PL/SQL procedure back to the calling stage?
I am working on the run time of a batch, one part of which calls a procedure and so currently black box.
I'd like to instrument the proc so that I can see in Operator some kind of timed activity so that I can profile its activity better.
The best I've had suggested so far is to write out to file from the procedure and then use ODI to parse this and spit it out in the stage log. I don't like this approach for two reasons:
1) Our DBAs quite rightly get very itchy with the privs required for writing to files, and another app to read from the same
2) It's messy :)
Any ideas?
thanks, Robin.Robin
I don't know ODI. However if you are calling a stored proc procA and you have control over what you call, at the very least you could write a wrapper procB as
CREATE OR REPLACE PROCEDURE PROCB (parms)
AS
BEGIN
SYS.DBMS_MONITOR.SESSION_TRACE_ENABLE();
MYUSER.PROCA(parms);
SYS.DBMS_MONITOR.SESSION_TRACE_DISABLE();
END;
/ If ODI sets service,module and action (as it should) then you could ask the DBA to set SERV_MOD_ACT_TRACE_ENABLE instead.
Niall Litchfield
http://www.orawin.info/ -
Calling sql script from pl/sql block
Hi
I want to call a sql script from pl/sql block.
like
CREATE OR REPLACE procedure DataBaseExport(user_name in varchar2, pwd in varchar2)
as
begin
execute immediate '@ C:\Documents and Settings\umesh\emp.sql';
end DataBaseExport;
/Try something like this -
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
import java.io.*;
public class Host
public static void executeCommand(String command)
try {
String[] finalCommand;
if (isWindows())
finalCommand = new String[4];
// Use the appropriate path for your windows version.
finalCommand[0] = "C:\\windows\\system32\\cmd.exe"; // Windows XP/2003
//finalCommand[0] = "C:\\winnt\\system32\\cmd.exe"; // Windows NT/2000
finalCommand[1] = "/y";
finalCommand[2] = "/c";
finalCommand[3] = command;
else
finalCommand = new String[3];
finalCommand[0] = "/bin/sh";
finalCommand[1] = "-c";
finalCommand[2] = command;
final Process pr = Runtime.getRuntime().exec(finalCommand);
pr.waitFor();
new Thread(new Runnable()
public void run()
BufferedReader br_in = null;
try
br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String buff = null;
while ((buff = br_in.readLine()) != null)
System.out.println("Process out :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
br_in.close();
catch (IOException ioe)
System.out.println("Exception caught printing process output.");
ioe.printStackTrace();
finally
try {
br_in.close();
} catch (Exception ex) {}
).start();
new Thread(new Runnable()
public void run()
BufferedReader br_err = null;
try
br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
String buff = null;
while ((buff = br_err.readLine()) != null)
System.out.println("Process err :" + buff);
try
Thread.sleep(100);
} catch(Exception e) {}
br_err.close();
catch (IOException ioe)
System.out.println("Exception caught printing process error.");
ioe.printStackTrace();
finally
try
br_err.close();
catch (Exception ex) {}
).start();
catch (Exception ex)
System.out.println(ex.getLocalizedMessage());
public static boolean isWindows()
if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
return true;
else
return false;
CREATE OR REPLACE PROCEDURE Host_Command (p_command IN VARCHAR2)
AS LANGUAGE JAVA
NAME 'Host.executeCommand (java.lang.String)';
--- THE PERMISSIONS ---
call dbms_java.grant_permission('SYSTEM', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');And, finally,
create or replace procedure call_sql_file(usr in varchar2,
pwd in varchar2,
host_str in varchar2)
is
begin
host('sqlplus -s usr/pwd@host_str C:\UAX_Auto_Count.sql');
exception
when others then
dbms_output.put_line(sqlerrm);
end;Now, you can pass all the argument in order to execute that file.
N.B.: Not Tested...
Regards.
Satyaki De. -
Can't pass parameter from HTML form of multipart/form-dta type to JSP
I am using request.getParameter(passed variable name) to pass data from HTML form to JSP with no problem. WHen I try to pass data from HTML form of multipart/form-dta type to JSP as following:
< form enctype="multipart/form-data" name="theForm" method="post" ACTION="http://titan.ssd.loral.com:7778/ifs/jsp-bin/ifs-cts/stringsecond.jsp">
The passed value is null. Why?
How can I pass data successfully from this form to JSP?
How can I pass data from JavaScript to JSP?
Thank youI am using request.getParameter(passed variable name)
to pass data from HTML form to JSP with no problem.
WHen I try to pass data from HTML form of
multipart/form-dta type to JSP as following:
< form enctype="multipart/form-data" name="theForm"
method="post"
ACTION="http://titan.ssd.loral.com:7778/ifs/jsp-bin/if
-cts/stringsecond.jsp">
The passed value is null. Why?because the jsp most likely does not handling of POST parameters like this.
How can I pass data successfully from this form to
JSP?jsp's are not meant to read such amounts of data. this (= uploading) is a typical task for a specialized servlet. there you have full control over input and output. if you need to, you can still forward to a jsp after processing in the servlet.
How can I pass data from JavaScript to JSP???? i'm not sure what exactly you mean. normally you put it into an url and submit it.
robert -
Is it possible to call a windows batch file from PL/SQL block ??
Hi gurus,
Would require your help.Is it possible to call a windows batch file from PL/SQL block ??If yes can you give an example for the same or any workaround for the same.
Regards
VijayYou didn't specify a database version, but if you are 10g or higher, it's quite straightforward using an external job type in DBMS_SCHEDULER. Funnily enough i'm looking at something similar myself at the moment.
Useful guide to some of the issues here Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files -
Running sqlldr command from PL/SQL Block
DECLARE
BEGIN
END;In SQL * plus we can run DOS commands using the following command
HOST DIR
HOST DIR/P
But When we can't run the HOST command in PL/SQL Block..
I have to Run sqlldr command from PL/SQL Block..
i tried as follows
DECLARE
BEGIN
EXECUTE IMMEDIATE ' host sqlldr control= bad= ';
END;
By
BalaNagaRaju -
Exec SQLPLUS command from PL/SQL Block
Good Morning:
How I can execute a SQLPLUS command (like SPOOL or DESCRIBE) from PL/SQL Block Procedure?:
DECLARE
BEGIN
ls_command = 'DESCRIBE '||ls_table_name;
EXECUTE SQLPLUS(ls_command);
END;
Thanks a lot for any idea.That's correct.
However, in the case of the given example we can use DBMS_DESCRIBE package to get table descriptions. And we can use UTL_FILE to spool PL/SQL stuff to a file.
Cheers, APC -
Script fails when passing values from pl/sql to unix variable
Script fails when passing values from pl/sql to unix variable
Dear All,
I am Automating STATSPACK reporting by modifying the sprepins.sql script.
Using DBMS_JOB I take the snap of the database and at the end of the day the cron job creates the statspack report and emails it to me.
I am storing the snapshot ids in the database and when running the report picking up the recent ids(begin snap and end snap).
From the sprepins.sql script
variable bid number;
variable eid number;
begin
select begin_snap into :bid from db_snap;
select end_snap into :eid from db_snap;
end;
This fails with the following error:
DB Name DB Id Instance Inst Num Release Cluster Host
RDMDEVL 3576140228 RDMDEVL 1 9.2.0.4.0 NO ibm-rdm
:ela := ;
ERROR at line 4:
ORA-06550: line 4, column 17:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
The symbol "null" was substituted for ";" to continue.
ORA-06550: line 6, column 16:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev su
But when I change the select statements below the report runs successfully.
variable bid number;
variable eid number;
begin
select '46' into :bid from db_snap;
select '47' into :eid from db_snap;
end;
Even changing the select statements to:
select TO_CHAR(begin_snap) into :bid from db_snap;
select TO_CHAR(end_snap) into :eid from db_snap;
Does not help.
Please Help.
TIA,
NischalHi,
could it be the begin_ and end_ Colums of your query?
Seems SQL*PLUS hs parsing problems?
try to fetch another column from that table
and see if the error raises again.
Karl -
How can I pass parameters from one process flow to another process flow?
How can I pass parameters from one process flow to another process flow (sub process) in warehouse builder? let me know the steps I have to do in warehouse builder.
Thanks in advance,
KishanHi Kishan,
Please post this question to the Warehouse Builder forum:
Warehouse Builder
Thanks, Mark -
HT201250 how can i pass information from one mac to another mac by using the time capsule
how can i pass information from one mac to another mac by using the time capsule
If you want to transfer files, settings, etc., you must open Migration Assistant (Applications > Utilities) in the Mac that you want to transfer the files and follow the instructions
-
I would like to know how can I delete emails from my email block have more than 8000? Thank you.
I want to say, delete the 8000 not one by one, or 50 in 50... Minimum of 200 by
200 -
How can I pass parameter from report to form?
Hi :)
Now I try to build conference room like this by using form
and report. And i design that when users click at group report
then i'll show page that contain questions report and add
question form. And question form and report must receive the
same parameter from group report.
First Problem: is I don't know how group report send the
same parameter to question report and add question report at the
same time. And is it possible??? If not please suggest me what
should I do???
Second Problem: is I don't know how can I pass parameter from
report to form. I don't know the way to do it.
Please tell me!!! Please...
I look forward to hearing from all of you.
Thank You.One way is to create a link based on that form and attach that
link with the report. Through links you can pass parameters -
FETCHING OUTPUT VALUE FROM PL/SQL BLOCK
hI aLL,
I'm working on ODP.NET. I'm executing below pl/sql command. while executing this command in pl/sql it's showing the output which is an xml.
declare
xmloutput xmltype;
xmldata varchar(32767);
teid t_id := t_en_id( 'L','L',NULL,12121,'ABC','USER','N');
tgetinfo to_info := NULL;
RETVAL NUMBER;
begin
RETVAL := GET_DTLS(teid,tgetinfo);
dbms_output.put_line(RETVAL);
xmldata := tgetinfo.XML_info.getclobval();
dbms_output.put_line(xmldata);
end;
I passed above command in string variable for passing in code. like below
string StrQry = "";
StrQry += "declare \n";
StrQry += "xmloutput xmltype; \n";
StrQry += "xmldata varchar(32767); \n";
StrQry += "teid t_id := t_en_id( 'L','L',NULL,12121,'ABC','USER','N'); \n";
StrQry += "tgetinfo to_info := NULL; \n";
StrQry += "RETVAL NUMBER; \n";
StrQry += "begin \n";
StrQry += "RETVAL := GET_DTLS(teid,tgetinfo); \n";
StrQry += "dbms_output.put_line(RETVAL); \n";
StrQry += "xmldata := tgetinfo.XML_info.getclobval(); \n";
StrQry += "dbms_output.put_line(xmldata); \n";
StrQry += "end; \n";
I'm passing output parameter ":temp" for this command. I want to catch output xml in ":temp" variable
which is varchar2 type.
Added below line before printing xmldata;
StrQry += ":temp := xmldata; \n";
cn.Open();
OracleCommand cmd = new OracleCommand(StrQry, cn);
cmd.Parameters.Add(":temp", OracleDbType.Varchar2, 32767, ParameterDirection.Output);
cmd.ExecuteNonQuery();
But which executing through c# code it's showing the below error.
Oracle.DataAccess.Client.OracleException ORA-06502: PL/SQL: numeric or value err
or: character string buffer too small
ORA-06512: at line 11 at Oracle.DataAccess.Client.OracleException.HandleError
Helper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOp
oSqlValCtx, Object src, String procedure)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, Oracle
Connection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx
, Object src)
at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
at orclGetDetails.Program.DoProcess()
How can i get the output to output variable ":temp".
Pls help.
Ideas are appreciated.Your PL/SQL block isn't returning anything. DBMS_OUTPUT is, at best, a way of debugging code, not passing data around. Assuming you configure and enable an appropriately sized buffer, I suppose your ODP.Net application could make DBMS_OUTPUT.GET_LINE calls to retrieve the XML. But that's not not a way to design an application.
If you want a PL/SQL block that returns XML, you'll need to create a function and have the function return the XML (you could also create a procedure with an OUT parameter in which you could return the XML).
Justin -
How can I pass value from sql query to unix script
I am new to oracle/unix.
I want to write a simple script to find max date from a table and then pass date into a variable in a korn shell script.
sql is select max(date) from table;
how can I pass that value in unix shell as a variable. ThanksI use to code like this.
Enjoy Scripting.
cmd.sql
select sysdate from dual;
exit
db.sh
#! /usr/bin/ksh
. ~oracle/.orapaths
dbdate=$(sqlplus -S user/pwd@servicename @cmd.sql)
echo $dbdate
Run shell scripts
./db.sh
SYSDATE --------- 19-JAN-07
Maybe you are looking for
-
Basic functions missing after replacing hard drive
My drive crashed. I took it to Apple to have it replaced. I then noticed some differences. I no longer see the hard drive in the finder window or on the desktop. Its no where to be found. 2nd, there is no longer the folder with 'your name' that conta
-
Can't enable S-Video to TV on Satellite P305D-S8834 Vista 64bit
I've been trying to connect my TV thru the S-Video out but the second display won't stay enabled. I've updated the drivers with Toshiba's latest, using ATI's CCC ver 8.10 and neither will enable second display. Toshiba's phone Tech Support wants me t
-
Question about iDisk Public Folder Security
Is it possible to determine which folders in my iDisk's Public Folder are accessible to certain people. I am directing different people to my Public Folder, so I want some folders to be off limits to some, but accessible to others. Is that possible?
-
OS X 10.5.8 Upgrade
I am very new to the Mac world as our office has recently switched over from PCs. I have a MacBook Air OS X 10.5.8 with a 1.6GHz Intel Core 2 Duo. I need to upgrade to at least 10.6 Snow Leopard but do not have a CD drive. Any advice? Thanks!
-
Hi, We have a PCI NI7332 motion controller purchased with us. We installed the drivers and softwares from the cd that comes with the package. The problem is PCI NI7332 showing as NI7330 in MAX . Anyway its listing the two axis in max. When i tried t