PostgreSQL Pick one single random row from multiple tables - sql

How can we pick a random row from 3 tables, whereas the table row count for each table may vary. This would need to be fair if there not same count. This means if one table had only one row and the other table has 10 rows, then were much more likely get row from table with 10 rows. Each row in all tables get chance at winning
I was trying to convert this SQL code which I got from another Stack Overflow post here
SELECT preview_id, review_id
FROM (
select preview.*, row_number() over (order by newid()) as seqnum from
preview
) preview
JOIN (
select review.*, row_number() over (order by newid()) as seqnum
from review
) review ON preview.seqnum = review.seqnum;
3 Table schemas.
CREATE TABLE preview
(
preview_id SERIAL PRIMARY KEY NOT NULL,
preview_header VARCHAR(90) NOT NULL,
preview_text TEXT NOT NULL
);
INSERT INTO preview(preview_header, preview_text) VALUES ('Preview Header One', '"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.");
INSERT INTO preview(preview_header, preview_text) VALUES ('Preview Header Two', '"There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don''t look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn''t anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.");
INSERT INTO preview(preview_header, preview_text) VALUES ('Preview Header Three', '"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
INSERT INTO preview(preview_header, preview_text) VALUES ('Preview Header Four', '"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?" );
INSERT INTO preview(preview_header, preview_text) VALUES ('Preview Header Five', '"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?");
INSERT INTO preview(preview_header, preview_text) VALUES ('Preview Header Six', '"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.");
CREATE TABLE article
(
article_id SERIAL PRIMARY KEY NOT NULL,
article_header VARCHAR(90) NOT NULL,
article_text TEXT NOT NULL
);
SELECT * FROM article;
INSERT INTO article(article_header, article_text) VALUES ('Article Header One', '"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.");
INSERT INTO article(article_header, article_text) VALUES ('Article Header Two', '"There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don''t look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn''t anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.");
INSERT INTO article(article_header, article_text) VALUES ('Article Header Three', '"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
INSERT INTO article(article_header, article_text) VALUES ('Article Header Four', '"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?");
INSERT INTO article(article_header, article_text) VALUES ('Article Header Five', '"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?");
INSERT INTO article(article_header, article_text) VALUES ('Article Header Six', '"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.");
CREATE TABLE review
(
review_id SERIAL PRIMARY KEY NOT NULL,
review_header VARCHAR(90) NOT NULL,
review_text TEXT NOT NULL
);
INSERT INTO review(review_header, review_text) VALUES ('Preview Header One', '"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains." );
INSERT INTO review(review_header, review_text) VALUES ('Preview Header Two', '"There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don''t look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn''t anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.");
INSERT INTO review(review_header, review_text) VALUES ('Preview Header Three', '"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." );
INSERT INTO review(review_header, review_text) VALUES ('Preview Header Four', '"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?");
INSERT INTO review(review_header, review_text) VALUES ('Preview Header Five', '"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?" );
INSERT INTO review(review_header, review_text) VALUES ('Preview Header Six', '"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.");
The desired result will be a single full row from any one these tables. So each row has a fair chance at been the winner

If tables has similar structure just use UNION ALL
SELECT *,
row_number() over (order by newid()) as seqnum
FROM ( SELECT preview.* FROM preview
UNION ALL
SELECT review.* FROM review
) T
if doesnt have similar structure you need to do some tricks to make the union with same number of columns.
SELECT *,
row_number() over (order by newid()) as seqnum
FROM ( SELECT 'preview' as `source`, p.field1, p.field2, null , null
FROM preview P
UNION ALL
SELECT 'review' as `source`, null , null , r.field1, r.field2
FROM review R
) T
EDIT: for you new request
SELECT *, row_number() over (order by random()) as seqnum
FROM (SELECT 'preview' as `source`, preview_id as winning_id
FROM `preview`
UNION ALL
SELECT 'article' as `source`, article_id
FROM `preview`
UNION ALL
SELECT 'review' as `source`, review_id
FROM `preview`
) T
--LIMIT 1;

Related

How do I get a context from field table using regex in oracle SQL?

How can I catch the part of content "Description scenario::" and the rest of the information using REGEXP_LIKE in SQL Oracle?
select description
from tbl_error
where REGEXP_LIKE(description, '[Description scenario::].*$' )
Error Details
Report steps Erro: WEB
Contributor name:: Lorem Lorem
Description scenario:: Lorem ipsum dolor sit amet. Est ducimus magnam qui culpa internos in Quis neque et quibusdam ipsa. Aut dolorum omnis qui doloribus eveniet aut neque impedit est expedita consectetur et omnis nulla non sunt sequi. Hic dolor incidunt aut itaque ipsam autem fuga in rerum molestiae. A accusantium facere ad impedit quasi et dolorem quia cum veniam dolores et odit voluptate aut animi illum.
If regex isn't a must, use substr + instr combination:
SQL> select substr(description, instr(description, 'Description scenario::') +
2 length('Description scenario::') + 1
3 ) as result
4 from tbl_error;
RESULT
--------------------------------------------------------------------------------
Lorem ipsum dolor sit amet. Est ducimus magnam qui culpa internos in Quis neque
et quibusdam ipsa. Aut dolorum omnis qui doloribus eveniet aut neque impedit est
expedita consectetur et omnis nulla non sunt sequi. Hic dolor incidunt aut itaq
ue ipsam autem fuga in rerum molestiae. A accusantium facere ad impedit quasi et
dolorem quia cum veniam dolores et odit voluptate aut animi illum.
SQL>
You do not need (slow) regular expressions and can use simple string functions:
SELECT SUBSTR(
description,
INSTR(description, 'Description scenario::') + LENGTH('Description scenario::')
) AS description_scenario
FROM tbl_error;
Which, for the sample data:
CREATE TABLE tbl_error (description) AS
SELECT 'Error Details
Report steps Error:: WEB
Contributor name:: Lorem Lorem
Description scenario:: Lorem ipsum dolor sit amet. Est ducimus magnam qui culpa internos in Quis neque et quibusdam ipsa. Aut dolorum omnis qui doloribus eveniet aut neque impedit est expedita consectetur et omnis nulla non sunt sequi. Hic dolor incidunt aut itaque ipsam autem fuga in rerum molestiae. A accusantium facere ad impedit quasi et dolorem quia cum veniam dolores et odit voluptate aut animi illum.'
FROM DUAL
Outputs:
DESCRIPTION_SCENARIO
Lorem ipsum dolor sit amet. Est ducimus magnam qui culpa internos in Quis neque et quibusdam ipsa. Aut dolorum omnis qui doloribus eveniet aut neque impedit est expedita consectetur et omnis nulla non sunt sequi. Hic dolor incidunt aut itaque ipsam autem fuga in rerum molestiae. A accusantium facere ad impedit quasi et dolorem quia cum veniam dolores et odit voluptate aut animi illum.
If all the values are on individual lines and the separator between the key and the value is :: then you can extract all the key-value pairs (again, without regular expressions) using:
WITH bounds (description, spos, epos) AS (
SELECT description,
1,
INSTR(description, CHR(10), 1)
FROM tbl_error
UNION ALL
SELECT description,
epos + 1,
INSTR(description, CHR(10), epos + 1)
FROM bounds
WHERE epos > 0
),
lines (line) AS (
SELECT CASE epos
WHEN 0
THEN SUBSTR(description, spos)
ELSE SUBSTR(description, spos, epos - spos)
END
FROM bounds
),
separators (line, sep_pos) AS (
SELECT line,
INSTR(line, '::')
FROM lines
)
SELECT SUBSTR(line, 1, sep_pos - 1) AS type,
LTRIM(SUBSTR(line, sep_pos + 2)) AS value
FROM separators
WHERE sep_pos > 0
Which, for the sample data, outputs:
TYPE
VALUE
Report steps Error
WEB
Contributor name
Lorem Lorem
Description scenario
Lorem ipsum dolor sit amet. Est ducimus magnam qui culpa internos in Quis neque et quibusdam ipsa. Aut dolorum omnis qui doloribus eveniet aut neque impedit est expedita consectetur et omnis nulla non sunt sequi. Hic dolor incidunt aut itaque ipsam autem fuga in rerum molestiae. A accusantium facere ad impedit quasi et dolorem quia cum veniam dolores et odit voluptate aut animi illum.
db<>fiddle here

XSLT value-of not showing new paragraphs

I have problem of getting text from xml in original state.
When I use <xsl:value-of select="desc" /> I get full text, but merged, without spaces between paragraphs.
I have data like this:
<desc><![CDATA[Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat]]>
</desc>
And, as output I get this:
This is not good for me, because I want output text to be same as inside CDATA[], with blank lines between paragraphs.
I tried with using preserved spaces.
I'm using Saxon xslt processor
Using fo:block linefeed-treatment="preserve" as your container element might suffice, see https://www.w3.org/TR/xsl11/#linefeed-treatment.

Definitive relationship between sizeWithFont:constrainedToSize:lineBreakMode: and contentSize (text height in Objective-C)

// textView is type of UITextView
self.textView.text = #"Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.";
CGSize maxSize = {self.textView.contentSize.width, CGFLOAT_MAX};
CGSize computedSize = [self.textView.text sizeWithFont:self.textView.font
constrainedToSize:maxSize
lineBreakMode:UILineBreakModeWordWrap];
NSLog(#"Computed size - width:%f height:%f\nContent size - width:%f height:%f", computedSize.width, computedSize.height, self.textView.contentSize.width, self.textView.contentSize.height);
Console output:
Computed size - width:320.000000 height:450.000000
Content size - width:320.000000 height:484.000000
Why are not these values equal? At least heights.
What is the .bounds.size of the text view? If all text fits within the text view the content size can still be reported as the views full size.
The UITextView is implemented using an internal web view, with allot of private magic. It is generally not a good idea to trust the text view with anything apart from displaying and editing text. The internal measurements and calculations has, and will continues to, change between OS updates.
If what you want is to change the size of the UITextView to fit all text then you must let the text view itself do this calculation. For example:
CGRect frame = textView.frame;
frame.size.height = [textView sizeThatFits:CGSizeMake(frame.size.width, CGFLOAT_MAX)];
textView.frame = frame;

How to set left margin in PowerPoint textbox using VSTO

I'm taking some user data and adding it to a PowerPoint presentation using VSTO. To get the formatting to look right, though I need to be able to set the left margin of some of the text in the textbox. There will be an initial block of text followed by another, indented block. For example (underlines added to emphasize spacing):
Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Sed
vestibulum elementum neque id rhoncus.
In fermentum eros nec dolor lobortis
sit amet fermentum est consequat.
Curabitur eleifend nunc eu odio
vehicula ut elementum erat aliquam. Ut
adipiscing ipsum sit amet leo pulvinar
hendrerit. Cum sociis natoque
penatibus et magnis dis parturient
montes, nascetur ridiculus mus. Nulla
non neque in velit lacinia tempor et a
lacus.
___________Cras auctor bibendum urna, a facilisis lacus
lacinia non.
___________Nullam at quam a mauris consequat vulputate sed eu
sapien.
___________Fusce sed urna nulla, ut sagittis lacus. Pellentesque
tortor
___________augue, scelerisque at aliquet a, pretium ac
ipsum.
I can get this effect by setting Shape.TextFrame.TextRange.IndentLevel = 2 on the lower block of text. However, I cannot figure out how to programmatically set the value of the margin. Does anyone know how to do this?
This is taken care of via Shape.TextFrame.MarginRight and Shape.TextFrame.MarginLeft and the like.

create pdf with long lines, fit to pagewidth without wordwrap

i'd like to create a large pdf (not typical page size) with long lines, max ~1000 characters / line, where the page size and font are such that no lines need to wrap.
the intention is not for the text in this document to be readable when the full page is viewed on any reasonably-sized monitor -- instead the reader can zoom to individual portions of interest within the document.
i attempted this with a small font in latex, but no success.
any help is greatly appreciated. thanks.
This works with pdflatex:
\documentclass{article}
\pdfpagewidth 200cm
\pdfpageheight 200cm
\textwidth 190cm
\def\lorem{Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.}
\begin{document}
\lorem \lorem \lorem \lorem
\end{document}