How can I execute this procedure in sql developer, cursortype is refcursor
PROCEDURE GET_CNTRY(CNTRY_NME_IN IN VARCHAR2 DEFAULT NULL,
QRY_RSLT_OUT OUT CURSORTYPE) AS
BEGIN
OPEN QRY_RSLT_OUT FOR
select
CNTRY_NME,
FRGN_CNTRY_CDE,
INV_VEH_CNTRY_CDE,
FRGN_CNCY_CDE,
WTHH_PCT_COLA_CDE
FROM
CNTRY
WHERE
CNTRY_NME = NVL(CNTRY_NME_IN,CNTRY_NME);
END GET_CNTRY;
In SQL Developer run the following code as script (You need to hit F5 to run it as script).
var rc refcursor
exec get_cntry (<give your cntry_nme_in>, :rc)
print :rc
Similar Messages
-
How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?
Hi
I have a stored procedure. It can be executed like this
exec test @p = 1;
exec test @p = 2
exec test @p = n;
n can be hundred.
I want the sp being executed in parallel, not sequence. It means the 3 examples above can be run at the same time.
If I know the number in advance, say 3, I can create 3 different Execution SQL Tasks. They can be run in parallel.
However, the n is not static. It is coming from a table.
How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?
I think about using script task. In the script, I get the value of n, and the list of p, from the table, then running a loop with. In the loop, I create a threat and in the threat, I execute the sp like : exec test @p = p. So the exec test may
be run parallel. But I am not sure if it works.
Any idea is really appreciated.Hi nam_man,
According to your description, you want to call stored procedures in parallel, right?
In SSIS, we can create separate jobs with different stored procedures, then set the same schedule to kick the jobs off at the same time. In this way, we should be careful to monitor blocking and deadlocking depending on what the jobs are doing.
We can also put all stored procedures in SSIS Sequence container, then they will be run in parallel.
For more information about SSIS job and Sequence container, please refer to the following documents:
http://www.mssqltips.com/sqlservertutorial/220/scheduling-ssis-packages-with-sql-server-agent/
https://msdn.microsoft.com/en-us/library/ms139855(v=sql.110).aspx
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support -
How can I translate this from PL/SQL into embedded SQL!?
CURSOR TEMP1 is
SELECT emp.fname fname, emp.lname lname, emp.ssn, dname,emp.salary salary, emp1.fname supervisor_fname, emp1.minit supervisor_mdlname,emp1.lname supervisor_lname FROM employee emp, employee emp1,department d
WHERE emp.superssn=emp1.ssn(+) and emp.dno=dnumber order by ssn;
PNTR_TEMP1 TEMP1%ROWTYPE;
--calcualting values for the cursor TEMP1
for PNTR_TEMP1 in TEMP1 loop
fname:= PNTR_TEMP1.fname;
lname:= PNTR_TEMP1.lname;
ssn := PNTR_TEMP1.ssn;
dname:=PNTR_TEMP1.dname;
sup_name:=PNTR_TEMP1.supervisor_fname||' '|| PNTR_TEMP1.supervisor_mdlname||' '||PNTR_TEMP1.supervisor_lname;
salary := PNTR_TEMP1.salary;
n_deps:=0 ;
/* how can I translate this to embedded SQL...I'm using C++*/Hi,
you can follow this link to use cursor in Pro*c /C++
http://www.csee.umbc.edu/help/oracle8/server.815/a68022/sql.htm
Regards -
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 can I run beginddl in PL/SQL Developer
Here's my script:
begin
execute dbms_wm.beginddl('MyTable');
ALTER TABLE MyTable ADD NewColumn1 VARCHAR2(200)
execute dbms_wm.commitddl('MyTable');
end;
I got the following error:
ORA-06550: line 2, column 11:
PLS-00103: Encountered the symbol "DBMS_WM" when expecting one of the following:
:= . ( @ % ; immediate
The symbol ":=" was substituted for "DBMS_WM" to continue.
ORA-06550: line 3, column 3:
PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
( begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimi
What should I do then?
Thanks.in PL/SQL scripts you just omit the "execute". and for the SQL you need to put an execute before it.
so your script would be:
begin
dbms_wm.beginddl('MyTable');
execute immediate 'ALTER TABLE MyTable ADD NewColumn1 VARCHAR2(200)';
dbms_wm.commitddl('MyTable');
end;apart from that, you should be modifying MyTable_LTS in your DDL session.
regards,
Andreas -
How can I load this XML with sql loader ?
Hi,
Im try to load a XML file into a XML table:
Create table TEST of XMLTYPE;
XML file is something like this:
<!DOCTYPE list SYSTEM "myfile.dtd">
<list>
<item id = 1> lot of tags an info here </item>
<item id = 9000> lot of tags an info here </item>
</list>
I dont know how to exactly create an appropriate control file to my XML. All examples I saw in documentation are similar to this one:
this is an example control file
LOAD DATA
INFILE *
INTO TABLE test
APPEND
XMLTYPE (xmldata)
FIELDS
I dont know how to complete this control file. Can anyone help me ?
thank you!
Message was edited by:
pollopoleaWell I found this working code
LOAD DATA
INFILE *
INTO TABLE test APPEND
xmltype(xmldata)
FIELDS
ext_fname filler char(30),
xmldata LOBFILE (ext_fname) TERMINATED BY EOF
BEGINDATA
mifile.xml
mifile2.xml
mifile3.xml
the main diference I found is that when i use:
Insert into test values (XMLType(bfilename('XMLDIR', 'swd_uC000025127.xml'),nls_charset_id('AL32UTF8')));
tag <!DOCTYPE list SYSTEM "myfile.dtd"> is expanded
(I explain at DTD insertion and errors with long DTD entities
Now using sql loader the tag is not modified.
I dont know if is there any difference, between each case. did I lost performance?
Message was edited by:
pollopolea -
Can somebody help...
I have a procedure which takes parameter as IN OUT extended object type .Below is the example.
PROCEDURE p_save (example IN OUT xyz_obj)
my object type "xyz_obj" have elements with other object types also, and that itself have around 100 elements.
And when calling the above procedure for test purpose, how is it possible to pass partial elements of the object type rather than setting all unused elements to null.user13026549 wrote:
Can somebody help...
I have a procedure which takes parameter as IN OUT extended object type .Below is the example.
PROCEDURE p_save (example IN OUT xyz_obj)
my object type "xyz_obj" have elements with other object types also, and that itself have around 100 elements.
And when calling the above procedure for test purpose, how is it possible to pass partial elements of the object type rather than setting all unused elements to null.
It ISN'T possible. How could it be? Each attribute has to be set to something don't you think?
A common way to handle that is to define a public package variable that is an instance of the object type and has ALL elements set to null. As Odie suggested a custom constructor function can be used for that.
Then you create your procedure instance by starting with an instance of the package variable (where everything is null) and setting values for the attributes you need. -
How can I convert this small pl/sql block in a single query?
Hello,
I need to have a single SQL query which gives the same output as the following piece of code, which uses a cursor to iterate on the rows in order to get the informations I need:
declare
cursor c(p varchar2) is
select context_id, id, parent_id
from CONTEXT_CONTEXT
start with parent_id is null
and context_id = p
connect by prior id = parent_id
and context_id = p;
begin
for r in (select context_id from ALL_CONTEXTS where context_type in ('MYTYPE'))
loop
for j in c(r.context_id)
loop
-- I want to obtain the values of the following colums from a query:
dbms_output.put_line(j.context_id || ' ' || j.id || ' ' || j.parent_id);
end loop;
end loop;
end;
Additional informations:
CONTEXT_CONTEXT.context_id references ALL_CONTEXTS.id
CONTEXT_CONTEXT.id references ALL_CONTEXTS.id as well
CONTEXT_CONTEXT.parent_id references ALL_CONTEXTS.id as well
id is primary key of ALL_CONTEXTS
(context_id, id) is primary key of CONTEXT_CONTEXT
*/user10047839 wrote:
Unfortunately, the CONNECT_BY_ROOT is not supported by my version of the DB 9i.
SELECT context_id,
SUBSTR(
SYS_CONNECT_BY_PATH(context_id,'/'),
2,
INSTR(
SYS_CONNECT_BY_PATH(context_id,'/') || '/',
1,
2
) - 2
) AS parent_context_id
FROM CONTEXT_CONTEXT
START WITH parent_id IS NULL
AND context_id IN (
SELECT context_id
FROM all_contexts
WHERE context_type IN ('MYTYPE')
CONNECT BY PRIOR ID = parent_id
AND context_id = PRIOR context_id;SY. -
hi
create or replace procedure spSelgl(brcode varchar2, p_return_cur OUT SYS_REFCURSOR ) is
begin
open p_return_cur for select * from mytable
where col1=brcode;
end spSelgl;
how can I execute this query in sql plus ?
Regards
JoshHi,
Try this to execute your procedure :-
declare
v_brcode varchar2(20);
v_p_return_cur SYS_REFCURSOR;
begin
spSelgl(
brcode => v_brcode,
p_return_cur =>v_p_return_cur
end;
Thanks
Pavan Kumar N -
** URGENT** How can I loop this Unnamed procedure?
I have the following procedure
The total number of records is 10 million +.
I've limited the resultset to 80,000. How can I run this procedure in a loop for like 130 times.
I need to start this tonight and Have run out of time in developing a better way.
I tried a unix stript
#!/bin/ksh
let count = 3;
while count > 0;
do
sqlplus -s userid/password<<END
@sqluser6
quit
END
let count = count -1;
done
but it's not even working: error =
run_userupdate[2]: count: bad number
run_userupdate[2]: syntax error at line 5 : `<<' unmatched
My Code:
SET SERVEROUTPUT ON
DECLARE
CURSOR vt_mlr_cursor IS Select master_key, tn, user2 from vt_mlr Where user2 is not null
and line_medr is null
and line_aidr is null
and rownum < 80001;
USERFIELD VARCHAR2(100);
R_count NUMBER := 0;
Field1 VARCHAR2(20);
Field2 VARCHAR2(20);
key VARCHAR2(10);
phone VARCHAR2(11);
BEGIN
FOR vt_mlr_record IN vt_mlr_cursor
LOOP
BEGIN
key := vt_mlr_record.master_key;
phone := vt_mlr_record.tn;
USERFIELD := vt_mlr_record.user2;
Field1 := SUBSTR(vt_mlr_record.user2,12,4);
Field2 := SUBSTR(vt_mlr_record.user2,28,4);
UPDATE vt_mlr
SET
line_medr = Field1,
line_aidr = Field2
WHERE
master_key = vt_mlr_record.master_key;
R_count := R_count + 1;
EXCEPTION
when others then
Insert into temp_reject (REJECT_KEY, REJECT_TN, REJECT_VALUE) VALUES
(key, phone, 'USER2 ' || USERFIELD );
R_count := R_count - 1;
END;
END LOOP;
DBMS_OUTPUT.PUT_LINE('Rows Processed: ' || R_count);
commit;
EXCEPTION
when others then
DBMS_OUTPUT.PUT_LINE('Error code ' || sqlcode || ' Error desc' || SUBSTR(sqlerrm,1,200));
END;
Thanks guysIs there any reason why you can't just run this:
UPDATE vt_mlr
SET line_medr = SUBSTR(user2,12,4)
, line_aidr = SUBSTR(user2,28,4)
/It's not a big update statement, and of the top of my head shouldn't generate more than 100 MB of undo (my maths is world-famous for its dodginess so YMMV).
If you've got 10 million row tables then your DBAs ought to have sized the rollback segments accordingly (even better if you're using the 9i UNDO tablespace).
Large tables are nothing to be scared off. Apart from anything else, you procedure is going to run like a three-legged dog in a vat of cold treacle.
Cheers, APC -
How can I execute external application?
Hi friends I want printing my barcodes a laser printer (Kyocera) it isn't a barcode printer. So I think (and I look kyocera web page my model doesn't support barcode printing in sap) print my barcodes using an external system. Before SAP we are using JollyPrint application for printing barcodes. It is using an Excel file.
I can create a excel file for this application. I must execute this (JollyPrint-it is a label application) application when I press a button. How can I execute this application?
Thanks
Mehmet
P.S. I have been writing this message with details may be somebody can give me a simple way for thisWell, I can suggest you following steps. May be it works for you .
-Create an external OS command in SM69
-Test OS command in SM49 ( <u><i>about OS command if you search in SDN youll get lot of material</i></u> )
-Create a Script at your OS level, Im assuming you might have some UNIX flavor or Sun solarias.
-Create a Shell script , which execute the printer job from OS .
-Shell script will have parameters . ( e.g. printer name, destination etc )
-set the path of shell script directory in SM69 ( the command you just created )
-Execute shell script using your ABAP program ( use FM "SXPG_COMMAND_EXECUTE" )
In the ABAP program you can pass the parameters and execute the command from ABAP as a result your job will start printing on the required destination. Moreover, you can also capture the spool at OS level .
FYI
For UNIX script, if you search in www.google.com ( UNIX forums) . youll get shell script .
Hope thisll give you idea!!
<b>P.S award the points.</b>
Good luck
Thanks
Saquib Khan
"Some are wise and some are otherwise" -
How can i execute trigger from procedure
Hi
How can i execute trigger when-button-pressed from procedure.
I knew i have to get the button name and then execute the trigger When-button-pressed.
but how can i do that.
Thanks
nullhow can i execute trigger
such as When-Button-Pressed on item name "item1"
and i have more than one trigger with this name on onther
items
i know Execute_Trigger('when-button-pressed');
but any trigger
for example :
Execute_Trigger('Item1.when-button-pressed');
or
Execute_Trigger('Item2.when-button-pressed');
or
other syntax
i dont know
please help me
my email : [email protected]
Hani -
How can I get this thru SQL ?
Hi,
I am having following sample data
NUMRUB FORMAT
1 X(02)
2 9(02)
3 9(08)
4 X(20)
5 9(01)
6 X(03)
7 9(1)
8 X(02)
9 9(02)
I want output in following way
NUMRUB FORMAT NewFormat Start Position
1 X(02) 2 1
2 9(02) 2 3
3 9(08) 8 5
4 X(20) 20 13
5 9(09) 9 33
6 X(03) 3 41
7 9(1) 1 44
8 X(02) 2 45
9 9(02) 2 47
How can I get this thru SQL ?
Pl guide me.
thanks & regards
PJPSQL> create table mytable (numrub,format)
2 as
3 select 1, 'X(02)' from dual union all
4 select 2, '9(02)' from dual union all
5 select 3, '9(08)' from dual union all
6 select 4, 'X(20)' from dual union all
7 select 5, '9(09)' from dual union all
8 select 6, 'X(03)' from dual union all
9 select 7, '9(1)' from dual union all
10 select 8, 'X(02)' from dual union all
11 select 9, '9(02)' from dual
12 /
Tabel is aangemaakt.
SQL> select numrub
2 , format
3 , to_number(regexp_replace(format,'(X|9)\((.*)\)','\2')) "NewFormat"
4 , nvl
5 ( sum(to_number(regexp_replace(format,'(X|9)\((.*)\)','\2')))
6 over (order by numrub rows between unbounded preceding and 1 preceding)
7 , 0
8 ) + 1 "Start Position"
9 from mytable
10 order by numrub
11 /
NUMRUB FORMA NewFormat Start Position
1 X(02) 2 1
2 9(02) 2 3
3 9(08) 8 5
4 X(20) 20 13
5 9(09) 9 33
6 X(03) 3 42
7 9(1) 1 45
8 X(02) 2 46
9 9(02) 2 48
9 rijen zijn geselecteerd.Regards,
Rob. -
[SQL] how can i get this result....??(accumulation distinct count)
Hi everybody,
pls tell me how can it possible to get result?
### sample data
date visitor
10-01 A
10-01 A
10-01 B
10-01 B
10-01 C
10-01 C
10-02 A
10-02 C
10-02 C
10-02 D
10-02 D
10-03 B
10-03 B
10-03 B
10-03 A
10-03 A
10-03 F
10-04 A
10-04 A
10-04 F
result that i want...like this.
date date_unqiue_visitors acc_date_unique_visitors
10-01 3 3
10-02 3 4
10-03 3 5
10-04 2 5
date distinct visitors : count(distinct visitor)
but how can i get accumulation distinct visitor count???
Thanks to every body..SQL> select dt,cnt,sum(cnt1) over(order by dt) cnt1
2 from(
3 select dt,count(distinct visitor) cnt,sum(flg) cnt1
4 from
5 (select dt,visitor,(select decode(count(*),0,1,0)
6 from test
7 where rowid < t.rowid
8 and visitor = t.visitor) flg
9 from test t)
10 group by dt);
DT CNT CNT1
10-01 3 3
10-02 3 4
10-03 3 5
10-04 2 5
Message was edited by:
jeneesh
Wrong... -
How can I execute an external program from within a button's event handler?
I am using Tomcat ApacheTomcat 6.0.16 with Netbeans 6.1 (with the latest JDK/J2EE)
I need to execute external programs from an event handler for a button on a JSF page (the program is compiled, and extremely fast compared both to plain java and especially stored procedures written in SQL).
I tried what I'd do in a standalone program (as shown in the appended code), but it didn't work. Instead I received text saying the program couldn't be found. This error message comes even if I try the Windows command "dir". I thought with 'dir' I'd at least get the contents of the current working directory. :-(
I can probably get by with cgi on Apache's httpd server (or, I understand tomcat supports cgi, but I have yet to get that to work either), but whatever I do I need to be able to do it from within the button's event handler. And if I resort to cgi, I must be able to maintain session jumping from one server to the other and back.
So, then, how can I do this?
Thanks
Ted
NB: The programs that I need to run do NOT take input from the user. Rather, my code in the web application processes user selections from selection controls, and a couple field controls, sanitizes the inoputs and places clean, safe data in a MySQL database, and then the external program I need to run gets safe data from the database, does some heavy duty number crunching, and puts the output data into the database. They are well insulated from mischeif.
NB: In the following array_function_test.pl was placed in the same folder as the web application's jsp pages, (and I'd tried WEB-INF - with the same result), and I DID see the file in the application's war file.
try {
java.lang.ProcessBuilder pn = new java.lang.ProcessBuilder("array_function_test.pl");
//pn.directory(new java.io.File("K:\\work"));
java.lang.Process pr = pn.start();
java.io.BufferedInputStream bis = (java.io.BufferedInputStream)pr.getInputStream();
String tmp = new String("");
byte b[] = new byte[1000];
int i = 0;
while (i != -1) {
bis.read(b);
tmp += new String(b);
getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + tmp);
} catch (java.io.IOException ex) {
getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + ex.getMessage());
}Hi Fonsi!
One way to execute an external program is to use the System Exec.vi. You find it in the functions pallet under Communication.
/Thomas
Maybe you are looking for
-
I HAVE FIREFOX VERSION 17 IN MY LAPTOP. On logging it straight logs to yahoo but there after it cannot log to any website. After searching for some time it says time over . Please hepl
-
Now that I've installed my new windows CS6, all my .psd files have the 'generic icons' windows give to files they don't recognize. Everything else has normal icons (i.e. Illustrator files) but the Photoshop files are blank. This is true whether I'm
-
Ipod to Stereo- Low Volume from Receiver
I have connected my Ipod to my stereo receiver (Pioneer VSX-1015Tx) using a Monster Ipod to RCA. I have tried using various inputs on the receiver, but in each I have to crank up the volume to get a good sound. Does the Ipod need an amplifier? Does a
-
I would like to know where I can find the element names used in SRM containers so as I can retrieve the values using swc_get_element, etc. Thanks Cindy Sy
-
ok so im havin trouble with my ipod, i think it started happenin when i upgraded to itunes 7, the folder icon now shows up on my ipod and the pod isn't recognised by my pc or itunes, updater wont work it keeps tellin me to update using itunes, which