calling a package with in a select statement
Hi all..I created two packages and pack8 called tabpack8 package... two different ways...
There is an error with this statement
Select the name MyName rab8 where place = tabpack8.test2 (myplace, 10);
so... How can I call a package with in a select...
CREATE or REPLACE PACKAGE tabpack8 authid current_user as
procedure test1 (place out varchar2, myid number);
function return number (place in varchar2, myid number) test2;
end;
/
create or replace package body tabpack8 as
procedure test1 (place out varchar2, myid number) is
Start
SELECT place of rab8 where id = myid;
end Test1;
function test2 (place in varchar2, myid number) return number is
number of l_num;
Start
Select place in l_num rab8 where id = myid;
Return l_num;
end test2;
END tabpack8;
/
CREATE or REPLACE PACKAGE pack8 authid current_user as
operative;
end;
create or replace package body like pack8
operation is
MyPlace varchar2 (20);
MyName varchar2 (20);
Start
tabpack8.test1(MyPlace,10);
Select the name MyName rab8 where place = myplace;
dbms_output.put_line ('Res-' | myname);
Select the name MyName rab8 where place = tabpack8.test2 (myplace, 10);
dbms_output.put_line ('Res-' | myname);
end test;
END pack8;
/
Thanks in advance
gud day
Try this and let us know.
function test2(place in varchar2,myid in number ) return varchar2
is
l_var tab8.place%type;
begin
select place into l_var from tab8 where id = myid;
return l_var;
end test2;
Thank you
Knani.
Tags: Database
Similar Questions
-
Problem with the simple Select statements
Hi experts,
I have with SQL Server and I'm going to hurt when I use the similar syntax in sqlplus to query an Oracle table.
For example... my table contains column SCHID SET in the numeric form. Table has thousands of lines and the SCHID column is filled.
Select TOP 100 AFTSCHAUXDATA SCHID;
Get the "Word FROM key not found where expected" error
Select DISTINCT from AFTSCHAUXDATA SCHID;
Download "no selected lines.
Can someone help me please?
Thank you, JohnCan someone tell me how to find the names of the 20 largest tables (bigger which means that most of the files)?
Once you have updated statistics on the table, you can query the DataDictionary: USER_TABLES/ALL_TABLES/DBA_TABLES.
I'm assuming that user_tables will do:select * from ( select table_name , num_rows from user_tables order by num_rows desc nulls last ) where rownum <= 20;
You can find more explanations about the DataDictionary in the Oracle Online Documentation.
Just do a quick and easy search
http://www.Oracle.com/pls/db112/homepage
or
http://www.Oracle.com/pls/db102/homepage
Depending on your version of the database. -
function body pl/sql return SQL query - if with in the select statement
Hi all
I have a condition where, when the summary field is checked, only we see the this column for users in the report. IF statement is possible in this case? I gave the code below... is possible to write something like below, or y at - it another way to do it?
\
v_sql: = ' select TBLCASES. INVESTIGATOR as an INVESTIGATOR,';
v_sql: = v_sql | "TBLCASES. CASENUMBER as CASENUMBER,';
v_sql: = v_sql | "TBLCASES. OPENDATE as OPENDATE,';
v_sql: = v_sql | "TBLCASES. ESTCOMPLETE as DATE_CIBLE,';
v_sql: = v_sql | "TBLCASES. STATUS of STATUS ';
v_sql: = v_sql | "TBLCASES. Case CODE case CODE as,';
v_sql: = V_sql | "TBLCASES. FAIR_HOTLINE as FAIRHotline,';
v_sql: = v_sql | "TBLCASES. NYSIG as NYSIGCase,';
v_sql: = v_sql | "TBLCASES. The REGION';
IF: P44_INCLUDE_SUMMARY_FIELD is not null THEN
v_sql: = v_sql | "TBLCASES. SUMMARY,';
END IF;
v_sql: = v_sql | "TBLCASES. PROGAREA as PROGArea ';
v_sql: = v_sql | ' from TBLCASES where 1 = 1';
.. \Hi Lucie,.
You are adding and removing a column in a report, so it may be useful to have the extra on the end of the query.
You get an error? If so, paste it in...BUT - that I would put a condition on the column where ': P44_INCLUDE_SUMMARY_FIELD is not null '
It under 'Attributes of the column' report select the change column icon, and there a breadcrumb "Condition."
Select "In Expression 1 point value is not Null" and put the P44_INCLUDE_SUMMARY_FIELD in the Expression 1 text box.And I have to make it more readable like that when I do the dynamic SQL code:
IF: P44_INCLUDE_SUMMARY_FIELD is not null THEN
v_INCLUDE_SUMMARY_FIELD: = ' TBLCASES. SUMMARY summary ';
END IF;v_sql: = ' select TBLCASES. RESEARCHER, researcher,
TBLCASES. CASENUMBER as CASENUMBER
TBLCASES. OPENDATE as OPENDATE,
TBLCASES. ESTCOMPLETE as DATE_CIBLE,
TBLCASES. STATUS of STATUS,
TBLCASES. Case CODE case CODE as,
TBLCASES. FAIR_HOTLINE as FAIRHotline,
TBLCASES. NYSIG as NYSIGCase,
TBLCASES. REGION as the region,
TBLCASES. PROGAREA as PROGArea,' |
v_INCLUDE_SUMMARY_FIELD |
' from TBLCASES where 1 = 1; ';It will be useful,
BRITISH COLUMBIA -
Clause of update with a nested select statement, and a weird error
Hi all!
I am trying to execute the following SQL clause:
setting a day of f_kontakti kon set ikaluokka =
(
Select ikal of
(
Select kontakt_ik, ikaluokka_gen(1,ai2.pvm,ai.pvm) as ikal
of f_kontakti k
Join the a on (k.asiakas_ik = a.asiakas_ik) d_asiakas
Join d_aika HERE on (a.synt_aika_ik = ai .aika_ik)
Join d_aika ai2 on (k.aika_ik = ai2.aika_ik)
where k.kontakt_ik = kon.kontakt_ik
) salt
)
It works very well on our test database (10.2.0.1.0), but when I try to run it on our production database (10.2.0.4.0), it gives the following error:
ORA-00904: "KON". "" KONTAKT_IK ": invalid identifier
The nested select works fine when I run it separately (without where clause of course, because then it does not really anywhere point) on two databases, but for some reason, the full update only fails on the production system. Any ideas on what could cause this?
Kind regards
ErikYou can run it without selecting it nesting.
Like this
update f_kontakti kon set ikaluokka= ( select ikaluokka_gen(1,ai2.pvm,ai.pvm) as ikal from f_kontakti k join d_asiakas a on (k.asiakas_ik=a.asiakas_ik) join d_aika ai on (a.synt_aika_ik=ai.aika_ik) join d_aika ai2 on (k.aika_ik=ai2.aika_ik) where k.kontakt_ik=kon.kontakt_ik );
or even shorter
update f_kontakti kon set ikaluokka= ( select ikaluokka_gen(1,ai2.pvm,ai.pvm) as ikal from d_asiakas a on (kon.asiakas_ik=a.asiakas_ik) join d_aika ai on (a.synt_aika_ik=ai.aika_ik) join d_aika ai2 on (kon.aika_ik=ai2.aika_ik) );
-
A select statement to get the current pay rate.
If someone can share with me a select statement to get the current salary?Try the PER_PAY_PROPOSALS table with the fields Pay_xxxx.
See if the following threads help
Query to find the salary of the employee details in HRMS
HR Payroll - how to calculate the average hourly rate for workersSandeep Gandhi
-
Need help with the use of GROUP BY in a select statement UNION
I am writing a query that allows to combine a legacy system that interfaces it is trial balance in the Oracle of R12 GL. It was only meant to continue for a month or two, but it is likely to continue for 6 months. Please Auditors Auditors, to provide proof that the system is in balance with Oracle GL. By my verification requirements, I need to make a full reconciliation from the month of conversion (life in the amount of date), then PTD for each month.
The legacy account is placed in attribute1 on the lines of the journals. Uses of the old system balancing segments that are also used on the platform in Oracle for this division, i.e., Procure-to-Pay has been cut over Oracle, but not everything yet. So, I can't count on the GL_BALANCES table for the info, I get from the JE_LINES.
My problem is not the only request for the month. But when I try to combine the queries with a Union, to aggregation of each measurement period in its own column, the group is necessary after each selected instruction rather than allowing me to put at the end of the UNION. (When I put the group by at the end of the UNION, I have the 'not one group' function)
So I get duplicate for each month of discrete measure accounts. When I duplicate in my Oracle database accounts, I can't count on the VLOOKUP function in excel to exactly match an account of inheritance. I know there are more sophisticated ways to provide this output, but I'm hoping to get this info in a simple query.
Thank you in advance for any advice you can provide
Example of data output (the goal for me is to get the two rows to appear as one based on common points on the LEGACY_ACCOUNT and the ORACLE ACCOUNT
The LEGACY ACCOUNT ORACLE ACCOUNT JUN_15 JUL_15 AUG_15 SEP_15 OCT_15 NOV_15 DEC_15 010000001109000003584 190-600552-1001-100231-000-0000-0000-0000 0 0 -242961.04 0 0 0 0 010000001109000003584 190-600552-1001-100231-000-0000-0000-0000 0 192588.02 0 0 0 0 0 Here is a simplified version of my code that returns both records. In my research, I had found a number of conversations where it has been shown that the group could be put at the end of the select statement. However, when I remove the group from the first select statement I get SQL error: ORA-00937: not a function of simple-group
Select
l.attribute1 LEGACY_ACCOUNT,
C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | COMBINATION OF C.SEGMENT8,
JUN_15 TO_NUMBER('0').
JUL_15, sum (NVL(l.accounted_dr,0.00)-NVL(l.accounted_cr,0.00)),
TO_NUMBER('0') AUG_15.
TO_NUMBER('0') SEP_15.
TO_NUMBER('0') OCT_15.
TO_NUMBER('0') NOV_15.
DEC_15 TO_NUMBER('0')
Of
b GL.gl_je_batches,
GL.gl_je_headers h,
GL.gl_je_lines l,
GL.gl_code_combinations c,
GL.gl_je_sources_tl j
where b.je_batch_id = h.je_batch_id
and h.je_header_id = l.je_header_id
and l.code_combination_id = c.code_combination_id
and h.je_source = j.je_source_name
and c.segment1 ('190 ', '191', '192', '193', '194', ' 195 ', ' 196',' 197', ' 198 ', ' 199',)
('200 ', '203', ' 205', '206 ', '330', '331', '332',' 333 ', ' 334',' 335', ' 336 ', ' 337')
and j.language = 'en '.
and h.PERIOD_NAME ("JUL-15'")
Group
l.attribute1,
C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | C.SEGMENT8
UNION
Select
l.attribute1 LEGACY_ACCOUNT,
C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | COMBINATION OF C.SEGMENT8,
JUN_15 TO_NUMBER('0').
TO_NUMBER('0') JUL_15.
AUG_15, sum (NVL(l.accounted_dr,0.00)-NVL(l.accounted_cr,0.00)),
TO_NUMBER('0') SEP_15.
TO_NUMBER('0') OCT_15.
TO_NUMBER('0') NOV_15.
DEC_15 TO_NUMBER('0')
Of
b GL.gl_je_batches,
GL.gl_je_headers h,
GL.gl_je_lines l,
GL.gl_code_combinations c,
GL.gl_je_sources_tl j
where b.je_batch_id = h.je_batch_id
and h.je_header_id = l.je_header_id
and l.code_combination_id = c.code_combination_id
and h.je_source = j.je_source_name
and c.segment1 ('190 ', '191', '192', '193', '194', ' 195 ', ' 196',' 197', ' 198 ', ' 199',)
('200 ', '203', ' 205', '206 ', '330', '331', '332',' 333 ', ' 334',' 335', ' 336 ', ' 337')
and j.language = 'en '.
and h.PERIOD_NAME ("AUG-15'")
Group
l.attribute1,
C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | C.SEGMENT8
order by 1
Is there a good reason to make this period both as a series of trade unions? This looks like a classic pivot for me query. This will make a way through the tables and should get the desired results.
Select l.attribute1 legacy_account,
c.Segment1: '-' | c.Segment2: '-' | c.segment3: '-' | c.segment4: '-' |
c.segment5: '-' | c.segment6: '-' | c.segment7: '-' | combination of c.segment8,
sum (case when h.period_name = 'JUN-15'
then nvl(l.accounted_dr,0.00)-nvl(l.accounted_cr,0.00)
otherwise 0 end) jun_15,.
sum (case when h.period_name = 'JUL-15'
then nvl(l.accounted_dr,0.00)-nvl(l.accounted_cr,0.00)
otherwise 0 end) jul_15,.
- and similar to DEC - 15
GL.gl_je_batches b, gl.gl_je_headers h, gl.gl_je_lines l.
GL.gl_code_combinations c, gl.gl_je_sources_tl j
where b.je_batch_id = h.je_batch_id
and h.je_header_id = l.je_header_id
and l.code_combination_id = c.code_combination_id
and h.je_source = j.je_source_name
and c.segment1 ('190', '191', '192', '193', '194', '195',' 196', ' 197',
'198 ', '199', '200', '203', '205' ', 206',' 330 ', ' 331',
"332 ', '333', '334', '335',' 336 ', ' 337')
and j.language = 'en '.
and h.period_name (' Jun-15', ' 15 JUL', ' AUG-15'... "" ")
L.attribute1 group,
c.Segment1: '-' | c.Segment2: '-' | c.segment3: '-' |
c.segment4: '-' | c.segment5: '-' | c.segment6: '-' |
c.segment7: '-' | c.segment8
If you're on the 11G version of the database, you might want to look at the PIVOT keyword that will do the same thing in a more concise expression.
John
-
How to INSERT a SELECT statement with a GROUP BY clause on a table with an IDENTITY column?
n an application, I intend to truncate and insertion on a 12 c Oracle database, but have found this problem with a
IDENTITY
column. Even if theINSERT... SELECT
statement works on mostSELECT
uses I tried, if this statement was also aGROUP BY
clause, it does not work, delivering a "ORA-00979: not aGROUP BY
expression ' complaint. Some examples of code:create table aux ( owner_name varchar2(20), pet varchar2(20) );
insert into aux values ('Scott', 'dog');
insert into aux values ('Mike', 'dog');
insert into aux values ('Mike', 'cat');
insert into aux values ('John', 'turtle');
create table T1 (
id number generated always as identity,
owner_name varchar2(20),
pet_count number );
select owner_name, count(*) as pet_count from aux group by owner_name; -- works just fine
insert into T1 (owner_name, pet_count) select owner_name, count(*) as pet_count from aux group by owner_name; -- doesn't work
The select statement works by itself, but it fails as an INSERT... SELECT statement.
Appreciate the help!
Looks like a bug. You must open the SR with Oracle. Meanwhile, you could materialize select:
SQL > insert into T1 (owner_name, pet_count)
2 with t as (select / * + materialize * / owner_name, count (*) as pet_count to the owner_name group)
3. Select owner_name, pet_count t
4.3 lines were created.
SQL > select * from t1;
ID OWNER_NAME PET_COUNT
---------- -------------------- ----------
1 John 1
Scott 2 1
3 Mike 2SQL >
Keep in mind index THAT MATERIALIZE is undocumented.
SY.
-
There are two select statement, which are as follows: 1) select project id, the name of ppm.pm_projects project_name and request_id 2) select id, name from request_type_name to kcrt_request_details. There is a column called entity that can store a value i.e. project or request. I want to write a select statement containing a condition that is if the entity name is project and then run the select statement 1 otherwise, if the name of the entity's request, then run the select statement 2. All this must be written in a select statement. Can someone help me how to write this select statement type.
Hello
Hello
2726057 wrote:
... There is a column called entity that can store a value i.e. project or request. ...
In which table is this column? Assuming that it is in a table called entity_table, you can do something like this:
SELECT project AS id
project name AS the name
OF ppm.pm_projects
WHEN THERE IS)
SELECT 1
Of entity_table
Entity WHERE = "Project".
)
UNION ALL
SELECT request_id ID
request_type_name AS name
OF kcrt_request_details
WHEN THERE IS)
SELECT 1
Of entity_table
Entity WHERE = 'ask '.
)
;
This does not have anything on the number of lines is entity_table, or what are the values in the column of the entity. In other words, the query works in all cases. If any line in entity_table entity = 'Project', then the pm_projects data will be included in the result set. If any line in entity_table entity = 'Request', kcrt_request_details data will be included.
I hope that answers your question.
If this isn't the case, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: https://forums.oracle.com/message/9362002#9362002
-
SELECT statement in a Package body
I have the following in my package body and it gives me an error:
- Error (7.1): PLS-00428: an INTO clause in this SELECT statement
PROCEDURE MyQuery
AS
BEGIN
Select * from customer;
END MyQuery;
The error message is correct.
Your selection must have an INTO clause and must return 1 and only 1 row.
-
Insert a variable + string using the select statement with cfquery
I'm doing an insertion by a select statement where the insert for one of the fields should be a combination of a vaule comes from the selection and concatenated with a string of text. Is this possible and if what the correct syntax so? Here is an example of what I'm trying, but does not.
< name cfquery = "createnote" datasource = "#application.datasource #" >
INSERT INTO gtbl_notes (notedate, strCustomerID, notetype, note, notecreatedby)
SELECT "#currentdate #", strCustomerID, "miscellaneous", "#gtbl_people.email # DELETED because of HARD BOUNCE ', 'Bounce Routine.
OF gtbl_people, gtbl_bounces
WHERE gtbl_bounces.email = gtbl_people.email AND gtbl_bounces.subscriber = 1 AND gtbl_bounces.status = 2< / cfquery >
Any input would be greatly appreciated.
Concatonation is possible with most, if not all of the databases. The syntax is a specific software and you do not your specify.
-
Calling a procedure of package with only Date setting
Hi all
Please, help me to call a procedure of package with Date from the sql command prompt parameter.
ArifCheck the procedure below.
SQL> ed Wrote file afiedt.buf 1 create or replace procedure procdate (p_date_in date) 2 is 3 p_date_out date; 4 begin 5 p_date_out := add_months(p_date_in,6); 6 dbms_output.put_line(p_date_out); 7* end; SQL> / Procedure created. SQL> exec procdate('01-JAN-2010'); 01-JUL-10 PL/SQL procedure successfully completed. SQL> exec procdate(to_date('01/01/2010','DD-MM-YYYY')); 01-JUL-10 PL/SQL procedure successfully completed. SQL> exec procdate('31-DEC-2010'); 30-JUN-11 PL/SQL procedure successfully completed.
-
Can we call a procedure in the select statement?
Can we call a procedure in the select statement?Hello
Raghu_appsdba wrote:
Can we call a procedure in the select statement?# You can call functions, but not procedures.
If the procedure does not change the State of the database (for example, it isn't updated all tables), then you can wrap it in a function, or re - write function.
Here is an example of wrapping.
CREATE OR REPLACE FUNCTION fun_x (in_txt IN VARCHAR2) RETURN VARCHAR2 IS BEGIN proc_y (in_txt); RETURN in_txt END fun_x;
-
Update/insert with a select statement?
HELO,
I have the following select statement:
SELECT CLAIM_NO, SUM (LPA_AMT)
OF LPA_CREDHIST_RCA
CLAIM_NO GROUP
And I want to update the LPA_CLAIM field. TOTAL_AMT_PAID with the sum (LPA_AMT)
from above.
the join is lpa_credhist_rca.claim_no = lpa_claim.claim_no.
How can I do this?Try this, it's a correlated update statement:
UPDATE LPA_CLAIM LC SET TOTAL_AMT_PAID = ( SELECT SUM(LPA_AMT) FROM LPA_CREDHIST_RCA LCR WHERE LC.CLAIM_NO = LCR.CLAIM_NO )
-
Nothing wrong with including ORDER BY in INSERT into... SELECT statement?
Are there implications due to the use of ORDER BY (field3 control) in bottom INSERT INTO... SELECT statement.
insert into mytable ( field1, field2, field3 ) select field1, field2, field3 from source_Table order by field3;
Order by is used with functions select but not a mandate. Usually people uninterested by what people order insert data in a table. We have to try to keep operations and it inserts into a table.
-
call a function in a where clause of a select statement clause
Hello
is it possible to call a function in a where clause of a select statement clause?
ex: select col1, col2
from my_table
where my_package.my_function (32199, 2008, col3, 'P');
and I have the error message ' ORA-00920: invalid relational operator.
FUNCTION ma_fonction (v_matricule in NUMBER,
v_Year in NUMBERS
T_DATE IN a DATE,
v_type in DEFAULT CHAR 'P')
RETURN A BOOLEAN VALUE;
@+ RosagioYes, it is possible.
But you have no relational operator:
where my_package.my_function (32199, 2008, col3, 'P') =?
where my_package.my_function (32199, 2008, col3, 'P') >?
where my_package.my_function (32199, 2008, col3, 'P')<>Oops, I just noticed that your function returns a Boolean value.
Can't do that as in a SQL statement.
Boolean is known only to other code PL/SQL, no SQL statements.
Published by: SomeoneElse on November 7, 2008 09:24
Maybe you are looking for
-
How can I update my iPad 2 to 4G to work
How can I update my iPad 2 wifi / 3G to 4G to work
-
JDownloader does not work with Firefox15.0. ?
I got 15.0 Firefox.Usually, when I right click on a download link, a menu appears and ask me what I want to do. In this menu, I had writing for JDownloader. They have now disappeared. JDownoloader is not compatible with Firefox 15.0?
-
Satellite s875-s7242 - Ubuntu drivers needed
Hi all I declined to ask drivers for Toshiba satellite s875-s7242 favorite Linux, Ubuntu.I have already installed Ubuntu and looks like the touchpad is not working properly and there is no wireless connection. Thank you
-
hide a drive from observer but not computer
Is it possible to hide a drive from the Viewer, but not from the computer? I have a reserved system area that received a letter from Reader by the system, and makes me confused when I see listed everywhere drive readers are displayed. I won't try to
-
No driver installed for any other device
How to identify and download the driver for the universal series (USB) bus controller. Other devices in the Device Manager icon and the computer in both devices and printers have a yellow exclamations. In the properties of the window for the icon of