cursors

how do oracle stored procedures (w/ cursors) work?

折月煮酒 提交于 2019-12-11 10:49:03
问题 I have a following oracle stored procedure CREATE OR REPLACE PROCEDURE getRejectedReasons ( p_cursor IN OUT SYS_REFCURSOR) AS BEGIN OPEN p_cursor FOR SELECT * FROM reasons_for_rejection; END; However, when I run this stored procedure in sql-developer then I dont see anything. I just see something like this: Connecting to the database oracleLocal. Process exited. Disconnecting from the database oracleLocal. I'm coming from MS sql server and am used to seeing actual results when running a

PLS-00221: 'C1'(cursor) is not a procedure or is undefined

前提是你 提交于 2019-12-11 10:30:04
问题 I am creating a package to use with Jasper reports where I learnt that I need SYS_REFCURSOR but I cannot seem to be able to Loop my cursors:eg create or replace PACKAGE BODY fin_statement_spool AS PROCEDURE fin_main_spool(vacid in VARCHAR2, vfromdate in date, vtodate in date,c1 out SYS_REFCURSOR,c2 out SYS_REFCURSOR) AS cramount NUMBER; dramount NUMBER; countcr NUMBER; countdr NUMBER; BEGIN OPEN c1 FOR SELECT .......; OPEN c2 FOR SELECT ........; BEGIN FOR i IN c1--Error is here LOOP rnum :=

How to use datastore cursors with jpa on GAE

回眸只為那壹抹淺笑 提交于 2019-12-11 08:26:21
问题 Any body know how to use Datastore Cursors with JPA? 回答1: Can you try this (adapted from the JDO sample): List<Employee> results = (List<Employee>) query.execute(); // Use the first 20 results... Cursor cursor = JPACursorHelper.getCursor(results); String cursorString = cursor.toWebSafeString(); // Store the cursorString... // ... // Query query = the same query that produced the cursor // String cursorString = the string from storage Cursor cursor = Cursor.fromWebSafeString(cursorString);

Inconsistent cursor results when looping over databases

一个人想着一个人 提交于 2019-12-10 09:36:05
问题 I have several databases named very similar (my-db-1, my-db-2, my-db-3, my-db-4). I want to execute the same stored procedure on each of these databases. I decided to use cursors. However, I am getting some strange issues. First here is my simple code that I am executing through SQL Server Management Studio 2008. DECLARE @db_cursor CURSOR DECLARE @name varchar(255) DECLARE @Sql nvarchar(4000) SET @db_cursor = CURSOR FOR SELECT name FROM sys.databases WHERE name LIKE 'my-db-%' OPEN @db_cursor

Union data from cursors into one

半世苍凉 提交于 2019-12-09 12:54:32
问题 I have stored procedure which executes another stored procedure several times. I need union and return data, which I have after executing second procedure. Can I in some way union data from several cursors into one another cursor? It is possible without temporary tables or table-like datatype? EDIT: Cursor count for union actually is n (where n is 1, 2, 3, etc, detecting by another procedure). For example: CREATE OR REPLACE PROCEDURE proc_data ( data_out OUT SYS_REFCURSOR ) IS BEGIN OPEN data

Union data from cursors into one

可紊 提交于 2019-12-03 15:52:50
I have stored procedure which executes another stored procedure several times. I need union and return data, which I have after executing second procedure. Can I in some way union data from several cursors into one another cursor? It is possible without temporary tables or table-like datatype? EDIT: Cursor count for union actually is n (where n is 1, 2, 3, etc, detecting by another procedure). For example: CREATE OR REPLACE PROCEDURE proc_data ( data_out OUT SYS_REFCURSOR ) IS BEGIN OPEN data_out FOR SELECT '1' NUM FROM dual; END; / CREATE OR REPLACE PROCEDURE proc_result ( data_out OUT SYS

How do I disable query results when executing a stored procedure from a stored procedure?

寵の児 提交于 2019-11-30 04:55:11
Within a stored procedure, another stored procedure is being called within a cursor. For every call, the SQL Management Studio results window is showing a result. The cursor loops over 100 times and at that point the results window gives up with an error. Is there a way I can stop the stored procedure within the cursor from outputting any results? WHILE @@FETCH_STATUS = 0 BEGIN EXEC @RC = dbo.NoisyProc SELECT @RValue2 = 1 WHERE @@ROWCOUNT = 0 FETCH NEXT FROM RCursor INTO @RValue1, @RValue2 END Thanks! you could insert the results into a temp table, then drop the temp table create table #tmp

How do cursors work in Python's DB-API?

旧巷老猫 提交于 2019-11-30 02:56:38
I have been using python with RDBMS' (MySQL and PostgreSQL), and I have noticed that I really do not understand how to use a cursor. Usually, one have his script connect to the DB via a client DB-API (like psycopg2 or MySQLdb): connection = psycopg2.connect(host='otherhost', etc) And then one creates a cursor: cursor = connection.cursor() And then one can issue queries and commands: cursor.execute("SELECT * FROM etc") Now where is the result of the query, I wonder? is it on the server? or a little on my client and a little on my server? And then, if we need to access some results, we fetch 'em

call a stored procedure from the DECLARE statement when using cursors in MySQL

痞子三分冷 提交于 2019-11-29 15:52:49
I am trying to use a cursor in MySQL to call a stored procedure many times. I want to call it as many times as a value for my_id exists in some temporary table, and iterate through those ids and concatenate the results. Anyway, I'm having trouble with this part of the process: DECLARE curs CURSOR FOR SELECT something FROM somewhere; I don't want to select something from somewhere. I want something like DECLARE curs CURSOR FOR CALL storedproc(@an_id); Can the DECLARE statement be used to call a stored proc? Or does it have to be associated with a SELECT only? Googling around, I'm afraid that

How do cursors work in Python's DB-API?

故事扮演 提交于 2019-11-29 00:31:55
问题 I have been using python with RDBMS' (MySQL and PostgreSQL), and I have noticed that I really do not understand how to use a cursor. Usually, one have his script connect to the DB via a client DB-API (like psycopg2 or MySQLdb): connection = psycopg2.connect(host='otherhost', etc) And then one creates a cursor: cursor = connection.cursor() And then one can issue queries and commands: cursor.execute("SELECT * FROM etc") Now where is the result of the query, I wonder? is it on the server? or a