473,382 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

no data found error in an "execute immediate" statement

65
i dont know why pl/sql block below returns no data found error.
do you have any idea about it?

Expand|Select|Wrap|Line Numbers
  1. declare
  2. c1 varchar2(80);
  3. c2 varchar2(80);
  4. begin
  5. execute immediate 'select col2 from table1 where col1=:c1'
  6. into c2 using 'AAA';
  7. end;
  8. /

here is the definition of table:

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE TABLE1
  2. (
  3.   COL1  VARCHAR2(80 BYTE),
  4.   COL2  VARCHAR2(80 BYTE),
  5.   VAL   VARCHAR2(80 BYTE)
  6. )

and the data contained by the table:


Expand|Select|Wrap|Line Numbers
  1. Insert into TABLE1
  2.    (COL1, COL2)
  3.  Values
  4.    ('AAA', '1');
  5. Insert into TABLE1
  6.    (COL1, COL2)
  7.  Values
  8.    ('BB', '2');
  9. Insert into TABLE1
  10.    (COL1, COL2)
  11.  Values
  12.    ('C', '3');
  13. COMMIT;
error message:
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at line 5
Apr 4 '08 #1
5 11762
amitpatel66
2,367 Expert 2GB
Try This:

Expand|Select|Wrap|Line Numbers
  1.  
  2. declare
  3. c1 varchar2(80):= 'AAA';
  4. c2 varchar2(80);
  5. begin
  6. execute immediate 'select col2 from table1 where col1='||CHR(39)||c1||CHR(39)
  7. into c2;
  8. end;
  9. /
  10.  
Apr 4 '08 #2
stmfc
65
Try This:

Expand|Select|Wrap|Line Numbers
  1.  
  2. declare
  3. c1 varchar2(80):= 'AAA';
  4. c2 varchar2(80);
  5. begin
  6. execute immediate 'select col2 from table1 where col1='||CHR(39)||c1||CHR(39)
  7. into c2;
  8. end;
  9. /
  10.  

amitpatel66, thanks a lot for your reply.
i tried the way that you told, but it gives the same error (no data found)
Apr 4 '08 #3
amitpatel66
2,367 Expert 2GB
just a silly verification, I hope you had already checked, if not then Could you please check your table ones if it contains data?
Apr 4 '08 #4
stmfc
65
just a silly verification, I hope you had already checked, if not then Could you please check your table ones if it contains data?
i have checked it again, and for sure it contains data.
Apr 4 '08 #5
Dave44
153 100+
it must be something like your data isnt committed into the table. your code seems as though it should work.
Expand|Select|Wrap|Line Numbers
  1. [97]asok@DEV01> create table t (col varchar2(1));
  2.  
  3. Table created.
  4.  
  5. Elapsed: 00:00:00.20
  6. [97]asok@DEV01> insert into t values ('A');
  7.  
  8. 1 row created.
  9.  
  10. Elapsed: 00:00:00.03
  11. [97]asok@DEV01> commit;
  12.  
  13. Commit complete.
  14.  
  15. Elapsed: 00:00:00.01
  16. [97]asok@DEV01> select * From t;
  17.  
  18. C
  19. -
  20. A
  21.  
  22. Elapsed: 00:00:00.07
  23. [97]asok@DEV01> DECLARE
  24.   2       v1     VARCHAR2(30);
  25.   3       v2     VARCHAR2(30);
  26.   4  BEGIN
  27.   5       EXECUTE IMMEDIATE 'select col from t where col=:v1'
  28.   6       INTO              v2
  29.   7       USING             'A';
  30.   8  END;  
  31.   9  /
  32.  
  33. PL/SQL procedure successfully completed.
  34.  
  35. Elapsed: 00:00:00.06
  36. [97]asok@DEV01> DECLARE
  37.   2       v1     VARCHAR2(30);
  38.   3       v2     VARCHAR2(30);
  39.   4  BEGIN
  40.   5       EXECUTE IMMEDIATE 'select col from t where col=:v1'
  41.   6       INTO              v2
  42.   7       USING             'C';
  43.   8  END; 
  44.   9  /
  45. DECLARE
  46. *
  47. ERROR at line 1:
  48. ORA-01403: no data found
  49. ORA-06512: at line 5
  50.  
  51.  
  52. Elapsed: 00:00:00.06
  53. [97]asok@DEV01> DECLARE
  54.   2       v1     VARCHAR2(30) := 'A';
  55.   3       v2     VARCHAR2(30);
  56.   4  BEGIN
  57.   5       EXECUTE IMMEDIATE 'select col from t where col=:v1'
  58.   6       INTO              v2
  59.   7       USING             v1;
  60.   8  END;
  61.   9  /
  62.  
  63. PL/SQL procedure successfully completed.
  64.  
  65. Elapsed: 00:00:00.04
  66.  
Apr 4 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: RC | last post by:
In my Access 2002 form, I have a combo box and on the AfterUpdate event I use DoCmd.RunSQL ("UPDATE .... to update records in a table. When it starts to run I get a message "You are about to...
2
by: Eli | last post by:
Hi all We currently have a strange problem with calling a Stored Procedure (SQL Database) in our C# Project. The only error I get is "System error" which says a lot :) Background: We have...
2
by: Mike | last post by:
Is there an equivalent in VB.Net or C# of VBScript's "Eval" and "Execute" statements? Thanks, Mike
6
by: TJS | last post by:
in vbscript there was a command called "execute" which would process a dynamic string, vb.net dropped that feature ... does anybody have a working solution for sale or free that will execute a...
4
by: David A. Beck | last post by:
I was looking for the "Immediate" window like in Classic VB but could not find it.
23
by: ticfranca | last post by:
Hi, I'm getting this error in the code below: sub Pega_recorde { $database = 'bundinha'; $host = 'localhost'; $usuario = 'myhumoradm'; $senha = 'my8xr2d2'; ...
3
by: ChildProgrammer | last post by:
I am trying to upload data into an Access db from vb.net. The data was parsed out from text files. Everything seems to be working fine up till the .execute point. The debugger insists there is a...
8
by: cmuraz | last post by:
hi i need to insert values in a temporary teble which i dynamically create the columns like tbl_01, tbl_02.... for eg., execute immediate 'INSERT INTO...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.