SQL & PL/SQL :: How To Check Cursor Having Record Or Null

Jun 22, 2010

i want to check cursor having record or null/ if having records then count of records?

View 5 Replies


ADVERTISEMENT

SQL & PL/SQL :: Cursor With Bind Variable And Cursor Record

Feb 25, 2011

Is it possible to:

-define a cursor with bind variables
-get a cursor record from these cursor
-and pass the bind variable in the OPEN clause

Did'nt succeed as shown in the example.

SET SERVEROUTPUT ON SIZE 900000;
DECLARE
--works fine
CURSOR c1 IS SELECT * FROM USER_TABLES WHERE rownum<3;
--doesn't work
--CURSOR c1 IS SELECT * FROM USER_TABLES WHERE rownum<:1;
crec c1%rowtype;
BEGIN
--works fine
OPEN c1;
--isn't possible ?
--OPEN c1 USING 3;

[Code]....

View 3 Replies View Related

SQL & PL/SQL :: How To Use Or Condition To Check If 6 Col Values In A Row Is NULL

Aug 23, 2010

How can I use OR condition in sql to check whether if the 6 col values in a row is NULL, I need something like below, but idk the syntax of checking if either of the mentioned cols is null using an or condition.

select a.mid
FROM table_a a
JOIN table_b b
ON a.dept = b.dept
JOIN table_c c
ON b.eid = c.eid
WHERE a.tid = :tid
AND (a.i1 or a.i2 or a.i3 or a.n1 or a.n2 or a.n3 or a.t1 or a.t2 or a.t3 ) IS NULL

View 1 Replies View Related

SQL & PL/SQL :: Is NOT NULL Needed If A CHECK Constraint Is On Column

Dec 13, 2010

In the below code, do I need the 'NOT NULL' after the 'state char(2)'? I am guessing that I do not need it since I have the CHECK constraint on the column.

CREATE TABLE employee(
id PRIMARY KEY,
first varchar(20) NOT NULL,
middle varchar(20),
[code]....

View 10 Replies View Related

SQL & PL/SQL :: Use A Trim (col_name) To Check NULL Value In A Table?

Aug 8, 2013

Can i use a trim(col_name) to check a NULL value in a table? as IS NULL function is taking a long time.

View 8 Replies View Related

How To Check Cursor Stats At Run Time

Sep 24, 2011

I have a stored procedure running in which there is a cursor which fetches around 1500000 records and then query another table using the fetched record values.

I cannot modify the procedure as its on production. I want to know which cursor record is currently being processed by the procedure, and how many are still remaining ? How to check the cursor stats at runtime. I want to check up to which record the cursor has been fetched and how many are still remaining. I have cursor name. Is there some dynamic view to check cursor stats at runtime ?

View 1 Replies View Related

SQL & PL/SQL :: How To Check If Result Of Cursor Is Empty

May 20, 2010

How can i check if the result of a defined cursor is empty?

View 6 Replies View Related

SQL & PL/SQL :: Check If Element Present In Defined Column Of Cursor?

Apr 29, 2010

i want to produce a function who return XmlType element if she checks that a parameter (that i passed to here is contained in a row in a defined table)

for example

create table sec_form(
form_code VARCHAR2(8)
, sec_code VARCHAR2(5)
) ;
insert into sec_form values ('CSA','section1');
insert into sec_form values ('CSA','section2');
insert into sec_form values ('CSA','section3');

then i got my function

create or replace function checkIfSectionEnabled (elem XmlType,name_section varchar2)
return XmlType
is v XmlType;
CURSOR myCursor IS select * from sec_form where form_code = 'CSA';
begin
open myCursor;
loop

[code]....

now i'm gonna call the function (elem XmlType,name_section varchar2) and pass here "section1" for example ; and she must return me my xmltype element if she find "section1" finds section1 present;

when i try t compile i got:

Error(18,13): PL/SQL: Statement ignored
Error(18,26): PLS-00225: subprogram or cursor 'MYCURSOR' reference is out of scope

View 3 Replies View Related

Foreign Key Would Be Populated On Each Record / Other Would Be Null

Mar 22, 2013

I have a central entity Address. I have other entities that could have many addresses (Organization, Person for eg). The relation between Organization and Address is one to many and the relation between Person and Address is also one to many.When I modelled it, I ended up having two foreign keys in Address (Organization ID and Person ID).The question that is being raised by the client is "As only one of the foreign key would be populated on each record, the other would be null". The client is not comfortable having nullable foreign keys as they won't be able to maintain integrity. One of the requirement is that No orphan records in Address. By modeling the way above, there are chances for having some orphanned records. I tried to explain that this would be controlled by the program to ensure that no orphan records would be there but their question is that what if someone goes directly and enters a record in Address table without any foreign key value (I dont know who would have an insert/update access on the tables other than the dba's).

I am trying to get some pros and cons on using the nullable foreign keys.

View 1 Replies View Related

Forms :: How To Check Record Status

Sep 7, 2011

I am manually committing the form by writing commit statement in key - commit trigger for some reason.

Everything is working fine. I want to display a message if some necessary fields are not filled properly, like if a user filled half table and mistakenly he press the commit button. Here I want to show him a message that you can't saved the data because the table is not completely filled.

View 17 Replies View Related

SQL & PL/SQL :: How To Check Record Exists Validation

Jan 18, 2011

1. Below TXN_LOG table Expected to have 0.5 to 1 million records & TXN_LOG_HIST table will have max 3 million records.

2. On daily basis system will move records from TXN_LOG to TXN_LOG_HIST.

3. The below mentioned check will be performed for each transaction, With out this check currently my process is doing 10tps. (transaction per second).

CREATE TABLE TXN_LOG
(
REFNO VARCHAR2(16) PRIMARY KEY,
LOCATION VARCHAR2(3),
AC_NO VARCHAR2(20),
TXN_INIT_DATE DATE,
AMOUNT NUMBER(22,3),

[code]....

The below validation we are currently using which is overhead for our transactions processing. Also the below mentioned check will be performed for each transaction, With out this check currently my process is doing 10tps. (transaction per second).

BEGIN
SELECT COUNT(1)
INTO l_exists
FROMTXN_LOG
WHERE AC_NO = p_acho
TXN_INIT_DATE = p_txn_date
AMOUNT = p_amt

[code]....

Is there any fastest method to check above record exists validation from the both the table?

View 11 Replies View Related

SQL & PL/SQL :: How To Check Record Exist In Table

Feb 13, 2013

Usually we check 1 row of data in table and compare if they exist, i want to compare different set of row all together to comapre and take the decisions

eg.

emp table_source
d_key emp_no invol
1 103499 1
1 99262 2
2 103499 1
3 103499 1
3 99262 2

target table

emp_no invol
103499 1
99262 2
103499 1

in the above example i have to check for d_key for set of row exist in target or not, so by above example d_key 1 and 3 has save value in 2 different rows so i want to check if the combination of rows

103499 1
99262 2

as a set appear in source then do nothing else insert so first time d_key 1 both records will insert but for d_key has same set in 2 rows will not be inseted. the number of row can be more than 2 also . so for the given key if we have 3 rows in source then i have to compare all the 3 same set of row in target exist of . in the target i don't have any extra column.

View 3 Replies View Related

SQL & PL/SQL :: Record Doesn't Contain Page Then Need To Update As Null

Jun 13, 2013

frame a query for the below values .I have few records in a below format.

1) 'CODE#ATC#YEAR#1980#NUM#4229#VOL#80##'
2) 'CODE#NSWLR#YEAR#1985#PAGE#158#VOL#4##'
3) 'CODE#WASC#YEAR#1981#MONTH#07#DAY#24#'
4) 'CODE#RPC#YEAR#1919#PAGE#296#VOL#36#'

I need only the Page from the above records.For example if i take this record

'CODE#NSWLR#YEAR#1985#PAGE#158#VOL#4##' -- I need to extract only the Page from this like 158.

If the record doesn't contain Page then i need to update as null.

View 30 Replies View Related

Forms :: Stop Saving When Detail Record Is Null?

Feb 5, 2011

I have master detail block just consider Forms A as a master and Forms B as a Detail,when my cursor is in form A i try to save the record, it is saved Form A and putting Form B data as null, i have to put a validation to stop this activity, i have to inform the user "Provide values for form B text item",

I created a post block trigger in form A

Begin

If (:FORM-B.TEXT1 is null)l or( :FORM-B.TEXT2 is null)
then
Message( 'provide value for FORM-B');
Message( 'provide value for FORM-B');
raise form_trigger_failure;
ELSE
NULL;
END IF
END;

Im Getting error message and navigation got stopped in last item of form A itself,i need to show error message and cursor control should move to first item of form -B which trigger i have to use for this.

View 1 Replies View Related

PL/SQL :: How To Insert Null Record (some Column) In Table Using Loop

Jul 5, 2012

How to insert null record (for some columns) in table using loop.

sample data of x_tab

order_id order_name

231 xxx
123
345
111 vvvv

View 5 Replies View Related

PL/SQL :: How To Check Record Exists Prior To Insert Statement

Aug 12, 2012

Using a cursor and loop method records are inserted into the header and line tables. How do I code the IF statement prior to the INSert statement such that Insert if record does not exist else Update the record. If the record for insert fails in the line, the same record should be deleted from the header table as well and transaction should rollback. The Ora version used is 11.2.0.2.

CURSOR C1 IS
        SELECT H.*
        FROM   rex_head_extract h
        WHERE  TRUNC(h.create_date) BETWEEN v_begin_date AND v_end_date;  
FOR I IN C1 (v_begin_date, v_end_date)
 
[Code]....

--- Need to perform a check if record exists here prior to insert     
             INSERT INTO tran_head
                 (TRAN_SEQ_NBR,        ORG_NUMBER,
                  STORE_NUMBER,        TRAN_DATE,

[Code]....

View 9 Replies View Related

Server Utilities :: Field / Record Terminator - Trailing Null Col

Oct 7, 2010

I need to load a file with fields separated by '|^|' and at end of each record has '||*||'.

So in my ctl file what do i mention ? fields terminated by '|^|' ? for the record termination wat should I say?
Should I still mention 'trailing null col' in my ctl file...?

Sample data file:
Name|^|Age|^|city||*||
john|^|33|^|||*||
james|^||^|nyc||*||
ken|^|44|^|
washington||*||

the fields are properly terminated with |^| and the records are terminated with ||*||. Is it true that a file with |^| as field terminator cannot be loaded with sqlldr?

View 3 Replies View Related

SQL & PL/SQL :: Out Ref Cursor Based On Record Set

Sep 24, 2010

I have this record set coming from two tables.

cursor c1 is select cust_id from tab1 where login=in_login
union
select cust_id from tab2 where login_id = in_login;

in second step; I need to process and filter these ids based on some conditions.The final filtered record set I need to return as Out cursor;

How can I use the processed data to built the output ref cursor ?

View 4 Replies View Related

SQL & PL/SQL :: Using A Cursor Record In REGEXP_INSTR

Oct 18, 2012

I've got a task to star out account numbers in a free text field. The account numbers can be in a few different formats and there are a number of tables. The formats could increase or change as could the tables. For that purpose I want to use a couple of tables; one to store the formats and one to store the tablenames. The tablenames work fine, but I'm having problem with the formats.

The table definition for the formats is:-

CREATE TABLE account_format (acc_id number(2),acc_format VARCHAR2 (200), acc_replace VARCHAR2 (200),acc_process varchar2(1))
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;

and one insert would be

INSERT INTO account_format
VALUES (1,
'''[0-9]{5}[A-Z]{1}-[0-9]{5}''',
'''[0-9]{5}[A-Z]{1}-[0-9]{5}'',''****-****-****-****''',
'Y');

The idea is to bring back the format and use it in REGEXP_INSTR (or a similar REGEXP) to ascertain if the field contains the account number. The code I have been using looks a bit like this:-

CURSOR m_format_cur IS
SELECT acc.acc_format
FROM account_format acc;
m_format_rec m_format_cur%ROWTYPE;
IF REGEXP_INSTR (m_narrative, m_format_rec.acc_format) > 0 THEN
....
END IF;

I have tried several different ways to get this to work e.g. hardcoding the format and declaring a variable with the format, which both work. Whenever I try to use the value retrieved from the database field it never works. Why should a variable from a cursor not work?

View 8 Replies View Related

PL/SQL :: Way To Make A Cursor Of Record ID

Nov 15, 2012

I need to run a query that runs a stored procedure. The stored procedure takes a cursor of record ids as a parameter. I've been making the cursor like this, if there was a smarter way. I can't change the stored procedure, so this is the only thing I have control over.

CURSOR id_cur
IS
SELECT id
FROM table t
WHERE
t.id IN (
id1,
id2,
...
id500

);It just seems kind of strange to select only ids from records when the list of ids is given.

View 6 Replies View Related

Forms :: How To Check For Unique Value In Text Item In Multi-record Block

Mar 13, 2013

I have a multi-record block with several text items.

On one of the text items i want to enter a value and then check whether the same value for the item has already been entered on any other records within the block.

If it has already been entered then i want to display a message and null out the field.

I have tried using app_record.for_All_records from a when-validat-item trigger but this does not work as you get a 'FRM-40737 Illegal restricted procedure go_block in when-validate-item trigger ' error

View 17 Replies View Related

Forms :: Delete A Record In A Cursor

Mar 3, 2012

this is just the continuation of my previous topic,

After I bound data into the textboxes, now I want to delete it when I mistakenly click on the same data twice.

this is my screenshot:

View 4 Replies View Related

Forms :: Updating A Record In A Cursor?

Mar 3, 2012

when I updated a record in my form check my screenshot: and clicked save button the result was:

as you can see in the message at the bottom, it has 18 records. And since my original data(subjects) are just 9. And also the grades that I input didn't display all.

This is my code in when-new-block-instance trigger:
DECLARE
CURSOR studgrade_cur IS
SELECT e.student_id, s.subject_code --, g.grade

[code]...

View 39 Replies View Related

SQL & PL/SQL :: Cursor For Loop Updates Only One Record?

Feb 17, 2012

I have a table of 3 columns:

SQL> show user
USER is "ANDREY"
SQL>
SQL>
SQL>
SQL> --create the table:

[code]...

I insert rows into it:

SQL> --fill it with data:
SQL>
SQL> insert into a(key1 , key2) values (1 , 1);
1 row created.
SQL> insert into a(key1 , key2) values (1 , 5);

[code]...

i want to perform a logic by which:for every distinct value of key1 - values of key2 will be checked in all records holding that particular key1 value, and update the key3 field to 'inactive' where the key2 value for that particular key1 is the highest in number.

i've found out that i could do it by an SQL statement:

update a
set key3 = 'inactive'
where key2 = (
select max(key2)
from a a2 where a2.key1=a.key1
);

however I wanted to use the cursor to "load" the max key2 values FOR EACH distinct key1 value exists in the table,and do the same thing as the update statement above WITH A CURSOR,So tried and wrote the following:

SQL> create or replace procedure proc1
2 IS
3
4
5 var1 a.key1%type;

[code]...

unfortunately, it works only for one row, and i don't understand what's wrong, I executed, and checked what has changed:

SQL> exec proc1;
PL/SQL procedure successfully completed.
SQL> select * from a;
KEY1 KEY2 KEY3
---------- ---------- ----------
1 1 active
1 5 incative
2 24 active
2 21 active

ORA-01034: ORACLE not available

View 10 Replies View Related

Forms :: Cursor (control) On Current Record

Jul 18, 2011

In my form line level block contains 100 records.i will check the check box for line number 96 and 97. Then i will press save(I have written some logic here) button it will generate one number for selected check boxes. After generating this number cursor(control) should be on same line number 96 or 97.

View 10 Replies View Related

Forms :: Two Cursor Record Block - Decode Function

Sep 16, 2010

I have Two cursor record block..which is attached in form..

My TASK IS

In my first Block, When DBCR Column = 'D' Then in backend this column value should be save as a '1'
WHEN DBCR Column = 'C' Then Then in backend this column value should be save as a '2'

My Both Field is on Data Block...

In Property palette of this field can we write any decode condition..so it reflects directly on database.

View 2 Replies View Related

Forms :: Click Checkbox And Then Loop - Current Cursor Going To Last Record

Dec 7, 2010

i m using oracle 10g 10.2.0.2 version.i create a form and using check box on this form.when i click this check box then loop is using behind it.and current cursor is going to last record

i want if i click 4 record then cursor is still showing on 4 record mean i click which record after using loopmy current cursor is showing on that particular record

how it is possible

View 1 Replies View Related

PL/SQL :: Create Record Variable That Refers Dynamic Query Assigned To Ref Cursor?

Nov 11, 2012

Just explaining what I am trying to achieve:

1) i have a hr.departments table that was loaded in hr schema on 1st oct 2012 with 4 columns(department_id, department_name, manager_id, location_id)

2) now I have a new schema by my name 'rahul' and I have loaded departments table but now an additional column has come into picture,ie created_date, this table got loaded on 1st-Nov-2012

3) Now going forward my columns could be dropped from the departments table (it can be a case), for example might be my departments table in my schema 'rahul' one day could comprise of only 3 columns(department_id,department_name,manager_id)

4) Now in the next step, I have managed to extract common column names(in a single line where columns are delimited using a comma) from both the tables(hr.departments and rahul.departments) which are (department_id, department_name, manager_id, location_id) using all_tab_cols table and I have written a function for it which i will be pasting below.

5) now going forward, using the above column names line with column names delimited using comma, I have used a ref cursor and assigned a query to it using the line of columns that I have extracted from the above point

6) Now I want to create a record variable which refers to my ref cursor, something like we do when we create a record variable by reffering to an explicit cursor defination that we give in the declaration block.

PS:

1) I have been out of touch with plsql for a long time so I have lost a lot of mmeory regarding plsql.

2) basically I need to compare data in hr.departments table with rahul.departments table for only columns that are common to both the tables, rest new or discarded columns information will go in one of the log tables that I have created(this is done already)

Code :
===================================================================================================
create or replace procedure p_compare_data(fp_old_table_name in varchar2, fp_new_table_name in varchar2)
is

[Code].....

View 5 Replies View Related

SQL & PL/SQL :: Cursor Implement / Strings Of Data Concatenated Into One Sales Contact Record

Sep 23, 2013

how to write below query in pl/sql cursor. The help table has two associated tables, help_txt and help_id, which will have strings of data concatenated into one sales contact record. There are multiple lines of text per comment and multiple lines of resolution text at 40 characters per line. The key to the help_text table (id, date,seqno) is the main key to the help_txt table and help_id t table with a sequence added to each table

The formatted string will contain some text and variables with the comment lines (1-10 or more) concatenated first, followed by the resolution lines (1-10 or more). There will be multiple comment and multiple resolution lines. The Cust_Cmnt_Txt lines and the Resolved_Desc lines should be concatenated and formatted in the following string (% marks the variable string) :

'help taken ' %help.Taken_Dte 'received from the following source: ' %help.id. 'Remark Text: ' %help_text (where help_txt_Seq = 1) %help_text (where help_text_seq = 2-10 or more) 'Resolution: ' %help_id_Res_Txt.Resolved_Desc (where help_ID_Txt_Seq = 1) %help_ID_Res_Txt.Resolved_Desc (where help_id_Txt_Seq = 2-10 or more)

View 8 Replies View Related

Forms :: Put One Check Box To Check All The Check Boxes?

Jul 30, 2011

I want to put one check box to check all the check boxes.how can i do this?

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved