Basic stored procedure helps - not the return data
Hi all:To be fair, I come from a SQL Server environment and have never written anything for PL/SQL / Oracle before, this is my first attempt, so if nothing is better or more effective, please let me know. The immediate problem I'm having is, I have the following stored procedure, and all I want to do is return the data in the table, so that I can fill my DataSet in code. But when I run the code against this stored procedure, it still don't bring back any data (if I just do a standard "SELECT * FROM lkAllocation", I get the results, so I know data are there and the connection is good). If execution of the procedure in my window in Oracle SQL Developer (call PAYSOL.spallocationselectall ();), my results displays no data as well. What is the problem with this stored procedure?
create or replace
PROCEDURE spAllocationSelectAll IS
Whole AllocationID;
AllocationName Varchar2 (50);
BEGIN
AllocationID: = 0;
AllocationName: = ";
SELECT
AllocationID,
AllocationName
IN
AllocationID,
AllocationName
Of
lkAllocation
ORDER BY
AllocationName;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHILE OTHERS THEN
-Consider recording the error and then re-raise
LIFT;
END spAllocationSelectAll;
Well, I'm not really in .net (I would participate in another forum so ;)), but this might be useful?
Value (Oracle.DataAccess.Types) System.Data.DbType OracleDbType
OracleRefCursor Object RefCursor
http://download.Oracle.com/docs/CD/B19306_01/win.102/b14307/featOraCommand.htm#g1025379
http://download.Oracle.com/docs/CD/B19306_01/win.102/b14307/featOraCommand.htm#g1025072
Perhaps the [forum Windows and .net | http://forums.oracle.com/forums/category.jspa?categoryID=44] is worth a try as well.
Tags: Database
Similar Questions
-
Use the stored procedure to create the data model for the bi publisher report
Hi all
Can we use stored procedure to create the data model for BI Publisher reports? I did find an example by using the stored procedure to complete the data model in the bi publisher report.
Thank you
ViratCheck out these links
BI publisher to use the stored procedure
Re: Stored procedures and dynamic columns
Re: Is it possible to use stored procedures in BI Publisher GUI?
Re: PL/SQL stored w / model XML?If brand pls help
-
Trigger that executes the stored procedure does not
I have a trigger on a table which triggers the update of the column 'APPLICATION_OFFER_SENT '! The trigger looks like this:
Simply, he runs a procedure and takes the "PK_APPLICATION_NO" as a single parameter.CREATE OR REPLACE TRIGGER SCHEMA.COPY_APPLICATIONS AFTER UPDATE OF APPLICATION_OFFER_SENT ON PPLE_T_APPLICATION REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW BEGIN UPDATE_OR_INSERT_APPL(:old.PK_APPLICATION_NO); END;
When I run the SP itdefl: exec UPDATE_OR_INSERT_APPL (1042); It works very well.
But when its done through the relaxation it doesn't?
The Proc looks like this:
Published by: oraCraft on Oct / 09/2010 09:11CREATE OR REPLACE PROCEDURE SCHEMA.UPDATE_OR_INSERT_APPL (IN_APPL_NO NUMBER) IS CURSOR c1 IS SELECT title, fullname, universityid, appl_no, appl_no_hash, OFFER_EXPIRATION_DATE, APPLICATION_CANCEL_DATE, room_hall FROM SCHEMA.ACCOM_APPLICATION_VIEW WHERE appl_no = IN_APPL_NO; rowcnt NUMBER; BEGIN FOR rec IN c1 LOOP SELECT COUNT(*) INTO rowcnt FROM SCHEMA2.ACCOMM_OFFER_ACCEPTANCE a WHERE a.appl_no = IN_APPL_NO; IF rowcnt = 0 THEN INSERT INTO SCHEMA2.ACCOMM_OFFER_ACCEPTANCE (title, fullname, universityid, appl_no, appl_no_hash, offer_expiration_date, application_cancel_date, room_hall) VALUES (rec.title, rec.fullname, rec.universityid, rec.appl_no, rec.appl_no_hash, rec.offer_expiration_date, rec.application_cancel_date, rec.room_hall); COMMIT; ELSIF rowcnt !=0 THEN UPDATE SCHEMA2.ACCOMM_OFFER_ACCEPTANCE t SET (t.offer_expiration_date, t.application_cancel_date, t.room_hall) = (select OFFER_EXPIRATION_DATE, APPLICATION_CANCEL_DATE, ROOM_HALL from SCHEMA.ACCOM_APPLICATION_VIEW B where B.appl_no = IN_APPL_NO); END IF; END LOOP; END;
Published by: oraCraft on Oct / 09/2010 09:11>
Validation is in my stored procedure, is not my trigger. I'm sure it's very good
>It is not very well according to the Application Developer Fundametals guide...
>
DDL statements are not allowed in the body of a trigger. Furthermore, no control of transaction
statements are allowed in a trigger. SAVEPOINT, COMMIT and ROLLBACK cannot be
used. For system triggers, TABLE {CREATE/ALTER/DROP} instructions and
EDIT... COMPILE are allowed.
Note: A procedure is called by a trigger cannot perform the previous transaction control statements,
because the procedure runs in the context of the body of the trigger.
>There is an exception to this rule if you use the pragma AUTONOMOUS TRANSACTION, but I do not see that in your trigger.
Kind regards
Bob -
Hello
I'm new to the development of Oracle.
I have the following scenario for which I need your help/suggestions to write a stored procedure.
A load process in a table unfolds with about million files once a month.
I have a LOG Table to record the events of job loading IE when it starts, when it stops, status etc. with the following columns
job_name, job_status, start_time, end_time, date, flag
work focuses on the work that is in charge of the table.
Based on the values in this table, I want to develop a stored procedure sql pl verifies the status of the job and does the following
When the flag = R (assume for running job) set it to run the job again as 1 hour later... if its still ongoing then 1 hour later... so now up to 5 trys
= F (Finished)
= E (error problem) launch the load immediately
The flag State values noted above are not binding... values just to give you an idea... all the other variables to use to store procedure or any new passes in the table... .suggestions are welcome for these values as well.
Basically, I would like the stored procedure to be called at some point... say SUNDAY at 06:00 and check the STATUS of the INDICATOR/table newspaper column and run.
In short, I like the pl sql store procedure to use table to log and monitor the loading process.
Structure/Basic code stored procedure for this requirement or a stored procedure that you have met similar requirements are welcome.
Thanks in advance.
Published by: user13517642 on March 23, 2011 13:28
Published by: user13517642 on March 23, 2011 13:29Your process or procedure shud look like - [not tested]
DECLARE l_flag LOG.flag%TYPE; BEGIN SELECT flag INTO l_flag FROM LOG WHERE job_name = p_job_name; WHILE l_flag = 'R' LOOP DBMS_LOCK.sleep (3600); --3600secs in 1hr SELECT flag INTO l_flag FROM LOG WHERE job_name = p_job_name; END LOOP; IF (l_flag IN ('F', 'E')) THEN --<
> END IF; END; Look at the following to find out how to plan work-
http://www.oradev.com/dbms_scheduler.jsp
Published by: Sri on 23 March 2011 14:10
Published by: Sri on 23 March 2011 14:11
-
For loop stored procedure does not
Hello
I wrote a stored procedure that does not work (I mean do not display data)
I set serveroutput on option also.
If I run as a single SQL query its working very well. so please help
create or replace procedure show_empnos (p_deptno number)
is
emp_id emp. EMP_ID % TYPE;
cursor cur_emps is
Select emp_id emp where department_id = '12';
Start
for a cur_emps in
loop
dbms_output.put_line (emp_id);
end loop;
end;
See, when I ran that a single SQL interrogate data dosplayed
SQL > select emp_id from emp where department_id = '12';
EMP_ID
----------
* 101 *.
* 101 *.
* 101 *.
Help, please.You declare a local variable EMP_ID you initialize ever, so it will always be NULL.
In your cursor, you also select a column EMP_ID.The line
dbms_output.put_line(emp_id);
solve the use of uninitialized local variable and then print a NULL value (which would appear as a blank line in the output). Assuming you want to return the value of the column EMP_ID your cursor, you need
dbms_output.put_line(a.emp_id);
As a general approach, including local variables whose names match exactly in the name of a column will create problems on the line where you write the code assumes that you speak for column only to discover that the identifier is resolved to the local variable instead. If you need a local variable to store the EMP_ID, therefore, it would make much more sense to declare it as
l_emp_id emp.EMP_ID%TYPE;
While it is not accidentally get confused with the name of the column.
Finally, if department_id is a NUMBER, it should be compared to a number, not a string, i.e.
WHERE department_id = 12
Justin
-
How to run a stored procedure by using the steps in database?
Hello
I'm trying to run some procedures of the store and it will not work.
See the file attached is seq.
I have a varchar parameter (50), which must also be provided to the stored procedure and it returns an int.
To do this I had to only use data in an open statement
-
Stored procedure to get the Admin users and other users
Hey,.
I am new to stored procedures in Oracle and would really appreciate the help! I have two tables:
_ Of the users
ID USERNAME - PARENT_GROUP - IS_ADMIN
---------------------------------------
1 jsmith - 1-0
brogerson 2-1 - 1
3 jloren - 2-0
Groups
ID - GROUPNAME
-----------------------------------------
1 - ITUsers
2 - AcctUsers
I would like to create a procedure that accepts a users username and returns all users in their group and the user id, or if the user is marked IS_ADMIN, I want that procedure to return all of the users in all groups.
How can I do this? Ideally, I would like the result of the funnel in a DataGridView in c#.
Thank you in advance,
Jeffrey Kevin Pry
Published by: jeffrey.pry on May 10, 2010 10:42
Published by: jeffrey.pry on May 10, 2010 10:43Hi, Jeffrey.
You can create a view with two copies of the users table: one for the parameter (the original user, you intend to provide run-time) and one for all users in the two
(a) in the same Department, or,
(b) any Department, if the user is an administratorCREATE OR REPLACE VIEW p_users AS SELECT u.* , g.groupname , pu.username AS p_username FROM users pu JOIN groups g ON pu.parent_group = g.id OR pu.is_admin = 1 JOIN users u ON u.parent_group = g.id ;
You can use the view like this:
SELECT * FROM p_users WHERE p_username = 'jsmith' ;
The above query returns all users in Group 1, because jsith is in Group 1, but is not an administrator.
Change 'jsmith' to 'brogerson' and you get everybody, because brogerson is an administrator.This assumes that each user is member of a group.
If you create a namespace SYS_CONTEXT to contain the parameter (the target user name), then you could build the setting in the view:
CREATE OR REPLACE VIEW p_users AS SELECT u.* , g.groupname , pu.username AS p_username FROM users pu JOIN groups g ON pu.parent_group = g.id OR pu.is_admin = 1 JOIN users u ON u.parent_group = g.id WHERE pu.username = SYS_CONTEXT ('MY_APP_CONTEXT', 'USERNAME') ;
and you wouldn't need a WHERE clause when you query p_users.
Published by: Frank Kulash, 10 May 2010 15:28
-
Calling stored procedure with an input of DATE parameter
Hello. A question about the Date input parameters when you call a stored procedure.
I have a procedure that takes a DATE as input parameter. I would DATE this value to include a time element.
My Application Module method takes an input as a java.util.Date (myParamDate) parameter - that will preserve a time element (?).
However when I create the CallableStatement, I am trying to set the parameter using setDate like this (for the param 5):
I understand java.sql.Date does NOT include a time element. But setDate() only accepts a java.sql.Date so my parameter of the procedure ends with a zero time element.st = getDBTransaction().createCallableStatement("begin cs_my_pck.request_values(?,?,?,?,?,?,?,?); end;", 0); Connection myConn = st.getConnection(); ArrayDescriptor myArrDesc = ArrayDescriptor.createDescriptor("CS_FIELD_TABT", myConn); Array sqlParamNameArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramNames.toArray()); Array sqlParamValueArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramValues.toArray()); Array sqlFilterNameArray = new oracle.sql.ARRAY(myArrDesc,myConn,filterNames.toArray()); st.setString(1, repType); st.setObject(2, sqlParamNameArray); st.setObject(3,sqlParamValueArray); st.setObject(4,sqlFilterNameArray); java.sql.Date myRepDate = new java.sql.Date(myParamDate.getTime()); st.setDate(5,myRepDate); System.out.println("Report Date = " + myRepDate.toString()); st.setString(6,repUser); st.setString(7,repAttach); // set out param st.registerOutParameter(8, Types.NUMERIC); st.execute();
How to call this procedure keeping the time element?
Thank you.It includes the time element, if you want more precision with time stamp.
http://docs.Oracle.com/javase/6/docs/API/Java/SQL/date.html
-
Hello world
I want to be able to store data in a database using a form.
A stored procedure has been created to insert parameters in a database table. I am told that I can trigger a sql script with the name of the store procedure followed by the my HTML form parameter.
I don't know how I'd go all trigger the SQL script in HTML. I am using asp and dreamweaver.
I never did that before and I'm really stuck! Any help or advice are appreciated!
Thank you very much
You don't mention which language you are using. In any case, use a command object to execute a stored procedure:
-
stored procedure and in the app engine peoplecode
Hey all,.
I want to call a stored procedure in peoplecode using sqlexec. I guess that the syntax is correct.
SqlExec ("exec sp_name');
My question is
the peoplecode will wait until the end of the stored procedure?
or
is it just to send the command to the database to run the stored procedure and continue following the instructions after the exec sql.
Please let me know if I'm not better explain and need an example.
Please help me.
Thank you.«.. . "will be the peoplecode wait for the completion of the stored procedure.
Yes.Nicolas.
-
Personalization form - stored procedure call in the form library.
Let's say we have a form: OEXOEORD.fmb (sales order form)
Using Form Builder to open it, we see that it connects to other libraries PL/SQl, such as OEXOELIN (file: OEXOELIN.pll)
and there are several stored procedures in OEXOELIN.
is that possible in the customization of the form of good sales of command (OEXOEORD.fmb)
call us a procedure in the OEXOELIN library? for example: we call procedure OE_LINE_SHIPPING.packing_insruction in the OEXOELIN library?
I tried to use the Builtin FORMS_DLL or "Execute procedure", but does not work.
We use the R12.
the solution we found is:
(1) use the form customization to call a custom library
(2) custom library calls the forms library
-
Update or merge it with the return data
Hello, I want to do an update in a single statement, and select (I want to get the data and update a field in one of the tables involved with a timestamp), I tried this:
merge into table t
using (SELECT ... a long and complex select...) e
on (e.ID = t.ID)
When matched then
update the value t.ts = systimestamp
e return
It does not work because his return does not seem possible with the merger, he did the update but I get no data...
With an update, I tried:
Update
(
SELECT...) e
Aliens set = systimestamp
And I get ORA-01779: cannont change a column that maps to a table of key-preserver nonkey.
The select is complex with many paintings and selects involved and more than 20 KB of text only select... and this isn't mine so I want a solution that does not need to change the internal selection if possible.
Any ideas? Sorry for my limited knowledge of sql :-(
No, you did not read what I said. The RETURNING clause allows you to capture the details of the update table. You may not have the details of the complex query that you use to determine the return lines. There is no way in SQL to a single statement that updates a table and queries data from other tables at the same time.
The best you're going to manage is to update the data, turning the ID (or regardless of the primary key is appropriate) and then query the query data complex where once again the ID in your collection. However, it's really messy. What US the real purpose of all this?
-
Max_day must not exceed return data
Version of Oracle, Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
Hi gurus
Grateful if someone help out me. I have the following data samples:
Examples of data
Create the table max_count
(
max_day number (5),
age_from number (5),
age_to number (5),
batch_no number (5)
);Insert into max_count
Select max_day 275, age_from 0, age_to 79 700 double batch_no
Union of all the
Select max_day 275, age_from 80, age_to 999 700 double batch_no
;as with a reference
(
Select age_from 0, age_to 29, batch_no 700 max_day 5 double
Union of all the
Select age_from 0, age_to 29, batch_no 700 max_day 10 double
Union of all the
Select age_from 70, 79 age_to, 700 batch_no max_day 274 of the double
Union of all the
Select age_from 70, 79 age_to, 700 batch_no max_day 276 double
Union of all the
Select age_from 80, age_to 89, 700 batch_no, 75 max_day of the double
Union of all the
Select age_from 80, age_to 100, 700 batch_no 81 max_day of double
)
Select * reference;The reference query result
AGE_FROM, AGE_TO, BATCH_NO, MAX_DAY
0 29 700 5
0 29 700 10
70 79 700 274
70 79 700 276
80 89 700 75
80 100 700 81
The query result of max_count
Select * from max_count;
MAX_DAY, AGE_FROM, AGE_TO, BATCH_NO
275 0 79 700
275 80 999 700
Rules
Max_count table, we define rules against each batch_no, for example, batch_no 700, against the age range 0 ~ 79, max_day should be = < 275 in the reference table.
If you see the 4 rows in the reference table (filled with red) then MAX_DAY is greater than 275 against the age range 0 ~ 79, same thing happened with the last row of the table to reference as well.
Power required
AGE_FROM, AGE_TO, BATCH_NO, MAX_DAY
0 29 700 5
0 29 700 10
70 79 700 274
80 89 700 75
Thanks in advance.
Concerning
Shu
Same thing * not * occur with the last line of the table - at least not according to your rules.
Something like this:
as with a reference
(
Select age_from 0, age_to 29, batch_no 700 max_day 5 double
Union of all the
Select age_from 0, age_to 29, batch_no 700 max_day 10 double
Union of all the
Select age_from 70, 79 age_to, 700 batch_no max_day 274 of the double
Union of all the
Select age_from 70, 79 age_to, 700 batch_no max_day 276 double
Union of all the
Select age_from 80, age_to 89, 700 batch_no, 75 max_day of the double
Union of all the
Select age_from 80, age_to 100, 700 batch_no 81 max_day of double
)
Select * from reference d
where exists (select null
of max_count c
where d.batch_no = c.batch_no
and d.age_from between c.age_from and c.age_to
and d.age_to between c.age_from and c.age_to
and d.max_day<=>=>
-
Need help for the structured data to SEO/Google webmaster section...
I finished my Adobe Muse (www.redoaklegalpc.com) site and he has published on (online marketing) Business Catalyst and added the site on Google for webmasters... I downloaded my my sitemap.xml and had indexed pages. I've added the appropriate tags (H1, H2, H3, etc.), metadata, robot.txt and image assets. I edited the properties of page on all pages... but for some reason any Google still cannot read my pages. I use police Mako, which is listed as a 'web-safe' police When I shoot to the top of my site in the section of structured data, it contains no text and appears as images that are missing. (see image below) The text on the muse has no small image box in the corner, so it seems that I am using the html text and exporting is not the text as an image... So now I'm stuck. How can I do to make my text appears in Google so I can use the data marker to help Google to create site links, etc. ?
Here's a similar thread which should clarify your doubts about Google Sitelinks - http://forums.adobe.com/message/5409377.
Thank you
Vinayak
-
Stored procedure to create the table .csv file
Hi all
I have a table with 4 columns and 10 rows. Now I need a stored procedure to create a file .csv from the data in the table. Here the script to create a table and insert the line.
Create table emp (emp_id number (10), emp_name varchar2 (20), Department varchar2 (20), number (10)) of salary;
Insert into emp values ('1', 'AAAAA', '' SALES, 10000');
Insert into emp values ('2', 'BATH', 'MARKETING', '8000');
Insert into emp values ('3', 'CCCCC', '' SALES, 12000');
Insert into emp values ('4', 'JAMES', 'FINANCE', '10000');
Insert into emp values ('5', 'EEEEE', '' SALES, 11000');
Insert into emp values ('6', 'FIRE', 'MANAGER', '90000');
Insert into emp values ('7', 'GEORGE', '' SALES, 12000');
Insert into emp values ('8', 'HAROLD', 'FINANCE', '14000');
Insert into emp values ('9', 'IIIII', '' SALES, 20000');
Insert into emp values ('10', 'GG', 'FINANCE', '21000');
commit;
Now I need a stored procedure to create a .csv file in my local location. Please let me know if you need more details...A few tips:
http://www.Oracle-base.com/articles/9i/GeneratingCSVFiles.php
http://tkyte.blogspot.com/2009/10/httpasktomoraclecomtkyteflat.html
also, doing a search on this forum or http://asktom.oracle.com will give you many clues.in my local location .csv file.
What is your "local position"?
A client machine? The database server machine?
Which version of the database you use?
(the result of: select * version of $ v ;))
Maybe you are looking for
-
From this date (March 29, 2016), I see through research within this community and my own attempts, that the great Apple Drive efforts will not play even Blu - ray video/audio and SACD discs. My Super ejected disk to format when I try to play them, b
-
Preserving the NB200 karim battery
It's true that the disconnection of the battery when it is connected, canned, the battery life?
-
Portege 7010CT: max capacity HARD disk support + CPU
HelloSince I am a student I can't afford a new laptop (unfortunately) so I have to use my old 7010... That's why I think a small update... a bigger HARD drive (used)... But I cannot find anywhere the maximum size HARD drive for the 7010 - everyone kn
-
Brief history on my project. I have a PXI system configuration to read signals from DSA devices, Series S, and an encoder. I use matlab to make calls to functions in libraries NI DAQmx and nilibddc.h. I collect the data and the flow of data on the
-
can I fix this error - \windows\system32\config\system
my daughter has a compaq mini netbook... start says file is missing or damaged - \windows\system32\config\system he says that you can attempt to repair by starting windows configured using the original installation CD. I have not... How can I fix?