Do ampersands work for user input in reports? - oracle-sqldeveloper

I have a working query that goes something like this:
Base table ACCT, link to others (listagg/subqueries) and ensure matching year("rollyear") field. Then the final step is to say which year ACCT table is in.
SELECT
FROM table ACCT
FULL OUTER JOIN table TABLE2 on ACCT.id = TABLE2.id and ACCT.rollyear= TABLE2.rollyear
...
FULL JOIN table TABLE7 on ACCT.id = TABLE7.id and ACCT.rollyear= TABLE7.rollyear
where ACCT.rollyear = extract (year from sysdate) +1
I typically use the calendar year plus one. I've been playing with using ACCT.rollyear = &rollyear to get user input... The limitation/issue I have is getting that running using the "User Defined Reports" feature.
Am I using this feature correctly? Does that only work for SQL Queries and not reports? Ive seen videos/comments about Stored Procedures and using "Accept...." but my attempts to mimic give errors and I'm not sure I'm on the right track. Thanks for any advice.

Change your query to use a bind variable:
where ACCT.rollyear = :rollyear
Then in the 'Binds' section you will see a variable with that name:
When you run your query you'll then be prompted to supply the value:

Related

uSync Dropdown DataType Issue

I have 2 sites, dev branch and production. On my dev branch I'm using a couple of archetype DataType which are able to be configured by a simple dropdown with couple color names (like Green, Blue etc). I have like 300 published nodes which uses that datatype (required field). After I've exported "Full Export" in uSync dashboard and then copy/pasted the whole uSync folder to my production branch and clicked "Full Import". After import complete I check my nodes. All fields are there except that dropdown.
There are some old issues on the our.umbraco.com website stating the same issue, but they seem to been fixed.
I've posted there this issue, but has been 6 days, and the topic still is on manual approval.
Any idea what must be causing this issue?
I am using (uSync.BackOffice 4.0.16.0) (uSync.Core 6.0.15.0) [uSync.Content: 4.1.9.1]
Umbraco version 7.15.4
Thank you in advance.
Best regards,
Artur
PS. I am unable to create the USync label. Would appreciate if someone would edit with it!
I'd open up the database and look at the values in the cmsDataTypePreValues table. I suspect that uSync has changed the prevalues out from under you. Prevalues are really tricky and uSync does its best given the circumstances. You'll notice that the uSync .def files in Umbraco 7 don't record any unique ids on those prevalues. They just get inserted into the database and are assigned an id automatically. This means if the prevalues are deleted and recreated, they will have different ids. If those dropdown prevalues are being picked by the id field on the cmsDataTypePreValues record, that is probably what is going wrong.
Use the following query to see your prevalues for the datatype:
DECLARE #dataTypeNodeId AS INT = <dataTypeNodeId, INT, 0>
SELECT *
FROM cmsDataType dt
INNER JOIN cmsDataTypePreValues pv
ON pv.datatypeNodeId = dt.nodeId
WHERE dt.nodeId = #dataTypeNodeId
Compare the values you see here between the dev database and the production database. To help give you a better picture of what the data looks like, you could also run this query to see what the actual picked values look like. The query is so long because it is filtering out results from old versions. This might not work very well for you because your datatype is inside of Archetype. Hopefully it can still give you an idea about what selected dropdown values actually look like in the database.
DECLARE #dataTypeNodeId AS INT = <dataTypeNodeId, INT, 0>
SELECT TOP 1000 n.id
,n.[text]
,n.[path]
,pt.[alias] AS 'property alias'
,dtn.id AS 'Datatype Id'
,dtn.[text] AS 'Datatype Name'
,dtn.uniqueID AS 'Datatype Guid'
,d.templateId
,t.[alias] AS 'template alias'
,pd.dataInt
,pd.dataDate
,pd.DataNvarchar
,pd.dataNtext
,cv.VersionDate
FROM umbracoNode n
INNER JOIN cmsDocument d
ON d.nodeId = n.id
INNER JOIN cmsContentVersion cv
ON cv.VersionId = d.versionId
INNER JOIN cmsPropertyData pd
ON pd.contentNodeId = n.id AND pd.versionId = d.versionId
INNER JOIN cmsPropertyType pt
ON pt.id = pd.propertytypeid
INNER JOIN cmsDataType dt
ON dt.nodeId = pt.dataTypeId
INNER JOIN umbracoNode dtn
ON dtn.id = dt.nodeId
LEFT OUTER JOIN cmsTemplate t
ON t.nodeId = d.templateId
WHERE d.newest = 1
AND dtn.id = #dataTypeNodeId
You can try to manually fix the prevalue entries in the database. I've run into enough prevalue trouble with Umbraco dropdowns that I try to always use something like nuPickers to avoid picking prevalues by id.

Microsoft Access - Creating a form which looks up data between 2 dates

For my College assignment, I have to create a database in Access, I have done 99% of my database, apart from this section which I'm stuck on.
In my DB, I have a tickets table, which contains records on order information and a field containing a date. For my assignment, I have to create a Form which reads from a Query.
For example, in my Form i have already created i have 2 Combo boxes with the dates already pulled from the Query. I need to be able to drop down one of the boxes and input 1 date, and then drop down the other box and select a different date, press a button and it generate me a Report.
The part I am asking for help on is the expression which is used to look up the data inside the Query. I tried using this expression, which Access said was too complicated.
[Forms]![frmOrdersBetweenTwoDates]![Combo33] And [Forms]![frmOrdersBetweenTwoDates]![Combo36]
My full SQL query is:
SELECT tblTickets.CustomerID, tblCustomers.FullName, tblCustomers.AddressLine1, tblTickets.OrderNumber, tblTickets.OrderDate
FROM tblCustomers INNER JOIN tblTickets ON tblCustomers.[CustomerID] = tblTickets.[CustomerID]
WHERE ((("WHERE [OrderDate]") Between [Forms]![frmOrdersBetweenTwoDates]![Combo52] And [Forms]![frmOrdersBetweenTwoDates]![Combo54]));
My expression/query now returns the report, but there is no data inside the report. How could i fix this?
Cheers.
Should post the complete query statement. Expect the filter clause should be like:
WHERE [date fieldname] BETWEEN [Forms]![frmOrdersBetweenTwoDates]![Combo33] AND [Forms]![frmOrdersBetweenTwoDates]![Combo36]
However, I don't use dynamic parameterized queries. I prefer to use the WHERE argument of OpenReport (same for OpenForm), in VBA:
DoCmd.OpenReport "report name", , , "[date fieldname] BETWEEN #" & Me.Combo33 & "# AND #" & Me.Combo36 & "#"

Number each nested table inside a master table on a Jasper report

So i have the following issue. In my database I have a table named
bp_minutes_app.
This table stores records of minutes from committee meetings. Each minute can consist of many files. The database design regarding minutes is the following:
The table bp_minutes_attachments is connected via a foreign key to the bp_minutes_app and holds the following information:
description, createdby
The table
bp_files
is connected via a foreign key to the
bp_minutes_app
and holds the file along other information. We are interested in taking only the name and id of the file (the latter in order to create a hyperlink to the file, but this is out of scope of the present question).
Final remark. All those tables are linked to the master
bp_full
table that is joined only to get the id of each specific report.
In my report I want to print on a table all minutes and the accompanying information (file name, description, createdby, submission date), but make a separate entry for each minute. In order to achieve this, I first created a table that uses the following dataset:
SELECT bp_minutes_app.id
FROM bp_minutes_app
INNER JOIN bp_full ON
bp_minutes_app.bp_full_app_id = bp_full.id
WHERE bp_full.id = $P{id}
With this dataset I retrieve each minutes record. In my example, I get two records with ids 39 and 40.
Inside this table I nested another table to retrieve information for each file in each minutes record. The dataset that I used is the following:
SELECT bp_minutes_app.submission_date,
bp_minutes_attachments.createdby,
bp_minutes_attachments.description,
bp_files.id,
bp_files.name
FROM bp_minutes_attachments
left JOIN bp_minutes_app ON
bp_minutes_attachments.bp_minutes_app_id = bp_minutes_app.id
AND bp_minutes_app.id = $P{mid}
left JOIN bp_full ON
bp_minutes_app.bp_full_app_id = bp_full.id
left JOIN bp_files ON
bp_minutes_attachments.bp_file_id = bp_files.id
WHERE
bp_full.id = $P{id}
The id parameter is used again to take the specific report and the mid parameter to take a specific minute. On parameter specification mid is declared as follows:
mid = $F{id}
, where id is the bp_minutes_app.id.
Following this setup I managed to get nested tables for each minute (forgive me for the greek headers):
What I want to do is number each subtable from 1...n, according to the number of minutes/ subtables. How can I achieve this? I tried to create a suitable variable but it was not met with success. I want to somehow "save" in a parameter / variable the count of bp_minutes_app records and manipulate this number for each nested table header, instead of just numbering each table with the corresponding id.
Sorry for the long post but I am new to Jasper and I wanted to be clear about the steps I have taken and what I want to achieve.
Alot of sql not much jrxml in your post so I start by guessing.
Have you tried something like this in the jrxml:
<variable name="counter" class="java.lang.Integer" calculation="Count">
<variableExpression><![CDATA[$F{id}]]></variableExpression>
</variable>

Modifying existing Crystal Reports to include additional filters

I have an existing report that I didn't make. It is pretty complicated. It does not use the command function, so I cannot directly change the filters in the SQL code. I have reviewed several links that basically say that there is no way around this and that I will need to create a new command and redo the report. I would like to find a solution that doesn't involve me redoing the report.
My logic that I need is to only select subcontracts that only have one instance (regardless if approved or not), if they have two instances associated only choose the one that has been approved
This is the current backend Crystal SQL
SELECT columns
from several tables joins etc
WHERE subcontract = '12345'--parameter entry
AND company=1 --parameter entry
I would like to add this logic which works in a normal sql statement but since I can't modify Crystal's SQL I am stuck...
AND ((subcontract in (select subcontract from table
group by subcontract having count(*) = 1))
OR (subcontract in (select subcontract from table group by subcontract having count(*) > 1)
AND "approved = 'Y'))
I have looked at you the Select and Group Expert but I am just not getting there. Has anyone found some simple work-arounds?
Thanks!!!
edit: I already have a select expert that involves subcontract but I don't know how to add what I want to it since it is validation based and I am wanting to add a filter component to it..
(
if (IsNull({?BeginSub}) or Trim({?BeginSub})="") then
true
else
{subcontract} >= Trim({?BeginSub})
) and
(
if (IsNull({?BeginSub}) or Left(Trim({?BeginSub}),3) in ["","zzz"]) then
true
else
{subcontract} <= Trim({?EndSub})
)
Edit Update: I have found a way to get what I want in crystal reports but it throws an error when I run the report from my application. I create a command with the conditions that I want and then link to the other tables where command.subcontract=othertables.subcontract.
I found what I needed.. I added the following sql expression field,
(Select count(subcontracts) from subcontract table)
then I added the following to the select expert
if(({%SubContractCount} <>2) or ({%SubContractCount}>1 AND
approved = Y)) then true else false
Thank you!!

changing a record to a different area

I hope yo can point me in the right direction.
I have a SSRS report organized by Continent/Country/Customer and I need to change (force?) some of the customers to appear in a different region/country from the DB. ie:
I have a local NZ customer in the right Region/Country (australasia/New Zealand) but I want this one to show up in a different Region/Country namely (Asia/China) as this customer buys locally but exports all to China.
There are some others customers that needs to be manually organized, following the same criteria, of course.
any idea on how can I do this?
and will be the best option to do it through SQL-Server or SSRS?
Thanks in advance.
Eric
I would create a new table called something like AreaOverride with the following columns:
CustomerId
Continent
Country
Then link to this in your query using a left outer join and replace the Continent and Country with the overridden values if they exist:
Select CustomerId,
Case when AreaOverride.Continent is not null then AreaOverride.Continent else Customer.Continent end as Continent,
Case when AreaOverride.Country is not null then AreaOverride.Country else Customer.Country end as Country
From Customer
Left outer join AreaOverride On AreaOverride.CustomerId = Customer.CustomerId
You might want to make this a view if you are going to use it in several reports or other places.
Then whenever you need to override a customer's details you simply add a row for them in this table and the values will be overridden in your reports.
Note that if you are dealing with a vendor database rather than your own you don't want to be messing with their database structure but you can still do this by creating a new database and put the AreaOverride table in it. Then you add the database name to your join. For example if your database was called MyStuff then your join looks like this:
Left outer join MyStuff.dbo.AreaOveride On ...