?
Solved

something to deal with Long Data type

Posted on 2003-03-25
11
Medium Priority
?
359 Views
Last Modified: 2013-12-12
Hi,
   I have a table where we have a column with Long data type and we usually store the ules which are SQL statements in that column. say for eg: the column would hold data like this...

insert into tab1(col1,col2)
select 100,colx from tab2
where coly is not null
/

In my procedure I have to execute these rules and I get an error saying that my SQL syntax is not correct.
I have trid running the same SQL in SQL plus and it works. I think it has got something to do with the Long data type becuase, I created an other table with varchar2(2000) instead of long and it worked fine.

procedure test_commit is
v_sql validate_rules.validate_code%type;
begin
select validate_code into v_sql from validate_rules where validate_id = 1001;
dbms_output.put_line(v_SQL);
execute immediate v_SQL;
end;

ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at "test_SCHEMA.TEST_COMMIT", line 7
ORA-06512: at line 1


Any ideas on the why long cannot be used here???

ukorep
0
Comment
Question by:ukorep
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
11 Comments
 
LVL 15

Expert Comment

by:andrewst
ID: 8204180
I don't think there is any problem with using LONG, provided that the SQL statements do not exceed 32767 characters in length - that is the limit for a PL/SQL long variable.

What does the PUT_LINE show?
0
 
LVL 1

Author Comment

by:ukorep
ID: 8204245
This is the outcome when I run my procedure

INSERT INTO ERROR_LOG (LINE_NUMBER, BATCH_ID, ERROR_NUM
SELECT LINE_NUMBER, BATCH_ID,
'1001'
FROM TEMP_WATER_LVL
WHERE WELL_NUM NOT IN (SELECT WELL_NUM
FROM WELL)

/
BEGIN test_commit; END;

*
ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at "WQD_SCHEMA.TEST_COMMIT", line 7
ORA-06512: at line 1
0
 
LVL 1

Author Comment

by:ukorep
ID: 8204256
This is the outcome when I run my procedure

INSERT INTO ERROR_LOG (LINE_NUMBER, BATCH_ID, ERROR_NUM
SELECT LINE_NUMBER, BATCH_ID,
'1001'
FROM TEMP_WATER_LVL
WHERE WELL_NUM NOT IN (SELECT WELL_NUM
FROM WELL)

/
BEGIN test_commit; END;

*
ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at "WQD_SCHEMA.TEST_COMMIT", line 7
ORA-06512: at line 1
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:ukorep
ID: 8204267
This is the outcome when I run my procedure

INSERT INTO ERROR_LOG (LINE_NUMBER, BATCH_ID, ERROR_NUM
SELECT LINE_NUMBER, BATCH_ID,
'1001'
FROM TEMP_WATER_LVL
WHERE WELL_NUM NOT IN (SELECT WELL_NUM
FROM WELL)

/
BEGIN test_commit; END;

*
ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at "WQD_SCHEMA.TEST_COMMIT", line 7
ORA-06512: at line 1
0
 
LVL 15

Expert Comment

by:andrewst
ID: 8204276
Your SQL is missing a bracket after ERROR_NUM:

INSERT INTO ERROR_LOG (LINE_NUMBER, BATCH_ID, ERROR_NUM)
SELECT ...

0
 
LVL 1

Author Comment

by:ukorep
ID: 8204277
Oh.. I am sorry after I submitted, I refreshed  the page and it started displaying that many number of times. I didn't mean to post my outcome three times.
0
 
LVL 1

Author Comment

by:ukorep
ID: 8204282
sorry that is my fault that I didn;t copy from sql plus properly. Here you go

SQL> exec test_commit;
INSERT INTO ERROR_LOG (LINE_NUMBER, BATCH_ID, ERROR_NUMBER)
SELECT LINE_NUMBER, BATCH_ID,
'1001'
FROM TEMP_WATER_LEVEL
WHERE DEQ_WELL_NUM NOT IN (SELECT DEQ_WELL_NUM
FROM WELL)

/
BEGIN test_commit; END;

*
ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at "WQD_SCHEMA.TEST_COMMIT", line 7
ORA-06512: at line 1
0
 
LVL 15

Expert Comment

by:andrewst
ID: 8204332
Is that blank line and / after the INSERT statement actually stored in the validate_code column?  It should not be.

What is the output of:

select validate_code from validate_rules where validate_id = 1001;

?
0
 
LVL 1

Author Comment

by:ukorep
ID: 8204419
Even I thought that would be the issue and changed it. Hereis the outcome..
SQL> exec test_commit;
INSERT INTO ERROR_LOG (LINE_NUMBER, BATCH_ID, ERROR_NUMBER)
SELECT LINE_NUMBER, BATCH_ID, 1001 FROM
TEMP_WATER_LEVEL
WHERE DEQ_WELL_NUM NOT IN (SELECT DEQ_WELL_NUM FROM WELL)
/
BEGIN test_commit; END;

*
ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at "WQD_SCHEMA.TEST_COMMIT", line 7
ORA-06512: at line 1


Also, I ran the SQL that you would like to see the outcome for...and here is the output.

VALIDATE_CODE
--------------------------------------------------------------------------------
INSERT INTO ERROR_LOG (LINE_NUMBER, BATCH_ID, ERROR_NUMBER)
SELECT LINE_NUMBER, BATCH_ID, 1001 FROM TEMP_WATER_LEVEL
WHERE DEQ_WELL_NUM NOT IN (SELECT DEQ_WELL_NUM FROM WELL)
/
0
 
LVL 15

Accepted Solution

by:
andrewst earned 200 total points
ID: 8204467
Remove that trailing / from the validate_code value, and it should work.
0
 
LVL 1

Author Comment

by:ukorep
ID: 8204573
hey, You are right!!! Thank you so much. I did so much research and did bother to remove that little "/" from there.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question