PL/SQL :: How To Reset Primary Key to 1 Using Store Procedure
Mar 19, 2013I have created table and i am using sequence to increment primary key value.
Now i need to delete the table content and reset primary key to 1 using store procedure.
I have created table and i am using sequence to increment primary key value.
Now i need to delete the table content and reset primary key to 1 using store procedure.
I have a Sap Primry Database and also a standby db that was working perfectly.. We migrated the primary db from windows 2003 to windows 2008 and brought the primary db up.. I had to create a controlfile and do a system copy and had to reset the logs on the Primary.. All came up and when i checked the standby it was receiving the logs but after a month. i see that it was not applying the logs as I think because of the sequence number .. it stopped.
I did the ffg as per the attachement...My logs have been shipped across but not applied, But What worrries me is the log sequence number on my Primary
SQL> select max(sequence#),thread# from gv$archived_log group by thread#;
MAX(SEQUENCE#) THREAD#
-------------- ----------
27727 1
I have a question like, Is it possible to hide the Store Procedure?
Scenario: I have write the SP which contains some logic based on my requirement. Once i developed this i need to implement this to my client page. So i need to hide the logic even the client opened the SP like exe file.
Store procedure code, I want to insert data in a database in this fashion,I want to check first if the record exist, if not Insert or else Update.
View 2 Replies View RelatedThe current update store procedure that I have updates a list of input provided, but it there are fields that are left blank, they are being updated as null in the database.
I'm having a trouble creating a store procedure that will just update the provided fields only.
I am very new to oracle and SQL.I am trying to create a store proc that will copy 14 day of data into a table and then truncate the original table. When i compile following code....
CREATE OR REPLACE PROCEDURE STOPROC_TRUNCATE
( dateNum IN NUMBER )
IS
BEGIN
create table AUDIT_14Days as select * from AUDIT where TIMESTAMP >= (SYSDATE - dateNum);
truncate table AUDIT drop storage;
[code]....
i am trying to update multiple records using store procedure but failed to achieve
for example my source is
emp_name sal
abhi 2000
arti 1500
priya 1700
i want to increase salary of emp whose salary is less than 2000 it means rest two salary should get update..using stored procedure only
i have tried following code
create or replace procedure upt_sal(p_sal out emp.sal%type, p_cursor out sys_refcursor)
is
begin
open p_cursor for
select sal into p_sal from emp;
if sal<2000 then
update emp set sal= sal+200;
end i;f
end;
and i have called the procedure using following codes
set serveroutput on
declare
p_sal emp.sal%type;
v_cursor sys_refcursor;
begin
upt_sal(p_sal,v_cursor);
fetch v_cursor into p_sal;
dbms_output.put_line(p_sal);
end;
the program is executing but i should get o/p like this after updating
1700
1900
but i am getting first row only
2000
and record is not updating...
Need a trigger in view with select statement that means
CREATE OR REPLACE VIEW TEST_VIEW AS SELECT * FROM TEST_TABLE;
CREATE OR REPLACE TRIGGER TEST_VIEW_TRG1
INSTEAD OF DELETE ON TEST_VIEW DECLARE
BEGIN
Dbms_Output.Put_Line('STATEMENT TRIGGER.');
END;
i wanted to use select statement instead of delete.How can i get that
I have created this store procedure:
create or replace PROCEDURE INSERT_TESTTABLE
(
PrimaryKey IN NUMBER
,One IN VARCHAR2
,Two IN VARCHAR2
,Three IN VARCHAR2
,Four IN VARCHAR2
[code].......
And I get this error: Error(15,13): PL/SQL: ORA-00942: table or view does not exist
I have a table that has 10 columns which is used to store the customer information (e.g Gender, Age, Name). And i have wrote a store procedure to compare the before and after value of column since there has a parameter to control which column need/no need to be updated while the value being changed.
For example, master table "CUST" has column (NAME, GENDER, AGE). "CUST_TEMP" is a temporary table to store the input image which has the same table structure as "CUST".
DECLARE
bef_val CUST%ROWTYPE;
aft_val CUST_TEMP%ROWTYPE;
BEGIN
SELECT * INTO bef_val FROM CUST WHERE name = 'ABC';
SELECT * INTO aft_val FROM CUST_TEMP WHERE name = 'ABC';
[code]....
For the above case, i need to type 3 times of "sp_compare_val ( bef_val.xxx, aft_val.xxx )" on the program. And if the table has more than 10 columns, i need to type more than 10 times.Thus, is it possible to pass in a dynamic variable while calling the store procedure. let say, where the 'xxx' can be definable?
I'm trying to create a store procedure that will accept a username from a flat file but i don't know how to do read file into store procedure.
Below is a sample store procedure by itself i created to add user which created okay but when i execute I got the error displayed below.
create or replace procedure addUsers(userNam in varchar2)
is
begin
EXECUTE IMMEDIATE 'CREATE USER'||userNam||'IDENTIFIED BY "pass1234" DEFAULT TABLESPACE USERS'||'QUOTA "1M" ON USERS'||
'PASSWORD EXPIRE';
end addUsers;
/
[code].....
i want to store all rows of columns into single variable and then use in inside of SP
declare
CUR_REC SECURITY_TYPE%rowtype;
begin
select *
into CUR_REC
from SECURITY_TYPE;
[code]....
it return ORA-01422: exact fetch returns more than requested number of rows error. Is any chance to implemented above scenario in oracle 10g
I've a staging table STG_TABLEA which has a primary key discount_seq_no.
I am creating a pl/sql procedure to populate a primary key (discount_seq_no) with a database sequence. The intent is to keep this populated with next value incrementing by 1.
I am using Oracle 11.2.0.2 version.
I've put together the below code, not sure on next steps...
BEGIN
UPDATE STG_TABLEA
SET A.DISCOUNT_SEQ_NO = "INSERT A SEQUENCE HERE AND KEEP INCREMENTING the seq value by 1
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
RAISE;
END;
primary key constraint on transaction_dtl_bk is affecting the insertion of next correct rows.
CREATE OR REPLACE PROCEDURE NP_DB.san_po_nt_wnpg_1 (
dt DATE
)
IS
v_sql_error VARCHAR2 (100); -- added by sanjiv
v_sqlcode VARCHAR2 (100); ---- added by sanjiv added by sanjiv
[code]...
I have Follwoing Table and data.
CREATE TABLE ABC(DPT_NUM NUMBER,LOT_NUM NUMBER);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 501, 1);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 502, 2);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 509, 3);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 511, 4);
Insert into ABC(DPT_NUM, LOT_NUM, SRL_NUM) Values (1, 503, 5);
[Code]...
I write Following query.
SELECT DPT_NUM,LOT_NUM,ROW_NUMBER() OVER(PARTITION BY DPT_NUM ORDER BY DPT_NUM) SRL_NUM FROM ABC;
Result is
DPT_NUMLOT_NUMSRL_NUM
15011
15022
15093
15114
15035
15166
15227
15698
[Code]...
But i want to reset rownum after each 4. Mean after serial number 4 , serail number must start from 1. I want to reset serial number after each 4 records (lot_num) against dpt_num;
[#|2010-03-17T19:00:26.689+0530|SEVERE|glassfishv3.0|tcplistener.ModuleHandler|_ThreadID=30;_ThreadName=Thread-1;|The log message is null.
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.net.SocketInputStream.read(SocketInputStream.java:182)
at java.io.FilterInputStream.read(FilterInputStream.java:66)
at tcplistener.ByteWrapper.unwrapFromStream(ByteWrapper.java:136)
at tcplistener.ModuleHandler.run(ModuleHandler.java:106)
at java.lang.Thread.run(Thread.java:619)
|#]
[code].....
In oracle is it possible to find if a sequence was reset? I know my sequence was reset, looking at the nextval of my sequence, but is there an oracle log or anything which proves that sequence was reset ?
View 2 Replies View RelatedSrl no - Srl no w.r. to the date of transaction.i.e will be incremented for every day and should again reset for the next day-Length -4 Purpose code -Purpose code of the transaction.
View 8 Replies View RelatedI had a question with regards to the reset of sequence in DB.
From what I had know, there are 2 ways of reseting it...
1. Alter Sequence method
2. Drop and Create Sequence method.
It seems to me (from what I find online )that Alter method is much preferred. Why is this so? Is there any impact using Drop and Create Sequence method?
Just trying to figure out a way to reset a lost sys password.The Customer has a database that were configured by the application provider.They were however kicked out and did not leave any kind of documentation behind
they also configured the passwordfile to disable OS (oracle) user to login to the DB.Is it possible to change the password file with orapwd to set a new password for the sys user?I some how recall that it can only be done if the passwordfile is set to exclusive and not as in this case set to shared.
I often use "alter session set xxx=xxx;" command to change parameter value temporarily. After that, how to reset parameter value to default and I don't want logout sqlplus.
View 3 Replies View RelatedI need to reset the line number for each header values.
create table header_table(header_value varchar2(100));
create table line_table(header_value varchar2(100), line_number number);
insert into header_table values('ALAOF');
[Code]....
But My line table output looks like below
LINE TABLE:
header value line_number
ALAOF 1
ALAOF 2
ALAOF 3
[Code].....
I have a java application (jdk 6) that use a db oracle 11g with ojdbc6.jar version 11.2.0.1.0 on linux.
Sometimes (one or two cases on 11k sql insert on table in one day) I obtain, the error:
java.sql.SQLRecoverableException I/O Error: Connection reset
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:866)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1145)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1259)
oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1469)
oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.ja
va:389)
...
Account XYZ has expired and we don't know the password of account xyz and don't want reset the password also. How can open account XYZ without change the password?
View 1 Replies View RelatedI have an Oracle 9i developer database on my Windows workstation. I havent used it in a couple weeks and forgot my Sysdba login password. how I can reset it or get into the database?
View 6 Replies View RelatedI have developed an application Customer Call Handling where the main form of the Application has about 42(Data & Control) Blocks, many canvases and windows.This main form Calls many other forms which all work fine. But whenever this Main form is Cleared,Queried it calls the Code gems_ proc_ clear which has CLEAR_FORM(NO_VALIDATE).Immediately after the Clear_form(no_validate) is fired it throws this error FRM-92100.
On Save too, the form needs to be cleared once data is saved. The save works fine. but when the call to gems_proc_clear is made after save it throws the error again.
Since its the main form of the application, The Call Center users are having difficulty Clearing or Querying the form.
The forms have been developed in Forms 6i Version and work absolutely fine in 6i Test-Server Environment. But the moment we run the Forms in the Live Server(Oracle 11G) Environment when the form is Cleared,Queried this error throws.
How to reset the status of Refresh Group?
In our database, it is showing the status of Refresh group to 'Broken'.
10.2.0.3 on Linux
I reset a user password and the user is unable to login as you can see below
[oracle@testdb 10.2.0]$ sqlplus sys/manager as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Nov 27 16:20:21 2012
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production With the Partitioning, OLAP and Data Mining options
SQL> alter user sysman identified by oracle;
User altered.
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production With the Partitioning, OLAP and Data Mining options
[oracle@testdb 10.2.0]$ sqlplus sysman/oracle
SQL*Plus: Release 10.2.0.3.0 - Production on Tue Nov 27 16:20:32 2012
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
ERROR: ORA-01017: invalid username/password; logon denied
User unable to login even after password reset
We have a production database on 11.2.0.2 version. The application user was prompted to change the password after his password expired.
USERID NTIMESTAMP# ACTION# RETURNCODE
------------------------------ --------------------------------------------------------------------------- ---------- ----------
M500796 13-DEC-11 06.11.06.065209 PM 100 28001
After changing the password he is not able to logon. The aud$ table does not show any occurrence of 1017, therefore it is not a question of Invalid password.
LVV> show parameter SEC_CASE_SENSITIVE_LOGON
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
sec_case_sensitive_logon boolean FALSE
I'm trying to write short program to reset password on databases. I'm trying to use OCINewPassword property with following
public void ResetPassword(String sOldPass, String sNewPass) {
this.sCurrent = sOldPass;
this.sNewPassword = sNewPass;
Properties props;
Connection conn = null;
[code]....