Required stored procedure
HelloI need to create a stored procedure based on the requirements of the customer. Any body can help me...
create table SAMPLE
(
WEB_LOGIN VARCHAR2(30),
WEB_PASSWORD VARCHAR2(30),
PWD_EXP_DT DATE
);
insert into SAMPLE (WEB_LOGIN, WEB_PASSWORD, PWD_EXP_DT)
values ('[email protected]', 'abc', to_date('10-12-2010', 'dd-mm-yyyy'));
insert into SAMPLE (WEB_LOGIN, WEB_PASSWORD, PWD_EXP_DT)
values ('[email protected]', 'abc', to_date('01-01-2011', 'dd-mm-yyyy'));
insert into SAMPLE (WEB_LOGIN, WEB_PASSWORD, PWD_EXP_DT)
values ('[email protected]', 'def', to_date('10-02-2011', 'dd-mm-yyyy'));
commit;
conditions
*********
if web_login = web_login and web_password = web_password and
sysdate - pwd_exp_dt > 180 days
message " your password has been expired"
if web_login = web_login and web_password = web_password and
sysdate - pwd_exp_dt > 165 days and sysdate-pwd_exp_dt <180 days then
message " your password has been expired very soon..pls update ur old password"
Please help me in this regard...!Concerning
SA
Hello
845299 wrote:
...create table SAMPLE ( ...
Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!
conditions ********* if web_login = web_login and web_password = web_password and
Is not web_login always equal to web_login (unless its NULL value)?
Did you mean you want to pass an argument to the procedure and test if argument equals web_login?
sysdate - pwd_exp_dt > 180 days message " your password has been expired" if web_login = web_login and web_password = web_password and sysdate - pwd_exp_dt > 165 days and sysdate-pwd_exp_dt <180 days then message " your password has been expired very soon..pls update ur old password"
I think that a function would be better than a procedure in this case. You probably want your front-end to display the message, and a function call is a logical way for the front-end information as necessary for the back-end.
Here's one way:
CREATE OR REPLACE FUNCTION password_warning
( in_web_login IN sample.web_login%TYPE
, in_web_password IN sample.web_password%TYPE
, in_check_dt IN DATE DEFAULT SYSDATE
)
RETURN VARCHAR2
IS
password_age NUMBER; -- Days from pwd_exp_date to in check date
return_txt VARCHAR2 (100); -- Message to be returned (may be NULL)
BEGIN
SELECT in_check_dt - pwd_exp_dt
INTO password_age
FROM sample
WHERE web_login = in_web_login
AND web_password = in_web_password;
IF password_age > 180
THEN
return_txt := 'Your password has expired.';
ELSIF password_age > 165
THEN
return_txt := 'Your password will expire very soon. Please change your password.';
END IF;
RETURN return_txt;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
RETURN NULL; -- Or return 'Incorrect web_login/password.'
END password_warning
;
/
SHOW ERRORS
This assumes that sample.web_login is unique.
Here's some code to test. In addition to your actual data, I made some incorrect data, to see what the function returns when you give a bad web_login or web_password.
WITH expanded_sample AS
(
SELECT web_login
, web_password
FROM sample
UNION
SELECT CASE
WHEN MOD (ROWNUM, 3) = 1
THEN web_login
ELSE '? ? ?'
END AS web_login
, CASE
WHEN MOD (ROWNUM, 3) = 2
THEN web_password
ELSE '? ? ?'
END AS web_login
FROM sample
)
SELECT web_login
, web_password
, password_warning (web_login, web_password) AS warning_now
, password_warning (web_login, web_password, DATE '2011-06-19')
AS warning_june_19
FROM expanded_sample
ORDER BY web_login
, web_password
;
Output:
WEB_LOGIN WEB_PASSWORD WARNING_NOW WARNING_JUNE_19
------------ ------------ -------------------------- --------------------------
? ? ? ? ? ?
? ? ? abc
[email protected] ? ? ?
[email protected] abc Your password will expire Your password has expired.
very soon. Please change
your password.
[email protected] def
[email protected] abc Your password will expire
very soon. Please change
your password.
As you can see, this function returns NULL when the password is aged less than 165 days, or when the web_login and/or the password does not match what is in the table. You can easily change this, if you wish, so that there is a separate message in each case.
You can encrypt the passwords in the table. Oracle provides a package for encryption, called dbms_crypto.
http://download.Oracle.com/docs/CD/B28359_01/AppDev.111/b28419/d_crypto.htm#i1005082
Tags: Database
Similar Questions
-
Required privilege to view the source code for the stored procedure
RDBMS Version: 11.2.0.4
Platform: Oracle Linux 6.4
In our Production database, we have an application schema named CRM_PROD. And we have a read-only user named steve in this PB.
Steve must be able to view the source code of all stored procedures, functions and packages in the CRM_PROD schema. But steve shouldn't be able to run these procedures, functions and packages in the CRM_PROD schema. What a privilege should give Steve for this?
SYS is owner of the dictionary of data and tables for the source code. See configuration of privilege and role authorization - 11 g Release 2 (11.2).
Select it no matter what dictionary grant will give user (read) access to the full data dictionary.
-
I can't using stored procedures and need advice.
If I try to run the stored procedure code, I get an error saying that I not provided a required entry, but the LabVIEW looks I'm him.
But I get this error message.
The database table is as follows:
@ID is generated in the process, he is looked at and inserted.
I don't have the opportunity to get into the database. It is a stored procedure of writtin by the DB of my COMPUTER service engineer. The image above has the required fields highlighted in yellow I need to provide when executing my code.
Can you see where my mistake was made?
Thanks for the comments.
Ben
The procedure does not match the names of parameters with the values that you provide. You provide only 5 params, but there are 8 in the stored procedure. In your case, SerialNumber is spent in the ID, PartNumber in SerialNumber, etc.. Add some empty in your cluster params, if they are not mandatory.
-
Calling stored procedures with parameters with the database connectivity Toolkit
Hi all
I'm new to the forum and struggling to find a solution to a particular problem I have in this respect, using the LabVIEW Database Connectivity Toolkit on a project, I am currently working on my work. I have a database in which I tables and stored procedures with parameters. Some of these stored procedures have input, output and return parameters.
I tried to follow this example, but to no avail: http://digital.ni.com/public.nsf/allkb/07FD130746083E0686257300006326C4?OpenDocument
Such a stored procedure I am working on the implementation is named "dbo.getAllowablePNs", running "SELECT * from DeviceType" (DeviceType is the table). In this case, it requires no input parameter, it has an output parameter that generates the table [cluster] and has a return parameter that returns an integer value (status code for execution) to show if an error occurred. The DeviceType table has 3 columns; ID (PK, int not null), PN (nvarchar ((15), null) and NumMACAddresses (int, null).) I have surpassed many examples and I talk to the support OR try to implement this and similar procedures stored in LabVIEW but have not been successful. I am able to connect to the database with the VI of open connection without error, but spin in some confusion as a result of this step. I then try to use the VI of parameter query create to call the stored procedure and set the parameters. I guess I would then use the Set parameter value for each parameter that is connected to the entry of parameters on the previous query with parameters VI VI? I am also having some confusion during and after these steps as well. I would greatly appreciate advice or suggestions that anyone could have in this situation because I am not a SQL expert. Also, I would be happy to provide more information that might be useful.
Kind regards
Jon
Here's what I use to do this. I think I had to change him create parameterized query VI for him to work. There is a post on the forum about this somewhere.
-
My source data in the remote database schema (say C3.case). And I am trying to insert data of this CASE table in my database table (for example SIMS.case) I use the stored procedure to load the data.
I was going through the documentation and I thought that the creation of MV is not possible in this case is the source table in the remote database schema. Is this correct?
or create a link DB is the only option available to access the remote database schema table.
Thank you.
Hello
2929538 wrote:
My apologies for the bad conventions help. I meant remote schema.
the required data and the destination table, the two are in oracle, but in totally different schemas.
Yes, you said a table is in a scheme called C3, and the other is in a schema called SIMS. Are these schemas in the same database or in different databases?
If they are in the same database, then you do not have a database link. Or the other schema can reference tables in the other qualifying names correctly, for example
SELECT *.
OF C3. case_studies
...
assuming that the right privileges have been granted.
If the schemas are in different databases, a database link is the best way to access data in a database in a different database.
Without a database link, you will probably use some kind of use outside the database to write the data to a database, the file if necessary, transport and read in other databases. DataPump files of images or CSV files, as Paulzip said in answer to #1, could be used for this.
-
Cannot access stored procedure parameters
Hello
We are at the point where you try to use a stored procedure from our Java through Toplink code but we seem to have a problem here I couldn't find an answer to. Maybe it's that my Google-Fu is miss you in this case.
Our problem is thto so that the procedure seems to be cited correctly, we get nothing to Java code. The procedure in question has been tested with the same input parameters of SQLDeveloper and the procedure returns values as it should.
The procedure signature is
create or replace PACKAGE FORM_METADATA AS
PROCEDURE FORM_LIST_GET)
P_USER_ID IN VARCHAR2,
P_CHANNEL_NO NUMBER,
P_START_FROM in NUMBERS, paging
P_COUNT_TO_RETURN in NUMBERS, paging
P_GET_TOTAL_COUNT in NUMBER, - if number must total be returned then 1, other wise 0
P_RESULT_SET ON SYS_REFCURSOR,
P_TOTAL_COUNT CERTAIN NUMBER);
end FORM_METADATA;
Java code invoking this procedure looks like this:
County of BigDecimal = new BigDecimal(-1);
A session = getSession().
session.setLog (new OutputStreamWriter (System.out));
session.setLogLevel (SessionLog.FINEST);
StoredProcedureCall procedureCall = new StoredProcedureCall();
procedureCall.setProcedureName "(FORM_METADATA. FORM_LIST_GET");
procedureCall.addNamedArgumentValue ("P_USER_ID", "name of user-1");
procedureCall.addNamedArgumentValue ("P_CHANNEL_NO", new BigDecimal (1));
procedureCall.addNamedArgumentValue ("P_START_FROM", new BigDecimal (1));
procedureCall.addNamedArgumentValue ("P_COUNT_TO_RETURN", new BigDecimal (1000));
procedureCall.addNamedArgumentValue ("P_GET_TOTAL_COUNT", new BigDecimal (1));
procedureCall.useNamedCursorOutputAsResultSet ("P_RESULT_SET");
procedureCall.addNamedOutputArgument ("P_TOTAL_COUNT", "count", BigDecimal.class);
DataReadQuery dq = new DataReadQuery();
dq.setCall (procedureCall);
dq.prepareForExecution ();
Object result = session.executeQuery (dq);
System.out.println ("result:" + result);
System.out.println ("result from StoredProcedreCall:" + procedureCall.getResult ());
The output we get looks like this:
[Warning TopLink]: 2015.08.31 16:11:30.781 - failed to get InitialContext for saving of MBean: javax.naming.NoInitialContextException: need to specify the class name in the environment or property of the system, as a cmdlet parameter or in a file of application resources: java.naming.factory.initial
[Warning TopLink]: 2015.08.31 16:11:30.797 - failed to get InitialContext for saving of MBean: javax.naming.NoInitialContextException: need to specify the class name in the environment or property of the system, as a cmdlet parameter or in a file of application resources: java.naming.factory.initial
[TopLink info]: 2015.08.31 16:11:31.685 - DatabaseSessionImpl (1827000661) - TopLink, version: Oracle TopLink - 11 g Release 1 (11.1.1.5.0) (Build 110305)
[TopLink info]: 2015.08.31 16:11:34.147 - DatabaseSessionImpl (1827000661) - dev connection successful
[TopLink Finest]: 2015.08.31 16:11:34.147 - DatabaseSessionImpl (1827000661) - wire (wire [main, 5, main])-Execute query DataReadQuery()
[TopLink Finest]: 2015.08.31 16:11:34.163 - DatabaseSessionImpl (1827000661) - wire (wire [main, 5, main])-re-connect to the external connection pool
[TopLink fine]: 2015.08.31 16:11:34.227 - DatabaseSessionImpl (1827000661) - connection (1635575430) - wire (wire [main, 5, main])-START FORM_METADATA. FORM_LIST_GET (P_USER_ID = >?, P_CHANNEL_NO = >?, P_START_FROM = >?, P_COUNT_TO_RETURN = >?, P_GET_TOTAL_COUNT = >?, P_RESULT_SET = >?, P_TOTAL_COUNT = >?); END;
link = > [name of user-1, 1, 1, 1000, 1, = > P_RESULT_SET = > P_TOTAL_COUNT]
[Result:]
Result of the StoredProcedreCall: null
Process has finished with exit code 0.
I'm pretty sure that our problem is with Java code invoking the procedure, but as I said, we were not able to find the right solution yet. Anyone have a pointer as to where we should begin to look for next?
Thank you in advance,
Mika Leino
One of my colleagues managed to find the reason why the procedure does not seem to return anything. For brevity, I've redacted a couple of settings that we were not used to this forum and we do not believe the reason for the perceived behavior. However, as well as the required parameters these have the value NULL. My colleague seems to try initialize parameters without value and after that the query returned a set of data that was expected.
Our change of code (in Java) was therefore to spend
procedureCall.addNamedArgumentValue("P_ORDER_BY", OracleTypes.NULL);
TO
procedureCall.addNamedArgument("P_ORDER_BY");
Now we're getting data from the cursor, as expected, but the second parameter value still eludes us.
-
How to create simultaneous program of type PL/SQL stored procedure?
I have the procedure to reset sequence as below:
CREATE OR REPLACE PROCEDURE DEV_RESET_XX IS
V_NEXT_VAL1 NUMBER;
BEGIN
RUN IMMEDIATELY "ALTER SEQUENCE DEV_RECEIPT_S1 MINVALUE 0';"
RUN IMMEDIATELY "SELECT DEV_RECEIPT_S1. DOUBLE NEXTVAL ' IN V_NEXT_VAL1;
RUN IMMEDIATELY "ALTER SEQUENCE DEV_RECEIPT_S1 INCREMENT BY ' |" -V_NEXT_VAL1;
RUN IMMEDIATELY "SELECT DEV_RECEIPT_S1. DOUBLE NEXTVAL ' IN V_NEXT_VAL1;
RUN IMMEDIATELY "ALTER SEQUENCE INCREMENT DEV_RECEIPT_S1 1 ';"
END DEV_RESET_XX;
And if I run this query don't use PL/SQL, no problem and success.
EXEC DEV_RESET_XX
And then I want to create simultaneous program for this procedure.
1. create the executable program
-Methods: PL/SQL, stored procedure
2. create the simultaneous program
-Call the executable program
-Nothing parameter
3. assign the application group to receive
And then I try to run this competitor.
But, status complete error.
Help, please.
Thank you.
Hello
To save pl sql program, we have two required parameters. ERRBUFF and RETCODE
Steps to create a concurrent program of type PL/SQL stored procedure. Techmandate.com
No need to create these parameters in the simultaneous program window. Just use those in your procedure.
hope this will help you
-
To proceed if a condition is fulfilled in a stored procedure
Hello Experts,
I have a fairly simple requirement and I was not able to solve, I hope someone could help me with this.
I have an existing stored procedure that captures data in a cursor and writes it to a file using the UTL utilities. It works very well. I want to add a condition before the cursor, if this condition is met, it must proceed to the cursor and write the file, otherwise it's just not the procedure with an error message saying the unmet condition. I'm doing something wrong here, can someone please fix the part of the State. I think I could use 'IF EXISTS'. Please notify. Thank you in advance.
This is the model,
CREATE OR REPLACE PROCEDURE < PROC >
as
Define variables
n_cnt number: = 0;
...
...
..
-Here is the condition I want to go far from other I want to fail the procedure-
BEGIN
SELECT COUNT (TABLE_NAME) made a MISTAKE in n_cnt
EXTRACT
WHERE
AND STATE = 'error ';
IF n_cnt <>0 THEN go - continue the procedure -
END else fail PROCEDURE - the procedure-
-Creates a cursor/temp table that contains the data to be processed at line by line, which is used to write to a file
<>SLIDER
IS
-Home select query starts here.
SELECT DISTINCT FIRSTNAME
LASTNAME
NAMES
;
BEGIN
UTL_FILE. PUTF (v_FILE_HANDLE, '% s%s\n',
'FIRST NAME' |' | ',
"LASTNAME");
CURSOR OPEN.
-Get the cursor in the temporary folder
CURSOR FETCH IN REC.
CURSOR % WHILE
-Using the loop to load data
LOOP
-Using the UTL package to write to a file
UTL_FILE. PUTF (v_FILE_HANDLE, '% s%s\n',
RECOMM. FIRSTNAME |' | ',
RECOMM. LASTNAME );
end loop;
END '
Hello
You can do the following.
IF n_cnt = 0 THEN
RAISE_APPLICATION_ERROR (-20001, 'condition not met');
END IF;
See more info on PL/SQL Error Handling http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/errors.htm#LNPLS007
-
Creation of XML report using the PL/SQL stored procedure
Hi friends,
I'm working on a report xml with the xml source as a PL/SQL stored procedure.
I mean the fiscal year indicated in the following link to understand the process:
http://orclapp.blogspot.com/2012/02/developing-xml-publisher-report-using.html
In the example shown in the link above, I did not understand the following:
(1) in the following procedure, setting out "retcode" is not used at all.
What is the importance of this parameter.
REPORT PROCEDURE (errbuf OUT VARCHAR2, retcode OUT VARCHAR2, p_product_id in NUMBERS)
(2) after the xml data are prepared and updates 'l_result' variable Clob, what follows
Loop is executed. I am not able to understand why the following loop is required.
LOOP
EXIT WHEN l_length = l_retrieved;
IF (l_length - l_retrieved) < 32000
THEN
SELECT SUBSTR (l_result, l_retrieved + 1) IN l_xmlstr FROM DUAL;
l_retrieved: = l_length;
fnd_file.put_line (fnd_file.output, l_xmlstr);
ON THE OTHER
SELECT SUBSTR (l_result, l_retrieved + 1, l_offset)
IN l_xmlstr
FROM DUAL;
l_retrieved: = l_retrieved + l_offset.
fnd_file.put_line (fnd_file.output, l_xmlstr);
END IF;
END LOOP;
(3) in the example it is not explained how the concurrent program gets the xml data?
I guess that it is written to a file by using the following line of code:
fnd_file.put_line (fnd_file.output, l_xmlstr);
I would be grateful if someone can shed some light in my questions above so that I can well understand the process.
Thanks and greetings
Hawker
Hi 32000 in the code is a 'safe' than 32767 available max mesh, loops is intended to get around the entire thing into pieces that can be managed within the limits of the data type.
BTW; If you are in the following Oracle e-business, you can also use the Oracle reports very simply to create the XML output.
If you have reports developer all you need to do is put raw sql (create XML without any "Fireworks") in the SQL report and then set reporting in XML format in the definition of program in Oracle e-business.
Best regards
Robert.
-
Re: "insufficient privileges" error when you run the Java stored procedure in another schema
I get an "insufficient privileges" error when you run the Java stored procedure in another schema, see details below. I don't know what are missing privileges (I already granted the EXECUTE privilege), suggestions? -Thank you.
Define a simple java class and deploy it as a Java stored procedure to test:
Schema: User1
test of the package;
public class HelloWorld {}
public HelloWorld() {
Super();
}
public static String Hello () {}
Return "HELLO";
}
}
CREATE or REPLACE FUNCTION HELLO RETURN VARCHAR2 AUTHID CURRENT_USER AS LANGUAGE JAVA NAME ' test. HelloWorld.hello () return java.lang.String';
Grant execute on USER2 HELLO
Test the Java stored procedure through the PL/SQL function call (in the same schema):
Schema: User1
SET SERVEROUTPUT ON
DECLARE
v_Return VARCHAR2 (200);
BEGIN
v_Return: = User1. HELLO;
DBMS_OUTPUT. Put_line ('v_Return =' | v_Return);
END;
anonymous block filled
v_Return = HELLO
Test the Java stored procedure through the PL/SQL function call in a different pattern:
Schema: USER2
SET SERVEROUTPUT ON
DECLARE
v_Return VARCHAR2 (200);
BEGIN
v_Return: = User1. HELLO;
DBMS_OUTPUT. Put_line ('v_Return =' | v_Return);
END;
Error report-
ORA-01031: insufficient privileges
ORA-06512: at "User1." HELLO', line 1
ORA-06512: at line 4 level
01031 00000 - "insufficient privileges".
* Cause: An attempt was made to change the user name or password
without the privilege appropriate. This error also occurs if
trying to install a database without the need for employment
access privileges.
When Trusted Oracle is configure in DBMS MAC, this error may occur
If the user has been granted the privilege necessary for a higher label
that the connection is active.
* Action: Ask the database to perform the operation or grant administrator
the required privileges.
For users Trusted Oracle get this error, well that granted the
the privilege that is suitable for the top label, ask the database
administrator to grant the privilege to the appropriate label.
You have created the function with AUTHID CURRENT_USER, which means that the function is executed with the rights of the applicant (but not with the rights of the author). This means that the applicant must have grants (directly or through roles) on all used/accessible objects in the service. In your case the user USER2 has not granted with EXECUTE on the class/source Java test. Class HelloWorld, causing the ORA-01031 exception. You create service without AUTHID CURRENT_USER (i.e. with AUTHID DEFINE, which is by default, if you do not have a specific reason to use AUTHID CURRENT_USER) or grant EXECUTE on JAVA test SOURCE. Class HelloWorld to User2.
Dimitar
-
optimize a stored procedure to insert data
Hello
I followed table structures,
Client:
ID number pk,
name varchar2 (100),
number of autooption);
CustItem:
The ItemId number,
Number of CustomerId
CustItemAdd:
(ItemId number,
Number of assets)
CustItemAddLog:)
The ItemId number,
Number of CustomerId,
LogDate date,
autooption)
I wrote after a stored procedure to load the elements of CustItemAdd to CustItem. My query select fetch 18000000, so finally I insert these many records in
2Tables, as in stored proc.
Loading of the required data, it takes about 7 hours to complete. I used addition of suspicion, he worked a little faster in sql directly, but in sp for the two statements,
It is throwing error that I can't use it in parallel.
Can I use a way to insert quickly data?
create or replace procedure SPCUSTITEMNEWSAVE
(sFlag out varchar2)
is
Start
-Boot flag
sFlag: = '0';
--===============================================================
-Insert new elements to save the table.
--=================================================================
INSERT INTO CustItemAddLog
SELECT
ca.itemId,
Cust,
SYSDATE,
Cust.autooption
OF CustItemAdd CA,.
Customer Cust
WHERE THERE IS NO
(SELECT 1 FROM custitem WHERE customer = Cust AND item = ca.itemid)
)
AND cust.autooption in (1,2)
AND (ca.active = 0
GOLD ca.active IS NULL);
--===============================================================
-Insert new elements.
--===============================================================
INSERT INTO CustItem
(
Customer,
Agenda
)
SELECT
Cust,
CA. Item,
100
OF CustItemAdd CA,.
Customer Cust
WHERE THERE IS NO
(SELECT 1 FROM custitem WHERE customer = Cust AND item = ca.itemid)
)
AND cust.autooption in (1,2)
AND (ca.active = 0
GOLD ca.active IS NULL);
--===============================================================
-Remove the downloaded items.
--===============================================================
DELETE CustItemAdd
WHERE THERE ARE
(SELECT point above CustItem WHERE, .itemid = CustItemAdd.itemid
);
COMMIT;
sFlag: = '100';
--================================================================
-Exception handling
--================================================================
EXCEPTION
WHILE OTHERS THEN
sFlag: = '300'-| SQLERRM;
ROLLBACK;
end;
Little does not return the error code in a parameter out. Next EXCEPTION WHILE OTHERS without STIMULUS is completely false. Never do this.
Now in regards to performance try using the INSERT all statement.
create or replace procedure spcustitemnewsave
is
Start
Insert / * + APPEND * /.
all the
in custitemaddlog
(
ItemId
CustomerId
LogDate
autooption
)
values)
ItemId
id
dt
autooption
)
in custitem
(
customer
element
)
values)
ID
element
)
Select ca.itemid
Cust
sysdate dt
cust.autooption
from custitemadd ca
customer cust
where there is no
(
Select 1
of custitem
where customer = Cust
and item = ca.itemid
)
and cust.autooption in (1,2)
and)
CA.active = 0 or
CA.active is null
);delete custitemadd
where there are
(
Select the item
the custitem this
where ci.itemid = custitemadd.itemid
);commit;
end; -
[BC] Call a stored procedure taking parameters of table
Hello!
I currently have a request of the OIC that makes thousands of calls per second stored procedure. The stored procedure runs a business logic that I want my client application to stay informed. I want to reduce the cat of the database and instead to call the stored procedure from thousands of times per second, call the procedure (for example) once per second, but with values of one mile.
I used OCIBindArrayOfStruct successfully to perform inserts bulk, where my OCI application executes a () INSERT INTO using the function "iters" and it might be possible to do something similar with the stored procedure, but I want to do something slightly different, because the procedure stored something like this:
* If a specific condition is set, call a secondary stored procedure
* If another special condition is set, insert a row into a table of some
I so wanted to do was to pass a table (or a series of tables) in the stored procedure, then the stored procedure to use optimal methods that are available, such as FORALL, to perform each of the tasks, the more effectively.
So I thought to create a type, such as a TABLE OF VARCHAR2, or a VARRAY and possessing of the parameters for the stored procedure based on this type, something like:
create or replace TYPE 'NTT_VARCHAR2' AS TABLE OF VARCHAR2 (32700);
create or replace FUNCTION bulk_process_values)
p_error_message OUT NOCOPY VARCHAR2,
p_module_context_name OUT NOCOPY VARCHAR2,
p_sql_error OUT NOCOPY VARCHAR2,
p_count in NUMBERS
p_non_array_var_1 IN VARCHAR2,
p_non_array_var_2 IN VARCHAR2,
p_array_var_1 IN NTT_VARCHAR2,
p_array_var_2 IN NTT_VARCHAR2,
p_array_var_3 IN NTT_VARCHAR2
< etc. for all the variables in table >)
RETURN NUMBER
.. .but I am struggling to find an example of how call the procedure "bulk_process_values" stored, and even if I use a TABLE OF VARCHAR2 or a VARRAY as a parameter type.
I searched the Internet and found this: binding table of the structs (OCIBindArrayOfStruct) sample code
- and- but they take different approaches and a bit confused (the second example spoke of OTT).
I think that the first approach is more likely to be the solution I need - but I can't help thinking - it is a bunch of stuff to move if it does not end up significantly improve performance!
My questions are:
* Moves to a call-SP-thousands-of-times-per-second to call-SP-fewer-times-but-with-array-parameters sensitive?
* Should the table or VARRAY, TABLE OF VARCHAR2 parameters or something else?
* Should I use for my case OTT?
Samples I found are both very old - and the second example indicators that the optimal approach evolves with the OCI versions - I'm on 11.2, what is the optimal approach these days?
* < added later > why is there no official useful example?
Thank you very much
Much appreciated. has actually worked, with VARRAY, with a proof of concept. Now I just need to shake a little and then get my PL/SQL for optimal PC experts. I think I was really discouraged by the lack of official documents, with the Community (Paradise) is the only way to get real results.
Thank you JJ.
I intend me to use the binding enforcement of the table and the table and avoid N back and forth, but I do not then get the opportunity to do something clever in the PL/SQL.
In the PL/SQL, there is no logic occurring - I don't call the same SP tons of times, but then I want to be able to use PL/SQL optimizations such as FORALL, BULK COLLECT, reduce the number of validations and others. There is a commit after each SP run, because otherwise the nature of demand means that the application hangs occur; However, there is a way (I think) be smart on the part that is likely to deadlock (making a shape on the Bay First, then applying the updates in the order sorted and then failed to get a blocking theoretically), and then FORALL insert for the second part of the stored procedure.
I guess I may apply the single return, passing a table (to a commit in the SP)-which will reduce back and forth, so gain in performance, but it will not reduce the number of validations that I do - and Oracle said that commits too frequent is not good for performance. I already have code in my framework that does - by making a simple INSERT INTO.
Good to hear that OTT is not explicitly required - and VARRAY resembles the approach to try first.
-
How to call a stored procedure in ADF
How to call a stored procedure in the ADF (Jdev 11.1.1.6)?
Code sample stored procedure:
CREATE or REPLACE PROCEDURE SP_HELLOWORLD
(
NAME IN VARCHAR2
OUT VARCHAR2 DESIRES
) AS
BEGIN
WISHES: = 'Hello'. name | ', Welcome to MS.';
END SP_HELLOWORLD;
Your Code of ADF is:
try {}
System.out.println ("* beginning of the code *");
String sql = "start SP_HELLOWORLD(:NAME,:WISHES); end; ";
CallableStatement st = getDBTransaction () .createCallableStatement (sql, getDBTransaction(). DEFAULT VALUE);
st.setObject ("NAME", "ABC"); Replace with required param
st.registerOutParameter ("WISHES", Types.VARCHAR); import java.sql.Types;
St.Execute ();
System.out.println ("the output of the function DB is:" + st.getObject ("WISHES"));
System.out.println ("* end of code *");
} catch (Exception e) {e.printStackTrace () ;}
-
Passing parameters to the query to extract in a stored procedure
How pass us in a parameter of a query retrieves in a stored procedure?
Because for example I: -.
FOR SheikYerbouti in company
LOOP
SELECT extract (response,'/ list/hwid [@name = "Tom"] / descendant::node () / address) employee where id = 9506;
END OF LOOP
Instead of TOM, I want to pass a variable because I use the stored procedure. The variable is emp_rec.name
SELECT extract (response,'/ list/hwid [@name = emp_rec.name]/descendant::node()/address) employee where id = 9506; does not work?
The XPath expression is of type string, concatenate the value:
extract (answer, "/ List/hwid[@name="' |) emp_rec. Name | ([""] descendant::node () ')
However, depending on your version of the database, there may be better alternatives, so if you can give us a little more explanation on your requirement, we would be able to offer other options.
-
Adding apostrophe in dymanic, stored procedure
Hello world
I use a stored procedure that prints the triggers which is called as a script to dynamic triggers.
Here I store the values required in M_ALL_DYNAMIC_DRIVER_TEMP table name
for ex: M_ALL_DYNAMIC_DRIVER_TEMP:
TABLE-NAME DATA_UID_ALT1_PREFIX IU_TRG_FLAG
-------------- -------------------------- -------------
BA_ORG ALT Y
stored procedure is:
create or replace
PROCEDURE SP_TRIGGER_SCRIPT_temp
AS
SQLSTR VARCHAR (4000);
SQLSTR_ETL VARCHAR (4000);
SQLSTR1 varchar (40);
SQLSTR2 varchar (40);
SQLSTR3 varchar (40);
SQLSTR4 varchar (40);
Table-name varchar (40);
PK_TABLE varchar (40);
Start
for c in (select TABLE_NAME, DATA_UID_ALT1_PREFIX from M_ALL_DYNAMIC_DRIVER_TEMP where IU_TRG_FLAG = 'Y' and DATA_UID_ALT1_PREFIX is not null)
loop
SQLSTR1: = c.TABLE_NAME;
SQLSTR2: = TRIM (SQLSTR1) | ' _ID'.
DBMS_OUTPUT. PUT_LINE ('-TABLE_NAME START :'||) SQLSTR1 |', DATA_UID_GEN_METHOD:ALT1, SHORT_TRG_BASENAME:-");"
SQLSTR: = ' create or replace
TRIGGER ' ' |. ' TRIM (SQLSTR1) | "' _IU_TRG ' INSERT BEFORE THE '. SQLSTR1 | "FOR EACH LINE
BEGIN
If the insertion
If: new. ROW_CHANGED_BY is NULL then
: new. ROW_CHANGED_BY: =: new. ROW_CREATED_BY;
end if;
If: new. DATA_UID is NULL then
SELECT GENERATE_DATA_UID('||) SQLSTR1 |',: new.'. SQLSTR2 |') IN: new. DATA_UID FROM DUAL;
end if;
end if;
If the update can
If it isn't updating ("ROW_CHANGED_BY") then
: new. ROW_CHANGED_BY: = USER;
end if;
end if;
END ';
DBMS_OUTPUT. PUT_LINE (SQLSTR);
DBMS_OUTPUT. PUT_LINE (SQLSTR_ETL);
DBMS_OUTPUT. PUT_LINE ('-END OF ' |) SQLSTR1 | » -------------------------------------------------------------');
end loop;
end;
When I run the stored procedure out put:
-LAUNCH TABLE_NAME:BA_ORG, DATA_UID_GEN_METHOD:ALT1, SHORT_TRG_BASENAME:-
create or replace
"BA_ORG_IU_TRG" TRIGGER BEFORE INSERT ON BA_ORG FOR EACH LINE
BEGIN
If the insertion
If: new. ROW_CHANGED_BY is NULL then
: new. ROW_CHANGED_BY: =: new. ROW_CREATED_BY;
end if;
If: new. DATA_UID is NULL then
SELECT GENERATE_DATA_UID (BA_ORG,: new.BA_ORG_ID) INTO: new. DATA_UID FROM DUAL;
end if;
end if;
end if;
END
--------------------------------------END OF BA_ORG-------------------------------------------------------------
I want to:
statement: SELECT GENERATE_DATA_UID (BA_ORG,:new.BA_ORG_ID) IN: new. DATA_UID FROM DUAL;
be: SELECT GENERATE_DATA_UID ('BA_ORG',: new.BA_ORG_ID) INTO: new. DATA_UID FROM DUAL;
That is to say, function GENERATE_DATA_UID ('BA_ORG',: new.BA_ORG_ID) first parameter I want apostrophe
Please help on this
SELECT GENERATE_DATA_UID ("' |) SQLSTR1 | ''',:new.' ||
----
Ramin Hashimzade
Maybe you are looking for
-
Inbox appears twice on the IMAP subscription list
Hi, I'm looking to install a Fastmail IMAP with Thunderbird account and all records are recognized with the exception of the Inbox, which is grayed out. I noticed that on the subscription list, it appears as "INBOX" and even "Inbox", and here again,
-
Whenever I run Malwarebytes on my laptop Win 7 I get at least 69 elements referring to the sqlite files. I don't know whether to remove them or not. I don't have this problem on my Vista desktop. If I have, or I should NOT delete these files when Mo
-
Already have my contact information?
I got a call last night from a lady in an Indian call centre supposedly from Microsoft Support saying that someone was trying to access my computer and she would help me to stop. She was able to tell me that I am the primary user of the computer to
-
My photos are imported in windows photo gallery, then they automatically in 'my images' where I can put them in individual cases. I decided to remove some photo gallery, but now, they have also disappeared from my photos. How can I get back them?
-
my computer fan is running constantly