Solved

Cannot insert function in select statement in oracle forms record group query

Posted on 2004-09-22
10
2,440 Views
Last Modified: 2013-12-12
Hi,

I have created a packadge. Its specification:
"
PACKAGE GET_O_NUMBER
  IS
 
FUNCTION F_O_NUMBER
  ( kodas IN number,
    numeris IN  varchar2 )
  RETURN  varchar2;
 
  PRAGMA RESTRICT_REFERENCES(F_O_NUMBER, WNDS, RNDS,TRUST);
 
END;
"

But when i add it in select in forms record group query i get an error :
'' Unhandled error in icrg 102"

In record group query i write :
SELECT ORVIS.GET_O_NUMBER.F_O_NUMBER(past.kodas, pat_numeris) from ..........

ORVIS is my username. I use oracle forms 5.0.6.8.0 on database 9i

What could cause this error?
Thanks for any help
0
Comment
Question by:sky_lt
  • 4
  • 3
10 Comments
 
LVL 22

Expert Comment

by:Helena Marková
ID: 12121865
Maybe the problem is caused by package body. Did you try it like this:
SELECT kodas,pat_numeris,GET_O_NUMBER.F_O_NUMBER(kodas, pat_numeris) from ... ?
0
 

Author Comment

by:sky_lt
ID: 12121917

yes i tried but it outpust:
"FRM-12001 Cannot create record group"

The packedge is ok as it works in sql navigator.
0
 

Author Comment

by:sky_lt
ID: 12121940
my select in record group is :

SELECT
past.kodas,
pat.pat_numeris,
GET_O_NUMBER.F_O_NUMBER(past.kodas, pat.pat_numeris)

from
patalpos pat,
pastatai past

where
pat.id = past.id
0
 
LVL 22

Expert Comment

by:Helena Marková
ID: 12122064
You can try this, if it cannot help, then I don't know what  is the problem:

SELECT
pastatai.kodas KODAS,
patalpos.pat_numeris PAT_NUMERIS,
GET_O_NUMBER.F_O_NUMBER(pastatai.kodas, patalpos.pat_numeris) G_O_N
from
patalpos patalpos,pastatai pastatai
where patalpos.id = pastatai.id
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:sky_lt
ID: 12122372
Thanks henka for help!

well i think i found the reason but i do not know how to solve it:

My function F_O_NUMBER returns varchar2(20) but when i put it in a select statement
the column in which it returns the values becomes  of varchar2(4000) datatype.
I created view using that function and saw that the column which is made by the function
became of varchar2(4000) datatype. That is why i can not create the record group.
What could be the reason of it?
How i could make the datatype of varchar2(20) as defined in funcion?
0
 

Author Comment

by:sky_lt
ID: 12122619
I do not know why the column becomes of varchar2(4000) but i used
substr and solved this problem. Thanks for yor help.
Do you have any ideas about how the function of return type varchar2(20) returns varchar2(4000) ?
Thanks


0
 
LVL 15

Accepted Solution

by:
ishando earned 50 total points
ID: 12129627
Your function doesn' t have a return type of varchar2(20), but a return type of varchar2.

The size of the returned value is determined by the size of the field that the function is to populate (if you are using it in PL/SQL script)
When returning it to a select statement, there is no pre-determined size so it will allow for the maximum size (4000) to cater for all possibilities.

If you are returning this value to be displayed in a Forms field you should probably give is an alias (as Henka suggested) which is the same as the Forms field name to populate. As the function picks up the field size from the calling environment it should see that you only want a varchar2(20) returned. It should work the same as using a 'column' statement in sqlplus. However, its a long while since I used Forms so I can't say for certain what the behaviour will be.
0
 
LVL 22

Expert Comment

by:Helena Marková
ID: 12130284
This is an addition to ishando's comment:

Query record group
      A query record group is a record group that has an associated SELECT statement.  The columns in a query record group derive their default names, data types, and lengths from the database columns referenced in the SELECT statement.  The records in a query record group are the rows retrieved by the query associated with that record group.Query record groups can be created and modified at design time or at runtime.

So if it is a function I think that if you use substr() in it the problem is gone.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
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 syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now