Csv to sql commands
hi ,
I am using the below file to convert my csv file to sql commands. I am currently trying to update the contents of the stationary csv. So i replace the existing stationary csv with the new stationary csv, then run the make-sql.sh which creates an oracle compatable sql script all.sql....now my problem is that this all.sql is not getting updated right. i.e. when i compare the csv file and the all.sql there are fields that hold different data...pls let me know what cld be causing this....
make-sql.sh
#!/bin/sh
GX_ROOTDIR=/apps/iasdev06/ias6/ias
JAVA_HOME=/apps/iasdev06/ias6/ias/usr/java
RMI_IIOP_HOME=${GX_ROOTDIR}/orbtools
PATH=${JAVA_HOME}/bin:$PATH
CLASSPATH=$GX_ROOTDIR/classes/java/ktjdk11.jar:$GX_ROOTDIR/classes/java/kadmin.jar:$JAVA_HOME/lib/tools.jar
CLASSPATH=$GX_ROOTDIR/classes/java/ldapjdk.jar:$GX_ROOTDIR/classes/java/SWING.JAR:$GX_ROOTDIR/ias/APPS:$GX_ROOTDIR/APPS:$JAVA_HOME/jre/lib/rt.jar:$CLASSPATH
CLASSPATH=$GX_ROOTDIR/classes/java/jdbc20.jar:$GX_ROOTDIR/classes/java/javax.jar:$GX_ROOTDIR/classes/java/kfcjdk11.jar:$GX_ROOTDIR/classes/java:$JAVA_HOME/lib/classes.zip:$CLASSPATH
CLASSPATH=$GX_ROOTDIR/classes/java/servlet.jar:$CLASSPATH
PKG=com.dupont.refrigerants.distributorlocator
cd ../..
SOURCE=`pwd`
GENERATE_SQL=$JAVA_HOME/bin/java\ -classpath\ ${SOURCE}/build/lib/classes:${CLASSPATH}\ -Djava.compiler=NONE\ ${PKG}.DistributorDBABeanImpl\$GenerateInsertFromCSV
cat < ${SOURCE}/buildscripts/datasource/prolog.sql > all.sql
${GENERATE_SQL} ${SOURCE}/buildscripts/datasource/stationary.csv 1 US | sort | uniq >> all.sql
${GENERATE_SQL} ${SOURCE}/buildscripts/datasource/canada.csv 1 CA | sort | uniq >> all.sql
${GENERATE_SQL} ${SOURCE}/buildscripts/datasource/mobile.csv 2 US | sort | uniq >> all.sql
Hi,
What you are doing here is, generating some data with prolog.sql and then, your main logic to csv to sql is in the Java program GenerateInsertFromCSV.java .
So, you need to find out the logic of that code. The shell script is not doing anything apart from calling the Java code.
Have a deep look into the same.
Regards
Similar Messages
-
How do i get a output in CSV of a SQL query executed via SQL Command prompt
Hi All,
I have a question with reference to SQL command prompt. I have a sql query which runs properly and gives proper execution in SQL Management console in GUI.
This report is used to pull the free disk space report of our servers
As i want to schedule it as a report so i want to script it to run via SQL command prompt. I made the script and it works fine if i enter it in SQL command prompt. When i try to extract the output to a CSV File it fails. Below is the details of the command
i am using to query to pull the data. Can anyone help me in getting the output of this query in SQL command prompt.
sqlcmd -W -s , -S Servers FQDN
use operationsmanager
Go
Query:"select Path, InstanceName, SampleValue
from PerformanceDataAllView pdv with (NOLOCK)
inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
order by countername, timesampled" -s "," -o "C:\DataSqlCmd.csv"
Go
When i enter the command without the quotes when the query is starting and ending and also without the output command (-s "," -o "C:\DataSqlCmd.csv") it is working and shows the output in the command prompt. Below is the screen shot for
your reference.
Due to security reasons i have to erase the server names:
But when i add the line to extract the output ( -s "," -o "C:\DataSqlCmd.csv") It gives me this error:
The exact command would be:
sqlcmd -W -s , -S CINMLVSCOM01.e2klab.ge.com
use operationsmanager
Go
"select Path, InstanceName, SampleValue
from PerformanceDataAllView pdv with (NOLOCK)
inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
order by countername, timesampled" -s "," -o "C:\DataSqlCmd.csv" -h-1
Go
saying the syntax is not correct or some thing as per the below screenshot.
Can any one please help. Below is just the query whi i use to get the output in SQL management studio.
Can any one make a command for the below quer so i can directly execute and test for getting the output.
select Path, InstanceName, SampleValue
from PerformanceDataAllView pdv with (NOLOCK)
inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
order by countername, timesampled
Gautam.75801Can you try the below query?
select Path, InstanceName, SampleValue
from PerformanceDataAllView pdv with (NOLOCK)
inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
where SampleValue < 20 and CounterName like '% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
order by countername, timesampled
-- replace the below query part in the below SQLCMD C:\>SQLCMD -S SERVERNAME -E -d operationsmanager -Q "select * from sys.databases ds with (nolock) where name='master'" -s "," -o "F:\PowerSQL\MyData.csv" -h -1
SQLCMD -S SERVERNAME -E -d OperationsManager -Q "select Path, InstanceName, SampleValue
from PerformanceDataAllView pdv with (NOLOCK)
inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
order by countername, timesampled" -s "," -o "c:\MyData.csv" -h -1
Refer for the other ways
http://dba.stackexchange.com/questions/23566/writing-select-result-to-a-csv-file
--Prashanth -
How to eliminate SQL command in Spool output?
Hi,
I'm trying to Spool an output to a txtfile without the SQL command being at the top of the page. I've tried a number of ways, but I'm having no luck.Any Ideas?
Sorry for the long msg, but maybe if some saw what I'm trying to do it would be helpful.
Many thanks,
James
Also does anyone know if its possible to import straight into Excel from PL/SQL?
The following is the Script I'm running:
set echo off
set validate off
set termout off
set linesize 100
set feedback off
set verify off
set heading off
set serveroutput on;
SPOOL C:/test12.txt
spool on
alter session set NLS_DATE_FORMAT='DD-Mon-YYYY';
SET SERVEROUTPUT ON
declare
V_DATE_FILED DATE;
V_DATE_FILED_PREV DATE;
v_count_file_per_day NUMBER(10) := 0;
v_count_agents NUMBER(10);
v_count_farmers NUMBER(10);
v_count_total NUMBER(10);
V_AG_DATE_FILED DATE;
V_AG_DATE_FILED_PREV DATE;
v_AG_count_file_per_day NUMBER(10) := 0;
begin
DBMS_OUTPUT.ENABLE(1000000);
select count(*) into v_count_agents
from TDSP_SAVED_DRAFT_DATA
where syr_scheme_year_code =2007
and SDD_FORM_TYPE=330
and SDS_FORM_SUBMITTED_IND ='Y'
and SDD_AUDIT_USER LIKE 'aga%';
for rec in (select sph_sps_holding_id
from TDSP_SAVED_DRAFT_DATA
where syr_scheme_year_code =2007
and SDD_FORM_TYPE=330
and SDS_FORM_SUBMITTED_IND ='Y'
and SDD_AUDIT_USER LIKE 'aga%'
order by SDD_AUDIT_DATE)
Loop
select app.APP_DATE_OF_RECEIPT
INTO V_AG_DATE_FILED
from TDSP_APPLICATION app, TDSP_SAVED_DRAFT_DATA sdd
where app.syr_scheme_year_code =2007
and app.syr_scheme_year_code = sdd.syr_scheme_year_code
and app.sph_sps_holding_id = sdd.sph_sps_holding_id
and app.sph_sps_holding_id = rec.sph_sps_holding_id
and sdd.SDD_FORM_TYPE=330
and sdd.SDD_AUDIT_USER LIKE 'aga%'
and rownum =1;
if TO_CHAR(V_AG_DATE_FILED_PREV, 'dd/mm/yyyy') <> TO_CHAR(V_AG_DATE_FILED, 'dd/mm/yyyy') then
DBMS_OUTPUT.PUT_LINE(V_AG_DATE_FILED_PREV || '/' || v_AG_count_file_per_day);
v_AG_count_file_per_day := 0;
end if;
V_AG_DATE_FILED_PREV := V_AG_DATE_FILED;
if TO_CHAR(SYSDATE, 'dd/mm/yyyy') = TO_CHAR(V_AG_DATE_FILED, 'dd/mm/yyyy') then
select count(*)
INTO v_AG_count_file_per_day
from TDSP_APPLICATION app, TDSP_SAVED_DRAFT_DATA sdd
where app.syr_scheme_year_code =2007
and app.syr_scheme_year_code = sdd.syr_scheme_year_code
and app.sph_sps_holding_id = sdd.sph_sps_holding_id
and sdd.SDD_FORM_TYPE=330
and sdd.SDD_AUDIT_USER LIKE 'aga%'
and TO_CHAR(app.APP_DATE_OF_RECEIPT, 'dd/mm/yyyy') = TO_CHAR(SYSDATE, 'dd/mm/yyyy');
DBMS_OUTPUT.PUT_LINE(SYSDATE || '/' || v_AG_count_file_per_day);
exit;
end if;
end loop;
select count(*) into v_count_farmers
from TDSP_SAVED_DRAFT_DATA
where syr_scheme_year_code =2007
and SDD_FORM_TYPE=330
and SDS_FORM_SUBMITTED_IND ='Y'
and SDD_AUDIT_USER LIKE 'P%';
for rec in (select sph_sps_holding_id
from TDSP_SAVED_DRAFT_DATA
where syr_scheme_year_code =2007
and SDD_FORM_TYPE=330
and SDS_FORM_SUBMITTED_IND ='Y'
and SDD_AUDIT_USER LIKE 'P%'
ORDER BY SDD_AUDIT_DATE)
Loop
select app.APP_DATE_OF_RECEIPT
INTO V_DATE_FILED
from TDSP_APPLICATION app, TDSP_SAVED_DRAFT_DATA sdd
where app.syr_scheme_year_code =2007
and app.syr_scheme_year_code = sdd.syr_scheme_year_code
and app.sph_sps_holding_id = sdd.sph_sps_holding_id
and app.sph_sps_holding_id = rec.sph_sps_holding_id
and sdd.SDD_FORM_TYPE=330
and sdd.SDD_AUDIT_USER LIKE 'P%'
and rownum =1;
if TO_CHAR(V_DATE_FILED_PREV, 'dd/mm/yyyy') <> TO_CHAR(V_DATE_FILED, 'dd/mm/yyyy') then
DBMS_OUTPUT.PUT_LINE(V_DATE_FILED_PREV || '/' || v_count_file_per_day);
v_count_file_per_day := 0;
end if;
V_DATE_FILED_PREV := V_DATE_FILED;
if TO_CHAR(SYSDATE, 'dd/mm/yyyy') = TO_CHAR(V_DATE_FILED, 'dd/mm/yyyy') then
select count(*)
INTO v_count_file_per_day
from TDSP_APPLICATION app, TDSP_SAVED_DRAFT_DATA sdd
where app.syr_scheme_year_code =2007
and app.syr_scheme_year_code = sdd.syr_scheme_year_code
and app.sph_sps_holding_id = sdd.sph_sps_holding_id
and sdd.SDD_FORM_TYPE=330
and sdd.SDD_AUDIT_USER LIKE 'P%'
and TO_CHAR(app.APP_DATE_OF_RECEIPT, 'dd/mm/yyyy') = TO_CHAR(SYSDATE, 'dd/mm/yyyy');
DBMS_OUTPUT.PUT_LINE(SYSDATE || '/' || v_count_file_per_day);
exit;
end if;
end loop;
end;
spool offi use to use this kinda spooling..
SET ECHO OFF
SET FEEDBACK OFF
SET HEADING OFF
SET LINESIZE 32000
SET PAGESIZE 0
SET TERMOUT OFF
SET TRIMSPOOL ON
spool c:\test.csv
PROMPT employeename,emp_id
select employeename||','||emp_id
from employees;
SPOOL OFF
SET ECHO ON
SET FEEDBACK ON
SET HEADING ON
SET LINESIZE 80
SET PAGESIZE 24
SET TERMOUT ON
SET TRIMSPOOL OFF
to spool data into .csv file -
Working With Two External Files With T-SQL Commands
Hi friends,
In a VSTO Excel AddIn of mine I have come across a need to use T-SQL commands before bringing the dataset on the activesheet, derived from two tables in the shape of external CSV files. However,
since using SQL Express in this regard requires connection to a server. With Visual Studio as well as SSMS installed on my laptop I'm able to use the said facility but I am unable to distribute such an addin to other team members not having any of the studios
installed nor access to any server.
Is there any way to use the similar features on the users' side?
In other words, how to develop a macro, for example, in which I could consider two CSV files as two different tables as in a database, and carryout some T-SQL functions/commands on the same like:
UNION of first three columns from both the tables;
Creating a temporary table with the DISTINCT sets of the said three columns; and
Then carryout LEFT JOINS between the new table and the earlier two tables;
to derive a simple comparative dataset?
Looking forward for you experts' valuable advices in this regard.
Thanx in advance.
Thanx in advance, Best Regards, Faraz A QureshiHi FARAZ,
As with Excel files, you can also use Odbc driver to connect to CSV files. As long as the user's machine installs the ODBC driver, you can OdbcConnection to connect to the CSV files.
The sample code to manimulate CSV files with ODBC driver(C#):
string connectionString = @"Driver={Microsoft Text Driver (*.txt; *.csv)}; Dbq=C:\; Extensions=asc,csv,tab,txt;";
using (OdbcConnection conn = new OdbcConnection(connectionString))
conn.Open();
string sql = "SELECT u.UserName,u.Age,c.Phone,c.Address FROM user.csv u left join contact.csv c on u.Id=c.UserId";
using (OdbcCommand cmd = new OdbcCommand(sql, conn))
But if you want to publish the Add-in to the user's machine, you still need to install the .Net Framework and the VSTO runtime to support the Add-in.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Possible to change the datasource from a business-view to a Sql Command ?
Hello,
When a business view contains a lot of elements it takes a while just to open the report.
We'd like to keep the BV as the dictionnary, but,
once the report design completed,
we'd like to disconnect the business view and replace it by the Sql command which can be seen in the menu option 'show SQL query'.
Is it possible via the RAS sdk ?
Did somebody experience this ?
How to proceed ?
Thanks a lot
AlainHi Ted,
I'm thinking opening a Case for this problem of opening reports based on a big BV.
We can't really reduce the BV, since it is the dictionnary and we need the whole thing...
I'm wondering why it is impossible to change the Datasource if the tables and fields underneath are identical.
Is it impossible to change the fields' mapping ?
The other solution, as you suggest, is to create a report from scratch, create a new Datasource with the Sql command format, and rebuild the report... I agree it looks like a big job...
Do you know if it is possible to export the report in XML for instance, change the XML, and then re-import ?
Thanks for your Help.
Alain -
using apex 4.1 i'm entering the following query in the sql command window and I keep getting a pop-up for Entering Bind Variable. I'm not using bind variables though, anyone else see this issue before?
SELECT A.FIRST,A.LAST,A.COMPANY AS CNAME,
J.TOT_MAN_HOURS,
J.ACREAGE,
W.NUM_WORKERS,
W.START_DT
FROM EW_ACCOUNTS A, EW_WORK_ORDER W, EW_JOBS J
WHERE A.ID = J.ACCT_ID
AND J.JOB_ID = W.JOB_ID
AND W.START_DT >= SYSDATE
AND W.START_DT < SYSDATE+1
ORDER BY W.START_DTI tried that and it didn't seem to help either.
Funny though, if I write a new query against just one of the tables and write out each column name. it works. If I use the * instead of writing each column name, I have the same issue.
This is in apex.appshosting.com free demo environment. I sent them an email asking about it and they told me it was a code issue and they don't support the demo environment. -
Hello,
As part of my report I populate a table then reference it in several following subreports.
The issue I'm having is that I need to clear all the data from my table after using it to allow the report to run again (and not get multiple results)
To do this I have tried to add a sub report at the very end (and start) of my report with the SQL command truncate table <tablename> or delete <tablename> or delete <tablename> where 1 = 1.
When I try truncate I get an error saying that I don't have permission (despite granting it but hey...) which is why I switched to delete, this runs fine but the table doesn't get deleted...
Any thoughts as to why this isn't working/how I can clear my table? I have thought of setting up a separate scheduled job to delete the table contents however I do also need to run the report several times with different parameters so this isn't an ideal solution.
I have tried adding a select after my delete statement as I thought if it had something to display on the report it would have to look at it but this didn't make any difference.
Any help will be much appreciated!
Thanks
ChrisThanks for that!
I have had a go at this and I can see how it will work although I have limited access on the Crystal userid I have so will need to have the SP created as part of our nightly refresh script I think.
Is there no way of getting crystal to run my delete statement otherwise?
Thanks again
Chris -
Crystal Report performance - subreports or sql command?
Hello,
bit of quandary, I've an existing report that contains six subreports all sharing the same parameter to the main report, a 'projectID' field.
The main report approximately returns 300 records/projects and each of the 6 subreports are passed the corresponding 'projectID' field 300 times.
Now, I've succesfully incorporated the main report query and corresponding subreports into a TSQL command containing a number of subqueries in the Select clause:
SELECT PROJECT.PROJECTID, PROJECT.TITLE, PROJECT.REFERENCE, PROJECTSTATUS.PROJECTSTATUS, PROJECT.INPUT_DATE
,(SELECT max(INPUT_DATE) FROM V_PROJECT_NOTE AS VPN
WHERE PROJECT.PROJECTID = VPN.PROJECTID) AS LastHeadline
,(SELECT
MAX(CASE
WHEN MODIFIED_DATE IS NULL THEN INPUT_DATE
WHEN INPUT_DATE > MODIFIED_DATE THEN INPUT_DATE
ELSE MODIFIED_DATE
END) FROM ISSUE WHERE PROJECT.PROJECTID = ISSUE.PROJECTID) AS LastNewIssue
,(SELECT max(ISSUENOTE.INPUT_DATE) FROM ISSUE
INNER JOIN ISSUENOTE ON ISSUE.ISSUEID = ISSUENOTE.ISSUEID
WHERE PROJECT.PROJECTID = ISSUE.PROJECTID ) AS LastIssueNote
,(SELECT max(modified_date) FROM V_PROJECT_RISK_LAST_AMMENDED AS VPR
WHERE PROJECT.PROJECTID = VPR.PROJECTID) AS LastRiskLogUpdate
,(SELECT max(INPUT_DATE) FROM PROJECT_CHECKLIST AS PC
WHERE PROJECT.PROJECTID = PC.PROJECTID) AS LastChecklistUpdate
,(SELECT max(input_date) FROM V_PROJECT_ACTIVITY_LAST_AMMENDED AS VPA
WHERE PROJECT.PROJECTID = VPA.PROJECTID) AS LastGANTTUpdate
,V_PROJECT_KEYCONTACT.USERNAME AS KeyContact
,(SELECT USERPROFILE.USERNAME AS Supervisor
FROM USERPROFILE INNER JOIN
PROJECT_MEMBER AS SUPERVISOR ON USERPROFILE.USERID = SUPERVISOR.USERID RIGHT OUTER JOIN
PROJECT_MEMBER AS KEYCONTACT ON SUPERVISOR.PROJECT_MEMBERID = KEYCONTACT.PARENTID
WHERE PROJECT.PROJECTID = KEYCONTACT.PROJECTID
AND KEYCONTACT.KEY_CONTACT =1) AS Supervisor
FROM PROJECT INNER JOIN
PROJECTSTATUS ON PROJECT.PROJECTSTATUSID = PROJECTSTATUS.PROJECTSTATUSID LEFT OUTER JOIN
V_PROJECT_KEYCONTACT ON PROJECT.PROJECTID = V_PROJECT_KEYCONTACT.PROJECTID
WHERE V_PROJECT_KEYCONTACT.USERNAME IN ('aaa','bbb','ccc')
AND (PROJECTSTATUS.PROJECTSTATUS IN ('111', '222', '333'))
AND ((PROJECT.TITLE NOT LIKE 'xxx%') AND (PROJECT.TITLE NOT LIKE 'yyy%') AND (PROJECT.TITLE NOT LIKE 'zzz%'))
ORDER BY V_PROJECT_KEYCONTACT.USERNAME, PROJECT.INPUT_DATE
Now, I've run both SQL Server Profiler and looked at the Performance Information in Crystal and the SQL command method is an order of magnitude less efficient!!
I may have to post my query on a TSQL forum but was wondering if anyone on here can possible shed any light on it?
Thanks in advance,
DomDom,
I assume that the last edit was to remove a few curse words...
The reality is that we can give a good explanation as to why the sub-report version would execute faster that the command version w/o seeing the report (with the sub-reports included).
Looking at the SQL, I can tell that it's a fairly expensive query, firing several sub-queries for every row returned by the outer query. That said, I sounds like the same thing is taking place with the sub-report version too... So I would think that the performance would be similar.
The only thing that I can think of, and this is just a guess... With the sub-report version, each all queries are being run independently and then combined locally by CR, whereas the command version, everything is combined. The more complex the query, the harder the optimizer has to work to come up with the best execution plan... and the greater the likelihood that that the resulting plan isn't as optimized as it could be.
That said, I'd still think the command version would be faster over all. Are you seeing real differences between the two reports, in the amount of time that it takes from refresh to final render?
Either way, I think moving all of those sub-queries from the select list (where they are executing once for every row) down to the FROM area (where they only have to execute once) should increase the speed dramatically and surpass the sub-report version by a decent margin.
Give this version of your SQL a test drive and see if it yields an improvement.
SELECT
PROJECT.PROJECTID,
PROJECT.TITLE,
PROJECT.REFERENCE,
PROJECTSTATUS.PROJECTSTATUS,
PROJECT.INPUT_DATE,
VPN.LastHeadline,
ISSUE.LastNewIssue,
ISSUE_NOTE.LastIssueNote,
VPR.LastRiskLogUpdate,
PC.LastChecklistUpdate,
VPA.LastGANTTUpdate,
V_PROJECT_KEYCONTACT.USERNAME AS KeyContact,
Supervisor.Supervisor
FROM PROJECT
INNER JOIN PROJECTSTATUS ON PROJECT.PROJECTSTATUSID = PROJECTSTATUS.PROJECTSTATUSID
LEFT OUTER JOIN V_PROJECT_KEYCONTACT ON PROJECT.PROJECTID = V_PROJECT_KEYCONTACT.PROJECTID
LEFT OUTER JOIN (
SELECT PROJECTID,
max(INPUT_DATE) AS LastHeadline
FROM V_PROJECT_NOTE
GROUP BYPROJECTID) AS VPN ON PROJECT.PROJECTID = VPN.PROJECTID
LEFT OUTER JOIN (
SELECT PROJECTID,
MAX(CASE
WHEN MODIFIED_DATE IS NULL THEN INPUT_DATE
WHEN INPUT_DATE > MODIFIED_DATE THEN INPUT_DATE
ELSE MODIFIED_DATE END) AS LastNewIssue
FROM ISSUE
GROUP BY PROJECTID) AS ISSUE ON PROJECT.PROJECTID = ISSUE.PROJECTID
LEFT OUTER JOIN (
SELECT ISSUE.PROJECTID,
max(ISSUENOTE.INPUT_DATE) AS LastIssueNote
FROM ISSUE
INNER JOIN ISSUENOTE ON ISSUE.ISSUEID = ISSUENOTE.ISSUEID
GROUP BY ISSUE.PROJECTID) AS ISSUE_NOTE ON PROJECT.PROJECTID = ISSUE_NOTE.PROJECTID
LEFT OUTER JOIN (
SELECT PROJECTID,
max(modified_date) AS LastRiskLogUpdate
FROM V_PROJECT_RISK_LAST_AMMENDED
GROUP BY PROJECTID) AS VPR ON PROJECT.PROJECTID = VPR.PROJECTID
LEFT OUTER JOIN (
SELECT PROJECTID,
max(INPUT_DATE) AS LastChecklistUpdate
FROM PROJECT_CHECKLIST
GROUP BY PROJECTID) AS PC ON PROJECT.PROJECTID = PC.PROJECTID
LEFT OUTER JOIN (
SELECT PROJECTID,
max(input_date) AS LastGANTTUpdate
FROM V_PROJECT_ACTIVITY_LAST_AMMENDED
GROUP BY PROJECTID) AS VPA ON PROJECT.PROJECTID = VPA.PROJECTID
LEFT OUTER JOIN (
SELECT PROJECTID,
USERPROFILE.USERNAME AS Supervisor
FROM USERPROFILE
INNER JOIN PROJECT_MEMBER AS SUPERVISOR ON USERPROFILE.USERID = SUPERVISOR.USERID RIGHT
OUTER JOIN PROJECT_MEMBER AS KEYCONTACT ON SUPERVISOR.PROJECT_MEMBERID = KEYCONTACT.PARENTID
WHERE KEYCONTACT.KEY_CONTACT =1) AS Supervisor ON PROJECT.PROJECTID = Supervisor.PROJECTID
WHERE V_PROJECT_KEYCONTACT.USERNAME IN ('aaa','bbb','ccc')
AND (PROJECTSTATUS.PROJECTSTATUS IN ('111', '222', '333'))
AND ((PROJECT.TITLE NOT LIKE 'xxx%')
AND (PROJECT.TITLE NOT LIKE 'yyy%')
AND (PROJECT.TITLE NOT LIKE 'zzz%'))
ORDER BY V_PROJECT_KEYCONTACT.USERNAME, PROJECT.INPUT_DATE
HTH,
Jason -
Query running on sql commands prompt not running on report region
Hi All,
Facing a weird issue now. I have written a report query which is running absolutely fine in sql command prompt but when i trying to run this as a report it is just processing and the report is not loading. What could be the reason behing this?
Thanks in Advance
RegardsHi,
With no other information about the problem is hard to know what's happening. If you could at least provide us with the query then I think it would be easier for us to help you.
Regards,
Sergio -
"Between NVL" - Works in SQL Command, not in APEX report region
First, I realize I could use dynamic SQL (model 4), but I don't want to (too hard just yet).
I have a select statement with a series of Where conditions that employ values, in bind variables, supplied by the user.
I want the choice of parameters to be optional, so I am checking for and replacing nulls.
Select emp_name from employee_table where
emp_rating between nvl(:p7_rating_choice, 0) and nvl(:p7_rating_choice, 99)
and
emp_language_no between nvl(:p7_lang_choice, 0) and nvl(:p7_lang_choice, 99);
(the binds should be numeric).
The actual statement is quite a bit longer, but the point is that the BETWEEN NVL(:x, min) AND NVL(:x, max) piece does not seem to work when used in a report region.
It works fine if ALL parameters are provided, but returns an error if one or more are null.
In the SQL command window it works (with a pop-up) just fine.
By the way, the :p7_lang_choice bind variable is chosen from a LOV list which works in all other cases.
Also, if I disable nulls (choosing "no" in ITEM page), everything works fine. It seems that the substitution of the min and max values via the NVL returns the wrong data type.
Any ideas what I have done wrong?Thanks Scott.
Every day brings a little more understanding!
I also noticed a simplified method in the APEX documentation (although there was no explanation of the code) as follows:
Where
(column = :p1_user_input_1 OR :p1_user_input_1 = [null substitution value])
AND
(column = :p1_user_input_2 OR :p1_user_input_2 = [null substitution value])
AND
etc...
Using the value you provide in the LOV section for the null, the second part of the OR handles the null situation.
For some reason I was so tied up with comparing to the column that I never thought to have an OR with a compare to something else.
Oh well.
Thanks,
Norm -
Without using SubReport or SQL Command in Main Report, get desired results without duplicating
It seems so simple. I just need the cost, at a certain time (based on a parameter), for each item. I wrote a SQL Command that works beautifully, but when it connects to the existing report, it slows to a horrible crawl and cannot be used for tables with over 4 million records. Here is the SQL Command that provides the desired results:
SELECT TOP 1 WITH TIES "INVENTITEMPRICE"."ITEMID", "INVENTITEMPRICE"."PRICETYPE", "INVENTITEMPRICE"."MARKUP", "INVENTITEMPRICE"."PRICEUNIT", "INVENTITEMPRICE"."PRICE", "INVENTITEMPRICE"."PRICEQTY", "INVENTITEMPRICE"."ACTIVATIONDATE", "INVENTITEMPRICE"."DATAAREAID"
FROM ("AX09PROD"."dbo"."INVENTITEMPRICE" "INVENTITEMPRICE" INNER JOIN "AX09PROD"."dbo"."INVENTTABLE" "INVENTTABLE" ON (("INVENTITEMPRICE"."ITEMID"="INVENTTABLE"."ITEMID") AND ("INVENTITEMPRICE"."DATAAREAID"="INVENTTABLE"."DATAAREAID")))
WHERE ("INVENTITEMPRICE"."DATAAREAID"=N'TMC' AND "INVENTITEMPRICE"."PRICETYPE"=0 AND "INVENTITEMPRICE"."ACTIVATIONDATE"<={?As Of Date})
ORDER BY ROW_NUMBER () OVER(PARTITION BY "INVENTITEMPRICE"."ITEMID" ORDER BY "INVENTITEMPRICE"."ACTIVATIONDATE" DESC)
I've attached the report with saved data. However, when I remove the restrictions of just certain items, it is unusable as it is SO SLOW!
I can also get the desired results from using a subreport but it takes forever to export due to the number of records/items. Whenever possible, I avoid subreports for this reason. I've attached that report with data as well.
Please be patient as I'm not savvy in SQL, but decent in generating reports. What am I doing wrong? This seems SO simple. The premise is that I want the corresponding information based on the date entered: If the date entered is 3/15/2014, the result should be 91.15 as indicated below. I'd simply like this value to be placed in a formula per item.
Item 80014:
Activation Date
Cost Price
6/2/2014
104.43
4/1/2014
91.58
3/1/2014
91.15
2/1/2014
92.89
1/1/2014
93.57
Any assistance would be GREATLY appreciated!
Thanks!
Teena
Update: I was unable to attach the reports with .rpt or .txt extensions. There were well under 1MB. Any suggestions?hi Teena,
if you're going the inline subquery route, try something like the following...the last line in the sub-query 'where' clause should in theory take care of matching the correct price based on relating the item id's between your cost price & inventory data. this should leave you with distinct values for each itemid then. hopefully it won't error out as i'm just guessing on the syntax.
SELECT DISTINCT
"INVENTTABLE"."ITEMID",
"INVENTTRANS"."DATAAREAID",
"INVENTTRANS"."DATEPHYSICAL",
"INVENTTRANS"."QTY",
"INVENTTABLE"."ITEMGROUPID",
"INVENTTABLE"."ITEMNAME",
"INVENTTRANS"."TRANSREFID",
"INVENTTRANS"."STATUSISSUE",
"INVENTTABLE"."ITEMTYPE",
"INVENTTRANS"."TRANSTYPE",
"INVENTTRANS"."RECID",
"INVENTTRANS"."DIRECTION",
SELECT TOP 1 "INVENTITEMPRICE"."PRICE"
FROM "AX09PROD"."dbo"."INVENTITEMPRICE" "INVENTITEMPRICE"
WHERE "INVENTITEMPRICE"."DATAAREAID" LIKE 'TMC%'
AND "INVENTITEMPRICE"."PRICETYPE"=0
AND "INVENTITEMPRICE"."ACTIVATIONDATE"<={?As Of Date}
AND "INVENTITEMPRICE"."ITEMID" = "INVENTTABLE"."ITEMID"
ORDER BY "INVENTITEMPRICE"."ACTIVATIONDATE" DESC
) AS ITEMPRICE
FROM
"AX09PROD"."dbo"."INVENTTABLE" "INVENTTABLE"
LEFT OUTER JOIN "AX09PROD"."dbo"."INVENTTRANS" "INVENTTRANS"
ON ("INVENTTABLE"."DATAAREAID"="INVENTTRANS"."DATAAREAID")
AND ("INVENTTABLE"."ITEMID"="INVENTTRANS"."ITEMID")
WHERE
"INVENTTRANS"."DATAAREAID" LIKE 'TMC%'
AND (("INVENTTABLE"."ITEMGROUPID" LIKE 'RAW%') OR ("INVENTTABLE"."ITEMGROUPID" BETWEEN '000' AND '999') OR ("INVENTTABLE"."ITEMGROUPID" LIKE 'Ship_Box'))
AND "INVENTTABLE"."ITEMTYPE" IN (0,1)
ORDER BY
"INVENTTABLE"."ITEMGROUPID",
"INVENTTABLE"."ITEMID",
"INVENTTRANS"."DATEPHYSICAL" ASC
Message was edited by: Jamie Wiseman -
Problem creating a SQL command object and adding it to a Crystal report
Hi,
I'm trying to add the following SQL command object with the following sql for MYSQL 5.1
SELECT lic.id, lic.productionname, comp.companyname, lic.paymentreceiveddate, lic.licenseissuedate,
IFNULL((SELECT sum(licsong.feequoted) from licensesong licsong where licsong.licenseid = lic.id), 0) as totalfeequoted,
IFNULL((SELECT sum(licsong.feetax) from licensesong licsong where licsong.licenseid = lic.id), 0) as totalfeetax,
IFNULL((SELECT sum(licsong.feequoted + licsong.feetax) from licensesong licsong where licsong.licenseid = lic.id), 0) as totalfee,
IFNULL((SELECT sum(pay.fullamount) from payment pay where pay.licenseid = lic.id),0) as totalpaid
FROM license lic
INNER JOIN company comp on lic.licensecompanyid= comp.id;
This sql runs fine in the Query Browser of mysql and returns what I want.
When I try to add this SQL command to a new Crystal Report, (by right clicking in the sql editor and selecting Crystal Reports - Add to new Crystal Report), it locks up my Eclipses and it ends up not responding. If I just do a simple SELECT * FROM license it works fine.
The Eclipse I'm using is from the CR4E download page with the crystal plugin already installed.
Any help with this would be greatful, as I am not having much joy with this CR4E 2.0 with MySQL and may have to scrap it and go back creating reports in Apache POI.
Any help greatly received.
Kind regardsHi,
Try to select a particular columns instead of doing SELECT * FROM license.
Thanks,
Saravanakumar -
How can I search multiple columns in a SQL command of Union tables
Hi:
We have a database with tables that are nearly identical that we use for production and production history.
I have created an SQL command in Crystal 2008 to joins several of the tables and then added a "UNION" to connect the History and Prod tables.
I need to search multiple (3 total) columns for 5 different data types, to return the records being investigated. I tried this using an "OR" statement in the where clause and have had inconsistant results.
The first two or statement function perfectly the third works as long as the value being passed is numeric and the last two fail consistantly with invalid column name errors. It appears that crystal is getting confused and passing the wrong data type especially if I do a new search using a different option for the "?SearchParam"
Can some one offer some insite on how I can search these fields to return the record data needed
-- {?SearchParam} is the search parameter passed by Crystal that is a number 1 thru 5
-- {?Search_Val} is a parameter that is passed by Crystal that is a string of what to search for 1 = Numeric CMP ord #("TBSLI21"."LI21_OR_NO"), 2 = Numeric CI ord # ( "TBSLI33"."LI33_CI_OR_NO"),
-- 3 =String Ext Sys ord string ("TBSLI33"."LI33_EXT_SYS_SL_OR_NO"), 4 = String CMP Grp string ("TBSLI21"."LI21_OP_GRP_NO"), 5 = composit string PP ord string ("TBSOP13"."OP13_CLR_DAY" & "TBSOP13"."OP13_PP_GRP_SEQ_NO" & "TBSOP13"."OP13_CELL_ID")
SELECT "TBSLI21"."LI21_OR_NO",
"TBSLI21"."LI21_SH_DT_SCDL",
"TBSLI21"."LI21_TS_EN_ORIG",
"TBSLI21"."LI21_TS_SHIP",
"TBSLI21"."LI21_SYS_ORD_CD",
"TBSLI21"."LI21_SHIP_ID",
"TBSLI21"."LI21_WRKST_ID",
"TBSLI21"."LI21_LI_NO",
"TBSLI33"."LI33_CI_OR_NO",
"TBSLI33"."LI33_EXT_SYS_SL_OR_NO",
"TBSLI21"."LI21_OP_GRP_NO",
"TBSLI21"."LI21_LI_STAT",
"TBSOP13"."OP13_OP_GRP_STAT",
"TBSLI31"."LI31_LI_EV_DTL_TX",
"TBSLI31"."LI31_DT_EN",
"TBSLI31"."LI31_TM_EN",
"TBSLI31"."LI31_LI_EV",
"TBSLI21"."LI21_OP_WSH_FLNM",
"TBSLI21"."LI21_PR_ITF_CD",
"TBSLI21"."MFG_PLANT_CD",
"MFG_PLANT_LI"."MFG_PLANT_CD" as PrefPlant,
"TBSOP13"."OP13_OP_GRP_DSP_CD",
"TBSLI21"."LI21_LI_DSP_CD",
"TBSOP13"."OP13_CLR_DAY",
"TBSOP13"."OP13_PP_GRP_SEQ_NO",
"TBSOP13"."OP13_CELL_ID",
"MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG",
"TBSLI21"."LI21_OP_GRP_PS_NO1",
"TBSLI21"."LI21_POMS_MERGE_NO",
"TBSLI31"."LI31_OP_ID",
"TBSLI21"."LI21_LI_POR_FG",
"TBSLI21"."LI21_BIN_ID",
"TBSLI21"."LI21_TS_MRSHL",
"TBSLI33"."LI33_CI_LI_NO",
"TBSLI33"."LI33_SH_ADDR_1",
"TBSLI33"."LI33_SH_ADDR_2",
"TBSLI33"."LI33_SH_ADDR_3",
"TBSLI33"."LI33_SH_ADDR_4",
"TBSLI33"."LI33_SH_CITY_NM",
"TBSLI33"."LI33_SH_ST_NM",
"TBSLI33"."LI33_SH_ZIP_CD",
"TBSLI33"."LI33_CU_NM",
"TBSLI33"."LI33_CU_BUS_NM"
FROM ((("CMPREPORTING"."dbo"."TBSLI33" "TBSLI33" FULL OUTER JOIN "CMPREPORTING"."dbo"."TBSLI21" "TBSLI21" ON ("TBSLI33"."LI33_BS_OR_NO"="TBSLI21"."LI21_OR_NO") AND ("TBSLI33"."LI33_BS_LI_NO"="TBSLI21"."LI21_LI_NO")) LEFT OUTER JOIN "CMPREPORTING"."dbo"."TBSOP13" "TBSOP13" ON "TBSLI21"."LI21_OP_GRP_NO"="TBSOP13"."OP13_OP_GRP_NO") LEFT OUTER JOIN "CMPREPORTING"."dbo"."TBSLI31" "TBSLI31" ON ("TBSLI21"."LI21_OR_NO"="TBSLI31"."LI31_OR_NO") AND ("TBSLI21"."LI21_LI_NO"="TBSLI31"."LI31_LI_NO")) LEFT OUTER JOIN "CMPREPORTING"."dbo"."MFG_PLANT_LI" "MFG_PLANT_LI" ON ("TBSLI21"."LI21_OR_NO"="MFG_PLANT_LI"."OR_NO") AND ("TBSLI21"."LI21_LI_NO"="MFG_PLANT_LI"."LI_NO")
WHERE {?aSearchParam} = 1 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND "TBSLI21"."LI21_OR_NO"=Cast( {?Search_Val} as Int)
or {?aSearchParam} = 2 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND "TBSLI33"."LI33_CI_OR_NO"=Cast( {?Search_Val} as numeric(12,0))
or {?aSearchParam} = 3 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(20),"TBSLI33"."LI33_EXT_SYS_SL_OR_NO")= Convert( VarChar(20), {?Search_Val})
or {?aSearchParam} = 4 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(8),"TBSLI21"."LI21_OP_GRP_NO") = Convert( VarChar(8), {?GroupNo})
or {?aSearchParam} = 5 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(8), ("TBSOP13"."OP13_CLR_DAY" & "TBSOP13"."OP13_PP_GRP_SEQ_NO" & "TBSOP13"."OP13_CELL_ID")) = Convert( VarChar(8), {?GroupNo})
Union
SELECT "TBSLI21_HIST"."LI21_OR_NO",
"TBSLI21_HIST"."LI21_SH_DT_SCDL",
"TBSLI21_HIST"."LI21_TS_EN_ORIG",
"TBSLI21_HIST"."LI21_TS_SHIP",
"TBSLI21_HIST"."LI21_SYS_ORD_CD",
"TBSLI21_HIST"."LI21_SHIP_ID",
"TBSLI21_HIST"."LI21_WRKST_ID",
"TBSLI21_HIST"."LI21_LI_NO",
"TBSLI33_HIST"."LI33_CI_OR_NO",
"TBSLI33_HIST"."LI33_EXT_SYS_SL_OR_NO",
"TBSLI21_HIST"."LI21_OP_GRP_NO",
"TBSLI21_HIST"."LI21_LI_STAT",
"TBSOP13_HIST"."OP13_OP_GRP_STAT",
"TBSLI31_HIST"."LI31_LI_EV_DTL_TX",
"TBSLI31_HIST"."LI31_DT_EN",
"TBSLI31_HIST"."LI31_TM_EN",
"TBSLI31_HIST"."LI31_LI_EV",
"TBSLI21_HIST"."LI21_OP_WSH_FLNM",
"TBSLI21_HIST"."LI21_PR_ITF_CD",
"TBSLI21_HIST"."MFG_PLANT_CD",
"MFG_PLANT_LI_HIST"."MFG_PLANT_CD",
"TBSOP13_HIST"."OP13_OP_GRP_DSP_CD",
"TBSLI21_HIST"."LI21_LI_DSP_CD",
"TBSOP13_HIST"."OP13_CLR_DAY",
"TBSOP13_HIST"."OP13_PP_GRP_SEQ_NO",
"TBSOP13_HIST"."OP13_CELL_ID",
"MFG_PLANT_LI_HIST"."PRFR_MFG_PLANT_FLG",
"TBSLI21_HIST"."LI21_OP_GRP_PS_NO1",
"TBSLI21_HIST"."LI21_POMS_MERGE_NO",
"TBSLI31_HIST"."LI31_OP_ID",
"TBSLI21_HIST"."LI21_LI_POR_FG",
"TBSLI21_HIST"."LI21_BIN_ID",
"TBSLI21_HIST"."LI21_TS_MRSHL",
"TBSLI33_HIST"."LI33_CI_LI_NO",
"TBSLI33_HIST"."LI33_SH_ADDR_1",
"TBSLI33_HIST"."LI33_SH_ADDR_2",
"TBSLI33_HIST"."LI33_SH_ADDR_3",
"TBSLI33_HIST"."LI33_SH_ADDR_4",
"TBSLI33_HIST"."LI33_SH_CITY_NM",
"TBSLI33_HIST"."LI33_SH_ST_NM",
"TBSLI33_HIST"."LI33_SH_ZIP_CD",
"TBSLI33_HIST"."LI33_CU_NM",
"TBSLI33_HIST"."LI33_CU_BUS_NM"
FROM ((("CMPREPORTING"."dbo"."TBSLI33_HIST" "TBSLI33_HIST" FULL OUTER JOIN "CMPREPORTING"."dbo"."TBSLI21_HIST" "TBSLI21_HIST" ON ("TBSLI33_HIST"."LI33_BS_OR_NO"="TBSLI21_HIST"."LI21_OR_NO") AND ("TBSLI33_HIST"."LI33_BS_LI_NO"="TBSLI21_HIST"."LI21_LI_NO")) LEFT OUTER JOIN "CMPREPORTING"."dbo"."TBSOP13_HIST" "TBSOP13_HIST" ON "TBSLI21_HIST"."LI21_OP_GRP_NO"="TBSOP13_HIST"."OP13_OP_GRP_NO") LEFT OUTER JOIN "CMPREPORTING"."dbo"."TBSLI31_HIST" "TBSLI31_HIST" ON ("TBSLI21_HIST"."LI21_OR_NO"="TBSLI31_HIST"."LI31_OR_NO") AND ("TBSLI21_HIST"."LI21_LI_NO"="TBSLI31_HIST"."LI31_LI_NO")) LEFT OUTER JOIN "CMPREPORTING"."dbo"."MFG_PLANT_LI_HIST" "MFG_PLANT_LI_HIST" ON ("TBSLI21_HIST"."LI21_OR_NO"="MFG_PLANT_LI_HIST"."OR_NO") AND ("TBSLI21_HIST"."LI21_LI_NO"="MFG_PLANT_LI_HIST"."LI_NO")
WHERE {?aSearchParam} = 1 and "MFG_PLANT_LI_HIST"."PRFR_MFG_PLANT_FLG"='Y' AND "TBSLI21_HIST"."LI21_OR_NO"= Cast( {?Search_Val} as Int)
or {?aSearchParam} = 2 and "MFG_PLANT_LI_HIST"."PRFR_MFG_PLANT_FLG"='Y' AND "TBSLI33_HIST"."LI33_CI_OR_NO"= Cast( {?Search_Val} as numeric(12,0))
or {?aSearchParam} = 3 and "MFG_PLANT_LI_HIST"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(20), "TBSLI33_HIST"."LI33_EXT_SYS_SL_OR_NO")= Convert( VarChar(20),{?Search_Val})
or {?aSearchParam} = 4 and "MFG_PLANT_LI_HIST"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(8),"TBSLI21_HIST"."LI21_OP_GRP_NO")= Convert( VarChar(8), {?GroupNo} )
or {?aSearchParam} = 5 and "MFG_PLANT_LI_HIST"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(8), ("TBSOP13_HIST"."OP13_CLR_DAY" & "TBSOP13_HIST"."OP13_PP_GRP_SEQ_NO" & "TBSOP13_HIST"."OP13_CELL_ID")) = Convert( VarChar(8), {?GroupNo})This is actually a fairly easy fix - because of the way the "OR" works in SQL, you need to surround each "set" of statements in the or with parentheses. So, it would look something like this:
Where
({?aSearchParam} = 1 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND "TBSLI21"."LI21_OR_NO"=Cast( {?Search_Val} as Int))
or
({?aSearchParam} = 2 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND "TBSLI33"."LI33_CI_OR_NO"=Cast( {?Search_Val} as numeric(12,0)))
or
({?aSearchParam} = 3 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(20),"TBSLI33"."LI33_EXT_SYS_SL_OR_NO")= Convert( VarChar(20), {?Search_Val}))
or
({?aSearchParam} = 4 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(8),"TBSLI21"."LI21_OP_GRP_NO") = Convert( VarChar(8), {?GroupNo}))
or
({?aSearchParam} = 5 and "MFG_PLANT_LI"."PRFR_MFG_PLANT_FLG"='Y' AND Convert( VarChar(8), ("TBSOP13"."OP13_CLR_DAY" & "TBSOP13"."OP13_PP_GRP_SEQ_NO" & "TBSOP13"."OP13_CELL_ID")) = Convert( VarChar(8), {?GroupNo}))
-Dell -
How to execute stored procedure in the SQL Commands page
i'm oracle express edition newbie :) i have this stored procedure. it not belong to a package.
create or replace procedure "LIST_MEMBERS"
("MEMBER_CUR" OUT SYS_REFCURSOR)
is
begin
OPEN MEMBER_CUR FOR
SELECT * FROM members;
end;
now, in the SQL Commands page, how to run the stored procedure and return the records. i do this:
begin
execute list_members();
end;
but i'm getting some errors. just need some immediate help :) thanks!!!Example of using a ref cursor:
SQL> ed
Wrote file afiedt.buf
1 create or replace procedure open_cur(c IN OUT SYS_REFCURSOR) is
2 begin
3 open c for 'select rownum rn from dual connect by rownum <= 10';
4* end;
SQL> /
Procedure created.
SQL> ed
Wrote file afiedt.buf
1 declare
2 c SYS_REFCURSOR;
3 v_val NUMBER;
4 begin
5 open_cur(c);
6 loop
7 fetch c INTO v_val;
8 exit WHEN c%NOTFOUND;
9 dbms_output.put_line(v_val);
10 end loop;
11 close c;
12* end;
SQL> /
1
2
3
4
5
6
7
8
9
10
PL/SQL procedure successfully completed.
SQL> -
SQL Command returns multiple records, but I see only one record in report
I work with Crystal Reports XI R2 SP3 and Oracle 10g R2 database.
I have an SQL Command that returns multiple records. Command name is "CommDivisionNames" and it returns column "CommDivisionNames.DIVISION_NAME". When I place this field into report details section of the report, I can see all 10 records returned and this is how it should be. I actually need this field to be placed in the report header section, and when I place the field there, then I see only the first record. I set that field as "can grow = true". When I do "browse field data" for this field, I see that all 10 records are there, but only the first one is displayed in report header section.
I thought that I can place SQL Command field anywhere on the report (page header, footer, details) and that it will always show all records that it returns from the database. Can that be done?
My "main part" of the report returns different set of records, and that's what I have in "report details" section. I need this list of divisions to be in the report header section, so user can see that the report was executed for DivA, DivC, DivE.
Thank you,
Milansharonamt:
Users select divisions from parameter, but the parameter multi values are division_numbers (1,5,10), not division_names. Division_names are visible in parameter_prompt_window as description, but parameter remembers only numbers and I don't know how I can reuse division_names later in formula.
I do join for division_numbers and make them into one string variable and pass to sub-report, but I think that I can only get these division_names by calling an SQL command or calling stored procedure.
If I try to do join({MySQLcommand.DIVISION_NAME}) I get error message "A string array is required here".
Carl:
I'm playing with cross-tab and I can use it to see all division_names in the report-header section. Since I need them in only one column or only one row, I have to edit cross-tab object and turn all unneeded border lines to white to make them look invisible. So, cross-tab could be a solution for my problem here.
Another option could be to re-write my SQL command. Since I've read here that SQL command could be written in the same way as I would write a stored procedure, then I could use a bit more complex code to get all multiple division names from the database table into a local cursor, and then use do-while loop to concatenate them into one string, and then to return that string as one record (like 'DivA, DivB, DivC'), and then it should not be a problem to display only that one record/string in report header. It is my understanding that Crystal Reports can call stored procedure that works with many cursors/recordsets and CR will use only the last recordset from the stored procedure. Do you think it could be done this way?
Thank you,
Milan
Maybe you are looking for
-
We have a client who uses a 3rd party application called Articulate to develop online learning courses. Those courses are then compiled and exported out to Flash. Everything works fine in IE and used to work in FF now on any machine with FF 11 it fai
-
hi,everybody, As we all know, there is a com.sap.tc.webdynpro.progmodel.api.IWDView object in wdDoModifyView() parameters.We can use the IWDView object in the method or after the method.But in my project, I want to use the IWDView object before
-
Hi everyone! I am working in ERP 4.6B and I have the following problem: I create a SES by transaction code ML81N, when I save the document the message is not appearing in the messages screen independing on that the configuration is complete on transa
-
I'm using OnStage and it works fine by simply clicking on the track number to to open and close projects, and it's also designed to accept MIDI program changes to do the same thing. Now I'm using a MIDI footpedal to change Performance patches via MID
-
Hello, help change the control questions in my profile. I forgot my initial responses and now I can not change their questions. Now I can not use the services of the store AppStore. TY.