Retrieve the random record from SQL and also an ORDER
I need a query that is able to get X amount of random records from a database of SQL2008, but I also want those results to then order by a field in the same table numberic, camp_priority
I have
SELECT TOP #DisplayAmount #, camp_uid, camp_title, camp_text, camp_image_type | |
Campaigns | |
WHERE camp_uid IN |
etc... etc.
then, at the bottom, I
ORDER BY newid (), camp_priority
The problem seems to be that I'm random records, but it is not ordered by the camp_priority
Anyone have any ideas?
Thank you
Mark
Hey Adam,.
I misread your original post, now I see how it was supposed to work, just posted below... got it works... works very well. If all goes well, is not to kill the CPU that this query will use a LOT... I'll just take a plu ;-) CPU
Regarding the performance of NEWID() issue, I do not have a specific link, I was just hunting around different forums etc and found a few posts that talked about performance issues and who had a command I never saw that took a percentage of files with a lot of perfomance test graphic showing it was 10 times slow the other approach.
I'll just have to see how it goes
Thanks for the help
Mark
Tags: ColdFusion
Similar Questions
-
Hi all
Here I have the image BLOB in the database files,
I want to show the image to PDF using file to rtf using Oracle Xml Desktop Publisher,
Hi all
I found the solution for reading Image BLOB of data base & display in Pdf format.
(1) read the image from DB.2) and then copy the picture using IO. UtilsCopy method to copy the picture
(3) then encode with base64 converter then you will get the tag XML with Base64 as string then placed in your XML Code & preview the output, you will find the image
Photo = (BlobDomain) currentRow.getAttribute ("Image"); ByteArrayOutputStream OutputStream = new ByteArrayOutputStream();
Byte [] imageByte; Byte [] b = null; try {} IOUtils.copy (photo.getInputStream (), outputStream); BS = outputStream.toByteArray (); outputStream.flush (); System.out.println("==="+BS.) Length); Encoded byte [] is Base64.encodeBase64 (bs).; encodedString = new String (encoded); -
SQL query to retrieve the same record because no. boxes
Hi all
I have a table of Bill XXINV.
the columns are
INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES
1122 XXITEM1 1 5
1123 XXITEM2 2 6
I can do a sql query so that I can retrieve the same records repeated as number INVH_BOXES.
Select * from XXINV
where invh_no = 1122
output:
INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES
1122 XXITEM1 1 5
Desired output:
INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES
1122 XXITEM1 1 5
1122 XXITEM1 1 5
1122 XXITEM1 1 5
1122 XXITEM1 1 5
1122 XXITEM1 1 5
or
INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES
1122 XXITEM1 1 1 of 5
1122 XXITEM1 1 2 of 5
1122 1 3 5 XXITEM1
1122 XXITEM1 1 4 of 5
1122 XXITEM1 1 5 of 5
Please suggest. Like I need to print each line in a single page to stick them on boxes so that packaging.
Kind regards
Afzal.
Just add INVH_ITEM_CODE to the connection by the clause.
Select invh_no
invh_item_code
invh_qty
to_char (, 'fm99') | 'from ' | TO_CHAR (invh_boxes, 'fm99') invh_boxes
of xxinv
where invh_no = 1122
connect
by level<=>=>
and prior invh_item_code = invh_item_code
and prior sys_guid() is not null
-
Hi all, please help me to retrieve the last record value in field
Hi all
Shape the table below, I want to retrieve the latest data from column 4 disks in a new field that will be my field of view as shown in the end of the table by means of BI publisher, please help to achieve this goal.
Column1 2 3 4 5 6
May 1, 10 672 0 567198 2868062 May 1, 10 0 3492 570690 2868065 15 May 10 25000 0 545690 1634220 15 June 10 600000 0 -54310 1657501 New field -54310
Thank you and best regards,
Prasad.
something like
for each: ByWhichLoop [last()]
end foreach
-
Original title: outlook can duplicate the same messages from yesterday, and I can't delete them.
I use outlook express for my e-mail yesterday same emails keep coming, I tried to remove them, but can't everytime I open outlook I get the same
The other post:I opened outlook express the same messages from yesterday, continue to repeat every time error 0x800CCC0F had no new messages and I can't delete these messagesHi glendamcmillan,
You did it all change hardware or software on your computer before this problem?
You can follow this link & check if the problem persists:
Hope the helps of information.
-
remove the last record from the plsql table
Under certain conditions, I need to remove the last record from i_CustomerLoopTYPE r_LOOPElement IS RECORD (TermID NUMBER ); TYPE t_LOOPType IS TABLE OF r_LOOPElement INDEX BY BINARY_INTEGER; i_CustomerLoop t_LOOPType ; i_CustomerLoop(1).TermID=1; i_CustomerLoop(2).TermID=2; i_CustomerLoop(3).TermID=3;
whichi s the best way to do it. because I sometimes get duplicates for TermID in this plsql table.Hello
See [removing items from Collection (DELETE method) | http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/collections.htm#CJAFGFIG]
Kind regards
-
create the cookie using pl sql and retrieve values
Hello
I am currently in an urgent need to create cookies to BE oracle and also read the values of the. I tried to use code below. his display error
code
DECLARE
ourcookie owa_cookie.cookie;
BEGIN
ourCookie: = owa_cookie.get('SESSION2');
END;
/
BEGIN
owa_util.mime_header ("text/html", FALSE ");
-Create a cookie
(owa_cookie). Send
name = > 'SESSION. "
value = > '344444',.
expires = > sysdate + 2,.
path = > ' / ');
owa_util.http_header_close;
EXCEPTION
WHEN OTHER THEN NULL;
END;
But when I'm reading the cookie that I created, I am unable to exercise
-It's for reading cookies
DECLARE
ourcookie owa_cookie.cookie;
BEGIN
ourCookie: = owa_cookie.get('SESSION2');
END;
/
error:
ORA-06502: PL/SQL: digital error or value
ORA-06512: at "SYS." OWA_UTIL", line 325
ORA-06512: at "SYS." OWA_COOKIE', line 36
ORA-06512: at "SYS." OWA_COOKIE', line 140
ORA-06512: at line 4 level842106 wrote:
Now according to the guidelines of your comment, I created a simple OWA environment and run the code below. Now I get not found error of data
ORA-01403: no data found
ORA-06512: at line 23The error is caused the cookie is not found.
The following is not valid - as there is no browser to receive the cookie:
(owa_cookie). Send
name-online "SESSION1"
value-online '344433',
expires => it sysdate + 2,.
=> path ' / '.
);The following code must set the CGI environment - and add the cookie to the environment for the following code to read (as shown in the code example that I posted in the 2nd thread I talked to you):
/ * Initialization * /.
OWA.cgi_var_name (1): = 'something ';
OWA.cgi_var_val (1): = "other";
OWA.init_cgi_env (1, owa.cgi_var_name, owa.cgi_var_val);
/ * End initialization * /.Of course, the following code will fail with a NO_DATA_FOUND there is no cookie.
ourCookie: = owa_cookie.get('SESSION1');
v_session: = ourCookie.vals (1);So it is not possible to create a true cookie and retrieve the value of CGI environment or apex not?
Yes. But the web browser is non-existent. Then, you need create the CGI environment, which would have created the web server, before you call your allowed web code PL/SQL.
In other words, if your initialization code of CGI should pretend that it is the web server, he received the call from web browser, it received the cookie (s) from the web browser - and now she needs to create the CGI (including cookies) environment for this web browser, and then call the procedure PL/SQL referenced by the browser in the URL, he argued.
-
How to retrieve a single record from access by program?
I need to recover a single access record. I have two columns, 'Sess' and 'Topic' in my database. I want back the Session number ('Sess') for a particular topic and post it on the front panel. I wrote the attached VI based on an example I found. This VI contains the number of the Session for the first record, but I can't understand how to identify a search for a specific record in the table. Thank you!
Do a google search for «sql tutorial» You need to learn how the SELECT statement. The general syntax is:
SELECT column_name (s)
Table_name FROM
WHERE column_name operator value -
I feel as if I'm fighting my way around a paper bag trying to insert a record. I have recently converted from MySQL for PDP, which cannot be applied. I'm not trying to write routines to update data and started with insert. I tried the example in your PHP Solutions edition two, pp. 361-363, but I can't get a written account.
It is a database, which I supported since the host server using phpMyAdmin. I'm very well display the data on the site, so I guess that my login script is ok. However, nothing I've tried has got a registered insert. I tried to get back to the basics, and it still does not work. This is my current code. Something is wrong with my statement = $sql and I can't identify the problem. Help, please!
If (isset($_POST['insert'])) {}
try {}
create the SQL
$sql = "INSERT INTO Homepage_text (enriched, h_date, h_seq, h_col, p_heading, p_text, h_hide) VALUES ($_POST ['enriched'], $_POST ['h_date'], $_POST ['h_seq'], $_POST ['h_col'], $_POST ['p_heading'], $_POST ['p_text'], $_POST ['h_hide']);"
$sainttim-> execute ($sql);
echo "new record successfully created ';
}
catch (PDOException ($e) exception
{
echo $sql. "< br / > '. $e-> getMessage();
}
}
There are several things wrong with your code:
- You use elements of an associative array within a double quoted string. Which will cause a parse error.
- The values you are trying to insert in the database are for most (if not all) of the text fields. If you use a literal SQL query, text fields must be wrapped in quotes.
- You try to use the method execute() with a literal SQL query. In AOP, execute() only works with a prepared statement. To run a literal SQL query, you must use the exec() method.
- Passing the values in the array $_POST directly in the database without any sort of validation and without escaping quotes or other characters just asking for trouble.
Follow the examples in the book, and use a prepared statement. To address all these issues quickly and easily.
-
How to display the output of PL/SQL and difficulty package below error (please help)
-PACKAGE SPECIFICATION AND met with success, but I see no way out, an error is also here... Please help. How do I solve this problem
-with the code
CREATE OR REPLACE PACKAGE package_variables
-Declare the components of a package.
Established PROCEDURE (VARCHAR2 value);
Public FUNCTION get RETURN VARCHAR2;
END package_variables;
/
CREATE OR REPLACE PACKAGE BODY package_variables
-Declare the package-scoped variable.
variable VARCHAR2 (20): = "initial value";
-Define the function
Get function RETURN VARCHAR2 IS
BEGIN
RETURN variable;
END get;
-Define the procedure.
PROCEDURE set(value VARCHAR2) IS
BEGIN
variable: = value;
The END value;
END package_variables;
/
Result VARIABLE VARCHAR2 (20)
CALL package_variables.get () IN: result;
SELECT: result AS result FROM dual;
RUN package_variables.set ("new value '");
CALL package_variables.get () IN: result;
SELECT: result AS result FROM dual;
/*
OUTPUT
PACKAGE compiled package_variables.
PACKAGE compiled package_variables BODY.
Error at startup on line 2 of the command:
CALL package_variables.get () IN: results
Error report:
SQL error: ORA-01008: not all variables
01008 00000 - "not all variables.
* Cause:
* Action:
RESULTS
--------------------------------
1 selected lines
anonymous block filled
Error at startup on line 2 of the command:
CALL package_variables.get () IN: results
Error report:
SQL error: ORA-01008: not all variables
01008 00000 - "not all variables.
* Cause:
* Action:
RESULTS
--------------------------------
1 selected lines
*/The package name is package_variables (note the 's'. Plural.) But using package_variable (in the singular) in your call.
Also select in as a SQL statement seems to be not valid. You encapsulate a begin - end around her block.SQL> begin 2 select package_variables.get into :outcome from dual; 3 end; 4 / PL/SQL procedure successfully completed outcome --------- Initial Value
-
Dell v715w - cannot retrieve the application list from your computer
I have a new desktop WIN7 64 bit Voastro (replaced a dimension on XP) I can't use the printer control panel to scan. I get is unable to retrieve the list of applications on your computer on the screen of the printer.
Have reinstalled the printer at least 3 times now with different downloaded drivers from the original printer disk
I've seen a lot of posts on here for similar problems, but none seems to have a definitive solutiuon for this problem.
Any help much appreciated!
Thank you - sdgconc
Hello
Thanks for the reply.
Please disable the firewall on the computer and check if the printer works fine.
If parsing is successful after you turn off the firewall, please add printer Dell as an exception to the firewall.
If the search was unsuccessful, please follow the steps below:
Click Start > Control Panel > devices and printer > printer right click and select Properties.
Select the Ports tab in the printer properties window, and then configure the Port.
Printer IP appears in the Port configuration window.
Enter the printer's IP address in the browser to log on to the website of the printer.
Click on Configuration and management of home network analysis.Then click on start > all programs > Dell printers > the home printer settings tab > network computer name.
Remove the scan to PC host.
Please let me know if you use printer wireless or USB cable.
In case you use wireless printer, try it please I scan a document with the printer connected via USB cable.
Thank you & best regards
Mustapha S
#iworkfordell -
For example, while I'm typing this message, the keyboard no longer responds and seems to zero. Also watching the video in full screen, it automatically reduced to a small screen every 15-20 seconds.
In time that he has taken to this windows type "refreshed" and interrupted my type 5 times.
I have avast, adaware and malibytes (removal of malware). Nothing has been fixed.
What should I do? I'm ready to go back to my computer and trigger a huge stink. It's terrible.
I really need help here. IM no computer genius, but I know my way and I'm stuck
Help, please!
Assuming that it worked before, what you have changed / installed since then?
Try to update your video driver from your site to the.
-
In my windows7 when I migrated to the task force to the area, crashed by the firewall. And also it does not show in the services. In the firewall rules of incoming and outgoing traffic is missing.
Hello arjunpottekkad,
It is disheartening to know that have problems you with the firewall. As I understand it the incoming and outgoing traffic rules are missing from the firewall.
The question you posted would be better suited in the TechNet Forums . I would recommend posting your query in the TechNet Forums. You can follow the link to your question:
Answer to us if you are having problems with the Windows Firewall or any other problem of Windows, and I'd be happy to help you again and try to correct the problem as soon as possible.
Good day!
Hope this information helps.
-
Master-detail functionality between the regions of PL/SQL and IR possible?
4.2.1
THM 2
Hi all
We have two regions in a page. The upper region is a region of PL/SQL that lists the 5 best wages by Dept. This was not done using traditional reports because management wanted a "dashboard" as the look and feel that is already existing and what is happening in that it is a pl/sql block that has the sliders and the necessary HTML, CSS in there.
Below that is an IR when the user clicks on the dept of region of PL/SQL, it will refresh the IR below to display all employees in this Department
Top of the page shows region of PL/SQL
EMP name Dept wage
Emp1 10 10000
EMP2 10 950
Emp3 20 800
The Dept field is a hyperlink.
When we click on Dept on this region of PL/SQL
The lower IR should be updated (without submit page)
Output
Emp1 10 10000
EMP2 10 950
It is a kind of master-detail relationship between PL/SQL and Report (Detail) (Master) area Interactive
We can hyperlink in the SQL in pl/sql area, but you wonder how trap line and pass the dept id to the IR and get this region to refresh account?
All suggestions from the experts?
Thank you
Ryan
It is a way to pass the info in connection
Perform the dynamic Action of the link column report
The dynamic action can submit the session state value, and then refresh the IR.
On either by the way, you must create dynamic PL/SQL region to solve this problem, see this
APEX reports: layout custom with a column named (model line)
-
Lack the last record in second and so forth
When I record a stream to the FMS, press stop and then play my recorded stream, I seem to always miss the last second or two. What is a buffer problem? How can I solve this?Yes, that could be due to a problem of buffer. You want to ensure that the buffer is empty before you stop the publication. If you examine the code for the VideoRecord component, you will see an example of how to see the buffer. I find this also helps empty the stream (server side) before starting playback.
Maybe you are looking for
-
I want to cancel my iMessage, but it is not available in Cambodia, so how can I do
I want to cancel my iMessage, but it is not available in Cambodia, so how can I do
-
iPhone with iOS 9.3.1 not sync with iCal/iCloud
My iPhone (updated with iOS 9.3.1) is more iCal events synchronization is entered through iCloud.com / #calendar. I did everything - the phone reboots, check the Apple ID, etc., etc., nothing helped. Help!
-
incompatibility of office 2011 with OS 10.11.1
I had a multitude of problems running the latest update of Office 2011 with my iMac running OS 10.11.1 (El Capitan) that I didn't have with the previous OS versions. It's Word suddenly quit Word telling me he didn't is not enough space for the job f
-
Disorders of Outlook since the February 10 update
Hello System:Win 7 64-bit operating systemOffice Enterprise 2007 I recently started having trouble with Outlook (since 10 February update, where I installed updates Windows 11 - I can list if necessary, but the forum seems to be familiar with who is
-
How to load a programe so can be observed in a single account and not others
I want to load a programe in my administrator account and do not have what we see into account children on the same computer. I tried to load it, but all icons appear on all accounts. Tried to delete his account, but he is also my account and now can