Count number of colums for that query.
Hi all,
I need to return the number of columns for that query, the columns are not known...dynamic columns.
i.e
1) Example 1
select column1, column2
from dual;
Result should return counter = 2
2) Example 2:
select column1, column2,column3,column4, column5
from dual;
Result should return counter = 5
from dual;
Result should return counter = 2
Thanks.
qwestion wrote:
I need to return the number of columns for that query, the columns are not known...dynamic columns.For this you'll need to use the DBMS_SQL package:
e.g.
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE procedure query_col_count(p_sql IN VARCHAR2) IS
2 c NUMBER;
3 rec_tab DBMS_SQL.DESC_TAB;
4 col_cnt INTEGER;
5 BEGIN
6 c := DBMS_SQL.OPEN_CURSOR;
7 DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
8 DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
9 DBMS_SQL.CLOSE_CURSOR(c);
10 DBMS_OUTPUT.PUT_LINE('Number of columns: '||col_cnt);
11* END;
SQL> /
Procedure created.
SQL> exec query_col_count('select empno, ename from emp');
Number of columns: 2
PL/SQL procedure successfully completed.
SQL> exec query_col_count('select * from emp');
Number of columns: 8
PL/SQL procedure successfully completed.
SQL>
Similar Messages
-
RPD - Cannot obtain number of columns for the query result :Working with MS SQL 2012 schema
Hi All,
I have created my warehouse in MS SQL 2012.
For management purpose, I have created different schemas in SQL database
In RPD, Physical layer, when i view data > I get error as
[nQSError:16002] Cannot obtain number of columns for the query result.
[nQSError:16001] ODBC error state : S0002 code : 208 message: [Microsoft][ODBC SQL Server Driver][SQL Server] Invalid object name 'tbl'..
[nQSError:16001] ODBC error state : S0002 code : 208 message: [Microsoft][ODBC SQL Server Driver][SQL Server] Statements could not be prepared..
I have already browsed : OBIEE 11g Strange ODBC Driver Error with SQL Server : Total Business Intelligence ... did not help me
please help!!!Hi All,
After all R&D it is been found that Oracle business administrator( RPD) needs default dbo schema. It doesn't accept custom schema for pulling data.
If anybody have other views please share.!!
Thank you -
Script to count number of emails for multiple users
I am needing a little help with my script. I have this working if I use just a single email address. I need to add a list of 8 emails addresses for this to scan. How would I modify this to send 1 email for all 8 users?
I have seen scripts that make a html file that displays everything in a nice table but those are ran against all users in exchange and I only needs this for a group of 8 users.
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
#Powershell Garbage
$nl = [Environment]::NewLine
#Mailbox to gather stats on
$mailbox= "[email protected]"
#Get todays date twice
$startDate=Get-Date
$endDate=Get-Date
#Subtract 1 day from todays date (report ending day) and 7 days from todays date (report starting day)
$startDateFormatted=$startDate.AddDays(-7).ToShortDateString()
$endDateFormatted=$endDate.AddDays(-1).ToShortDateString()
#Who to send the e-mail report to.
#Multiple e-mail addresses should be in this format "<[email protected]>, <[email protected]>"
$emailFrom = "[email protected]"
$emailTo = "[email protected]"
$subject = "Weekly e-mail report for $mailbox for $startDateFormatted - $endDateFormatted"
$smtpServer = "mail.domain.com"
# Sent e-mails
$sendCount = Get-TransportService | Get-MessageTrackingLog -Start "$startDateFormatted 00:00:00" -End "$endDateFormatted 23:59:59" -Sender $mailbox -resultsize unlimited | select-object -unique MessageId
# Received e-mails - This works but not on generic accounts
$receiveCount = Get-TransportService | Get-MessageTrackingLog -Start "$startDateFormatted 00:00:00" -End "$endDateFormatted 23:59:59" -Recipients $mailbox -resultsize unlimited | select-object -unique MessageId
$sendCountString = $sendCount.count
$receiveCountString = $receiveCount.count
$body = "Mailbox stats for: $mailbox $nl
Report date range: $startDateFormatted 00:00:00 - $endDateFormatted 23:59:59 $nl
Total e-mails sent: $sendCountString $nl
Total e-mails received: $receiveCountString"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)Could you elaborate a little bit more? I have not done a lot with powershell in exchange.
Would this be correct?
$mailbox= "[email protected]"
for each ($mailbox in $mailboxes)
#Get todays date twice
$startDate=Get-Date
$endDate=Get-Date
etc. -
How to count number of records for a field based on condition?
Hi guys,
I want to know how to find count of records coming from the database for a particular field based on some condition.
I need to use this count to suppress some headers. Because of this i am not able to use running totals. Is there any other way?
Ex scenario:
I have account number and currency fields, those are coming from database. And i need to count the number of accounts whose currency is not Euro.
Thanks in advance,
Vijay.A simple formula can do that:
//Formula begin
if {your account field}<>"Euro" then 1
//Formula end
This formula can be summarized. (by group or report)
Bryan Tsou@Taiwan -
Count number of rows for TWO QUERIES USING MINUS OPERATOR
I have the following piece of sql, i would like to know how could i programatically using plsql count the number of rows returned by the following statement. I know that %ROWCOUNT returns the rowcount for the last execute INSERT, UPDATE, DELETE and SELECT INTO statement. Any help is much appreciated thanks.
select *
from admt1m4.usr@tcprod u
where u.authoriztion = 'Omf99FullUsage'
and u.obid in (select right from admt1m4.usrtogrp@TCPROD ug where ug.left in
(select obid from admt1m4.usrgrp@tcprod g
where g.participant not in ('super user grp', 't1_WbsPSAnalystGrp')))
and u.activeuser = '+'
MINUS
select *
from admt1m4.usr@TCPROD u
where u.authoriztion = 'Omf99FullUsage'
and u.obid in (select right from admt1m4.usrtogrp@TCPROD ug
where ug.usrgrpname in ('super user grp', 't1_WbsPSAnalystGrp'))
and u.activeuser = '+'Hi,
Have you tried
SELECT COUNT (1) cnt
FROM (SELECT *
FROM admt1m4.usr@tcprod u
WHERE u.authoriztion = 'Omf99FullUsage'
AND u.obid IN (
SELECT RIGHT
FROM admt1m4.usrtogrp@tcprod ug
WHERE ug.LEFT IN (
SELECT obid
FROM admt1m4.usrgrp@tcprod g
WHERE g.participant NOT IN
('super user grp', 't1_WbsPSAnalystGrp')))
AND u.activeuser = '+'
MINUS
SELECT *
FROM admt1m4.usr@tcprod u
WHERE u.authoriztion = 'Omf99FullUsage'
AND u.obid IN (
SELECT RIGHT
FROM admt1m4.usrtogrp@tcprod ug
WHERE ug.usrgrpname IN
('super user grp', 't1_WbsPSAnalystGrp'))
AND u.activeuser = '+')or your requirement is something else...
*009* -
How to count number of colums ina sql database
is there a command to find out the length of a column,using rs.next possible???
is there a way of finding out the number of rows in a
database??See my first post for the number of rows in a table.
If you want to get the total rows in an entire database (cant think why) it should be possible with DatabaseMetaData.getTables() and do a SELECT COUNT(*) for each table then add the results.
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Connection.html#getMetaData() -
SQL help: return number of records for each day of last month.
Hi: I have records in the database with a field in the table which contains the Unix epoch time for each record. Letz say the Table name is ED and the field utime contains the Unix epoch time.
Is there a way to get a count of number of records for each day of the last one month? Essentially I want a query which returns a list of count (number of records for each day) with the utime field containing the Unix epoch time. If a particular day does not have any records I want the query to return 0 for that day. I have no clue where to start. Would I need another table which has the list of days?
Thanks
RayPeter: thanks. That helps but not completely.
When I run the query to include only records for July using a statement such as following
============
SELECT /*+ FIRST_ROWS */ COUNT(ED.UTIMESTAMP), TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD') AS DATA
FROM EVENT_DATA ED
WHERE AGENT_ID = 160
AND (TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY')+(ED.UTIMESTAMP/86400)), 'MM/YYYY') = TO_CHAR(SYSDATE-15, 'MM/YYYY'))
GROUP BY TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD')
ORDER BY TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD');
=============
I get the following
COUNT(ED.UTIMESTAMP) DATA
1 07/20
1 07/21
1 07/24
2 07/25
2 07/27
2 07/28
2 07/29
1 07/30
2 07/31
Some dates donot have any records and so no output. Is there a way to show the missing dates with a COUNT value = 0?
Thanks
Ray -
How to COUNT number of UNION results ?
Dear SQL experts,
How can I get number of records for this query ?
select a.* from ACCDET a
where a.instcode='ZZZ'
and a.custcode='0000000000000'
union
select a.* from ACCDET a, CRDACC c
where a.instcode = c.instcode
and a.accno = c.accno and a.currcode = c.currcode
and c.pan = '0000000000000000' and a.instcode='ZZZ'
thank you
Maris Orbidans12:47:59 SQL> select count(*) from t;
COUNT(*)
245960
1 row selected.
Elapsed: 00:00:00.00
12:48:06 SQL> select count(*) from (
12:48:13 2 select * from t
12:48:38 3 union all
12:48:41 4 select * from t);
COUNT(*)
491920
1 row selected.
Elapsed: 00:00:00.00
Also you should use UNION only if you REALLY need unique records and you know that each query may return the same ones.
NjÄ un vispÄr, te pat vÄl kÄds latvietis ir :) -
How to count number of line items in BEX
Hello friends,
I am showing summarized data in BEX but i have to show one column number of records for that line .
For e.g.
Profit Center Document Number amount
Newyork 101 1000
Newyork 102 2000
I have to show as
Profit Centre Amount Line Items
Newyork 3000 2
Please give me suggestion how to do it in BEX ?
Regards
Nilesh VakilHi Nilesh,
Check here...
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/009819ab-c96e-2910-bbb2-c85f7bdec04a
Re: Count the values of a characteristic
Thanks,
Vijay. -
Short dump in report generation for bex query
Hi,
I have e newly installed SAP NetWeaver 7.3 and I'm not able to run BEx-Queries. When I start transaction RSRT and try to generate the report for the selected bex query, I get the following short dump:
Category ABAP Programming Error
Runtime Errors RAISE_EXCEPTION
ABAP Program SAPLRRSI
Application Component BW-BEX-OT
If I start the test in RSRV for that query I get:
Generation limits for the generated report
Unable to load report GPEM3XZBL2Y9VX9H6SN
Am I missing a profile parameter for that generartion limits or something else?
Thanks in advance!Hi,
Check whether your SAP GUI is activated and installed correctly.
check following threads
Runtime error RAISE_EXCEPTION has occurred
Dump when activating Business Content 7.35
Thanks and regards
Kiran -
Pre-fill the OLAP cache for a query on Data change event of infoprovider
Hi Gurus,
I have to pre-fill the OLAP cache for a query,which has bad performance.
I read a doc 'Periodic Jobs and Tasks in SAP BW'
which suggested sum steps to do this
i hav created the setting for Bex broadcasting for scheduling job Execution with data change in info provider
thereafter doc says "an event has to be raised in the process chain which loads the data to this InfoProvider.When the process chain executes the process u201CTrigger Event Data Change (for Broadcaster)u201D, an event is raised to inform the Broadcaster that the query can be filled in the OLAP cache."
how can this b done please provide with sum proper steps
Answers are always appreciated.
Thanks.Hi
U need to create a process chain or use the existing process chain which you are using to load your current solution, just add event change process type in the process chian and inside it add the info provider which are going to be affected.
Once you are done with this go to the broadcaster and create new setting for that query...you will see the option for event data chainge in infoprovider just choose that and create the settings.
hope it helps -
Number range buffering for dimension tables (DIM IDs) and InfoObjects (SIDs
Hi BW Experts,
How to check whether this number range buffering for dimension tables (DIM IDs) and InfoObjects (SIDs) is Active or not ??
can you please provide me this technical information where to go and check in the system ?
Thanks in Advance.The Early Watch report lists these because of the large number of rows in the MD/Dim tables. Keep in mind though, that Number Range buffering will really only help if you continue to generate a large volume of new SIDs or Dim IDs with ongoing loads, e.g.
If your transactions being loaded to a cube result in several thousand new rows being added a Dim table, then it makes sense to turn on Number Range buffering for that Dim ID. But if the transaction volume is only cause a few hundred DIM IDs to be added, buffering will not really get you anything. -
Table Name which contains Role for a Query
Hi
Please let me know if there is any table present where i will give Query name as Input and i will get the Role name for that query.
Regards
AtulGo to RSA1--> Meta data repository --> search for the query , in its details you will find the role to which it is assigned .
-
Number range Object for Production order Number range profile.
Hi ffriends,
Can anybody tell me how to maintain the <b>Serial Number Range</b> for production order serial no.
I working on automatic serail no generation for production order.I have one serial no range profile which I am assigning to material in material master but I don't know the number range object for that profile.
Or can anybody tell me how we attach serail no profile to a serial no range object.?
Please it is urgently required..........
Regards,
Rajesh Akartehi rajesh
in the serial number profile there are certain business procedures which will create the serial no ,kindly check whether for your procedure you have assinged whether serial number to be arranged or not
slecect the serial number profile in sutomization field( which you have specified in Material master) and select the serialization procedure and check whether the <b>PPRL</b> procedure is assinged,also check the serial no usage assigned
for detailed process have a look here
<b>http://help.sap.com/saphelp_47x200/helpdata/en/3c/abc38a413911d1893d0000e8323c4f/frameset.htm</b>
regards
thyagarajan -
How do you count number of changes?
I know lots of threads out there address counters. I am trying to count number of changes for example.
T,T,T,F,F,T,T,T,F,F,F.
This would give give me count of 3. I have done several renditions, but it would give me number of T or number F. I am not sure what would be the best option.
HenryHere's a faster routine:
Ton
Message Edited by TonP on 09-25-2008 07:03 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas
LabVIEW, programming like it should be!
Attachments:
ArrayCount.PNG 5 KB
Maybe you are looking for
-
How to go about creating a schedule grid.
Hello, I want to create a scheduling program and I am not sure how to go about it. I am hoping you can point me in the right direction. I want to create a scheduling program where it would be a rows and columns. The columns would be the days of the w
-
Masses of white space, how to get rid of it?
Hi every body. Im reading in an XMl file, changing a few values then printing it back to the same file. But everytime I read it in and print it back, its putting a blank line after every other line. So if I read in a file that looked like this::: <re
-
Can't find Adobe Collage in location services on iPad, and can't import photos from library
Why am I not able to find Adobe Collage in location services on my iPad? And why can't I import photos from my photo library on my iPad? Best regards Joachim Mortensen
-
No interfaces visible in ECC's SPROXY for user A, while visible for user B
Hi guys, we're facing a strange issue.. One user can see wothout any problems all available intarfces in the ECC's SPROXY, but another one doesn't. This obviously can't be then a problem of a connection, and what is even more interesting, both users
-
Can I boot an iMac from my PB in Target Disk Mode?
I'm housesitting at my parents this weekend, and would like to know if I can bootup my Powerbook G4 in Target Disk mode and then use it as the Startup volume on my parents Intel iMac. In System Preferences it doesn't give my Hard Drive as an option f