PL/SQL :: Passing Char Variable In Cursors - Not Taking?

Apr 9, 2013

i trying to pass the char varible to the cursor but it is not taking ,,, if i hardcode the values to the cursor it is takinghere is the detailed program ... any body can tell why this is not taking and tell me how to pass the values through it..

declare
v_name char(6) ;
cursor c1(c_name char) is
select name, parent,child,status from relation
start with name='%'

[code]....

View 4 Replies


ADVERTISEMENT

SQL & PL/SQL :: Passing The Char Variable In Cursor

Apr 9, 2013

i trying to pass the char varible to the cursor but it is not taking ,,, if i hardcode the values to the cursor it is taking

here is the detailed program ... why this is not taking and tell me how to pass the values through it..

declare
v_name char(6) ;
cursor c1(c_name char) is
select name, parent,child,status from relation
start with name='%'
connect by prior parent=child
union

[Code]...

View 9 Replies View Related

SQL & PL/SQL :: Ref Cursors For Passing Parameters?

Mar 20, 2013

declare
type ref_cur is ref cursor;
r ref_cur;
enam emp%rowtype;
dno dept.deptno%type;
begin
dbms_output.put_line('The Employee details are');
open r for select deptno from dept;
loop
fetch r into dno;

[code]....

Error at line 1
ORA-06550: line 12, column 28:
PLS-00103: Encountered the symbol "FOR" when expecting one of the following:

. ( % ;

if i need to use ref cursor to send parameters, is it possible? if yes how to use it?

View 3 Replies View Related

SQL & PL/SQL :: Passing Multiple Parameters To Cursors?

Jun 18, 2013

How can we pass multiple parameters to cursors?

Ex: Cursor C_employees(C_empid number, C_cityname varchar2) is select emp_name, office_name from employee where employees where empid = c_empid and city = c_city_name;

I know we can pass one parameter to the cursor but I do not know how to pass multiple parameters.

View 8 Replies View Related

SQL & PL/SQL :: Passing Bind Char Correctly

Dec 7, 2010

I tried google and most of bind example using number instead of character, ?

I have the code as below:

variable oldId varchar2(5)
exec :oldId :='&1'
variable newId varchar2(5)
exec :newId :='&2'

[Code]...

Since in TAB1, ID is defined as varchar2(5), and I have defined both oldId and newId as varchar2(5) in my code, I wonder why it doesn't work.

It returned this error:

DECLARE
*
ERROR at line 1: ORA-01722: invalid number ORA-06512: at line xx

After supply the value for oldId(val2) and newId(val1)

SQL > @thisScript val1 val2

I use dbms_output.put_line to print the command executed, it seems it is doing

UPDATE TABLE1 SET ID = val1 WHERE ID = val2

without the single quote ('val1'), ('val2'). But if I put in single quotes, the output statement

UPDATE TABLE1 SET ID = ':newId' WHERE ID = ':oldId'

The same bind logic works in SQL prompt

SQL > variable oldId varchar2(5);
SQL > variable newId varchar2(5);
SQL > exec :oldId :='val2'
SQL > exec :newId :='val1'
SQL > UPDATE TABLE1 SET ID = :newId WHERE ID = :oldId;
1 row updated.

I am wondering what should I do then? With or without single quotes?

View 9 Replies View Related

Declaring Cursors With A Variable

Jul 7, 2010

I'm currently looking for a way to declare a cursor in the 'declare' block using a previously defined variable that got its value from a query. For instance:

declare
my_company_id INTEGER := 'select c.company_id from company_table c where company_name='Wal-Mart';

cursor employees is
select e.employee_id from employees e where e.company_id = my_company_id;

Any way to do this?

View 4 Replies View Related

Passing Variable To Exp In UNIX?

Sep 20, 2013

I want to pass a variable in unix to oracle exp command

I have a file with owner and password

I did

export user=$(head -$riga $file | tail -1)
echo $user
let riga+=1
export psw=$(head -$riga $file | tail -1)
echo $psw
exp $user/$psw file=exp_$current.dmp

but this doesn't work.

View 4 Replies View Related

SQL & PL/SQL :: Passing Variable Into TO_DATE Function

Apr 14, 2011

select to_date('13:14:00', 'HH24:MI:SS') FROM DUAL;

what is output of this?

and why this result is coming?

View 32 Replies View Related

SQL & PL/SQL :: Passing Variable Into TO_DATE Function?

Aug 10, 2010

I am trying convert number value in date. I know somewhere I doing mistake. But I cant get it.

Here is my Partial Code

create or replace
PROCEDURE "REPORT_ARTICLEMOSTVIEWED2"
(

[Code]....

Error starting at line 5 in command:
EXEC REPORT_ARTICLEMOSTVIEWED2(null,null,null,null,:RC)
Error report:
ORA-01858: a non-numeric character was found where a numeric was expected
ORA-06512: at "IIS_ORACLE_11GR2_LIVE.REPORT_ARTICLEMOSTVIEWED2", line 22
ORA-06512: at line 1
01858. 00000 - "a non-numeric character was found where a numeric was expected"
*Cause: The input data to be converted using a date format model was
incorrect. The input data did not contain a number where a number was
required by the format model.
*Action: Fix the input data or the date format model to make sure the
elements match in number and type. Then retry the operation.
RC

How do I put condition for Null value in this procedure And set dateTo = sysdate if v_day,v_month,v_year are null.

View 9 Replies View Related

Passing Sh Variable Value To Input Of PL/SQL Procedure

Aug 30, 2012

how can I pass the sh variable (.i.e file name stored in sh variable called($F)) as a input of below mention procedure (YODEL_XL_ INS_SDG_ COMMER_ PROD)

for F in *.dat; do
#
echo $F
#
#sqlldr apps/apps control=$CONTROL data=$F
# Below Part is used for Add the file name into table
[code]...

View 8 Replies View Related

SQL & PL/SQL :: Passing Input Parameter To Like Variable In Procedure

Dec 27, 2012

I have a procedure named 'GetShipperinfo' which takes i_name as input and needs to build a cursor taking i_name as input

i.e.

The following sql when executed at sqlplus prompt gives correct results.

select dept, supplier, shipper_id
from shippers
where upper(shipper_name) like upper('Frank Robert%');

How can I transform this inside a cursor within a procedure passing 'Frak Robert' value as i_name input.

i.e I should be able to call the procedure as follows

sql> variable v1 varchar2;
sql> exec pkg_shipment.GetShipperinfo('Frank Robert',:v1);
sql> print :v1;

Should the cursor inside the procedure be built as follows

cursor c1 is
select dept, supplier, shipper_id
from shippers
where shipper_name like ''||upper(i_name'%''||)'';

Iam unable to build the sql for the cursor.

View 3 Replies View Related

PL/SQL :: Passing Json String Into Varchar2 Variable

Jan 11, 2013

I'm trying to pass a JSON string into a stored procedure that has a single VARCHAR2 variable.

begin
SAVE_JSON('{"app_id":"800414","merch_id":"84657156","user_id":"6985","P25_DBA_NAME":"TEST"}');
end;
/

I'm getting the ORA-20001: ORA-06502: PL/SQL: numeric or value error

View 3 Replies View Related

Application Express :: Passing Variable To Javascript

Aug 28, 2013

4.1.2theme 24

I have a .js process in the before header of a page which has this pl/sql process using htp script javascript function {code} 

function check(flag_val){ if(flag_val=="N") 
document.getElementById("btn").disabled = true;
else 
document.getElementById("btn").disabled = false;  } 
{code} 

and then there is the actual pl/sql process which  has a cursor 

{code} 
declareflg varchar2(1);
..begin selectflag into v_flagfrom table where rownum = 1;
-- actual conditions are different but this returns one value.

 Then below using htp package I had html table with something like 

<td align="right">
<button class="btn btn-success" type="button" id="btn"  onclick="check(flg);"
title="Accept Lead" style=" width:50px;">Flag value</button> </td>  
 {code}

For some reason the script function is not called if I use onload. If I change the onload to onclick it works. Also, if I pass check(flg) it does not work. If I use check(''N'') then is works fine. question is how do I pass a pl/sql variable flg in this case to a javascript function as a parameter? I basically, want the value of flg checked on page load and then if it is N then disable the button. Or else keep it enabled.

View 0 Replies View Related

Client Tools :: Passing Variable And Displaying Select Data In TOAD?

Apr 22, 2010

All I want to do is run a procedure (DO_H_RUN) that returns a number into "v1" and then use that variable to return the result sets in three selects. This is all in TOAD. If I do not have a where clause, the code executes fine (allowing me to see the data in multiple Grid tabs)! But, I want to filter the rows.

I've tried doing a number of different things (finding all sorts of stuff on the Web) like declaring cursor variables and the like but after spinning on this for a couple of hours, I'm stuck.

Here's my attempt (the names have been changed to protect the innocent!):

declare
v1 Numeric;
BEGIN
DO_H_RUN('Me', v1);
--DBMS_OUTPUT.PUT_LINE(v1); --This line works okay!
select * from h_run where h_run_id=v1; --NO GO

[code]....

View 10 Replies View Related

SQL & PL/SQL :: Search Swedish / Danish / German Char Using English Char

Oct 27, 2010

I want to pass english character as a parameter and search a string that having swedish character, this needs to be done for all the swedish characters.

test _t table having the below 3 values

päiväp
metervara
flerfärgad

1. If user searches based on english char like below then they should get all the 3 values bcz fist & last have swedish ä and second one having english a.

Query : select name from test_t where name like '%a%'

Regsult:
päiväp
metervara
fräg

2. If user searches based on swedish char like below then they should get only 2 values bcz fist & last have swedish ä and second one having english a.

select name from test_t where name like '%ä%'

päiväp
fräg

Is any in-built function available, for Text alternative string search. If not how to search the string based on the query.

View 6 Replies View Related

Selection Criteria Char Between Char

Jul 22, 2009

I have a table with column val1 having data's starting with 0920 and 4 digit char values.

so we have the query to find

select * from table
where val1 between '0920' and 'ZZZZ'

will it work fine?

View 1 Replies View Related

Time Spent Using Cursors?

Jun 17, 2013

I have two methods using pro*c to execute a query SQL and read the results. The query is a "select from" a view, this view is a union between two tables. The first method creates a cursor and fetches the results line by line. A second method creates a cursor and fetches the results in parts.

Method 1)
CODEEXEC SQL FETCH Cursor1 INTO ...

Method 2)
CODEEXEC SQL FOR :numLines FETCH Cursor1 USING DESCRIPTOR areaDescSQL;

I had executed this methods in my development enviroment, using Oracle 11g, Suse linux. As I expected, the method 2 spent much less time than the method 1. But, in the "customer enviroment", using another database, Oracle 11g and HP-UX, these methods spent almost the same time.

Is there some Oracle's configuration or parameter's settings that maybe explain that? What configuration can be differente between the two databases? What can I do to improve the time spent?

View 1 Replies View Related

SQL & PL/SQL :: Alternative To Oracle Cursors

Aug 13, 2013

an alternative to Oracle Cursors.My table has huge amount of data and is taking time in processing. I had thought of using BULK COLLECT but it can only be used to insert, delete or update data and will not allow me to select data.

View 33 Replies View Related

SQL & PL/SQL :: Usage Of Cursors In Stored Procedure

Feb 22, 2012

i have created a stored procedure with a cursor in order to perform a function where the annual_sal from the employee_annual_sal table is refered and checked. The empno for all the records which satisfies the condition mentioned inside the loop should be displayed in an variable. My code is below

create or replace PROCEDURE sp_test_cursor(out_empno OUT number)
IS
v_get_data number;
v_get_empno number;
cursor c1 is
select annual_salary
from employee_annual_sal;

[Code]...

What should i do to return mulitple values in a single variable??

View 4 Replies View Related

SQL & PL/SQL :: Creating Procedure Which Will Process All The Cursors?

Apr 19, 2012

My requirement is like as follows,

declare
v1str varchar2(100):='select empno,ename from emp';
v2str varchar2(100):='select empno,ename,sal from emp';
type t_array is varray(2) of varchar2(100);

[Code]....

So my problem is while executing the different sql statements by passing it to the procedure,how can the procedure would behave dynamically.It must be able to process all the sql statements.

View 21 Replies View Related

SQL & PL/SQL :: How To Remove Odd Rows From A Table Without Using Cursors

Nov 16, 2011

I have a table table1 with 2 crore records.

select * from table1;
id code updateddatetime
------------------------------------
1 10001 2011-10-21 15:31:21.390
2 10001 2011-10-21 15:31:22.390
3 10001 2011-10-21 15:31:21.390
4 10001 2011-10-21 15:31:22.390
5 10002 2011-10-21 15:31:22.390

I want to delete records like id 2 which has odd updated time which is more than id 3 updated time.

is there any alternatives without using cursors as it taking so much time to process.

View 12 Replies View Related

SQL & PL/SQL :: How To Use Cursors / Loops And Proper Syntax

May 31, 2011

homework assignment using pl/sql based on 2 tables I have created below? I am not sure of how to use cursors, loops and proper syntax.

ASSIGNMENT:

1. Create a PL/SQL Procedure (cursor to loop through the records, check the LastName, then update the grade table
where id=id on grade table)

Rule:
A
‐ LastName ends with a character between A‐F
B
‐ LastName ends with a character between G‐K
C
‐ LastName ends with a character between L‐P
D
‐ LastName ends with a character between Q‐T
E
‐ LastName ends with a character between U‐Z

Create TABLE Registration (RegistrationID number(10), SectionID number(10), CourseID number(10),
SectionNumber varchar2(10),
StudentID number(10), FirstName varchar2(20),
LastName varchar2(20), CourseNumber varchar2(20), CourseName varchar(20));
[code].....

View 20 Replies View Related

SQL & PL/SQL :: Cursors To Load Data Into A Table?

Oct 3, 2011

DB version: Oracle DB 10g Enterprise Edition 10.2.0.4.0

I have the following four tables:

tab_main- which lists main projects
tab_sub_main - which lists sub projects
tab_budget - amounts per projects/subprojects
tab_total - I want to load the data here

The table script with data is attached.

I want to load data into tab_total fields for prj_type= 'J' as follows:

1. accn_no from tab_main table.

2. fy from tab_budget table

3. fy_total_amt which is the sum(amt) from tab_budget table by accn_no and fy

4. all_FY_amt which is the sum(amt) from tab_budget table by accn_no

5. all the audit fields- date/user inserted/updated will come tab_budget table

how to create this procedure with cursors.

CREATE OR REPLACE PROCEDURE LOAD_DATA_INTO_TAB_TOTAL_PROC
IS
CURSOR C IS
select distinct m.accn_no, a.control_no,m.prj_type,
b.fy, b.amt, b.user_created, b.date_created, b.user_last_mod, b.date_last_mod
from tab_main m,
tab_sub_main a,

[code]....

CREATE TABLE tab_main
(
ACCN_NO NUMBER(7) NOT NULL,
PRJ_TYPE VARCHAR2(1 BYTE) NOT NULL
)
/
Insert into TAB_MAIN
(ACCN_NO, PRJ_TYPE)

[code]....

View 34 Replies View Related

PL/SQL :: Return Cursors To Front End Program

Mar 14, 2013

I am trying to write which will return cursors to front end program.The logic which I got stuck is while exiting the procedure.I am having some cursors in teh procedures which are read by the front end script.I have one condition which when satisfied I have to exit from the procedure.But the constraint I am facing is if I exit at that logic, oracle closes all the cursor and front end script is not able to read teh cursor and hence throws an error.Is there any way to exit the procedure without closing the REF cursors.

View 3 Replies View Related

Cursors - Display Data Gathered From 3 Different Tables?

Apr 30, 2010

I am stuck somewhere in my project, situation is that we are trying to display data gathered from 3 different tables, we used cursors for this, here is the cursor declaration.

DECLARE
procedure DocInfoCur(myWhere IN varchar2) IS

init_dept_id number;
init_dept_name varchar2(40);

rcvg_dept_id number;
rcvg_dept_name varchar2(40);

CURSORCUR_DOCINFO IS
SELECT DISTINCT I.CTN, I.DIARYNUMBER, I.INITIATINGDATE, T.TYPENAME, I.INITIATINGDEPT,
I.DOCUMENTSUBJECT, I.DESTINATIONDEPT
FROM DOCUMENTINFO I, DOCUMENTTYPE T, DEPARTMENT D

[code]...

This displays all the records out there.

Now, I have a search form where I need to filter the same data with different parameters, I have compiled the entered data in one string, now i need to join that string at the end of where clause of my cursor, how can I do that, i have tried concatenating both but received compile error, is there a way out in the current scenario???

View 1 Replies View Related

ORA 0100 - Maximum Open Cursors Exceeded?

Oct 23, 2006

I think this is the scariest error I've encountered in oracle. After some thime of developing/debuggin I've always reached this error. This leaves me no choice but to restart the java app server, in that case I'll be affecting all the other applications deployed on it which is a very bad thing for me.

Is there anyway I could solve this, I've made it sure that I've handled all errors so that I could always close the connection. Simply put, for every termination case of my program I've placed a closing statement just to be sure that no connections are left open. But even after this, I still experience the ORA 0100 error.

View 8 Replies View Related

SQL & PL/SQL :: How To Make General Procedure Print Cursors

May 27, 2011

how to print cursors? I mean like columnname : value. of couse curosr.columnname gives what I want. but I want genrally used way.

CREATE OR REPLACE PROCEDURE PROC_TEMP
IS
BEGIN
FOR C1 IN ( SELECT sbjct_id,sbjct_step
FROM RND.SBJCT_ORDR M) LOOP
DBMS_OUTPUT.PUT_LINE('c1 : '||c1);
END LOOP;
END;

View 3 Replies View Related

SQL & PL/SQL :: Exceptions Does Not Raise In Cursors Declared By User?

Feb 17, 2012

Why exceptions does not raise in cursors declared by user like in the following program

create or replace function sal (p_id employees.department_id%Type) return number is
----sal1 employees.salary%type:=0;
cursor cx is
select * from employees where department_id=p_id;
begin
for i in cx

[code]...

View 13 Replies View Related

SQL & PL/SQL :: How To Loop Through Nested Cursors Based On Value From 1st Cursor

Jul 21, 2011

I loop through the 1st cursor (account_csr), while in the 1st csr loop, based on some conditions being true, I want to loop through a 2nd cursor (acctper_csr) but I only want to retrieve data/rows in the 2nd cursor where the account_id column in 1st cursor = account_id column in the 2nd cursor. This will enable me to pull all the account_periods for each account I loop through in the first cursor.

I have attempted several different ways and cannot make this work. Thought I could somehow define a variable and store the account_id from 1st cursor and use on the 'where' clause in the 2nd cursor definition. Have not been able to make this work successfully.

Following is the sample of my

--First cursor (accounts)
CURSOR account_csr is
SELECT *
FROM s_dev_xref1.account A
WHERE a.source = 1

[Code]...

View 7 Replies View Related

Performance Tuning :: PLSQL And Related Cursors Generated In V$sql

Jan 26, 2012

I wanted to know how to find the links between cursors that have been created in v$sql after compiling a PLSQL procedure.

For example, if i compile the following procedure :

create or replace
PROCEDURE PROCEDURE1
AS
BEGIN
insert into t values(1,1);
END PROCEDURE1;

, the 2 following cursors are created in v$sql :

select SQL_ID, SQL_TEXT from v$sql
where sql_id in ('71pj8t5nz1d80','2s567zb6684sh');

"SQL_ID""SQL_TEXT"
"2s567zb6684sh""BEGIN PROCEDURE1; END;"
"71pj8t5nz1d80""INSERT INTO T VALUES(1,1)"

Thus, i would like to know how to find that the cursor 71pj8t5nz1d80 is called/linked by the cursor 2s567zb6684sh.

This would be useful for interpreting some sql statistics in v$sqlstats in where such cursors appear and related sql statistics are accounted twice.

View 1 Replies View Related







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