SQL Command - Paramater and wildcard
Post Author: edy80y
CA Forum: Crystal Reports
Hi All,
I have successfully dumped an SQL into a 'Add Command' function and it returns the data exactly how i want it. But now i want to add a parameter so that i dont have to manually update the date which is referenced 8 times.
The TIME_KEY field is in this format YYYYMMDDHHMMWST (for 20/12/2007 2:30PM) = 200712201430WST
I have used LIKE '20071220%' so it returns all rows within that one date.
Now, i created a string parameter {?date) so i can enter '20071220' and i want to attach the wildcard (%) to the parameter.
If i do any of the following it doesn't work:
LIKE {?date} + '%'
LIKE {?date} || '%'
LIKE {?date} & '%'
Here is the code:
SELECT "T1"."OBJECT_ID", "T1"."TIME_KEY", (SELECT SUM("N_ANSWERED") AS "ANSWERED_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'), (SELECT SUM("N_ABANDONED_RING") AS "ABANDONED_RING_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'), (SELECT SUM("N_ABANDONED_QUEUE") AS "ABANDONED_QUEUE_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'), (SELECT SUM("N_ENTERED") AS "ENTERED_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'), (SELECT SUM("N_ABANDONED_SHORT") AS "ABANDONED_SHORT_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'), (SELECT SUM("N_ANS_IN_THRESH") AS "ANS_IN_THRESH_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%'), (SELECT SUM("N_ABANDONED") AS "ABANDONED_ROLLING" FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T2" WHERE "T1"."OBJECT_ID" = "T2"."OBJECT_ID" AND "T2"."TIME_KEY" <= "T1"."TIME_KEY" AND "T2"."TIME_KEY" LIKE '20071220%')FROM "GENESYSIINET"."R_WFM_GRO_Q_NO_AGG" "T1"WHERE "T1"."TIME_KEY" LIKE '20071220%'GROUP BY "T1"."OBJECT_ID", "T1"."TIME_KEY"ORDER BY "T1"."OBJECT_ID", "T1"."TIME_KEY"
Post Author: yangster
CA Forum: Crystal Reports
putting the parameter within a single quote is incorrect if it is a string as it will look for a litteral reference to {?date} instead of the valueLIKE {?date} || '%'that should work np as you are con catting a string to another string with 0 to infinite number of characters followingwhat db are you using?
Similar Messages
-
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 -
Mixing SQL Command parameters and UI created parameters
Post Author: shecter
CA Forum: Data Connectivity and SQL
I'm using Crystal Reports XI. I've created a report with an SQL Command - no other tables or views. I want to allow my users to be able to choose data from a dynamic parameter and have the SQL read that and spit out the results. I was able to add a parameter to the SQL using the Parameter column in the Command window. This allows my user to type in a parameter. However, when I run the report after creating a parameter using the UI (i.e. Field Explorer/Parameters/right clicking and selecting "new" and then adding the parameter to a field using the selection wizard), i first get a screen that shows me the parameter that I created in the SQL Command window, then I get a screen that shows me the UI created parameters. How can I make it show only one screen with all the parameters? -MarcPost Author: jenxia
CA Forum: General
SQL Command is :
SELECT UNIQUE ContactID, incomingAddress,applicationid,
MediaStatus, MediaDirection, EndDateTime, StartDateTime
FROM MMCAContactMediaViewwhere EndDateTime>= {?1-reportstarttime} and EndDateTime <= {?2-reportendtime}
Order by ContactID
Select formula using dynamic prompts as
{Command.contactid} = {?ContactID} and{Command.applicationid} = {?ApplicationID} and{Command.incomingaddress} = {?IncomingAddress} -
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. -
In batch file i want to execute sql commands
in x.bat file i write the following
sqlplus user/pass@host @c:\a.sql
@c:\b.sql
when i execute this batch file it is connected to the databse
and the table of a.sql is created in the database.
but b.sql is not created.
it is creating only one table
i want ot create more no of tables with different .sql files
like @c:b.sql
@c:c.sql
@c:d.sql
please any body helpThe problem you are running into is that SQL Plus only recognizes the first command you have written in the batch file.
sqlplus user/pass@host
SPOOL c:\master.log
@c:\a.sql
@c:\b.sql
SPOOL OFF
SQLPlus will recognize the spool and first sql command, but the batch file gets command back after the first sql command executes and doesn't recognize @c:\b.sql or know what to do with it. To run multiple SQL commands you have to create an external SQL file with all the sql commands in it with the Spool files you want created, then in the batch file you only call the one SQL script.
Create a master file like so:
-- Script Name : AllFiles.sql
SPOOL c:\master.log
@c:\a.sql
@c:\b.sql
SPOOL OFF
In x.bat
CALL SQLPlus user/password@database @AllFiles.sql
This should get you your required results. -
Cannot change SQL command text in Data Flow Task
I have an SSIS package that extracts data from Teradata into a SQL Server DB.
I'm using SQL Server 2008 R2 EE x64, and Visual Studio 2008 PE (BIDS) supplied with it, accessing Teradata v13.
In the Integration Services project, I have a Data Flow Task, it has an ADO .net source which has Data access mode set to “SQL Command”.
This worked for a while when I initially entered a SQL statement to select data.
But, when I change the existing SQL Command text and save the package, the changes are lost.
It keeps going back to the original SQL Statement.
It is currently “select col1, col2, … col10 from view1”.
When I change it to anything else, like “select col5 from view1”, and save, and then double click the ADO NET source again, I find that the SQL command text is still the old one. It goes back to the previous statement.
I’ve tried other statements like “exec macro” for Teradata, etc. but the same thing keeps happening - changes are not saved.
Does anyone have any ideas on this, or have you seen this before?This is odd, but seems to be a component metadata corruption; so why don't you:
delete the teradata connector and source component, then re add them back, see if it now accepts the new SQL statement, if this does not work
abandon this package and create a new one replicating the functionality incorporating the new SQL.
In case #1 and 2 both fail post here any errors observed and find out whether you are missing any updates to either Teradata provider or SQL Server
Arthur My Blog -
Code block works in SQL Command Processor but not in application
Hello forum,
Been struggling with this for a few days without success:
I have a form with a popup LOV called P6_POPUP, a file browse item called P6_BROWSE, a SUBMIT button, and a Process with the following code:
declare
q_image_id number;
begin
select host_family_photos_seq.nextval into q_image_id from dual;
insert into host_family_photos (image_id, file_object_id, image_name)
select q_image_id, id, filename
from htmldb_application_files where filename = :P6_BROWSE;
update host_family set image_id = q_image_id where family_name = :P6_POPUP;
end;
The Process Point is set to On Submit after Computations and Validations and When Button Pressed is set to the Submit button.
When I run the page the file is imported into HTMLDB_APPLICATION_FILES
but the insert and update do not occur.
The URL header after submitting is as follows:
http://127.0.0.1:8080/apex/f?p=115:1:480837828458787::NO:::&success_msg=Photo%20Imported%2FB87C5A54684B0DF005D09D0DFE6E98D6%2F
However if I run the above code in the APEX SQL Command window and supply the required variables it works every time - most confusing.
Not sure what to try from here.
thanks for your time,
BrettScott:
I always thought that the File Browse item maps to the NAME column in the view (below) and that is guaranteed to be unique. The NAME column seems to have a system-generated "F1234" id embedded in it (to guarantee uniqueness, I thought).
In other words, when we put a File Browse item on the page, submitting the page uploads the file into the HTMLDB_APPLICATION_FILES table and the way to access that record (to copy/move it into our own custom table) is by doing
from htmldb_application_files
where name = :P1_BROWSEThanks
SQL> desc htmldb_application_files
Name Null? Type
ID NOT NULL NUMBER
FLOW_ID NOT NULL NUMBER
NAME NOT NULL VARCHAR2(90)
FILENAME VARCHAR2(400)
TITLE VARCHAR2(255)
MIME_TYPE VARCHAR2(48)
DOC_SIZE NUMBER
DAD_CHARSET VARCHAR2(128)
CREATED_BY VARCHAR2(255)
CREATED_ON DATE
UPDATED_BY VARCHAR2(255)
UPDATED_ON DATE
LAST_UPDATED DATE
CONTENT_TYPE VARCHAR2(128)
BLOB_CONTENT BLOB
LANGUAGE VARCHAR2(30)
DESCRIPTION VARCHAR2(4000)
FILE_TYPE VARCHAR2(255)
FILE_CHARSET VARCHAR2(128) -
Passing Params & Formulas to SQL Command & Strd Proc in CR 11.5 & 2008 - 1
I am working with CR 11.5 and heavily use SQL Command rewrites and Stored Procedures (SPs)with the usual limitation that only single parameter values can be passed into SPs, and Parameters must be created within the SQL Command editor (and cannot be referenced to those generated in Field Explorer, or can they?)
I understand from BE/CR's sales material for CR 2008 that multiple values can now be used under these conditions. As I recall, Multivalue Parameters are actually arrays that can be made into comma delimited strings.
Local StringVar StringExpression;
Local NumberVar ArrayCount := Count({?Code});
Local NumberVar i;
if ArrayCount = 0
then StringExpression := ""
else
StringExpression := {?Code}[1];
i := 2;
While i <= ArrayCount Do
StringExpression := StringExpression + ", " + {?Code}<i>;
i := i + 1;
See part 2 for continuation....Here is my use case (since most of my reports are against very large databases, running "tuned" SQL Commands is essential).
SELECT
PERSON.PatientName,
PROBLEM.Code,
PROBLEM.Description
LASTLABS.HDID,
RPTOBS.ObsDate,
RPTOBS.ObsValue
FROM
((PERSON INNER JOIN
PROBLEM ON
PERSON.PId = PROBLEM.PId) LEFT OUTER JOIN
LASTLABS ON
(PERSON.PId = LASTLABS.PId AND
LASTLABS.HDID IN (28, 53, 67, 102) LEFT OUTER JOIN -- Paramaterize
RPTOBS ON
(LASTLABS.HDID = C.HDID AND
LASTLABS.MaxObsDate = RPTOBS.ObsDate AND
LASTLABS.PId = RPTOBS.PId AND
RPTOBS.Change IN (2, 5, 7)) -- Paramaterize
WHERE
(PROBLEM.Code LIKE '249%' OR -- Paramaterize
PROBLEM.Code LIKE '250%' OR -- Paramaterize
PROBLEM.Code IN ('V77.1', 'V80') -- Paramaterize
What I am looking for is a Parameterized form as follows....
SELECT
PERSON.PatientName,
PROBLEM.Code,
PROBLEM.Description
PROBLEM.Qualifier,
LASTLABS.HDID,
RPTOBS.ObsDate,
RPTOBS.ObsValue
FROM
((PERSON INNER JOIN
PROBLEM ON
PERSON.PId = PROBLEM.PId) LEFT OUTER JOIN
LASTLABS ON
(PERSON.PId = LASTLABS.PId AND
LASTLABS.HDID ({?HDID_In_Param}) LEFT OUTER JOIN -- Paramaterize
RPTOBS ON
(LASTLABS.HDID = RPTOBS.HDID AND
LASTLABS.MaxObsDate = RPTOBS.ObsDate AND
LASTLABS.PID = RPTOBS.PID AND
RPTOBS.Change ({?Change_In_Param})) -- Paramaterize
WHERE
(PROBLEM.Code {?Code_Like_Param} OR -- Paramaterize
PROBLEM.Code {?Code_In_Param}) -- Paramaterize
Is this possible? Has it been thought of yet. Has passing in well-constructed @formulas been considered? -
Does CTAS evaluate "order by" in APEX SQL Command window?
I need to recreate my table in order to change the column order. When I use the SQL Commands window and run the SQL, it runs successfully, creates the new table, but doesn't reorder the columns.
Is this expected behavior?user648567 wrote:
Please update your forum profile with a real handle instead of "user648567".
I need to recreate my table in order to change the column order. When I use the SQL Commands window and run the SQL, it runs successfully, creates the new table, but doesn't reorder the columns.
What do you mean by "order by"?
Using an "ORDER BY" clause in a CTAS (in APEX or anywhare else) will have no effect on column order, which is determined by the order in which columns appear in the projection. It will affect the order in which rows are returned by that query, and it will not determine the order in which rows will be returned by querying the new table in the future.
To change the column order the columns in the SELECT clause of the CTAS would have to be in a different order from those in the original table, -
COPY command not working SQL Commands editor
Hi All,
I want to have a simple 'one-button-solution' for copying few tables from an external DB into the database where my Apex application is running.
When I issue the following from the sqlplus command line I get the following output:
SQL> COPY FROM schema/password@tnsnames_sid TO schema/password@tnsnames_sid REPLACE TABLE_TEST USING select * from TABLE_FOREIGN;
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
Table TABLE_TEST dropped.
Table TABLE_TEST created.
2 rows selected from schema@tnsnames_sid.
2 rows inserted into TABLE_TEST.
2 rows committed into TABLE_TEST at schema@tnsnames_sid.
SQL>
However, if I try exactly the same command from within the Apex 'SQL Commands' editor, I get the following error message:
ORA-00900: invalid SQL statement
NOTE that the reason I use COPY command is to overcome problems with LONG datatype which arise when doing simply CREATE TABLE AS.... with dblink.
In anycase, how can I make this work from within the 'SQL Commands' editor (and therefore in a button process).
Regards,
Pawel.Hi Harman,
yes, this is a known issue.
It's fixed with NW04 SPS 13.
Regards Matthias Röbig-Landau -
SQL Commands - uncheck autocommit hangs
If i uncheck the 'Autocommit' flag in the SQL Commands page and execute any command, it hangs (even for a simple select statement).
Is this a known problem ?Database parameter job_queue_processes must be set to a number > 0. See "Managing JOB_QUEUE_PROCESSES" in the Installation Guide.
Scott -
How: multiple insert stmt's in Database Express edition SQL commands GUI?
I have installed the Express 10g version today and played around with it for a while.
If I go to the SQL commands GUI and enter one insert like this:
INSERT INTO pageit (PagID, PagParent, PagName, PagActive) VALUES (19, 17, 'Mango tree', 1)
then it works nicely:
But if I do this:
INSERT INTO pageit (PagID, PagParent, PagName, PagActive) VALUES (20, 17, 'Grape trees', 1);
INSERT INTO pageit (PagID, PagParent, PagName, PagActive) VALUES (21, 16, 'Animals', 1);
Then it says:
ORA-00911: invalid character
Looks like semicolon is not allowed,
but if I remove the semicolon then it says;
ORA-00905: missing keyword
Is there a way to use multiple insert statements in one go in this GUI at all?
If not, could someone please recommend how I do this.
I have exported thousands of insert lines from MySql and I would like to get them into my newly created Oracle table without having to type one line at the time in this gui.
Any suggestions?
Then if there is a nice WEB GUI like phpmyadmin for Oracle then I would like to know about that to? (Preferably free)I've not done a lot with the express edition, so there may be tools I'm not aware of. There is a dedicated Express Edition forum that may be more helpful for some of these questions.
I would normally use the command-line SQL*Plus to run a script with a large number of SQL statements. I'd generally prefer, though, to get a comma-separated data file from the other system and load that into Oracle using SQL*Loader for efficiency reasons.
In Oracle, you would normally only want a single database on a single physical machine. I know in SQL Server that what they call a "database" is roughly equivalent to a "schema" in Oracle, which is created by creating a new user.
Justin -
I have created a execut sql task -
In that, i have a created a 'empidvar' variable of string type and put sqlstatement = 'select distinct empid from emp'
Resultset=resultname=0 and variablename=empidvar
I have added data flow task of ole db type and I put this sql statement under sql command - exec emp_sp @empidvar=?
I am getting an error.
[OLE DB Source [1]] Error: A rowset based on the SQL command was not returned by the OLE DB provider.
[SSIS.Pipeline] Error: component "OLE DB Source" (1) failed the pre-execute phase and returned error code 0xC02092B4.shouldnt setting be Result
Set=Full Resultset as your query returns a resultset? also i think variable to be mapped should be of object type.
Then for data flow task also you need to put it inside a ForEachLoop based on ADO.NET recordset and map your earlier variable inside it so as to iterate for every value the sql task returns.
Also if using SP in oledb source make sure you read this
http://consultingblogs.emc.com/jamiethomson/archive/2006/12/20/SSIS_3A00_-Using-stored-procedures-inside-an-OLE-DB-Source-component.aspx
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to find out the failed sql command and its data from DEFERROR
Hi,
has anybody a procedure or some other possibilities to read the content of column USER_DATA of the advanced replication view DEFERROR in order to find out the failed sql command and its column values?
Thanks in advance.Hi Vishwa,
The control would be something like this for navigation in Get_p_xxx method u mention as link and u mention a event name which gets triggered on the click of this hyperlink. So your GET_P_XXX method would have the following code:
CASE iv_property.
WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
rv_value = cl_bsp_dlc_view_descriptor=>field_type_event_link.
WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
rv_value = 'EXAMPLE'.
Now you have to create a method as EH_ONEXAMPLE at your IMPL class and within which you would give an outbound plug method. Within the outbound plug the target data would be filled in the collection and window outbound plug would be triggered.
This is a huge topic and i have just mentioned you basic things.
Regards,
Bharathy.
Maybe you are looking for
-
Hi we have created pricing Procidure but the tax calculation is computing on final amount, Their are conditions like discount after tax, procidure is not taking into account all that conditions How can we maintain that What the use of NAVS condition
-
Transfer disks from 2008 MBP to 2011 MBP?
My early 2008 MBP died (Apple Genius said logic board), so I took the opportunity to purchase a refurbished early 2011 MBP from the Apple Store. On the original MBP, I had replaced the HDD with an SSD and replaced the optical drive with a 7200 HDD.
-
Mac Pro and FCP - Very Unstable
I just purchased the Mac Pro and installed FCP 5.1.2. I have a dual 2.6 Ghz with 2.5 TB external eSATA Raid (using the Sonnet E4P card), Kona LHe Card and 3 GB of RAM. 1. FCP, Quicktime and Shake each unexpectedly quits on playback of video within a
-
Output results in rows of 10?
Is there a way to do this when outputing query results? Thanks
-
Hi, In my iOS app Capabilities.languages[0] is returning only the language, not the country code. Does Adobe Air provide any way to access to the country code in this case? thanks!