I am beginner in Microsoft Dynamic NAV.
So, I want to find out how to make my Primary Key in my table to be auto increment.
For example I have table with next Line: "Field No.= 10" "Field name = Code" -"Type = Code" "Lenght = 10";
I want that every time someone puts a new user, that my code to increase by 10. Can someone help me?
Normally you would create a no. series.
In your code you should use the standard NAV codeunit NoSeriesManagement (396).
This code would look something like:
NewNo := gCuNoSeriesMngmnt.GetNextNo('No series code',WORKDATE,TRUE);
If you want your table to always increment with 10 you will have to add some code in your table's OnInsert trigger.
I'm assuming that Field No. is your Primary Key
// if there is no "Field No." assigned yet
IF "Field No." = '' THEN BEGIN
// Get the last entry in the table and assign the next number to Field No.
<RecordVariableOfTable>.FINDLAST;
"Field No." := <RecordVariableOfTable>."Field No." + 10;
END;
RecordVariableOfTable has to be defined as a Record instance of your table in your C/AL global variables for the table.
If this is your master table and Field No. is your Primary Key
Then you should implement No. Series functionality on your table and assign a No. Series which increments by 10.
Related
I'm making a Microsoft Access table where one of the fields is a list of pre-made options. When I make a SQL query on that table it returns the values of the list as strings containing the spelled out choice. I would like to assign numerical values to each element of the list so a SQL query returns a number instead. How do I do this? I know it's possible because I have an access file with such a list but I'm unable to recreate it.
An easy way to do this is to have your combo box use a query of the table as a Rowsource. This query would have the table unique ID in the first field and the field you wish to return as the second field. Then change the setting on the combo box for "Column Count" to 2. If you want to show both fields change the "Column Widths" value to 1"; 1". If you want to show only one field, change the value of one you do not want to see to 0. Now we you refer to this list in an SQL queries, it will use the ID field but show the user the string field.
IR based on PL/SQL Function Body returning SQL Query.
How do i can create Interactive reports based on multiple table and Deferent column name.
Exp :-
Select list item return three value
1 or 2 or 3
And the function return query basen on select list value
when Value equal 1
Select name, satate, country_id from cities
when value equal 2 Return
Select country, id from country
when value equal 3 Return
Select ocean,oc_id,from oceans
The three query return different column name and value.
Ok firstly, your question is poorly written. But from what I gather, you want an SQL query that returns different things based on an input.
I dont think you even need a plsql function body for this.
Simply do something like this:
SELECT * FROM
(SELECT name as name,
state as state,
country_id as id,
1 as value
FROM cities
UNION ALL
SELECT country as name,
NULL as state,
id as id,
2 as value
FROM country
UNION ALL
SELECT ocean as name,
NULL as state,
oc_id as id,
3 as value
FROM oceans)
WHERE value = :input_parameter_value;
Because if you are trying to display a variable number of columns and constantly changing their names and such. You are gonna have a bad time, it can be done, as can everything. But afaik its not exactly simple
No objections to what #TineO has said in their answer, I'd probably do it that way.
Though, yet another option: if your Apex version allows it, you can create three Interactive Report regions on the same page, each selecting values from its own table, keeping its own column labels.
Then create a server condition for each region; its type would be Function that returns a Boolean and look like
return :P1_LIST_ITEM = 1;
for the 1st region; = 2 for the 2nd and = 3 for the 3rd.
When you run the page, nothing would be displayed as P1_LIST_ITEM has no value. Once you set it, one of conditions would be met and appropriate region would be displayed.
I have a form in my Oracle APEX based application, I want to have validation on submit button, so that the combination of two specific entries, if they already are present in the SQL table/View, I want to show an alert, like "The entry for this combination of values of A and B already exists, please enter correct values."
If those two specific entries are represented by two form items (e.g. :P1_ONE and :P2_TWO), then the validation procedure might be a function that returns error text, such as
declare
l_cnt number;
retval varchar2(200);
begin
select count(*)
into l_cnt
from your_table t
where t.column_one = :P1_ONE
and t.column_two = :P1_TWO;
if l_cnt > 0 then
retval := 'The entry for this combination already exists';
end if;
end;
The query itself might need to be modified, depending on what exactly you meant by describing the problem; that's the way I understood it.
Then you should have a unique constraint on the table, and let that validate incoming data.
Any violation of this constraint will have exception raised, which can be transformed within the APEX error handling procedure.
I am using Oracle APEX to build a interactive report. There is a field in my database called method which should contain either A or B. In the edit page, I want to show a list containing A and B so that users can choose from those two.
I set the type of the item to SelectList and since I need to add the other value to the list, in the List of Values area, I set the type to PL/SQL Function Body returning SQL Query and the code is as follows:
Begin
select TEST_METHOD into method from table_test
where ROWID = :P2_ROWID;
IF ('Live' = method) THEN
return select 'Screenshots' from dual;
END IF;
return select 'Live' from dual;
End;
However, I got the following error:
ORA-06550: line 5, column 10: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: ( - + ; case mod new not null continue avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe
I am new to plsql and APEX, I know the code looks wired but I don't know what's wrong. I am also wondering if there is any other way to achieve my goal? Thanks!
I use C++ Builder 6.0
I use TADODataSet execute following SQL statement:
SELECT Id, SUM(Saldo) AS Saldo
FROM Table
GROUP BY Id
I use this DataSet only for reporting. No need update date back to database.
When I try to modify field "Saldo"
adospCard->Edit();
adospCard->FieldByName("Saldo")->AsFloat=0.0;
adospCard->Post();
I get error:
Field 'Saldo' cannot be modified.
I add this line
adospCard->FieldByName("Saldo")->ReadOnly=false;
and error no more occurred, but field 'Saldo' has not changed.
adospCard->Edit();
//adospCard->FieldByName("Saldo")->AsFloat=1536.5
adospCard->FieldByName("Saldo")->AsFloat=0.0;
//adospCard->FieldByName("Saldo")->AsFloat=0
adospCard->Post();
//adospCard->FieldByName("Saldo")->AsFloat=1536.5
Howe to change ‘Saldo’ field value?
Add a calculated field to your dataset.
Calculate the right value for Saldo
in this calculated field (you can
use Saldo as source for it if you
want to)
display this calculated field in your report in
stead of the Saldo field.
Edit:
For examples of how to add calculated fields, see for instance here, here and here.
--jeroen
As ldsandon said, you cannot modify the "Saldo" field as it is computed.
If you need to set the value to zero when Id is "something" you are better off doing it in your query. The best approach depends on the criteria for setting the value to zero.
Or, save the results of the original query in a temp table then modify that before returning the results to the report.
Finally, what reporting tool are you using? Can that do the "Saldo = 0" change when rendering the report?
Consider storing your result in a ClientDataset - if you can be assured the result isn't too large.
I don't use "TADODataSet" so the following may not apply :)...
When I do the same (or similar) using my DB of choice (i.e. Advantage Database Server) I would use the INTO clause, albeit, with a TSQLQuery component (with the RequestLive property enabled). For example:
SELECT Id, SUM(Saldo) AS Saldo INTO #TempTable FROM Table GROUP BY Id