I'm trying to create a loop to delete all portal rows. But the loop doesn't stop.
What am i doing wrong?
Go to Portal Row [Select; First]
Loop
Delete Portal Row [No Dialog]
Go To Portal Row [Next; Exit after last]
End Loop
I suspect that you have Allow creation of related records through this relationship on in your Relationships graph. This means that there will always be one record in the portal and that record can't be deleted because it is where a user would enter new data.
You could modify your script to something like this:
Go to Portal Row [Select; First]
Loop
Delete Portal Row [No dialog]
Go to Portal Row [Select; First]
Exit Loop If [IsEmpty(relationship::index)]
End Loop
Where relationship::index is a value stored in every field of your foreign table.
Manipulating portals like this can be tricky. You might consider using a Go to Related Records script step go delete the records, instead. Something like:
Set Error Capture [On]
#
# Attempt to go to the related records, creating a new window "delete records"
Go to Related Record [Show only related records; From table: "<relatedtable>"; Using layout: "<relatedlayout>" (<relatedtable>); New window]
#
# If that failed exit the script. We should still be in the same window and layout.
If [not Get ( LastError )]
Exit Script []
End If
#
# Otherwise delete all found records
Delete All Records [No dialog]
#
# And close the window we created
Close Window [Name: "delete steps"; Current file]
Set Error Capture [Off]
Related
I referred to this link create a download zip button to download files in zip format in Oracle apex latest version 22.2. It is working fine without any issues but only concern is; it downloads all the files in one zip file. Whereas my requirement is to include a checkbox on a report (either IG or IR) and to download selected files in one zip file.
Below is the table I am referring to. Its from Oracle apex sample files upload and download.
select
ID,
ROW_VERSION_NUMBER,
PROJECT_ID,
FILENAME,
FILE_MIMETYPE,
FILE_CHARSET,
FILE_BLOB,
FILE_COMMENTS,
TAGS,
CREATED,
CREATED_BY,
UPDATED,
UPDATED_BY
from EBA_DEMO_FILES
I tried searching over the internet and found few links pointing to APEX_ZIP, PL/SQL compress blob etc. But could not see any demo or working model similar to the link I provided above.
If anybody has working demo or blog,I request to share it. Many thanks.
Update: As suggested by Koen Lostrie, I am updating Page process code below:
DECLARE
l_id_arr apex_t_varchar2;
l_selected_id_arr apex_t_varchar2;
var_zip blob;
BEGIN
-- push all id values to an array
FOR i IN 1..APEX_APPLICATION.G_F03.COUNT LOOP
apex_string.push(l_id_arr,APEX_APPLICATION.G_F03(i));
FOR j IN 1 .. APEX_APPLICATION.G_F01.COUNT LOOP
IF APEX_APPLICATION.G_F01(j) = APEX_APPLICATION.G_F03(i) THEN
-- push all selected emp_id values to a 2nd array
apex_string.push(l_selected_id_arr,APEX_APPLICATION.G_F03(i));
END IF;
END LOOP;
END LOOP;
-- Create/clear the ZIP collection
APEX_COLLECTION.CREATE_OR_TRUNCATE_COLLECTION(
p_collection_name => 'ZIP');
-- Loop through all the files in the database
begin
for var_file in (select fi.filename, fi.file_blob, pr.project
from eba_demo_files fi
inner join eba_demo_file_projects pr on fi.project_id = pr.id
where fi.id in (SELECT column_value FROM table(apex_string.split(apex_string.join(l_selected_id_arr,':'),':'))))
loop
-- Add each file to the var_zip file
APEX_ZIP.ADD_FILE (
p_zipped_blob => var_zip,
p_file_name => var_file.project || '/' || var_file.filename,
p_content => var_file.file_blob );
end loop;
exception when no_data_found then
-- If there are no files in the database, handle error
raise_application_error(-20001, 'No Files found!');
end;
-- Finish creating the zip file (var_zip)
APEX_ZIP.FINISH(
p_zipped_blob => var_zip);
-- Add var_zip to the blob column of the ZIP collection
APEX_COLLECTION.ADD_MEMBER(
p_collection_name => 'ZIP',
p_blob001 => var_zip);
END;
Once page process is done, follow step 3 and 4 from the link provided in OP.
Below is the updated query:
select
ID,
ROW_VERSION_NUMBER,
PROJECT_ID,
FILENAME,
FILE_MIMETYPE,
FILE_CHARSET,
FILE_BLOB,
FILE_COMMENTS,
TAGS,
CREATED,
CREATED_BY,
UPDATED,
UPDATED_BY,
APEX_ITEM.CHECKBOX(1,ID) checkbox,
APEX_ITEM.TEXT(2,FILENAME) some_text,
APEX_ITEM.HIDDEN(3,ID) hidden_empno
from EBA_DEMO_FILES
Big Thanks to Koen Lostrie.
All credits goes to Koen Lostrie.
Thanks,
Richa
This is just an answer to the last comment - the base question was answered in the comments. The question in the comment is "how do I include APEX_ITEM.HIDDEN columns in my report without hiding the columns".
When the columns are hidden in the report, they're not rendered in the DOM, so the values do not exist when the form is posted. That is the reason you're getting the error.
However, take a step back and check what APEX_ITEM.HIDDEN generates. Add a column of type APEX_ITEM.HIDDEN to the report and inspect the column in the browser tools. It generates an input element of type "hidden", so the value is not shown in the report. So to include the column in your report but not make it visible on the screen, just concatenate it to an existing other column:
In your case, with the select from the question that would be:
select
APEX_ITEM.HIDDEN(3,ID) || APEX_ITEM.HIDDEN(2,FILENAME) || ID,
ROW_VERSION_NUMBER,
PROJECT_ID,
FILENAME,
FILE_MIMETYPE,
FILE_CHARSET,
FILE_BLOB,
FILE_COMMENTS,
TAGS,
CREATED,
CREATED_BY,
UPDATED,
UPDATED_BY,
APEX_ITEM.CHECKBOX(1,ID) checkbox
from EBA_DEMO_FILES
Note that filename can also be in a hidden element.
I got this error while dropping the index ZQT64_CUA_LOGSYS for the table name ZQT64.
"Cannot drop the index 'ZQT64.ZQT64_CUA_LOGSYS', because it doesn't exist in the
system catalogs."
Seeing this i tried creating the index again, Where it showed "There is already an index on table 'ZQT64' named 'ZQT64_CUA_LOGSYS'"
Could someone suggest me what is the issue and how can I Drop the index?
Your create index command shows a user of SAPSR3.
I'm going to guess that you're not logged in as the user SAPSR3 (eg, perhaps you're logged in as sapsa). If this is the case try changing to user SAPSR3 to drop the index, eg:
use TST
go
-- switch to user SAPSR3
setuser 'SAPSR3'
go
drop index ZQT64.ZQT64_CUA_LOGSYS
go
-- switch back to your original user
setuser
go
ASE is a bit flaky in this area:
while you can provide database and user names for the create index
command, these identifiers are not supported by the drop index
command
error 3701 (cannot drop the index ... doesn't exist in the system
catalog) is a bit misleading; it should probably say something like
you don't own an object named ZQT64 (or something similar)
First of all I have never attempted something like this in SSIS and I am very new to SSIS package development.
I need to build a component in my package that will run through a table of data (say 80 rows) and set a field titled DisplayOrder to the auto incremented number. The catch is that one of the records HAS to be set to 0 and then the rest of he records set to the auto incremented number.
In regards to code, I am not even sure what code to attach to this question or even what screenshots.
I finally figured it out and there is no need for a loop.
Create a SQL Task to clear the linked Table.
Script Used
DELETE FROM [Currency].[ExchangeRates]
Create a SQL Task to clear the main table.
Script Used
DELETE FROM [Currency].[CurrencyList]
Load the values into the main table.
Actions Used
Load values from XML Source
Dump values to [ExchangeRates] Table
Create a SQL Task to load the Values from the main table to the linked table.
Script Used
INSERT INTO [Currency].[CurrencyList] (CurrencyCode, CurrencyName, ExchangeRateID, DisplayOrder) SELECT [er].[TargetCurrency] AS [CurrencyCode], [er].[TargetName] AS [CurrencyName], [er].[ID] AS [ExchangeRateID], ROW_NUMBER() OVER (ORDER BY [ER].[TargetName]) AS [DisplayOrder] FROM [Currency].[ExchangeRates] AS [er] ORDER BY [CurrencyName]
Create a SQL Task to load a new record to the main table for use as DisplayOrder 0.
Script Used
INSERT INTO [Currency].[ExchangeRates] ([Title], [Link], [Description], [PubDate], [BaseCurrency], [TargetCurrency], [TargetName], [ExchangeRate]) VALUES ('1 USD = 1 USD','http://www.floatrates.com/usd/usd/','1 U.S. Dollar = 1 U.S. Dollar',(SELECT TOP 1 [PubDate] FROM [Currency].[ExchangeRates]),'USD','USD','United States Dollar','1')
Create a SQL Task to reference the newly created record from the main table.
Script Used
INSERT INTO [Currency].[CurrencyList] (CurrencyCode, CurrencyName, ExchangeRateID, DisplayOrder) SELECT [er].[TargetCurrency] AS [CurrencyCode], [er].[TargetName] AS [CurrencyName], [er].[ID] AS [ExchangeRateID], 0 AS [DisplayOrder] FROM [Currency].[ExchangeRates] AS [er] WHERE [er].[TargetCurrency] = 'USD'
I have created Product entity in MDS.
It's having the following values:
Bike 1 ABC
Car 2 XYZ
Cycle 3 RRR
owner XYZ can change the record of RRR. But if owner XYZ or any other owner in this entity tried to update the ABC's record, access should be denied. That means, no one should have the permission to change the records which are entered by ABC.
for this I have executed following :
CREATE TRIGGER mdm.product_readonly
ON mdm.tbl_1034_1215_en
AFTER UPDATE, INSERT AS
If exists (system_user!='ABC')
and EXISTS (SELECT * FROM deleted a, inserted b, mdm.vw_product c
WHERE a.code=c.code
or b.code=c.code
And c.owner = 'ABC')
BEGIN
ROLLBACK TRANSACTION
RAISERROR ('Attempt to change a read-only row', 16, 1)
RETURN
END
After executing this, If I trying to update the record as ABC owner I can update all the records. If I try to update as other than ABC owner I couldnt update the ABC record. But from MDS I couldnt update any of the record. It showing like Database error.
How can we achieve this. Please help me out in this regard.
Thanks!
Please have a look on how to set permissions for MDS.
http://msdn.microsoft.com/en-us/library/hh231026.aspx
You can set permissions for users and/or groups.
I would recommend to assign permissions using AD groups as this is much easier to mantain on the long run.
If you need a more complex permission concept which is row based you can set permissions using derived hierarchies.
Permission settings are also stored in tables of MDSDB database. If you need to set permissions for many users I would recommend using code to copy permissiond. I can provide some snippets if needed.
I've created a very simple form with two textboxes and an 'update locations' button, the inputted values of which should be updating to two linked tables in a database. I'm eventually trying to put this in a standalone application but for now I just want the form itself to work. I'm very new to FoxPro so I don't know if it's possible for just a form to update my tables, or if there's some other issue at work.
Here's the code for my 'update locations' button (OldLoc is the first textbox and NewLoc the second):
SET DATABASE TO LOCATIONS
CLOSE ALL DATABASES
OPEN DATABASE locations\locations EXCLUSIVE
IF this.parent.OldLoc.Value == "" then
MESSAGEBOX('Please fill in the old location.', 48, 'Missing Location Information')
this.parent.OldLoc.SetFocus
ELSE
INDEX ON table1.loc TAG loc
SET ORDER TO loc
SEEK this.parent.OldLoc.Value IN table1
IF FOUND()
IF this.parent.NewLoc.Value == "" then
MESSAGEBOX('Please fill in the new location.', 48,
'Missing Location Information') this.parent.NewLoc.SetFocus
UPDATE table1 SET loc = this.parent.NewLoc.Value ;
WHERE loc = this.parent.OldLoc.value
UPDATE table2 SET loc = this.parent.NewLoc.Value ;
WHERE loc = this.parent.OldLoc.value
ENDIF
ENDIF
ENDIF
Any input you have is appreciated!
you are doing redundant work in your click event... Closing the database, then re-opening, then opening exclusive. The tables you are trying to update, should already have an index on the key columns you ever plan to join or search based on. Once that is done, you don't need to explicitly create the index tag over and over... Once an index "TAG" is created, you don't need to do again..
So, that being said...
Open the form, and open the "INIT" event. In there, that is where you can explicitly open the tables for use while the form is in use...
IF NOT DBUSED( "Locations" )
*/ You only need exclusive if you will be modifying the database.
*/ The indexes should already exist before the form ever starts
Open Database Locations\Locations SHARED
ENDIF
Now, the "CLICK" event of your update button... Pre-validate that there are values, don't worry about trying to seek or update unless BOTH are filled in...
IF ALLTRIM( This.Parent.OldLoc.Value ) == "";
OR ALLTRIM( This.Parent.NewLoc.Value ) == ""
*/ Simple one message about BOTH being required
messagebox( "Please fill in both Old and New Locations.", 48, ;
"Missing Location Information" )
ENDIF
*/ Then, update... if no entries match, no records will be updated.
*/ VFP sometimes chokes with multiple "." values such as form values
*/ as SQL commands are expecting "alias.field" format...
lcOldValue = This.Parent.OldLoc.Value
lcNewValue = This.Parent.NewLoc.Value
Update Locations!Table1;
set Loc = lcNewLoc;
where Loc = lcOldLoc
*/ Were there any updates?
llAnyUpdates = _Tally > 0
*/ Now, the OTHER table too...
Update Locations!Table1;
set Loc = lcNewLoc;
where Loc = lcOldLoc
*/ Were there any updates on THIS cycle...
llAnyUpdates = llAnyUpdates OR _Tally > 0
if llAnyUpdates
messagebox( "Locations have been updated.", 0, "Update complete" )
else
messagebox( "No such location found to be updated.", 0, "No Records Updated" )
endif
You might also want to take a look at the data environment of the form.
You can select which tables the form is to open when the form loads, this saves explicitly opening them either in the forms load event or in the forms init event
My humble offering for the Click Event of the 'Update Locations' button is :-
LOCAL lcOldLoc,lcNewLoc
WITH THISFORM
lcOldLoc=.oldloc.VALUE
lcNewLoc=newloc.VALUE
DO CASE
CASE EMPTY(lcOldLoc)
MESSAGEBOX("PLEASE ENTER OLD LOCATION",16,"ERROR")
CASE EMPTY(lcNewLoc)
MESSAGEBOX("NEW LOCATION CAN'T BE EMPTY",16,"ERROR")
OTHERWISE
UPDATE table1 SET loc=lcNewLoc WHERE loc=lcOldLoc
DO CASE
CASE _TALLY=0
MESSAGEBOX("OLD LOCATION NOT FOUND",16,"ERROR")
OTHERWISE
UPDATE tabel2 SET loc=lcNewLoc WHERE loc=lcOldLoc
ENDCASE
ENDCASE
ENDWITH
This should be the only code required. Clearly there are many improvements that can be made to the above , but in essence that will do the job.
If you would like to see the above form built from scratch, pop an email to support#foxsoft.co.uk and I will give you a live demonstration.