Iterate through a list of strings In SQL scriipt

I’m trying to create a sql file that iterates through a list and get me the information from a group of servers and save it on CSV file. The DB is Oracle, just in case :S.
I’m running the file using sqlplus in a playbook, so I’m able to change the query.

So far, I was able to do the following:

set markup csv on spool 'playbook-dir/roles/instances_db/files/servers.csv'  SELECT * FROM   (<some_internal_query>) WHERE  ROWNUM <= 600000 + 1 ORDER  BY server_name;    spool off 

This query will bring all 5000 servers and I just need 100 or so. I tried to add an array and loop around it Something like this:

DECLARE    arrayvalues sys.odcivarchar2list; BEGIN   arrayvalues := sys.odcivarchar2list('Matt','Joanne','Robert');   FOR x IN ( SELECT m.column_value m_value                FROM table(arrayvalues) m )   LOOP     SELECT *     FROM   (<some_internal_query>)     WHERE  ROWNUM <= 600000 + 1     ORDER  BY server_name;     END LOOP; END; 

But I got this error:

Error report - ORA-06550: line 7, column 1: PLS-00428: an INTO clause is expected in this SELECT statement 06550. 00000 -  "line %s, column %s:\n%s" *Cause:    Usually a PL/SQL compilation error. *Action: 

I’m not entirely sure if I’m doing the LOOP correctly.
Any help will be appreciated.

How to get count of an object, through 3 different tables in postgres with ID’s stored in each table

I’m currently using Postgres 9.6.16.

I am currently using 3 different tables to store a hypothetical users details.

The first table, called contact, this contains:

ID, Preferred_Contact_Method 

The second table, called orders, This contains:

ID, UserID, Contact_ID (the id of a row, in the contact table that relates to this order) 

The Third Table, Called order_details

ID, Orders_ID (the id in the orders table that relates to this order details) 

The tables contain other data as well, but for minimal reproduction, these are the columns that are relevant to this question.

I am trying to return some data so that i can generate a graph, in this hypothetical store, There’s only three ways we can contact a user: Email, SMS, or Physical Mail.

The graph is supposed to be 3 numbers, how many mails, emails, and SMS we’ve sent to the user; since in this hypothetical store whenever you purchase something you get notified of the successful shipment, these methods are 1:1 to the order_details, so if there’s 10 order_detail rows for the same user, then we sent 10 tracking numbers, and since there can be multiple order_details (each item has a different row in order_details) in an order, we can get the count by counting the total rows of order details belonging to a single user/contact, then attributing to what kind of contact method that user preferred at the time of making that order.

To represent this better: If a new user makes a new order, and orders 1 apple, 1 banana, and 1 orange. For the apple, the user set preferred tracking number delivery as SMS, for the banana, they set it to EMAIL, for the orange, they thought it would be funny to set the tracking number delivery via MAIL. Now, i want to generate a graph to this users preferred delivery method. So i’d like to query all those rows and obtain:

SMS, 1 EMAIL, 1 MAIL, 1 

Here’s a SQL Fiddle link with the schema and test data:!17/eb8c0

the response with the above dataset should look like this:

method | count SMS,     4 EMAIL,   4 MAIL,    4 

Why does my stencil buffer allow pixels through?

I’m rendering a scene using OpenGL. The scene consists of a grassy environment and a small lake (visible as two surfaces). To achieve water surface transparency, I’m using a stencil buffer to render water surfaces separately from other geometry. For context, here’s a screenshot of the scene without water surfaces:

Scene without water surfaces rendered.

Here’s the same scene, but with water surfaces stenciled out (the black portions of the screen):

Water surfaces stenciled out, but not rendered.

Here’s the fragment shader I’m using (where fSource is fullscreen UV coordinates). As you can see, it simply samples from a previously-used frame buffer and outputs the pixel directly to the screen. With stenciling enabled, only pixels not covered by a water surface are rendered.

#version 440 core  in vec2 fSource;  out vec4 outColor;  uniform sampler2D image;  void main() {     outColor = texture(image, fSource); } 

Here’s the problem. When I change this fragment shader to output a solid color, those underwater pixels are suddenly visible (the stencil buffer and stencil settings have not changed). What I’d expect here is non-submerged pixels to be purple, but the water surface pixels (previously black) to remain black (since they should still be rejected through stenciling). Instead, everything is purple, including the water surface.

#version 440 core  out vec4 outColor;  void main() {     outColor = vec4(1, 0, 1, 1); } 

Direct color output (purple) causing pixels to not be rejected through stenciling.

As an additional test, I tried rendering only pixels under the water surfaces with a solid color. These pixels should be rejected via stenciling (appearing black, just like before), but for some reason, they’re visible.

#version 440 core  in vec2 fSource;  out vec4 outColor;  uniform sampler2D image; uniform sampler2D positions;  void main() {     vec3 position = texture(positions, fSource).xyz;      // The water surfaces happen to sit at Y value 7.85.     if (p.y < 7.85)     {         outColor = vec4(1, 1, 0, 1);     }     else     {         outColor = texture(image, fSource);     } } 

Submerged pixels showing up, seemingly ignoring the stencil buffer.

I confirmed the problem by instead sampling with shifted UV coordinates (rather than outputting solid yellow). Again, pixels are showing up on the water surfaces, seemingly ignoring the stencil buffer.

#version 440 core  in vec2 fSource;  out vec4 outColor;  uniform sampler2D image; uniform sampler2D positions;  void main() {     vec3 position = texture(positions, fSource).xyz;      // The water surfaces happen to sit at Y value 7.85.     if (p.y < 7.85)     {         outColor = texture(image, fSource + vec2(0.1, 0));     }     else     {         outColor = texture(image, fSource);     } } 

Shifted UV pixels still showing up through the stencil buffer.

My understanding of stenciling is that it prevents the fragment shader from running at all on certain portions of the screen (i.e. fragments pass or fail based on stencil settings). If that were true, then no matter what the fragment shader outputs, that pixel should remain black (in this context). Clearly, the fragment shader is still being run for pixels that should be rejected due to stenciling, which means I must be misunderstanding how the stencil buffer works.

Why is the fragment shader still running on pixels that should be rejected through stenciling?

Update 1: here are my stencil settings. No other objects (apart from water surfaces) write to the stencil buffer.

// Render water surfaces. 0x10 represents water. glEnable(GL_STENCIL_TEST); glStencilMask(0xFF); glStencilFunc(GL_ALWAYS, 0x10, 0xFF); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);  BindWaterFrameBuffer(); BindWaterShader(); DrawWaterSurfaces();  // Render the scene. Due to the stencil settings, only non-surface pixels should be rendered. glStencilMask(0x00); glStencilFunc(GL_EQUAL, 0x00, 0xFF); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);  BindDefaultFrameBuffer(); BindSceneShader(); DrawFullscreenQuad(); 

Update 2: here’s another screenshot showing the submerged solid color test, but with a lower Y threshold (three meters below the water). What appears to be happening, then, is that pixels sampled using the GLSL texture function correctly honor the stencil buffer, while direct color outputs don’t. However, even that can’t quite be true since, as shown above, sampling pixels outside the stenciled portion of the screen still results in those pixels showing up.

#version 440 core  in vec2 fSource;  out vec4 outColor;  uniform sampler2D image; uniform sampler2D positions;  void main() {     vec3 position = texture(positions, fSource).xyz;      // The water surfaces happen to sit at Y value 7.85, but here, I'm using a threshold three meters below that.     if (p.y < 4.85)     {         outColor = vec4(1, 1, 0, 1);     }     else     {         outColor = texture(image, fSource);     } } 

Submerged pixels rendered using a solid color, but a few meters below the water surface.

Which Spheres of Might talents give a Vector attacks through Kinetic Overload?

The vector symbiat archetype, from Champions of the Spheres, has the ability Kinetic Overload, which reads, in part:

When a Brute, Scoundrel, or Wrestling talent would grant the vector an attack against a target within his telekinesis range as the result of performing a maneuver [emphasis mine], he may choose to make a ranged attack roll to pummel his target in place of the attack, dealing 1d6 + his casting ability modifier bludgeoning damage. This damage increases by 1d6 at 3rd level and every two levels thereafter and counts as magic.

My question is which martial talents from these three spheres actually grant these attacks? Some seem to obviously grant the attack (Scoundrel’s Mug, Wrestling’s Chink in the Armor), and others probably not (Wrestling’s Slip and Strike), but what about an ability such as Wrestling’s Piledriver?

When you successfully maintain a grapple against a creature you have already pinned, instead of one of the options normally available when you maintain a grapple, you may lift them over your head and smash them into the ground, automatically threatening a critical hit with your unarmed strike and rolling to confirm as normal. If the critical threat confirms successfully, the creature must make a successful Fortitude save or be staggered for 1 round. Use of this talent breaks your grapple on the creature. At +10 base attack bonus, the target is dazed for 1 round instead.

Does this fulfill the twin parts of Kinetic Overload, namely, "making an attack" (it’s automatically threatening a critical hit; no attack roll is being made, but a confirmation roll is called for), and "as the result of performing a maneuver" (it’s an option upon maintaining a grapple)? Does Kinetic Overload’s option to make the attack with telekinetic force override Piledriver’s requirement that the attack be made with an unarmed strike?

Piledriver’s the most confusing example I’ve found in my readings, but I’d like to see either a specific set of tests (does it have to be an attack roll, does it have to allow any weapon to be used with it, etc.) or a full list of all talents that grant an attack that Kinetic Overload can replace this way (probably no more than a dozen unless it’s a lot more generally applicable than I’m understanding it to be). I’m also working under the understanding that the attacks made as part of shove, marked target, and snag do not qualify, since they’re handled in their own paragraph of Kinetic Overload.

Would it be unbalanced to allow the Darkvision spell to see through magical darkness?

Darkvision is so prevalent among races that the spell Darkvision rarely sees use. Even with casters who do not have darkvision, it still seems unlikely to be taken, as a cantrip is able to provide light, and the situations where the caster without darkvision cannot use light sources are rare enough that it does not justify the spell slot or even having the spell prepared/on their spell list. To add more value to the spell, I’d propose the following changes (bolded below):

2nd-level transmutation
Casting Time: 1 action
Range: Touch
Components: V, S, M (either a pinch of dried carrot or an agate)
Duration: 1 hour
You touch a willing creature to grant it the ability to see in the dark. For the duration, that creature has darkvision out to a range of 60 feet. This darkvision is able to see through magical darkness.

There are 2 changes present:

  1. Duration: With the other proposed changes, if this spell remained an 8 hour spell it would become a must have, basically ensuring multiple allies (Through multiple castings) can see through any darkness for a full adventuring day. Keeping this down to 1 hour puts pressure on using it at the right time, and the spell will not remain active through a short rest.
  2. Magical Darkness: This is the big change, that I think gives the spell appeal. If you are expecting magical darkness you can be prepared, or if you are planning on using magical darkness you can ensure you and maybe some allies are still able to function within it.

Does this appear balanced as a second level spell? Would it be better suited at a higher level? I think second level is still viable, as the other methods of obtaining darkvision in magical darkness are available to the Warlock at 2nd level (Devil’s Sight), and the Sorcerer at 3rd level (though only through their own Darkness spell).

add_filter( ‘the_title’ gets through this if statement twice

I am using the accepted answer shown here: Apply the_title() filter in post & page title, but not in menu title

For some reason, the code is getting through this if statement twice:

if ( ! is_admin() && $  post instanceof WP_Post && ( $  post->post_type == 'page' ) && in_the_loop() && is_main_query() ) { 

I am already using the pre_wp_nav_menu and wp_nav_menu_items filters as shown on that answer.

What would be making this code run twice please? Or how would I debug to find out what is calling it and letting it through the if twice?

(When I use debug_backtrace() is shows apply_filters line 212 in plugins.php both times but I’m not sure what to do with that info)

Sorry, I would ask as a follow-up on the posted question, but I evidently can’t comment yet.

How long would you say it would take to break through this trap?

Here is the description of the trap. I removed module specific details to avoid spoilers.

The stone walls of this corridor are carved to resemble a stack of bamboo-like logs. The passage slopes down from a single door on its western leg, the lintel of which has been crafted to represent a stylized cavern entrance.

If the trap triggers, several of the logs swing out from either wall and buffet the party. Once they swing out, the stone logs don’t swing back and thus effectively block the passage, since they bar the way from ceiling to floor with only a 6-inch gap remaining between the logs.

I don’t want it to be impenetrable. How would you rule PCs breaking through?

Can subtle spell be used through a warlock’s familiar, and does it stop the stealth from being broken if it is currently sneaking [duplicate]

With the new Tasha’s Cauldron of Everything feat Metamagic Adept, warlocks get access to Subtle Spell. Can Subtle Spell be used in conjunction with a chain warlock’s familiar to cast, say, death ward at range without someone knowing?

Can weapons with Reach be used to attack “through” willing allies?

I’m picturing the Greek Phalanx formation, where soldiers were arranged in rows and the men in Row B or even Row C could attack the enemy by thrusting their spears between the soldiers in Row A.

Can you do that with a Reach weapon in DnD 5e? Attack an enemy even though there’s an ally (or even a row of allies) directly between you and them?

Casting spells that require sight through familiar sight [duplicate]

Here is the setup:

  • I play a sorcerer and got blinded and deafened at the start of the combat
  • I use my action to use my familiar’s senses, which leaves me blinded and deafened, which I already am
  • My familiar (an owl) uses his movement and lands on my head
  • I am 10 ft away from my ally, and I want to use quickened spell to cast haste as a bonus action.

Haste states: "Choose a willing creature that you can see within range". Technically, I can’t see him with my own eyes, but I can with my familiar’s eyes which are on top of my head. In a real-world scenario, I don’t believe this would be a problem for a caster. However, my DM ruled that I can’t cast it since it strictly states that you need to see the target.

Should this be allowed?