Can we create cursor using the table created dynamically
Dear all,
Can we create the cursor using the table which is created dynamically using "Execute immediate" within the same procedure,
or is there any way to call the table created dynamically ..
please Do Help me in this
thanks alot
Edited by: khaja on Jan 18, 2009 10:57 AM
Well, I don't think this approach is bad in any possible circumstances. It depends on the requirements we don't know. Yes, usually applications should not be designed in this way. But 'usually' does not mean 'never'. One possible case is described in Oracle's example Referencing Database Objects that Do Not Exist at Compilation. It's possible to assume that tables inv_01_2003, inv_04_2003, etc from the referenced topic What Is Dynamic SQL? are generated automatically by some job using dynamic create table stmt. If the OP has similar requirements tnen this approach is not bad. It may not be the best one but it at least is not so bad as you said.
I believe that OPs know their requirements much better than me. This is why I always try to answer the exact question. If the approach is really ugly then I don't answer such questions at all.
Regards,
Dima
Message was edited by:
DimaCit
Similar Messages
-
How can i view and manipulate the Tables created in SAP DB (Netweaver)
Hai ,
i created one table in SAP DB integrated in Netweaver for J2EE Application.
How can i view the table in SAP DB.
Can i see the data inserted in that table in table view manner ?.
can i edit the data in the SAP DB table?.Hello Kishor,
You need to download the SQL Studio. With this tool login to the SAPDB server and you will be able to view the content of your table and manipulate your table as well
http://dev.mysql.com/doc/maxdb/tools.html
Regards
Abdul -
How can I create cursors within the cursor?
How can I create cursors within the cursor?
Table1 2001 - 2007 data
Account_no
Account_eff_dt
No_account_holder
Num
Seq_Num
Value1
Value2
Table2_Historical (doesn't have Num as a field) 1990 - 2000 data
Account_no
Account_eff_dt
No_account_holder
Seq_Num
Value1
Value2
Table3_06
Account_no
Account_eff_dt
No_account_holder
Num
My result table should be:
Table_result_06
Account_no
Account_eff_dt
No_account_holder
Num
Value1_min (the minimum value for the minimum of record_sequence)
Value2_max (the maximum value for the maximum of record_sequence)
I have to get data from Table1 and Table2_Historical. If one account was open in 1998 and is still effective, the minimum value of that account is in the Table2_Historical.
Let's say I open a cursor:
cursor_first is
select * from table3_06;
open csr_first
loop
fetch cursor_first into
v_Account_no
v_Account_eff_dt
v_No_account_holder
v_Num
EXIT WHEN csr_first%NOTFOUND;
How can I open a second cursor from here that will get the Seq_Num from Table1
csr_second
select Seq_Num from Table1 where
v_Account_no = Account_no
v_Account_eff_dt <= Account_eff_dt
v_No_account_holder=No_account_holder
v_Num = Num
How does it works???
Thanks a lotThanks so much for replying back. Here is what I am trying to do.
I have to create a table for each year 2002, 2003, 2004, 2005, 2006 that has all the account numbers that are active each year plus some other characteristics.
Let’s say I will create Table_result_06. This table will have the following fields. The account number, account effective date, Number of the account holder and the field Num (The primary key is a combination of all 4 fields), the beginning look of value 1 in 2006, the last look of value 1 in 2006.
Table_result_06
Account_no key
Account_eff_dt key
No_account_holder key
Num key
Value1_min (the minimum value for the minimum of record_sequence)
Value2_max (the maximum value for the maximum of record_sequence)
All the active account numbers with the Account_eff_dt, No_account_holder and Num are in the Table3. As such I can build a query that connects Table3 with table Table1 on all 4 fileds, Account_no, Account_eff_dt, No_account_holder, Num and find the Value1_min for the min of req_sequence in 2006 and Value1_max for the max of req_sequence in 2006. Here my problem starts.
Table 1 doesn’t have a new entry if nothing has changed in the account. So if this account was open in 1993 and nothing has changed I don’t have an entry in 2006 but this doesn’t mean that this account doesn’t exist in 2006. So to find the minimum value I have to go back in 1993 and find the max and min for that year and that will be max and min in 2006 as well.
As such I have to go to Table_2 historical and search for min and max. But this table doesn’t have the field NUM and if I match only on the Account_no, Account_eff_dt and No_account_holder I don’t get a unique record.
So how can I connect all three tables, Table 1 for max and min, if it doesn’t find anything will go to table 2 find the two values and populate Table_result_06.
Thanks so much again for your hep, -
Creating cursor using Execute immediate
I am trying to create one cursor using a for loop, but I am not able to do so, could you please help me with the approach to get it done.
Here is the scenario:
I have one table table_1,it contains 2 columns source_query , target_query.
source_query and target_query are Select statements like source_query is Select name, age , valid from customer where customer_id=123456;
I fetched the data from these columns into 2 strings
select source_query into source_data from table_1;
select target_query into target_data from table_1;
Now out of these 2 I want to create 2 cursors, so that I can compare the column values one by one ( I am not using the source minus target approach because of difference in the data type).
I have to individually check the values.
So here are the cursors:
For source_data_value in ( EXECUTE immediate source_data)
LOOP
For target_data_value in (EXECUTE IMMEDIATE target_data)
LOOP
<executable statements>;
END LOOP;
END LOOP;
But the cursor creation is failing in the procedure.
Please let me know if it is possible to create a cursor using the execute immediate , if not what approach I should use other than this?Why exactly you are doing this inside a procedure. You can take the SQL's out and write a simple query to retrieve the data. Anyways, to work it out in a procedure, I can think of the below solution. I am trying to do away with Execute Immediate and use REF cursor. Please note that this is untested and just a try to present a possible solution which can be changed to implement your original requirement. I haven't done anything sort of this before, so if this approach doesn't approach, kindly ignore
DECLARE
TYPE TempTyp IS REF CURSOR;
temp_cv TempTyp;
temp_cv_2 Temptyp;
emp_rec emp%ROWTYPE;
source_data VARCHAR2(200);
target_data VARCHAR2(200);
BEGIN
source_data:= 'SELECT * FROM source tablej';
target_Date :='select * from target table';
OPEN temp_cv FOR source_data;
LOOP
FETCH temp_cv INTO emp_rec;
EXIT WHEN emp_cv%NOTFOUND;
OPEN temp_cv_2 FOR target_data;
FETCH Temp_cv_2 into emp_rec emp%ROWTYPE
loop
< And then your comparisons here >
END LOOP:
CLOST TEMP_CV_2;
END LOOP;
CLOSE temp_cv;
END;
Ishan -
Hi
While trying to Create Projects using the API, I'm getting two types of errors -
The first is : 'API failed in one stage 1 Customer Name is a mandatory Quick Entry field. Value must be passed'
The second is : '
'API failed in one stage 1 Project: '<Project_Number>'
The class category is invalid.'
Both the messages are produced by our custom program. .. however I am not able to understand why the underlying errors occur.
The first error ( Customer Name is a mandatory quick entry field), is caused by Projects that are to be created from Project templates where it is configured with Quick Entry Customer Name required. We are passing Customer Site number ( Party Bill to site number and Party Ship to side number). The site numbers being passed are also set as 'Primary'. Yet they are failing.
For the second Error ( The Class Category is invalid), I rechecked multiple times, the Class categories for the Projects I am trying to create, with the Config in R12 and they are fine. Can't understand the reason for these two issues. Has anyone encountered such an issue ? If so how was it resolved?
Regards
VivekHI All
I resolved both the issues. In case there are others facing similar issues, following was the cause and resolution of my errors
1. Error 1: Customer Name is a Mandatory Quick Entry field. Value must be passed.
The cause was that the data loaded into our custom staging table was not in the right fields. This was because the data file values and the CTL were not in sync.
Resolution:
Corrected the data file to be in Sync with the structure defined in the CTL and this loaded it successfully
2. Error 2: The class category is invalid.
The cause of this error was that in the Projects Template (used to create the project from), the Quick Entry setup had a Class Category set as required and I was not passing a value ( a class code value) for that Class Category.
Hope this helps somebody else
Cheers
Turnbill -
Import a dumpy file to newly created schema using the old schematablespace!
I'd created an export dump file of user X with rows=n (for Replicating the schema data structures to another schema). When I import using this dump file to newly created user Y. The newly created objects(tables,indexes) are using the tablespaces that were used in X instead of the default tablespace of Y.
How can I import X objects into Y with Y's default tablespace.?CJ and others,
This just worked fine for me. here is what I did:
sql> connect system/manager
create tablespace tbs1 datafile tbs1.f size 10m;
create tablespace tbs2 datafile tbs2.f size 10m;
create user user1 indentified by user1 default tablespace tbs1;
create user user2 indentified by user2 default tablespace tbs2;
create table user1.tab1 (a number);
insert into user1.tab1 values (100):
commit;
exit;
$ exp user1/user1 file=user1.dmp
sql> connect system/manager
drop tablespace tbs1 including contents;
exit
imp system/manager file=user1.dmp fromuser=user1 touser=user2
This imported user2.tab1 into tablespace tbs2. I think if tbs1 was still around, then it would have imported it into tbs1.
Thanks
Dean -
I have been unable to use the "Advanced - Create iPad or Apple TV Version" to convert my movies for use with my iPad2. The movie will go through the conversion process, and is the correct length, but the video is a black and there is no sound? Has anyone found a similar problem? If so, what can I do to fix the problem? Before I used Handbrake to convert the videos which worked well, but now that is not working either .
No, there is no direct download link. Those are days of the past, I'm afraid. You may need to reinstall Mavericks.
Install or Reinstall Yosemite, Mavericks, Mountain Lion, or Lion from Scratch
Be sure you backup your files to an external drive or second internal drive because the following procedure will remove everything from the hard drive.
How to Clean Install OS X Yosemite
OS X Mavericks- Erase and reinstall OS X
OS X Mountain Lion- Erase and reinstall OS X
OS X Lion- Erase and reinstall Mac OS X
Note: You will need an active Internet connection. I suggest using Ethernet if possible
because it is three times faster than wireless. -
How to import a doc file which is a file created by using the codings?
Hai to all....
i'm now trying to import a word doc file which is created by using the
CreateFile() method in Win32 Programming....
When i manually created a doc file and import that file using the
PlaceFileInFrame method.... the contents of the doc file is placing in
the document perfectly...
But when i'm trying to create a doc file using CreateFile() method and importing it... and use the PlaceFileInFrame method... its not placing the
contents of the file...
i will show u the codings what i had done...
HANDLE hFile;
DWORD wmWritten;
//FOR CREATING A DOC FILE....
hFile = CreateFile(L"C:\\tab.doc",GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
//FOR WRITIND DATA INTO THAT FILE FROM row[2] IN A MYSQL DATABASE
WriteFile(hFile,row[2],(DWORD)(strlen(row[2])),&wmWritten,NULL);
CloseHandle(hFile);
//USED PLACEFILEINFRAME METHOD FOR PLACING THE CONTENTS OF THE DOC FILE
tempfilename="C:/tab.doc";
target = "/" ;
replace = "\\" ;
s.Replace(tempfilename,target,replace);
IDFile idFile;
idFile.SetFileName(tempfilename);
UIFlags uiFlags = K2::kMinimalUI;
UIDRef ref = layoutHelper.PlaceFileInFrame (idFile,placeUIDRef,boundsInParentCoords,
uiFlags,
kTrue, //retainFormat
kTrue, //convertQuotes
kFalse, //applyCJKGrid
NULL);
But the import is failed...
When i manually created a doc file and import that file using the
PlaceFileInFrame method.... the contents of the doc file is placing in
the document perfectly...
Is there any ImportProvider or ImportFilter available for
importing this type of written files?
Can any one plzz explain me?
thanks in advance..
senthilHai Oscar,<br /><br />Now i'm trying like this for importing XML files...<br />----------------------------------------------------------------------<br />IActiveContext* activeContext = snpRunContext->GetActiveContext();<br />UIDRef documentUIDRef = ::GetUIDRef(myContext->GetContextDocument());<br />tempfilename="C:/1.xml";<br />target = "/" ;<br />replace = "\\" ;<br />IDFile idFile;<br />idFile.SetFileName(tempfilename);<br />IDataBase* db = documentUIDRef.GetDataBase();<br />InterfacePtr<IDocument> document(documentUIDRef, UseDefaultIID());<br /> ASSERT(document);<br /> if(!document) {<br /> break;<br /> }<br /> InterfacePtr<IXMLReferenceData> xmlReferenceData(document, UseDefaultIID());<br /> ASSERT(xmlReferenceData);<br /> if(!xmlReferenceData) {<br /> break;<br /> }<br /> XMLReference xmlRef = xmlReferenceData->GetReference();<br /><br /> <br /> InterfacePtr<IIDXMLElement> element(xmlRef.Instantiate());<br /> ASSERT(element);<br /> if(!element) {<br /> break;<br /> }<br /><br /> <br /> InterfacePtr<IK2ServiceRegistry> serviceRegistry(gSession, UseDefaultIID());<br /> ASSERT(serviceRegistry);<br /> InterfacePtr<IK2ServiceProvider> xmlParserServiceProvider<br /> (serviceRegistry->QueryServiceProviderByClassID(kXMLParserService, <br /> kXMLParserServiceBoss));<br /> ASSERT(xmlParserServiceProvider);<br /> if(!xmlParserServiceProvider) {<br /> break;<br /> }<br /> InterfacePtr<IXMLAccess> access(xmlParserServiceProvider, UseDefaultIID());<br /> ASSERT(access);<br /> if(!access) {<br /> break;<br /> }<br /> // -precondition<br /> <br /> InterfacePtr<ICommand> importCmd(CmdUtils::CreateCommand(kImportXMLFileCmdBoss));<br /> ASSERT(importCmd);<br /> InterfacePtr<IImportXMLData> importXMLData(CreateObject2<IImportXMLData>(kImportXMLDataBoss));<br /> ASSERT(importXMLData);<br /> if(!importXMLData) {<br /> break;<br /> }<br /> importXMLData->Set(db, idFile,kInvalidXMLReference, kSuppressUI);<br /> InterfacePtr<IXMLImportOptions> docXMLOptions( document->GetDocWorkSpace(), UseDefaultIID() );<br /> ASSERT(docXMLOptions);<br /> if(!docXMLOptions) {<br /> break;<br /> }<br /> InterfacePtr<IXMLImportOptions> importXMLOptions(importXMLData, UseDefaultIID());<br /> ASSERT(importXMLOptions);<br /> if(!importXMLOptions) {<br /> break;<br /> }<br /> importXMLOptions->Copy(docXMLOptions);<br /> <br /> InterfacePtr<IPMUnknownData> pmUnknownData(importCmd, UseDefaultIID());<br /> ASSERT(pmUnknownData);<br /> if(!pmUnknownData) {<br /> break;<br /> }<br /> pmUnknownData->SetPMUnknown(importXMLData);<br /> <br /> CmdUtils::ProcessCommand(importCmd);<br />--------------------------------------------------------------------- <br />But it showing the following 2 errors...<br /><br />error C2065: 'snpRunContext' : undeclared identifier<br />error C2227: left of '->GetActiveContext' must point to class/struct/union type is ''unknown-type''<br /><br />Then i tried to declare snpRunContext like this...<br />InterfacePtr<ISnpRunnableContext>snpRunContext(parentUIDRef,UseDefaultIID());<br /><br />its sucessfully compiled... But the output is not coming...<br />Its showing unhandled exception in the line<br />IActiveContext* activeContext = snpRunContext->GetActiveContext();<br /><br />So, what shal i do for declaring snpRunContext... <br /><br />plz give me an idea...<br /><br />thanks.<br />senthil.
-
Why should we create index on the table after inserting data ?
Please tell me the Reason, why should we create index on the table after inserting data .
while we can also create index on the table before insertion of the data.The choice depends on a number of factors, the main being how many rows are going to be inserted in the table as a percentage of the existing rows, or the percentage growth.
Creating index after a table has been populated works better when the tables are large or the inserts are large for the following reasons
1. The sort and creation of index is more efficient when done in batch and written in bulk. So works faster.
2. When the index is being written blocks get acquired as more data gets written. So, when a large number of rows get inserted in a table that already has an index , the index data blocks start splitting / chaining. This increases the "depth" of the inverted b-tree makes and that makes the index less efficient on I/O. Creating index after data has been inserted allows Orale to create optical block distribution/ reduce splitting / chaining
3. If an index exists then it too is routed through the undo / redo processes. Thats an overhead which is avoided when you create index after populating the table.
Regards -
How to use the dll created by c++ but not write a jni wrapper around
how to use the dll created by c++ but not write a jni wrapper around through a java program. now I can't access that dll like this directly from java.
Your question is unclear. (You haven't said what dll you are talking about.)
But:
If you are talking about an existing dll, then the only alternative to writing a wrapper is to use one of the wrapper generators floating around. Do a search on JACE.
If you are talking about a dll you are writing, then run jah and get the interface to match java right away; then you won't have to write a wrapper. -
when creating invoice using the API AR_INVOICE_AP_PUB.Create_Single_invoice Am Getting the below Error:
Transaction type is invalid with current transaction date
invalid transaction type
either an inventory item description must be provided
Kindly help me hereHi Team,
I tried creating the invoice and I got the above errors, however, when updated the batch source ID I am now getting this following error only, i am just left with the following Error only
Either an inventory item or description must be provided.
Please help me on this. -
How can I resize and reposition the Date Created window for All windows?
When setting view options for a finder window set to list view, I cannot get column resizing or positioning to hold. When making those changes, the option for "All Windows" automatically shifts to "This window only" and it then does not hold.
How can I resize and reposition the Date Created column for All WIndows?Hi Harmz,
Try dragging this file to the Îesktop & reboot...
/Users/YourUserName/Library/Preferences/com.apple.finder.plist -
How to let sql server 2008 know the table created at front end in c#
How to let sql server 2008 know the table created at front end in c#
The best solution is to create table type and pass the DataTable as table-valued parameter. I have an article on my web site about this:
http://www.sommarskog.se/arrays-in-sql-2008.html
The full article is a bit of overkill for what you are doing right now, but just the few first pages should get you going.
Erland Sommarskog, SQL Server MVP, [email protected] -
Execute PL/SQL using the defaul Create button.
I have created an application and everyting with working fine.
I have one page where I create a work order. This is saved by using the default create button.
What I want to do now is, when I save I want to execute some PL/SQL, so essentially kicking off another process.
Is this possible? Is so how.
cheers
JamesJames,
Since you want PL/SQL procedure to be fired after clicking the default create button, create a a conditional PL/SQL process. Please follow the below steps:
1. Create a page process (Click process create icon under page processing in edit page). Choose process category as 'PL/SQL'. Click 'Next'.
2. Enter the PL/SQL procedure that should be executed on clicking the button. (In your case, it is the sql insert statement). Click 'Next'
3. Enter the success and failure message if required. Click 'Next'
4. For'When Button Pressed' select list, please choose the Default 'Create' Button. Press 'Create Process'.
Hope this helps. -
How to use the Table Function defined in package in OWB?
Hi,
I defined a table function in a package. I am trying to use that in owb using Table function operator. But I came to know that, owb R1 supports only standalone table functions.
Is there any other way to use the table function defined in a package. As like we create synonyms for functions, is there any other way to do this.
I tryed to create synonyms, it is created. But it is showing compilation error. Finally I found that, we can't create synonyms for functions which are defined in packages.
Any one can explain it, how to resolve this problem.
Thank you,
Regards
Gowtham Sen.Hi Marcos,
Thank you for reply.
OWB R1 supports stand alone table functions. Here what I mean is, the table fucntion which is not inculded in any package is a stand alone table function.
for example say sample_tbl_fn is a table function. It is defined as a function.It is a stand alone function. We call this fucntion as "samp_tbl_fn()";
For exampe say sample_pkg is a package. say a function is defined in a package.
then we call that function as sample_pkg.functionname(); This is not a stand alone function.
I hope you understand it.
owb supports stand alone functions.
Here I would like to know, is there any other way to use the functions which are defined in package. While I am trying to use those functions (which are defined in package -- giving the name as packagename.functionname) it is throwing an error "Invalid object name."
Here I would like know, is there any other way to use the table functions which are defined in a package.
Thank you,
Regards,
Gowtham Sen.
Maybe you are looking for
-
How do I migrate bookmarks from one HD to another?
Windows XP became corrupted (?). It was cheaper to install another hard drive, and install windows on the new drive (backing up the original HD would cost more than the new HD did....) The old drive is easily accessed. How do I migrate Firefox bookma
-
How do i clear my old iphone 5 of data?
I saw in these support communities that I should go to settings/general/reset and then select "erase all content and settings" which is fine and good until I put in my password, hit erase iPhone, then select it again after I get a warning it can't be
-
Text variables with multiple lines
Like in my other question: we typeset a lot of juridical books. We use text variables in the header for showing the current chapter and for example current author of that chapter. So we let the paragraph style of the chapter show in the header. When
-
IPhoto - Sharing Library Problem
Hi I recently experienced a problem with the iPhoto Sharing option. I am currently on a MacBook Pro and a new iMac. Both are running iPhoto 6. If I select 'Share my Photos' and 'Look for shared Photos' on both, I cannot get a connection. Nothing appe
-
Problem in creating text index
While creating index on XMLType column i am getting this error ERROR at line 1: ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine ORA-20000: Oracle Text error: DRG-50857: oracle error in driddl.policycreate ORA-01400: cannot inser