Home » SQL & PL/SQL » SQL & PL/SQL » accessing package in SQL query (PL/SQL)
accessing package in SQL query [message #350249] Wed, 24 September 2008 08:54 Go to next message
tayana
Messages: 1
Registered: September 2008
Location: Bangalore
Junior Member
CREATE OR REPLACE PACKAGE Package
IS
feature CONSTANT PLS_INTEGER := 1;
END;

Create table test1
(
column1 number;
);

for this while inserting am getting following err:

insert into test1 values(Package.feature);
*
ERROR at line 1:
ORA-06553: PLS-221: 'FEATURE' is not a procedure or is undefined

[Updated on: Wed, 24 September 2008 08:56]

Report message to a moderator

Re: accessing package in SQL query [message #350255 is a reply to message #350249] Wed, 24 September 2008 09:07 Go to previous message
smartin
Messages: 1803
Registered: March 2005
Location: Jacksonville, Florida
Senior Member
Please don't paste fake stuff, just capture your exact sqlplus session and paste it (between code tags).

Your example doesn't work...the table doesn't even create.

And don't create a package with the name of package...

Also, the more common way of doing what you are doing would be to create a function that would return the value.

Or, do the insert inside plsql:

MYDBA@orcl > start test
MYDBA@orcl >
MYDBA@orcl > CREATE OR REPLACE PACKAGE mypack
  2  IS
  3          feature CONSTANT PLS_INTEGER := 1;
  4  END;
  5  /

Package created.

MYDBA@orcl > show errors
No errors.
MYDBA@orcl >
MYDBA@orcl > create table test1
  2  (
  3          column1 number
  4  );

Table created.

MYDBA@orcl >
MYDBA@orcl > insert into test1 values (mypack.feature);
insert into test1 values (mypack.feature)
                          *
ERROR at line 1:
ORA-06553: PLS-221: 'FEATURE' is not a procedure or is undefined


MYDBA@orcl >
MYDBA@orcl > begin
  2          insert into test1 values (mypack.feature);
  3          commit;
  4  end;
  5  /

PL/SQL procedure successfully completed.

MYDBA@orcl >
MYDBA@orcl > select * from test1;

   COLUMN1
----------
         1

1 row selected.

MYDBA@orcl >
MYDBA@orcl > drop package mypack;

Package dropped.

MYDBA@orcl > drop table test1;

Table dropped.

MYDBA@orcl >
MYDBA@orcl > set echo off

Previous Topic: help required in sql query
Next Topic: How to trace sql script execution
Goto Forum:
  


Current Time: Sun Feb 09 22:35:25 CST 2025