Procedures with the return statement
Hi all
I know that you can include a return statement in the procedure, but without value, but I can't imagine how it works,
could you give me an example and demonstrate the problem for me
Thanks in advance
Any reason you not try? There is no need to imagine anything, since you can always download Oracle on your local machine and try it.
CREATE PROCEDURE dont_do_this AS BEGIN RETURN; dbms_output.put_line( 'This line will never be reached' ); END;
Justin
Tags: Database
Similar Questions
-
Can someone help me create a procedure with the DML statements that insert values from 1 to 100 in a table "abc" and the procedure must connect the numbers into words in another table "xyz" without doing a commit explicitly. "."
Currently on trial...
SQL > create table abc (num number);
Table created.
SQL > create table xyz (num varchar2 (100));
Table created.
SQL > ed
A written file afiedt.buf1. insert all
2 values of 1 = 1 then in abc (num) (l)
3 when the values of 1 = 1 then in xyz (num) (to_char (to_date(l,'j'), 'jsp'))
4 * Select the level from dual connect by level<=>=>
SQL > /.200 rows created.
And the result...
SQL > select * from abc;
NUM
----------
1
2
3
4
5
6
7
8
9
10
11
12
..
..
..
98
99
100100 selected lines.
SQL > select * from xyz;
NUM
----------------------------------------------------------------------------------------------------
one
two
three
four
five
six
seven
eight
nine
ten
Eleven
twelve
..
..
..
98
Nineteen eighty
Cent100 selected lines.
-
CALL THE PROCEDURE IN THE SQL STATEMENT
Why we cannot call a procedure inside the SQL statement?Hello
Usually when you select an item should return you data. In the case of a procedure, you cannot return any return value from the procedure directly it has to be done through some settings and to access these settings, you cannot use a simple sql statement. Where as in a function, you must return one of data that can be easily obtained accordingly.
see you soon
VT
-
Why I can't use the procedure in the select statement
Why I can't use the procedure in the select statementAnd you may not usa a SQL function if it has out parameters
SQL> create function myfun(p1 in out number) return number is 2 begin 3 p1:=1; 4 return 2; 5 end; 6 / SQL> select myfun(5) from dual; select myfun(5) from dual * ERRORE alla riga 1: ORA-06572: Function MYFUN has out arguments
In fact, the problem is that an output parameter is passed 'ref' and not 'val '...
Max
-
problem with writing a procedure with the name of the table as an input parameter
Hi all
I am writing a procedure with the table name as input parameter:
Here is the code
create or replace procedure CEP (in_tbl in varchar2)
as
Start
run immediately 'truncate table tlb;
Insert into tbl
Select a, b, c of in_tbl;
end;user579585 wrote:
Hi allI am writing a procedure with the table name as input parameter:
Here is the codecreate or replace procedure CEP (in_tbl in varchar2)
as
Startrun immediately 'truncate table tlb;
Insert into tbl
Select a, b, c of in_tbl;
end;
You will also need to use dynamic sql for insert statements:
execute immediate 'begin insert into tbl select a,b,c from '||in_tbl||'; end';
-
Can we call a procedure in the select statement?
Can we call a procedure in the select statement?Hello
Raghu_appsdba wrote:
Can we call a procedure in the select statement?# You can call functions, but not procedures.
If the procedure does not change the State of the database (for example, it isn't updated all tables), then you can wrap it in a function, or re - write function.
Here is an example of wrapping.
CREATE OR REPLACE FUNCTION fun_x (in_txt IN VARCHAR2) RETURN VARCHAR2 IS BEGIN proc_y (in_txt); RETURN in_txt END fun_x;
-
need help with the Update statement
Hello
I received a question in a course and I tried my best to respond, and now my brain is giving. I would really appreciate help with the update statement. I don't mind if you do not validate a solution, a little nudge in the right direction would be really useful. I'll post that I got.
THE QUESTION
/ * For these agents disabled on more than seven missions, change their date of deactivation of the first date of deactivation of all the agents that have been activated in the same year as the agent that you update currently.
*/
I have it divided into parts, here is my select statement to agents disabled on more than 7 missions, which produces the deactivation_dates in the agents table that I want to update...
.. .and the code for the first date of deactivation for each year of activation agentSELECT s.deactivation_date FROM ( SELECT a.deactivation_date, count(m.mission_id) as nomissions FROM agents a INNER JOIN missions_agents m on a.agent_id=m.agent_id GROUP BY a.deactivation_date ) s WHERE s.nomissions>7 AND s.deactivation_date IS NOT NULL
..... I am not real to marry these two statements together in the Update statement. I can't extract each date of deactivation produced in the first select statement and their match against the first date of deactivation in the year they have been activated for the second select statement.select a2.deactivation_date from agents a2 where a2.deactivation_date= ( select min(a.deactivation_date) from agents a where to_number(to_char(a.activation_date,'YYYY'))=to_number(to_char(a2.activation_date,'YYYY')) )
Any help greatly appreciated... :))I began to wonder how things would :)
user8695469 wrote:
First of all why he chooses the date the earliest of all agentsUPDATE AGENTS_COPY AC /* (1) */ SET DEACTIVATION_DATE = ( SELECT MIN(AGS.DEACTIVATION_DATE) FROM AGENTS_COPY AGS , AGENTS_COPY AC /* (2) */ WHERE TRUNC(AGS.ACTIVATION_DATE,'YEAR') = TRUNC(AC.ACTIVATION_DATE,'YEAR') /* (3) */ )
He recovers as soon as the subquery has not been correctly set in the SET clause. It seems you are trying to update a correlated, but we are still having a conceptual shift. I have added a few comments to your code above and below will explain.
(1): when you do a correlated update it is useful to the table alias that you did right here.
(2): this table statement is not necessary and is the reason why the FIRST deactivation date is selected. The alias that you use (3) refers to THIS table, not the one defined in the update statement. Remove the line indicated by (2) in the FROM clause and a correlated update will happen.
and secondly why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)
user8695469 wrote: then why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)
WHERE EXISTS ( SELECT a.agent_id, count(m.mission_id) FROM agents a /* INNER JOIN AC ON AC.AGENT_ID = A.AGENT_ID */ INNER JOIN missions_agents m ON a.agent_id=m.agent_id GROUP BY a.agent_id, a.deactivation_date HAVING count(m.mission_id)>7 AND a.deactivation_date IS NOT NULL )
Once again this problem is similar to the question above that a correlation update doesn't work. Test existence of lines in an EXISTS subquery. Since your subquery is not related to the table that you are trying to update, it will be always return a line and, therefore, it returns true for EACH LINE in the AGENTS table. To limit the game to only agents > 7 missions results, you need to add a join condition that references the table in your update statement. I added one above (with comments) as a sample.
I recommend you look over all material that you have associated with correlated subqueries, including documents that I posted above. This seems to be what you're having the problem more with. If you need me to explain the concept of correlated queries any better please let me know.
Thank you!
-
Until the latest update when the url I wanted in the address bar of AutoComplete has been selected, it "accompanies" no more further by clicking on. I must now click the refresh arrow. It won't work even with the return. How can I operate the old way easier?
You can disable this extension in tools > Modules > Extensions and close and restart Firefox normally.
-
Hello! I got this message from malware (I clicked to delete) in surfing on firefox and after awhile the explorer.exe closes with an error. I try to open the Task Manager and it says explore cannot be found!
I rebooted and then I got this message "0xC000021A {fatal system error}, the initial session process or the process of the complete system in unexpected ways with the blocking state 0 x 00000000 (0xc0000034 0x001008ac) the system has been halted" and can't get anywhere.
I can't even go in safe mode, the same error messages appears.Hi James,
You could try the Startup Repair to see if it solves the problem:
http://Windows.Microsoft.com/en-us/Windows-Vista/startup-repair-frequently-asked-questions
Chris
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think. -
I try and install the SK and it fails for Web and ISO Setup > DVD drive. Same error every time:
12:22:50 Wednesday, July 11, 2012: C:\Program Files\Microsoft SDKs\Windows\v7.1\Setup\SFX\vcredist_x64.exe install failed with return code 5100
The following lines are less useful because they suggest to go to a place that I did not.
12:23:21 Wednesday, July 11, 2012: [SDKSetup:Error] Config_Products_Install: product Installation Microsoft Windows SDK for Windows 7 (failure): Please refer to Samples\Setup\HTML\ConfigDetails.htm document for more information. Fireplace: In SDKSetup.Product.ConfigureRelatedSfx () at SDKSetup.Product.ConfigureNewProduct (ManualResetEvent CancelEvent)
12:23:21 Wednesday, July 11, 2012: [SDKSetup] Config_Products_InstallNew: complete the installation of the new product: Microsoft Windows SDK for Windows 7
12:23:21 Wednesday, July 11, 2012: [SDKSetup:Error] Config_Products_Install: software Windows (failed) SDK installation: Installation of the product 'Microsoft Windows SDK for Windows 7' reported the following error: Please refer to Samples\Setup\HTML\ConfigDetails.htm document for more information. Fireplace: SDKSetup.Product.ConfigureNewProduct (ManualResetEvent CancelEvent) at SDKSetup.Product.SetupProduct (TaskMode taskMode, ManualResetEvent CancelEvent) at SDKSetup.ProductCollection.SetupProducts (TaskMode taskMode, believing believing, ManualResetEvent cancelEvent) to the SDKSetup.ConfigProducts.DoCurrentTask (Group TaskMode)Any ideas what could be worng? The rest of the log file is too big for this message but I can send it to someone who can help.
Hello
I suggest you try the steps listed from the link below,
Windows SDK fails to install with the return Code 5100
-
Help with the insert statement
Hello
I was wondering if someone could help write me a sql statement.
Here is my table:
Here are the instructions for correct insertion. This time, I posted 2 examples with 2 numbers different otherwise.CREATE TABLE "TEMP_INVOICE" ("INVOICE" VARCHAR2(100 BYTE), "DATE_OF_DOCUMENT" DATE, "DATE_OF_PAY_DAY" DATE, "D" NUMBER, "K" NUMBER );
I want to do is make an insert allows you to table another call is MADE:insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (1000,to_date('01.02.2012','dd.mm.yyyy'),to_date('01.03.2012','dd.mm.yyyy'),5000,0); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (1000,to_date('01.04.2012','dd.mm.yyyy'),'','',1000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (1000,to_date('01.05.2012','dd.mm.yyyy'),'','',3000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (1000,to_date('01.06.2012','dd.mm.yyyy'),'','',1000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (2000,to_date('01.07.2012','dd.mm.yyyy'),to_date('01.09.2012','dd.mm.yyyy'),8000,0); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (2000,to_date('01.10.2012','dd.mm.yyyy'),'','',5000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (2000,to_date('01.11.2012','dd.mm.yyyy'),'','',2000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (2000,to_date('01.12.2012','dd.mm.yyyy'),'','',1000);
Statements in the INVOICE table should be like this:CREATE TABLE "INVOICE" ("INVOICE" VARCHAR2(100 BYTE), "DATE_OF_DOCUMENT" DATE, "DATE_OF_PAY_DAY" DATE, "DATE_OF_PAYMENT_REC" DATE, "VALUE" NUMBER, "VALUE_DEDUCT" NUMBER, "DATE_FROM" DATE, "DATE_TO" DATE );
........ The Bill... date_of_document... date_of_pay_day... date_of_payment_rec... value... value_deduct... Date_from... Date_to
1...... 1000...............1.1.2012.................1.3.2012................NULL............................ 5000... NULL... 1.3.2012...1.4.2012
2...... 1000...............1.4.2012.................NULL..................... 1.4.2012...1000... 4000... 2.4.2012... 1.5.2012
3...... 1000...............1.5.2012.................NULL..................... 1.5.2012...3000... 1000... 2.5.2012... 1.6.2012
4...... 1000...............1.6.2012.................NULL..................... 1.6.2012...1000
Can someone help me with the sql statement that would insert data from table to table Bill temp_invoice as in the example?
Thank you!
PS
I would try to explain.
(1) the first statement that is to be inserted is original imply that at which is different DATE_OF_PAY_DAY to NULL.
To this inserted negative of the original imply, we must add date_from that is exatly the same date_of_pay_day and date_to which is exactly the same as the date of the first payment. Payment which came first!
(2) we have now in the second insert statement. It will be the first payment of lease with date_of_document and date_pf_payment_rec, which is the same as date_fo_document. Value field will be populated with the amount of payment received and value_deduct field will be the value of the original imply - value of the first payment. Date is date_of_document + 1 and date_to is the date of the next payment.
(3) Insert us the next installment. Date_od_payment_rec is the same as date_of_document... value is the amount of the second payment and value_deduct's previous value_deduct which was of 4000 - value of this second payment. date_from date_of_payment_rec + 1 and date_to is the date of the next payment
So we continue this same pattern until we reached the final payment when we finish insert with the statement:
Date of the document (date of the last payment received) and even for date_of_payment_rec and field value with the amount of the payment receieved. The rest (value_deduct, date_from, date_to) is null.
I really hope you understand what I'm trying to do here.
If you have any other questions please.
Published by: user13071990 on November 22, 2012 04:16
Published by: user13071990 on November 22, 2012 04:16Hello
user13071990 wrote:
... Here are the instructions for correct insertion. This time, I posted 2 examples with 2 numbers different otherwise.Ok!
Be sure to post the results you want new data.You probably need to add "PARTITION BY the Bill" to all analytical clauses in my solution:
INSERT INTO invoice ( invoice, date_of_document, date_of_pay_day, date_of_payment_rec , value, value_deduct, date_from, date_to ) SELECT invoice , date_of_document , date_of_pay_day , CASE WHEN k > 0 THEN date_of_document END AS date_of_payment_rec , NVL (d, k) AS value , NVL2 ( date_of_pay_day , NULL , SUM (d) OVER ( PARTITION BY invoice ORDER BY date_of_document ) - SUM (k) OVER ( PARTITION BY invoice ORDER BY date_of_document ) ) AS value_deduct , NVL ( date_of_pay_day , date_of_document + 1 ) AS date_from , LEAD (date_of_document) OVER ( PARTITION BY invoice ORDER BY date_of_document ) AS date_to FROM temp_invoice ;
Because I'm not an English speaker nativ, that I just posted what it should look like after the insert is successful.
OK, so you can't explain as you want, but you still need to explain.
... @Frank Kulash: you are very close, but still not quite what I'm looking for.
Point out where my solution is the production of incorrect results, and explain (as you can) how to get good results in these places.
-
How the parameter of the procedure with the default table type?
Hello!
How the parameter of the procedure with the default table type?
For example:type varchar2lType is table of varchar2(50) index by binary_integer;
Published by: bullbil on 16.01.2012 06:35create or replace procedure test1 ( s1 varchar2(50) sa2 Varchar2Type ) as begin dbms_output.put_line('yyxxyyy!'); end; /
If he should really be an associative array for some reason any (can't think why, but just for fun...) you could declare a dummy array in the packet header and specify as the default:
create or replace package wr_test as type varchar2ltype is table of varchar2(50) index by pls_integer; g_dflt_varchar2l_tab varchar2ltype; procedure testit ( p_testarray varchar2ltype default g_dflt_varchar2l_tab ); end wr_test; create or replace package body wr_test as procedure testit ( p_testarray varchar2ltype default g_dflt_varchar2l_tab ) is begin dbms_output.put_line('p_testarray contains ' || p_testarray.count || ' elements'); end testit; end wr_test;
It is a bit of a hack, because it relies on a global variable that is exposed. A more orderly approach would overload the procedure so that a version does not have the table and another argument:
create or replace package wr_test as type varchar2ltype is table of varchar2(50) index by pls_integer; procedure testit; procedure testit ( p_testarray varchar2ltype ); end wr_test; create or replace package body wr_test as procedure testit is v_default_array varchar2ltype; begin testit(v_default_array); end testit; procedure testit ( p_testarray varchar2ltype ) is begin dbms_output.put_line('p_testarray contains ' || p_testarray.count || ' elements'); end testit; end wr_test;
-
DatabaseProcedure with the return type preceded of the schema name
Salvation (Paco)
I have a question on the DatabaseProcedure class. We use proxy Oracle users to our database connections.
Everything is accessible via a role of database that are granted to the user. All of our database objects, tables, etc. are protected by this database role.
When I want to call a function/procedure of database, I need to add the name of the schema as a prefix to the custom database object that uses us for parameters and return types.
So far so good. I can also define a parameter prefixed by the name of schema via the DatabaseProcedure.registerArrayType...
But when I try to set a function call that uses this parameter I get an error saying "the statement is not valid.
The problem is the regular pattern of PROCEDURE_DEFINITION:
The return type cannot be prefixed by the name of schema.private static final Pattern PROCEDURE_DEFINITION = Pattern.compile("\\s* (FUNCTION|PROCEDURE) \\s+ ([\\w.$]+) \\s* (?:\\((.*?)\\))? \\s* (?:RETURN\\s+(\\w+))? \\s* ;? \\s*", CASE_INSENSITIVE | COMMENTS | DOTALL);
Any good suggestions or workarounds?
I have actually change the duration of reflection model to make it work-, but I really don't like this solution over the long term.
/ Torben
Published by: Zonic 2013-05-07 10:52Hi Torben,
I think that I have a work around for the problem which might work for you. If you look at the source of DatabaseProcedure.registerArrayType you will find that it is actually called DatabaseProcedure.registerCustomParamType.
public static void registerArrayType(String name) { registerCustomParamType(name, Types.ARRAY, Array.getORADataFactory(), name); }
A solution you can replace calls to DatabaseProcedure.registerArrayType with calls to DatabaseProcedure.registerCustomParamType as follows.
// Instead of DatabaseProcedure.registerArrayType("NAME.WITH.DOTS") call: DatabaseProcedure.registerCustomParamType("anyNameWithoutDots", Types.ARRAY, Array.getORADataFactory(), "NAME.WITH.DOTS"); // Don't forget to use uppercase here. DatabaseProcedure dp = DatabaseProcedure.define("procedure my.procedure(param1 in out anyNameWithoutDots)"); DatabaseProcedure.ParamType type = dp.getParamDef(0).getType(); System.out.println(type.getName() + " is " + type.getTypeName()); // ANYNAMEWITHOUTDOTS is NAME.WITH.DOTS
In this way, that you don't have to use the 'illegal' name in the definition of DatabaseProcedure.
Kind regards
Paco van der Linden -
Procedure with THE parameters - creating a report
I have the following procedure which is used in our applications (non-APEX) internal:
The body of the procedure made a lot of treatment and inserts data into an intermediate table. The cursor ON the parameter then returns a SELECT statement in the staging table. Since it is possible that this procedure be struck several times (several users), transaction ID is used to match the data in the staging table to demand appropriate. The procedure then deletes the data from the staging table. (I'll post if necessary, but it is quite long, and since it is used successfully in other applications, I don't think it relates to my question).PROCEDURE SelIssueActivityPublic ( p_results OUT SYS_REFCURSOR, p_IssueID IN ems.issue.issue_id%TYPE, p_TransactionID OUT VARCHAR2 )
Asked me to create a report of the APEX data generated by the procedure. I've never used a procedure with an OUT parameter to create a report. I was hoping to assign transaction ID to a variable hidden on the loading of the page and then use it to poplulate the report. I'm not interested in the OUT parameter slider, I wrote my own SELECT statement to retrieve the data from the staging table.
I tried to create a page that did that - agenda: H_P19_TRANSID, before the header calculation = EMS. EMS_READER. SelIssueActivityPublic (: H_P19_CURSOR, 454551,: H_P19_TRANSID) [454551 is a test question id], but I get the following error:
He seems to think that SelIssueActivityPublic is a function, and I don't know why.ORA-06550: line 1, column 43: PLS-00222: no function with name 'SELISSUEACTIVITYPUBLIC' exists in this scope ORA-06550: line 1, column 7: PL/SQL: Statement ignored flowComp=H_P19_TRANSID Error ERR-1030 Error executing computation expression.
Basically, I need to know how to use this procedure to put up my report. Once I can enter the transaction ID in a page element, I'll be set.How your procedure? You know that you can have the same procedure in the package with several definitions. Oracle allows you to use polymorphism, the ability to have multiple definitions of the same object with different signatures.
Correction... You can not have a procedure of p in the case, are a function, since the calculation is expected to a way to fill the hidden element... You need a function to return the type of variable you want in the hidden element...
Thank you
Tony Miller
Webster, TXPublished by: Tony Miller on March 16, 2010 12:34
-
Module MDS 9513-48 ports with the 'Suspended' State Bootflash
Hi team
We have a module in our Director of Cisco MDS9513 as below with bootflash State "suspended".
Module; DS - X 9248-96 k 9
Switch MDS 9513 (13 Slot)
Firmware: 5.0 (4B)
Is it possible online to change the State to return to the 'race' bootflash without reseating the module?
Appreciate your quick response in this regard
Status of frequency test action
-----------------------------------------------------------------
Bootflash 10s suspension allowed
5 active EOBC sec race
Loopback active Running 5 sec
AAGR 1 day active Running
-----------------------------------------------------------------
Hi Anand,
It is an indication that bootflash failed on the line card and the line card needs to be replaced.
If the line card is now in place and that you reinstall / reload it, I would expect the next State to be 'off' because the card online is unable to load the firmware. You should leave it until you can have it replaced.
Best regards
Jim
Maybe you are looking for
-
Sometimes the work email server fails. There are a lot of problems in the it Department at work and I'm afraid I might lose all my emails. Can I download all my emails so that in the event of a failure of server to work or even if IT guys delete my a
-
I see many questions about Courier font size but I can't find all the answers.
The font size of the headers of mail (subject) is small enough to be unreadable with any magnification.
-
Cannot install Adobe flash player el capitan
I couldn't watch HULU shows and had msg to Adobe flash player upgrade. I downloaded llatest version, browser closed, you click on install. It's never got to username login (verify) and p/w screen. I had to force quit. It has been suggested to uninsta
-
How can I download a file over 15 concerts on iCloud drive?
It seems it should be easy - but it seems impossible
-
XW4400: installation of XP in xw4400 with RAID 1
Hello We are trying to install Windows XP in the workstation HP xw4400 with RAID 1. Change the BIOS settings and confgigured RAID. But during installation of XP, the Setup program does not recognize the hard drive. We are able to install Windows 7, i