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 question
You 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
Similar Messages
-
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 -
How do you run Adobe Reader with New Lions
How do you run Adobe Reader with New Lions?
Lion has Preview, you may not need Adobe Reader.
Preview Help
View your images and PDF documents, touch them up, annotate them, and share your comments.
Regards,
Colin R. -
How to use union statement with declare & set function?
Hi Experts,
i have small query about how to use union statement with declare & set function?
Example as below :
DECLARE @name AS date
Declare @name2 AS date
/* SELECT FROM [2013].[dbo].[OINV] T0 */
/* WHERE */
SET @name = /* T0.DocDate */ '[%1]'
SET @name2 = /* T0.DocDate */ '[%2]'
select '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2013.dbo.orct t1
inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2013.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]
Union
/* SELECT FROM [2014].[dbo].[OINV] T0 */
/* WHERE */
SET @name = /* T0.DocDate */ '[%1]'
SET @name2 = /* T0.DocDate */ '[%2]'
select '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2014.dbo.orct t1
inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2014.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]You have to create stored procedure in SQL only .
Like u must have create for Crystal .
You can execute procedure in query manager but you have to enter parameter manually..
example
Exec @Test '20140101' '20140501'
Every time user has to enter it manually in yyyymmdd format in case of date parameters.
Example
Create Proc [@Test]
as begin
DECLARE @name AS date
Declare @name2 AS date
/* SELECT FROM [2013].[dbo].[OINV] T0 */
/* WHERE */
select '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2013.dbo.orct t1
inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2013.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between @Name and @Name2
Union
/* SELECT FROM [2014].[dbo].[OINV] T0 */
/* WHERE */
select '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2014.dbo.orct t1
inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2014.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between
between @Name and @Name2
end -
How can i import procedure with %ROWTYPE in Oracle 10.2 (paris) warehouse b
Hello.
How can i import procedure with %ROWTYPE in Oracle 10.2 (paris) warehouse builder?Everytime i try to do it i get an error message:
API0411: Name should be an empty string.
If i comment out %rowtype i can import it without problems.
I have tried re-creating the procedure in OWB but once again i cannot find the %rowtype anywhere. the %type is there etc. I have tried to use Publish transformation / custom and cannot find %rowtypa there either.
Thank you very much for your helpJust in case you are having the same problem and cannot find any help anywhere - it is a bug in OWB.
I got in touch with Oracle Support and it appears that it is possible to import procedure/package with %ROWTYPE inside it, but it is not possible if the %ROWTYPE is in the arguments.
Just waiting for them to provide me with the bug ID. -
How can I run MP350 with Windows 8.1 computer?
It works OK with Windows 7 machine, using drivers from original CD.
Windows 8,1 machine doesn't find those drivers (which I copied to its C drive).
It doesn't find needed drivers on the internet.Hi Larry-R,
I see that you made a later post regarding this. Please refer to the answer on that post regarding your inquiry.
Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well. -
How do you run apps on creative cloud? I can't seem to run them or see them on my desktop
How do you run apps on creative cloud? I can't seem to run them or see them on my desktop
Hi JasonLuong,
You will have to go to www.creative.adobe.com and login with your Adobe Id on which you have purchased the subscription.
You can go to the download center and then start downloading all the cc apps available. It will first download and install the Creative cloud desktop tool in your computer. This creative cloud desktop will show you the option to download all the CC programs, the updates, etc.
Thanks
Kapil Rupani -
How do you synch iCalendar with iCloud?
How do you synch iCalendar with iCloud?
I cannot get my father's Calendar data to transfer via iCloud to his iPad. His Mac is running 10.7.2, and the iPad is running OS 5.0.1 (I think, at least it is OS 5 for sure.) Everything else (Mail, Contacts, etc) is transferring, but not Calendar.Welcome to the Apple Community.
Check that both have calendar syncing enabled, also check that the calendars in iCal you are trying to sync are iCloud calendars and not on my mac calendars (click on the calendar button in the top left corner of iCal). -
How do you run a full virus scan
How do you run a full virus scan on the Imac
Take a look at this article:
http://en.wikipedia.org/wiki/Phishing
Running a virus scan would not help at all - someone got your email address and is now hoping you're dumb enough to use the links they provided and give them information so they can use your credit card or checking acount number, password, etc.
I would change my user name and password immediately (if not sooner!!) - make it difficult to guess. Do it at least with the bank involved; however, to be safe, it wouldn't hurt doing it with others as well. -
HT5246 How do you run the Flashback malware removal tool?
How do you run the Flashback malware removal tool?
ThanksI am away from my computer and it is somewhat awkward to reply on an iPad.
> I had already done what softwater instructed. I've read that it deletes itself on other threads, but it's still in my Finder as a Device. That's what confused me, because it doesn't appear to have deleted itself.
Sorry, I wasn't clear. That is not the tool. It is the .dmg image mounted to your desktop. Next to the name you will see a small eject icon. Click on it or highlight it and choose "Eject" from the appropriate Finder menu. Once that happens you can drag the .dmg file to the trash as it will not delete itself.
> I only recently upgraded to Snow Leopard and then Lion, in quick succession. My understanding is that there were (are) variants that would have infected my computer prior to my upgrading my OS to Lion. Before the upgrade, they were Adobe, but afterward they were Java. Could it be that be that the pop-ups were/are some other variant?
Difficult to say for certain. Apple says it deletes all the common variants but does not specify which and I haven't seen the results of any testing done to verify that it finds and deletes those. The only dialogs that appeared with the initial variants were for FlashPlayer. They are depicted in the descriptions for Flashback-A on F-Secures site if you want to take a look. There have been none that I am aware of for Java, so that is probably either a web page or application that needs Java to run giving you that alert.
> If the Flashback malware removal tool didn't find anything and my Software Update is current, does that mean the vulnerability has been fixed? At least for now? I understand that I Software Update will prompt downloads in the future if and when it needs to be patched again.
The vulnerability is in Java, nowhere else, so if you don't have it installed there was nothing to fix.
If you download Java in the future it will be the latest version Apple has available at the time, which hopefully will not be subject to exploitation, yet... -
How do you move itunes with playlists from one computer to another
how do you move itunes with playlists from a computer to ext hard drive, so it will play from the ext harddrive and not the computer
Type "move itunes library to external hard drive" into the google search bar.
-
How do you close programs with new iOS7? Old way doesn't seem to work!
How do you close programs with new iOS7? Old way doesn't seem to work!
After double tap home button, swipe up on the app card that appears above the icon.
-
HT4759 how do you update icloud with contacts transferred to Iphone by verizon
How do you update icloud with contacts transferred to Iphone by Verizon? The only contacts that show up in icloud are the ones I entered myself to the phone.
You'll need to copy them to iCloud in order to see them on your PC. To do this, do the following:
Go to Settings>iCloud, turn Contacts to Off, choose Delete from My iPhone when prompted (they will still be in iCloud).
Download the app My Contacts Backup. Use this to backup the remaining contacts on your phone (from Verizon) as a vCard attachment to an email that you send to yourself. Confirm that you have received the email.
Go to Settings>iCloud and turn Contacts back to On.
Open the My Contacts Backup email and tap the attachment to import the Verizon contacts back to your phone. They should now be in iCloud, and appear on your PC. You may see duplicate contacts on your phone because you are still viewing both the contacts from Verizon as well as the copies now in iCloud.
Open Contacts on your phone and tap Groups, tap the Groups that were imported from Verizon so they are unchecked and tap Done. This will hide them from view and illiminate the duplicates. -
Noob question... How do you familiarize yourself with a library?
I'm very new to Java and programming in general. but I am currently reading some beginner books for Java. From what I've read, libraries are nothing more than prewritten code which you can call to use in your programs. My question is how do you familiarize yourself with the libraries? With so many different libraries, how do you find out what they are capable of? Is is simply diving in it and analyzing the code? Can you create your own libraries? If so, what is the advantage of creating a library instead of baking the code right into the program? Why advantage do you have with referencing an outside file for code over having a self contained program?
Morisato13 wrote:
I'm very new to Java and programming in general. Welcome to the forums!
but I am currently reading some beginner books for Java. From what I've read, libraries are nothing more than prewritten code which you can call to use in your programs. Yes indeed. Why reinvent the wheel?
My question is how do you familiarize yourself with the libraries? Gradually.
With so many different libraries, how do you find out what they are capable of? The best way is by working through a good Java book.
Is is simply diving in it and analyzing the code? You can do that, too.
Can you create your own libraries?Yes.
If so, what is the advantage of creating a library instead of baking the code right into the program? 1. You can analyze it and test it separately.
2. You can reuse it separately.
Why advantage do you have with referencing an outside file for code over having a self contained program?Are you asking the same question, just with different wording? -
How do you shuffle genre with iOS7 on iPhone5?
How do you shuffle genre with iOS7 on iPhone5?
Turn the phone sideways - First make sure that landscape mode isn't locked by swiping up from the bottom to bring up Control Center and then the top right icon is Portrait lock.
Maybe you are looking for
-
A little help please as it's been years since I've done any coding of any sort. So I have a 4 page document with various field types. I have a document script that gets "TodaysDate" that works perfectly and a few other scripts as well. So what I'm t
-
Quicktime error that won't let me use iTunes
I have used an iPod video 60GB since Dec 2005 with Windows XP Pro. Recently, my Quicktime Pro began to show a failed codec type-thing when I would try to play a .mov. I uninstalled Quicktime Pro and attempted a reinstall but it will not allow me to i
-
Debugger wont trace source.
What the!? The Flex environment is great. Debugs well. I especially like the "Expressions" watcher. However, if I place my script code into files then the debugger ignores every break point in those files. For example, if I have a component and use t
-
Urgent...RFC FM not getting on the other system
I have 2 RFC in one Function Group. Other team is trying to access this FM's from NON -sap system. They are getting one FM on his system but not the other. What could be missing ... on R3 system or it must be import issue on Non-sap system
-
I recently upgraded my camera from Nikon D700 to D800. For two weeks tethering to LR 5.3 worked impeccably. The day before a major shoot I upgraded to newly released 5.4 which promised tether support for my backup camera, Nikon D 610, although 5.4 s